mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-20 00:04:10 +00:00
opt player keyboard event
opt triple opt desktop pip Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -1,15 +1,26 @@
|
||||
import 'dart:async';
|
||||
import 'dart:math' show pi;
|
||||
|
||||
import 'package:PiliPlus/pages/common/common_intro_controller.dart';
|
||||
import 'package:PiliPlus/utils/utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
abstract class TripleState<T extends StatefulWidget> extends State<T>
|
||||
with SingleTickerProviderStateMixin {
|
||||
CommonIntroController get introController;
|
||||
mixin TripleMixin on GetxController, TickerProvider {
|
||||
// 是否点赞
|
||||
final RxBool hasLike = false.obs;
|
||||
// 投币数量
|
||||
final RxNum coinNum = RxNum(0);
|
||||
// 是否投币
|
||||
bool get hasCoin => coinNum.value != 0;
|
||||
// 是否收藏
|
||||
final RxBool hasFav = false.obs;
|
||||
|
||||
bool get hasTriple => hasLike.value && hasCoin && hasFav.value;
|
||||
|
||||
void actionTriple();
|
||||
Future<void> actionLikeVideo();
|
||||
|
||||
// no need for pugv
|
||||
AnimationController? _tripleAnimCtr;
|
||||
@@ -34,13 +45,6 @@ abstract class TripleState<T extends StatefulWidget> extends State<T>
|
||||
_timer = null;
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_cancelTimer();
|
||||
_tripleAnimCtr?.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
static final _duration = Utils.isMobile
|
||||
? const Duration(milliseconds: 200)
|
||||
: const Duration(milliseconds: 230);
|
||||
@@ -48,12 +52,12 @@ abstract class TripleState<T extends StatefulWidget> extends State<T>
|
||||
void onStartTriple() {
|
||||
_timer ??= Timer(_duration, () {
|
||||
HapticFeedback.lightImpact();
|
||||
if (introController.hasTriple) {
|
||||
if (hasTriple) {
|
||||
SmartDialog.showToast('已完成三连');
|
||||
} else {
|
||||
tripleAnimCtr.forward().whenComplete(() {
|
||||
tripleAnimCtr.reset();
|
||||
introController.actionTriple();
|
||||
actionTriple();
|
||||
});
|
||||
}
|
||||
_cancelTimer();
|
||||
@@ -66,8 +70,15 @@ abstract class TripleState<T extends StatefulWidget> extends State<T>
|
||||
} else if (_timer != null && _timer!.tick == 0) {
|
||||
_cancelTimer();
|
||||
if (isTapUp) {
|
||||
introController.actionLikeVideo();
|
||||
actionLikeVideo();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
_cancelTimer();
|
||||
_tripleAnimCtr?.dispose();
|
||||
super.onClose();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user