mod: 一键三连
This commit is contained in:
@ -3,7 +3,6 @@ import 'dart:async';
|
|||||||
import 'package:bottom_sheet/bottom_sheet.dart';
|
import 'package:bottom_sheet/bottom_sheet.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:hive/hive.dart';
|
import 'package:hive/hive.dart';
|
||||||
import 'package:pilipala/http/constants.dart';
|
import 'package:pilipala/http/constants.dart';
|
||||||
@ -154,11 +153,10 @@ class VideoIntroController extends GetxController {
|
|||||||
}
|
}
|
||||||
if (hasLike.value && hasCoin.value && hasFav.value) {
|
if (hasLike.value && hasCoin.value && hasFav.value) {
|
||||||
// 已点赞、投币、收藏
|
// 已点赞、投币、收藏
|
||||||
SmartDialog.showToast('🙏 UP已经收到了~');
|
SmartDialog.showToast('UP已经收到了~');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
var result = await VideoHttp.oneThree(bvid: bvid);
|
var result = await VideoHttp.oneThree(bvid: bvid);
|
||||||
print('🤣🦴:${result["data"]}');
|
|
||||||
if (result['status']) {
|
if (result['status']) {
|
||||||
hasLike.value = result["data"]["like"];
|
hasLike.value = result["data"]["like"];
|
||||||
hasCoin.value = result["data"]["coin"];
|
hasCoin.value = result["data"]["coin"];
|
||||||
@ -604,4 +602,34 @@ class VideoIntroController extends GetxController {
|
|||||||
).buildShowContent(Get.context!),
|
).buildShowContent(Get.context!),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
oneThreeDialog() {
|
||||||
|
showDialog(
|
||||||
|
context: Get.context!,
|
||||||
|
builder: (context) {
|
||||||
|
return AlertDialog(
|
||||||
|
title: const Text('提示'),
|
||||||
|
content: const Text('是否一键三连'),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: () => navigator!.pop(),
|
||||||
|
child: Text(
|
||||||
|
'取消',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Theme.of(Get.context!).colorScheme.outline),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
TextButton(
|
||||||
|
onPressed: () async {
|
||||||
|
actionOneThree();
|
||||||
|
navigator!.pop();
|
||||||
|
},
|
||||||
|
child: const Text('确认'),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
import 'dart:ffi';
|
|
||||||
|
|
||||||
import 'package:bottom_sheet/bottom_sheet.dart';
|
import 'package:bottom_sheet/bottom_sheet.dart';
|
||||||
import 'package:easy_debounce/easy_throttle.dart';
|
|
||||||
import 'package:expandable/expandable.dart';
|
import 'package:expandable/expandable.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
@ -151,11 +148,6 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
|
|||||||
RxBool isExpand = false.obs;
|
RxBool isExpand = false.obs;
|
||||||
late ExpandableController _expandableCtr;
|
late ExpandableController _expandableCtr;
|
||||||
|
|
||||||
// 一键三连动画
|
|
||||||
late AnimationController _controller;
|
|
||||||
late Animation<double> _scaleTransition;
|
|
||||||
final RxDouble _progress = 0.0.obs;
|
|
||||||
|
|
||||||
void Function()? handleState(Future<dynamic> Function() action) {
|
void Function()? handleState(Future<dynamic> Function() action) {
|
||||||
return isProcessing
|
return isProcessing
|
||||||
? null
|
? null
|
||||||
@ -178,26 +170,6 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
|
|||||||
owner = widget.videoDetail!.owner;
|
owner = widget.videoDetail!.owner;
|
||||||
enableAi = setting.get(SettingBoxKey.enableAi, defaultValue: true);
|
enableAi = setting.get(SettingBoxKey.enableAi, defaultValue: true);
|
||||||
_expandableCtr = ExpandableController(initialExpanded: false);
|
_expandableCtr = ExpandableController(initialExpanded: false);
|
||||||
|
|
||||||
/// 一键三连动画
|
|
||||||
_controller = AnimationController(
|
|
||||||
duration: const Duration(milliseconds: 1500),
|
|
||||||
reverseDuration: const Duration(milliseconds: 300),
|
|
||||||
vsync: this,
|
|
||||||
);
|
|
||||||
_scaleTransition = Tween<double>(begin: 0.5, end: 1.5).animate(_controller)
|
|
||||||
..addListener(() async {
|
|
||||||
_progress.value =
|
|
||||||
double.parse((_scaleTransition.value - 0.5).toStringAsFixed(3));
|
|
||||||
if (_progress.value == 1) {
|
|
||||||
if (_controller.status == AnimationStatus.completed) {
|
|
||||||
await videoIntroController.actionOneThree();
|
|
||||||
}
|
|
||||||
_progress.value = 0;
|
|
||||||
_scaleTransition.removeListener(() {});
|
|
||||||
_controller.stop();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 收藏
|
// 收藏
|
||||||
@ -279,8 +251,6 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
|
|||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
_expandableCtr.dispose();
|
_expandableCtr.dispose();
|
||||||
_controller.dispose();
|
|
||||||
_scaleTransition.removeListener(() {});
|
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -573,123 +543,28 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
|
|||||||
Widget actionGrid(BuildContext context, videoIntroController) {
|
Widget actionGrid(BuildContext context, videoIntroController) {
|
||||||
final actionTypeSort = GlobalDataCache().actionTypeSort;
|
final actionTypeSort = GlobalDataCache().actionTypeSort;
|
||||||
|
|
||||||
Widget progressWidget(progress) {
|
|
||||||
return SizedBox(
|
|
||||||
width: const IconThemeData.fallback().size! + 5,
|
|
||||||
height: const IconThemeData.fallback().size! + 5,
|
|
||||||
child: CircularProgressIndicator(
|
|
||||||
value: progress.value,
|
|
||||||
strokeWidth: 2,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, Widget> menuListWidgets = {
|
Map<String, Widget> menuListWidgets = {
|
||||||
'like': Obx(
|
'like': Obx(
|
||||||
() {
|
() => ActionItem(
|
||||||
bool likeStatus = videoIntroController.hasLike.value;
|
icon: const Icon(FontAwesomeIcons.thumbsUp),
|
||||||
ColorScheme colorScheme = Theme.of(context).colorScheme;
|
selectIcon: const Icon(FontAwesomeIcons.solidThumbsUp),
|
||||||
return Stack(
|
onTap: handleState(videoIntroController.actionLikeVideo),
|
||||||
children: [
|
onLongPress: () => videoIntroController.oneThreeDialog(),
|
||||||
Positioned(
|
selectStatus: videoIntroController.hasLike.value,
|
||||||
top: ((Get.size.width - 24) / 5) / 2 -
|
text: widget.videoDetail!.stat!.like!.toString(),
|
||||||
(const IconThemeData.fallback().size!),
|
|
||||||
left: ((Get.size.width - 24) / 5) / 2 -
|
|
||||||
(const IconThemeData.fallback().size! + 5) / 2,
|
|
||||||
child: progressWidget(_progress)),
|
|
||||||
InkWell(
|
|
||||||
onTapDown: (details) {
|
|
||||||
feedBack();
|
|
||||||
if (videoIntroController.userInfo == null) {
|
|
||||||
SmartDialog.showToast('账号未登录');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_controller.forward();
|
|
||||||
},
|
|
||||||
onTapUp: (TapUpDetails details) {
|
|
||||||
if (_progress.value == 0) {
|
|
||||||
feedBack();
|
|
||||||
EasyThrottle.throttle(
|
|
||||||
'my-throttler', const Duration(milliseconds: 200), () {
|
|
||||||
videoIntroController.actionLikeVideo();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
_controller.reverse();
|
|
||||||
},
|
|
||||||
onTapCancel: () {
|
|
||||||
_controller.reverse();
|
|
||||||
},
|
|
||||||
borderRadius: StyleString.mdRadius,
|
|
||||||
child: SizedBox(
|
|
||||||
width: (Get.size.width - 24) / 5,
|
|
||||||
child: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
const SizedBox(height: 4),
|
|
||||||
AnimatedSwitcher(
|
|
||||||
duration: const Duration(milliseconds: 300),
|
|
||||||
transitionBuilder:
|
|
||||||
(Widget child, Animation<double> animation) {
|
|
||||||
return ScaleTransition(
|
|
||||||
scale: animation, child: child);
|
|
||||||
},
|
|
||||||
child: Icon(
|
|
||||||
key: ValueKey<bool>(likeStatus),
|
|
||||||
likeStatus
|
|
||||||
? FontAwesomeIcons.solidThumbsUp
|
|
||||||
: FontAwesomeIcons.thumbsUp,
|
|
||||||
color: likeStatus
|
|
||||||
? colorScheme.primary
|
|
||||||
: colorScheme.outline,
|
|
||||||
size: 21,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 6),
|
|
||||||
Text(
|
|
||||||
widget.videoDetail!.stat!.like!.toString(),
|
|
||||||
style: TextStyle(
|
|
||||||
color: likeStatus ? colorScheme.primary : null,
|
|
||||||
fontSize:
|
|
||||||
Theme.of(context).textTheme.labelSmall!.fontSize,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
'coin': Obx(
|
'coin': Obx(
|
||||||
() => Stack(
|
() => ActionItem(
|
||||||
children: [
|
|
||||||
Positioned(
|
|
||||||
top: ((Get.size.width - 24) / 5) / 2 -
|
|
||||||
(const IconThemeData.fallback().size!),
|
|
||||||
left: ((Get.size.width - 24) / 5) / 2 -
|
|
||||||
(const IconThemeData.fallback().size! + 5) / 2,
|
|
||||||
child: progressWidget(_progress)),
|
|
||||||
ActionItem(
|
|
||||||
icon: const Icon(FontAwesomeIcons.b),
|
icon: const Icon(FontAwesomeIcons.b),
|
||||||
selectIcon: const Icon(FontAwesomeIcons.b),
|
selectIcon: const Icon(FontAwesomeIcons.b),
|
||||||
onTap: handleState(videoIntroController.actionCoinVideo),
|
onTap: handleState(videoIntroController.actionCoinVideo),
|
||||||
selectStatus: videoIntroController.hasCoin.value,
|
selectStatus: videoIntroController.hasCoin.value,
|
||||||
text: widget.videoDetail!.stat!.coin!.toString(),
|
text: widget.videoDetail!.stat!.coin!.toString(),
|
||||||
),
|
),
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
'collect': Obx(
|
'collect': Obx(
|
||||||
() => Stack(
|
() => ActionItem(
|
||||||
children: [
|
|
||||||
Positioned(
|
|
||||||
top: ((Get.size.width - 24) / 5) / 2 -
|
|
||||||
(const IconThemeData.fallback().size!),
|
|
||||||
left: ((Get.size.width - 24) / 5) / 2 -
|
|
||||||
(const IconThemeData.fallback().size! + 5) / 2,
|
|
||||||
child: progressWidget(_progress)),
|
|
||||||
ActionItem(
|
|
||||||
icon: const Icon(FontAwesomeIcons.star),
|
icon: const Icon(FontAwesomeIcons.star),
|
||||||
selectIcon: const Icon(FontAwesomeIcons.solidStar),
|
selectIcon: const Icon(FontAwesomeIcons.solidStar),
|
||||||
onTap: () => showFavBottomSheet(),
|
onTap: () => showFavBottomSheet(),
|
||||||
@ -697,8 +572,6 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
|
|||||||
selectStatus: videoIntroController.hasFav.value,
|
selectStatus: videoIntroController.hasFav.value,
|
||||||
text: widget.videoDetail!.stat!.favorite!.toString(),
|
text: widget.videoDetail!.stat!.favorite!.toString(),
|
||||||
),
|
),
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
'watchLater': ActionItem(
|
'watchLater': ActionItem(
|
||||||
icon: const Icon(FontAwesomeIcons.clock),
|
icon: const Icon(FontAwesomeIcons.clock),
|
||||||
|
Reference in New Issue
Block a user