mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-04-20 11:08:03 +08:00
@@ -30,8 +30,10 @@ abstract class CommonSlidePageState<T extends CommonSlidePage> extends State<T>
|
||||
vsync: this,
|
||||
reverseDuration: const Duration(milliseconds: 500),
|
||||
);
|
||||
_anim = Tween<Offset>(begin: Offset.zero, end: const Offset(0, 1))
|
||||
.animate(_animController!);
|
||||
_anim = Tween<Offset>(
|
||||
begin: Offset.zero,
|
||||
end: const Offset(0, 1),
|
||||
).animate(_animController!);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,63 +59,63 @@ abstract class CommonSlidePageState<T extends CommonSlidePage> extends State<T>
|
||||
Widget buildList(ThemeData theme) => throw UnimplementedError();
|
||||
|
||||
Widget slideList(ThemeData theme) => LayoutBuilder(
|
||||
builder: (_, constrains) {
|
||||
final maxWidth = constrains.maxWidth;
|
||||
builder: (_, constrains) {
|
||||
final maxWidth = constrains.maxWidth;
|
||||
|
||||
void onDismiss() {
|
||||
if (isSliding == true) {
|
||||
if (_animController!.value * maxWidth + downPos!.dx >= 100) {
|
||||
Get.back();
|
||||
} else {
|
||||
_animController!.reverse();
|
||||
}
|
||||
}
|
||||
downPos = null;
|
||||
isSliding = null;
|
||||
void onDismiss() {
|
||||
if (isSliding == true) {
|
||||
if (_animController!.value * maxWidth + downPos!.dx >= 100) {
|
||||
Get.back();
|
||||
} else {
|
||||
_animController!.reverse();
|
||||
}
|
||||
}
|
||||
downPos = null;
|
||||
isSliding = null;
|
||||
}
|
||||
|
||||
void onPan(Offset localPosition) {
|
||||
if (isSliding == false) {
|
||||
return;
|
||||
} else if (isSliding == null) {
|
||||
if (downPos != null) {
|
||||
Offset cumulativeDelta = localPosition - downPos!;
|
||||
if (cumulativeDelta.dx.abs() >= cumulativeDelta.dy.abs()) {
|
||||
downPos = localPosition;
|
||||
isSliding = true;
|
||||
} else {
|
||||
isSliding = false;
|
||||
}
|
||||
}
|
||||
} else if (isSliding == true) {
|
||||
if (localPosition.dx < 0) {
|
||||
return;
|
||||
}
|
||||
_animController!.value =
|
||||
max(0, (localPosition.dx - downPos!.dx)) / maxWidth;
|
||||
void onPan(Offset localPosition) {
|
||||
if (isSliding == false) {
|
||||
return;
|
||||
} else if (isSliding == null) {
|
||||
if (downPos != null) {
|
||||
Offset cumulativeDelta = localPosition - downPos!;
|
||||
if (cumulativeDelta.dx.abs() >= cumulativeDelta.dy.abs()) {
|
||||
downPos = localPosition;
|
||||
isSliding = true;
|
||||
} else {
|
||||
isSliding = false;
|
||||
}
|
||||
}
|
||||
} else if (isSliding == true) {
|
||||
if (localPosition.dx < 0) {
|
||||
return;
|
||||
}
|
||||
_animController!.value =
|
||||
max(0, (localPosition.dx - downPos!.dx)) / maxWidth;
|
||||
}
|
||||
}
|
||||
|
||||
return GestureDetector(
|
||||
onPanDown: (details) {
|
||||
if (details.localPosition.dx > 30) {
|
||||
isSliding = false;
|
||||
} else {
|
||||
downPos = details.localPosition;
|
||||
}
|
||||
},
|
||||
onPanStart: (details) {
|
||||
onPan(details.localPosition);
|
||||
},
|
||||
onPanUpdate: (details) {
|
||||
onPan(details.localPosition);
|
||||
},
|
||||
onPanCancel: onDismiss,
|
||||
onPanEnd: (_) {
|
||||
onDismiss();
|
||||
},
|
||||
child: buildList(theme),
|
||||
);
|
||||
return GestureDetector(
|
||||
onPanDown: (details) {
|
||||
if (details.localPosition.dx > 30) {
|
||||
isSliding = false;
|
||||
} else {
|
||||
downPos = details.localPosition;
|
||||
}
|
||||
},
|
||||
onPanStart: (details) {
|
||||
onPan(details.localPosition);
|
||||
},
|
||||
onPanUpdate: (details) {
|
||||
onPan(details.localPosition);
|
||||
},
|
||||
onPanCancel: onDismiss,
|
||||
onPanEnd: (_) {
|
||||
onDismiss();
|
||||
},
|
||||
child: buildList(theme),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user