mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
opt: triple
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -455,7 +455,7 @@ class _BangumiInfoState extends State<BangumiInfo>
|
|||||||
bangumiItem!.stat!['likes']!,
|
bangumiItem!.stat!['likes']!,
|
||||||
),
|
),
|
||||||
needAnim: true,
|
needAnim: true,
|
||||||
hasOneThree: bangumiIntroController.hasLike.value &&
|
hasTriple: bangumiIntroController.hasLike.value &&
|
||||||
bangumiIntroController.hasCoin.value &&
|
bangumiIntroController.hasCoin.value &&
|
||||||
bangumiIntroController.hasFav.value,
|
bangumiIntroController.hasFav.value,
|
||||||
callBack: (start) {
|
callBack: (start) {
|
||||||
|
|||||||
@@ -862,7 +862,7 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
|
|||||||
? Utils.numFormat(videoDetail.stat!.like!)
|
? Utils.numFormat(videoDetail.stat!.like!)
|
||||||
: '-',
|
: '-',
|
||||||
needAnim: true,
|
needAnim: true,
|
||||||
hasOneThree: videoIntroController.hasLike.value &&
|
hasTriple: videoIntroController.hasLike.value &&
|
||||||
videoIntroController.hasCoin.value &&
|
videoIntroController.hasCoin.value &&
|
||||||
videoIntroController.hasFav.value,
|
videoIntroController.hasFav.value,
|
||||||
callBack: (start) {
|
callBack: (start) {
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
|
|
||||||
|
import 'package:PiliPlus/utils/extension.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:PiliPlus/utils/feed_back.dart';
|
import 'package:PiliPlus/utils/feed_back.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
|
|
||||||
class ActionItem extends StatefulWidget {
|
class ActionItem extends StatefulWidget {
|
||||||
final Icon icon;
|
final Icon icon;
|
||||||
@@ -14,7 +17,7 @@ class ActionItem extends StatefulWidget {
|
|||||||
final bool selectStatus;
|
final bool selectStatus;
|
||||||
final String semanticsLabel;
|
final String semanticsLabel;
|
||||||
final bool needAnim;
|
final bool needAnim;
|
||||||
final bool hasOneThree;
|
final bool hasTriple;
|
||||||
final Function? callBack;
|
final Function? callBack;
|
||||||
final bool? expand;
|
final bool? expand;
|
||||||
|
|
||||||
@@ -28,7 +31,7 @@ class ActionItem extends StatefulWidget {
|
|||||||
this.text,
|
this.text,
|
||||||
this.selectStatus = false,
|
this.selectStatus = false,
|
||||||
this.needAnim = false,
|
this.needAnim = false,
|
||||||
this.hasOneThree = false,
|
this.hasTriple = false,
|
||||||
this.callBack,
|
this.callBack,
|
||||||
required this.semanticsLabel,
|
required this.semanticsLabel,
|
||||||
this.expand,
|
this.expand,
|
||||||
@@ -42,28 +45,32 @@ class ActionItemState extends State<ActionItem> with TickerProviderStateMixin {
|
|||||||
AnimationController? controller;
|
AnimationController? controller;
|
||||||
Animation<double>? _animation;
|
Animation<double>? _animation;
|
||||||
|
|
||||||
bool get _isThumbUp => widget.semanticsLabel == '点赞';
|
late final _isThumbsUp = widget.semanticsLabel == '点赞';
|
||||||
late int _lastTime;
|
late int _lastTime;
|
||||||
bool _hideCircle = false;
|
late bool _hideCircle = false;
|
||||||
Timer? _timer;
|
Timer? _timer;
|
||||||
|
|
||||||
void _startLongPress() {
|
void _startLongPress() {
|
||||||
_lastTime = DateTime.now().millisecondsSinceEpoch;
|
_lastTime = DateTime.now().millisecondsSinceEpoch;
|
||||||
if (!widget.hasOneThree) {
|
_timer ??= Timer(const Duration(milliseconds: 100), () {
|
||||||
_timer ??= Timer(const Duration(milliseconds: 100), () {
|
if (widget.hasTriple) {
|
||||||
feedBack();
|
HapticFeedback.lightImpact();
|
||||||
|
SmartDialog.showToast('已经完成三连');
|
||||||
|
} else {
|
||||||
controller?.forward();
|
controller?.forward();
|
||||||
widget.callBack?.call(true);
|
widget.callBack?.call(true);
|
||||||
cancelTimer();
|
}
|
||||||
});
|
cancelTimer();
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void _cancelLongPress([bool isCancel = false]) {
|
void _cancelLongPress([bool isCancel = false]) {
|
||||||
int duration = DateTime.now().millisecondsSinceEpoch - _lastTime;
|
int duration = DateTime.now().millisecondsSinceEpoch - _lastTime;
|
||||||
if (duration >= 100 && duration < 1500) {
|
if (duration >= 100 && duration < 1500) {
|
||||||
controller?.reverse();
|
if (widget.hasTriple.not) {
|
||||||
widget.callBack?.call(false);
|
controller?.reverse();
|
||||||
|
widget.callBack?.call(false);
|
||||||
|
}
|
||||||
} else if (duration < 100) {
|
} else if (duration < 100) {
|
||||||
cancelTimer();
|
cancelTimer();
|
||||||
if (!isCancel) {
|
if (!isCancel) {
|
||||||
@@ -81,19 +88,23 @@ class ActionItemState extends State<ActionItem> with TickerProviderStateMixin {
|
|||||||
vsync: this,
|
vsync: this,
|
||||||
duration: const Duration(milliseconds: 1500),
|
duration: const Duration(milliseconds: 1500),
|
||||||
reverseDuration: const Duration(milliseconds: 400),
|
reverseDuration: const Duration(milliseconds: 400),
|
||||||
);
|
)..addListener(listener);
|
||||||
|
|
||||||
_animation = Tween<double>(begin: 0, end: -2 * pi).animate(controller!)
|
_animation = Tween<double>(begin: 0, end: -2 * pi).animate(
|
||||||
..addListener(listener);
|
CurvedAnimation(
|
||||||
|
parent: controller!,
|
||||||
|
curve: Curves.easeInOut,
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void listener() {
|
void listener() {
|
||||||
setState(() {
|
setState(() {
|
||||||
_hideCircle = _animation?.value == -2 * pi;
|
_hideCircle = controller?.value == 1;
|
||||||
if (_hideCircle) {
|
if (_hideCircle) {
|
||||||
controller?.reset();
|
controller?.reset();
|
||||||
if (_isThumbUp) {
|
if (_isThumbsUp) {
|
||||||
widget.onLongPress?.call();
|
widget.onLongPress?.call();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -108,7 +119,7 @@ class ActionItemState extends State<ActionItem> with TickerProviderStateMixin {
|
|||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
cancelTimer();
|
cancelTimer();
|
||||||
_animation?.removeListener(listener);
|
controller?.removeListener(listener);
|
||||||
controller?.dispose();
|
controller?.dispose();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
@@ -124,20 +135,20 @@ class ActionItemState extends State<ActionItem> with TickerProviderStateMixin {
|
|||||||
widget.semanticsLabel,
|
widget.semanticsLabel,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
borderRadius: BorderRadius.circular(6),
|
borderRadius: BorderRadius.circular(6),
|
||||||
onTap: _isThumbUp
|
onTap: _isThumbsUp
|
||||||
? null
|
? null
|
||||||
: () {
|
: () {
|
||||||
feedBack();
|
feedBack();
|
||||||
widget.onTap?.call();
|
widget.onTap?.call();
|
||||||
},
|
},
|
||||||
onLongPress: _isThumbUp
|
onLongPress: _isThumbsUp
|
||||||
? null
|
? null
|
||||||
: () {
|
: () {
|
||||||
widget.onLongPress?.call();
|
widget.onLongPress?.call();
|
||||||
},
|
},
|
||||||
onTapDown: (details) => _isThumbUp ? _startLongPress() : null,
|
onTapDown: (details) => _isThumbsUp ? _startLongPress() : null,
|
||||||
onTapUp: (details) => _isThumbUp ? _cancelLongPress() : null,
|
onTapUp: (details) => _isThumbsUp ? _cancelLongPress() : null,
|
||||||
onTapCancel: () => _isThumbUp ? _cancelLongPress(true) : null,
|
onTapCancel: () => _isThumbsUp ? _cancelLongPress(true) : null,
|
||||||
// borderRadius: StyleString.mdRadius,
|
// borderRadius: StyleString.mdRadius,
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
@@ -180,13 +191,14 @@ class ActionItemState extends State<ActionItem> with TickerProviderStateMixin {
|
|||||||
},
|
},
|
||||||
child: Text(
|
child: Text(
|
||||||
widget.text!,
|
widget.text!,
|
||||||
key: ValueKey<String>(widget.text ?? ''),
|
key: ValueKey<String>(widget.text!),
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: widget.selectStatus
|
color: widget.selectStatus
|
||||||
? Theme.of(context).colorScheme.primary
|
? Theme.of(context).colorScheme.primary
|
||||||
: Theme.of(context).colorScheme.outline,
|
: Theme.of(context).colorScheme.outline,
|
||||||
fontSize:
|
fontSize:
|
||||||
Theme.of(context).textTheme.labelSmall!.fontSize),
|
Theme.of(context).textTheme.labelSmall!.fontSize,
|
||||||
|
),
|
||||||
semanticsLabel: "",
|
semanticsLabel: "",
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -2129,10 +2129,9 @@ class _HeaderControlState extends State<HeaderControl> {
|
|||||||
videoIntroController.hasLike.value,
|
videoIntroController.hasLike.value,
|
||||||
semanticsLabel: '点赞',
|
semanticsLabel: '点赞',
|
||||||
needAnim: true,
|
needAnim: true,
|
||||||
hasOneThree:
|
hasTriple: videoIntroController.hasLike.value &&
|
||||||
videoIntroController.hasLike.value &&
|
videoIntroController.hasCoin.value &&
|
||||||
videoIntroController.hasCoin.value &&
|
videoIntroController.hasFav.value,
|
||||||
videoIntroController.hasFav.value,
|
|
||||||
callBack: (start) {
|
callBack: (start) {
|
||||||
if (start) {
|
if (start) {
|
||||||
HapticFeedback.lightImpact();
|
HapticFeedback.lightImpact();
|
||||||
@@ -2250,7 +2249,7 @@ class _HeaderControlState extends State<HeaderControl> {
|
|||||||
bangumiIntroController.hasLike.value,
|
bangumiIntroController.hasLike.value,
|
||||||
semanticsLabel: '点赞',
|
semanticsLabel: '点赞',
|
||||||
needAnim: true,
|
needAnim: true,
|
||||||
hasOneThree:
|
hasTriple:
|
||||||
bangumiIntroController.hasLike.value &&
|
bangumiIntroController.hasLike.value &&
|
||||||
bangumiIntroController.hasCoin.value &&
|
bangumiIntroController.hasCoin.value &&
|
||||||
bangumiIntroController.hasFav.value,
|
bangumiIntroController.hasFav.value,
|
||||||
|
|||||||
Reference in New Issue
Block a user