mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
opt: action item gesture
Closes #29 Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -300,7 +300,7 @@ class BangumiIntroController extends CommonController {
|
|||||||
delMediaIdsNew = [];
|
delMediaIdsNew = [];
|
||||||
SmartDialog.showToast('操作成功');
|
SmartDialog.showToast('操作成功');
|
||||||
Get.back();
|
Get.back();
|
||||||
Future.delayed(const Duration(milliseconds: 500), () {
|
Future.delayed(const Duration(milliseconds: 255), () {
|
||||||
queryBangumiLikeCoinFav();
|
queryBangumiLikeCoinFav();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -59,6 +59,8 @@ class FavDetailController extends MultiSelectController {
|
|||||||
if (result['status']) {
|
if (result['status']) {
|
||||||
List dataList = (loadingState.value as Success).response;
|
List dataList = (loadingState.value as Success).response;
|
||||||
dataList.removeWhere((item) => item.id == id);
|
dataList.removeWhere((item) => item.id == id);
|
||||||
|
item.value.mediaCount = item.value.mediaCount! - 1;
|
||||||
|
item.refresh();
|
||||||
loadingState.value = LoadingState.success(dataList);
|
loadingState.value = LoadingState.success(dataList);
|
||||||
SmartDialog.showToast('取消收藏');
|
SmartDialog.showToast('取消收藏');
|
||||||
} else {
|
} else {
|
||||||
@@ -103,6 +105,8 @@ class FavDetailController extends MultiSelectController {
|
|||||||
if (result['status']) {
|
if (result['status']) {
|
||||||
List dataList = (loadingState.value as Success).response;
|
List dataList = (loadingState.value as Success).response;
|
||||||
Set remainList = dataList.toSet().difference(list.toSet());
|
Set remainList = dataList.toSet().difference(list.toSet());
|
||||||
|
item.value.mediaCount = item.value.mediaCount! - list.length;
|
||||||
|
item.refresh();
|
||||||
loadingState.value =
|
loadingState.value =
|
||||||
LoadingState.success(remainList.toList());
|
LoadingState.success(remainList.toList());
|
||||||
SmartDialog.showToast('取消收藏');
|
SmartDialog.showToast('取消收藏');
|
||||||
|
|||||||
@@ -152,6 +152,7 @@ class LaterController extends MultiSelectController {
|
|||||||
Set remainList = ((loadingState.value as Success).response as List)
|
Set remainList = ((loadingState.value as Success).response as List)
|
||||||
.toSet()
|
.toSet()
|
||||||
.difference(result.toSet());
|
.difference(result.toSet());
|
||||||
|
count.value -= aids.length;
|
||||||
loadingState.value = LoadingState.success(remainList.toList());
|
loadingState.value = LoadingState.success(remainList.toList());
|
||||||
if (enableMultiSelect.value) {
|
if (enableMultiSelect.value) {
|
||||||
checkedCount.value = 0;
|
checkedCount.value = 0;
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import 'dart:async';
|
||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@@ -42,24 +43,31 @@ class ActionItemState extends State<ActionItem> with TickerProviderStateMixin {
|
|||||||
bool get _isThumbUp => widget.semanticsLabel == '点赞';
|
bool get _isThumbUp => widget.semanticsLabel == '点赞';
|
||||||
late int _lastTime;
|
late int _lastTime;
|
||||||
bool _hideCircle = false;
|
bool _hideCircle = false;
|
||||||
|
Timer? _timer;
|
||||||
|
|
||||||
void _startLongPress() {
|
void _startLongPress() {
|
||||||
_lastTime = DateTime.now().millisecondsSinceEpoch;
|
_lastTime = DateTime.now().millisecondsSinceEpoch;
|
||||||
if (!widget.hasOneThree) {
|
if (!widget.hasOneThree) {
|
||||||
controller?.forward();
|
_timer ??= Timer(const Duration(milliseconds: 100), () {
|
||||||
widget.callBack?.call(true);
|
feedBack();
|
||||||
|
controller?.forward();
|
||||||
|
widget.callBack?.call(true);
|
||||||
|
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 < 1500) {
|
if (duration >= 100 && duration < 1500) {
|
||||||
controller?.reverse();
|
controller?.reverse();
|
||||||
widget.callBack?.call(false);
|
widget.callBack?.call(false);
|
||||||
}
|
} else if (duration < 100) {
|
||||||
if (duration <= 50 && !isCancel) {
|
cancelTimer();
|
||||||
feedBack();
|
if (!isCancel) {
|
||||||
widget.onTap?.call();
|
feedBack();
|
||||||
|
widget.onTap?.call();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,7 +78,7 @@ class ActionItemState extends State<ActionItem> with TickerProviderStateMixin {
|
|||||||
controller = AnimationController(
|
controller = AnimationController(
|
||||||
vsync: this,
|
vsync: this,
|
||||||
duration: const Duration(milliseconds: 1500),
|
duration: const Duration(milliseconds: 1500),
|
||||||
reverseDuration: const Duration(milliseconds: 500),
|
reverseDuration: const Duration(milliseconds: 400),
|
||||||
);
|
);
|
||||||
|
|
||||||
_animation = Tween<double>(begin: 0, end: -2 * pi).animate(controller!)
|
_animation = Tween<double>(begin: 0, end: -2 * pi).animate(controller!)
|
||||||
@@ -88,8 +96,14 @@ class ActionItemState extends State<ActionItem> with TickerProviderStateMixin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cancelTimer() {
|
||||||
|
_timer?.cancel();
|
||||||
|
_timer = null;
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
|
cancelTimer();
|
||||||
_animation?.removeListener(() {});
|
_animation?.removeListener(() {});
|
||||||
controller?.dispose();
|
controller?.dispose();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
|
|||||||
Reference in New Issue
Block a user