mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-04-27 05:45:51 +08:00
opt video/intro page
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -9,29 +9,26 @@ import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
|
||||
abstract class TripleState<T extends StatefulWidget> extends State<T>
|
||||
with SingleTickerProviderStateMixin {
|
||||
late final tripleAnimCtr = AnimationController(
|
||||
vsync: this,
|
||||
duration: const Duration(milliseconds: 1000),
|
||||
reverseDuration: const Duration(milliseconds: 400),
|
||||
);
|
||||
CommonIntroController get introController;
|
||||
|
||||
late final tripleAnimation = Tween<double>(
|
||||
// no need for pugv
|
||||
AnimationController? _tripleAnimCtr;
|
||||
Animation<double>? _tripleAnimation;
|
||||
|
||||
AnimationController get tripleAnimCtr =>
|
||||
_tripleAnimCtr ??= AnimationController(
|
||||
vsync: this,
|
||||
duration: const Duration(milliseconds: 1200),
|
||||
reverseDuration: const Duration(milliseconds: 400),
|
||||
);
|
||||
|
||||
Animation<double> get tripleAnimation => _tripleAnimation ??= Tween<double>(
|
||||
begin: 0,
|
||||
end: -2 * pi,
|
||||
).animate(CurvedAnimation(parent: tripleAnimCtr, curve: Curves.easeInOut));
|
||||
|
||||
CommonIntroController get introController;
|
||||
|
||||
Timer? _timer;
|
||||
|
||||
// @mustCallSuper
|
||||
// void tripleListener(AnimationStatus status) {
|
||||
// if (status == AnimationStatus.completed) {
|
||||
// tripleAnimCtr.reset();
|
||||
// onTriple();
|
||||
// }
|
||||
// }
|
||||
|
||||
void _cancelTimer() {
|
||||
_timer?.cancel();
|
||||
_timer = null;
|
||||
@@ -40,14 +37,14 @@ abstract class TripleState<T extends StatefulWidget> extends State<T>
|
||||
@override
|
||||
void dispose() {
|
||||
_cancelTimer();
|
||||
tripleAnimCtr.dispose();
|
||||
_tripleAnimCtr?.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void onStartTriple() {
|
||||
_timer ??= Timer(const Duration(milliseconds: 200), () {
|
||||
HapticFeedback.lightImpact();
|
||||
if (introController.hasTriple) {
|
||||
HapticFeedback.lightImpact();
|
||||
SmartDialog.showToast('已完成三连');
|
||||
} else {
|
||||
tripleAnimCtr.forward().whenComplete(() {
|
||||
@@ -71,39 +68,3 @@ abstract class TripleState<T extends StatefulWidget> extends State<T>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class TripleBuilder extends StatefulWidget {
|
||||
const TripleBuilder({
|
||||
super.key,
|
||||
required this.builder,
|
||||
required this.introController,
|
||||
// this.tripleListener,
|
||||
});
|
||||
final CommonIntroController introController;
|
||||
final Widget Function(
|
||||
BuildContext context,
|
||||
Animation<double> tripleAnimation,
|
||||
void Function() onStartTriple,
|
||||
void Function([bool]) onCancelTriple,
|
||||
)
|
||||
builder;
|
||||
// final AnimationStatusListener? tripleListener;
|
||||
|
||||
@override
|
||||
State<TripleBuilder> createState() => _TripleBuilderState();
|
||||
}
|
||||
|
||||
class _TripleBuilderState extends TripleState<TripleBuilder> {
|
||||
@override
|
||||
Widget build(BuildContext context) =>
|
||||
widget.builder(context, tripleAnimation, onStartTriple, onCancelTriple);
|
||||
|
||||
@override
|
||||
late final CommonIntroController introController = widget.introController;
|
||||
|
||||
// @override
|
||||
// void tripleListener(AnimationStatus status) {
|
||||
// super.tripleListener(status);
|
||||
// widget.tripleListener?.call(status);
|
||||
// }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user