mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-30 23:58:13 +08:00
opt: handleState
weird Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -2,6 +2,7 @@ import 'dart:async';
|
|||||||
|
|
||||||
import 'package:PiliPalaX/common/widgets/http_error.dart';
|
import 'package:PiliPalaX/common/widgets/http_error.dart';
|
||||||
import 'package:PiliPalaX/http/loading_state.dart';
|
import 'package:PiliPalaX/http/loading_state.dart';
|
||||||
|
import 'package:PiliPalaX/utils/extension.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:font_awesome_flutter/font_awesome_flutter.dart';
|
||||||
@@ -136,14 +137,12 @@ class _BangumiInfoState extends State<BangumiInfo>
|
|||||||
late final BangumiInfoModel? bangumiItem;
|
late final BangumiInfoModel? bangumiItem;
|
||||||
int? cid;
|
int? cid;
|
||||||
bool isProcessing = false;
|
bool isProcessing = false;
|
||||||
void Function()? handleState(Future Function() action) {
|
void handleState(Future Function() action) async {
|
||||||
return isProcessing
|
if (isProcessing.not) {
|
||||||
? null
|
isProcessing = true;
|
||||||
: () async {
|
await action();
|
||||||
setState(() => isProcessing = true);
|
isProcessing = false;
|
||||||
await action();
|
}
|
||||||
setState(() => isProcessing = false);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
late final _coinKey = GlobalKey<ActionItemState>();
|
late final _coinKey = GlobalKey<ActionItemState>();
|
||||||
@@ -447,7 +446,8 @@ class _BangumiInfoState extends State<BangumiInfo>
|
|||||||
() => ActionItem(
|
() => ActionItem(
|
||||||
icon: const Icon(FontAwesomeIcons.thumbsUp),
|
icon: const Icon(FontAwesomeIcons.thumbsUp),
|
||||||
selectIcon: const Icon(FontAwesomeIcons.solidThumbsUp),
|
selectIcon: const Icon(FontAwesomeIcons.solidThumbsUp),
|
||||||
onTap: handleState(bangumiIntroController.actionLikeVideo),
|
onTap: () =>
|
||||||
|
handleState(bangumiIntroController.actionLikeVideo),
|
||||||
onLongPress: bangumiIntroController.actionOneThree,
|
onLongPress: bangumiIntroController.actionOneThree,
|
||||||
selectStatus: bangumiIntroController.hasLike.value,
|
selectStatus: bangumiIntroController.hasLike.value,
|
||||||
loadingStatus: false,
|
loadingStatus: false,
|
||||||
@@ -477,7 +477,8 @@ class _BangumiInfoState extends State<BangumiInfo>
|
|||||||
key: _coinKey,
|
key: _coinKey,
|
||||||
icon: const Icon(FontAwesomeIcons.b),
|
icon: const Icon(FontAwesomeIcons.b),
|
||||||
selectIcon: const Icon(FontAwesomeIcons.b),
|
selectIcon: const Icon(FontAwesomeIcons.b),
|
||||||
onTap: handleState(bangumiIntroController.actionCoinVideo),
|
onTap: () =>
|
||||||
|
handleState(bangumiIntroController.actionCoinVideo),
|
||||||
selectStatus: bangumiIntroController.hasCoin.value,
|
selectStatus: bangumiIntroController.hasCoin.value,
|
||||||
loadingStatus: false,
|
loadingStatus: false,
|
||||||
semanticsLabel: '投币',
|
semanticsLabel: '投币',
|
||||||
@@ -540,7 +541,7 @@ class _BangumiInfoState extends State<BangumiInfo>
|
|||||||
Obx(
|
Obx(
|
||||||
() => ActionRowItem(
|
() => ActionRowItem(
|
||||||
icon: const Icon(FontAwesomeIcons.thumbsUp),
|
icon: const Icon(FontAwesomeIcons.thumbsUp),
|
||||||
onTap: handleState(videoIntroController.actionLikeVideo),
|
onTap: () => handleState(videoIntroController.actionLikeVideo),
|
||||||
selectStatus: videoIntroController.hasLike.value,
|
selectStatus: videoIntroController.hasLike.value,
|
||||||
loadingStatus: widget.loadingStatus,
|
loadingStatus: widget.loadingStatus,
|
||||||
text: !widget.loadingStatus
|
text: !widget.loadingStatus
|
||||||
@@ -552,7 +553,7 @@ class _BangumiInfoState extends State<BangumiInfo>
|
|||||||
Obx(
|
Obx(
|
||||||
() => ActionRowItem(
|
() => ActionRowItem(
|
||||||
icon: const Icon(FontAwesomeIcons.b),
|
icon: const Icon(FontAwesomeIcons.b),
|
||||||
onTap: handleState(videoIntroController.actionCoinVideo),
|
onTap: () => handleState(videoIntroController.actionCoinVideo),
|
||||||
selectStatus: videoIntroController.hasCoin.value,
|
selectStatus: videoIntroController.hasCoin.value,
|
||||||
loadingStatus: widget.loadingStatus,
|
loadingStatus: widget.loadingStatus,
|
||||||
text: !widget.loadingStatus
|
text: !widget.loadingStatus
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import 'package:PiliPalaX/common/widgets/network_img_layer.dart';
|
import 'package:PiliPalaX/common/widgets/network_img_layer.dart';
|
||||||
import 'package:PiliPalaX/http/msg.dart';
|
import 'package:PiliPalaX/http/msg.dart';
|
||||||
|
import 'package:PiliPalaX/utils/extension.dart';
|
||||||
import 'package:PiliPalaX/utils/storage.dart';
|
import 'package:PiliPalaX/utils/storage.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';
|
||||||
@@ -27,14 +28,12 @@ class _ActionPanelState extends State<ActionPanel> {
|
|||||||
final DynamicsController _dynamicsController = Get.put(DynamicsController());
|
final DynamicsController _dynamicsController = Get.put(DynamicsController());
|
||||||
// late ModuleStatModel stat;
|
// late ModuleStatModel stat;
|
||||||
bool isProcessing = false;
|
bool isProcessing = false;
|
||||||
void Function()? handleState(Future Function() action) {
|
void handleState(Future Function() action) async {
|
||||||
return isProcessing
|
if (isProcessing.not) {
|
||||||
? null
|
isProcessing = true;
|
||||||
: () async {
|
await action();
|
||||||
setState(() => isProcessing = true);
|
isProcessing = false;
|
||||||
await action();
|
}
|
||||||
setState(() => isProcessing = false);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// @override
|
// @override
|
||||||
@@ -136,7 +135,7 @@ class _ActionPanelState extends State<ActionPanel> {
|
|||||||
Expanded(
|
Expanded(
|
||||||
flex: 1,
|
flex: 1,
|
||||||
child: TextButton.icon(
|
child: TextButton.icon(
|
||||||
onPressed: handleState(onLikeDynamic),
|
onPressed: () => handleState(onLikeDynamic),
|
||||||
icon: Icon(
|
icon: Icon(
|
||||||
widget.item!.modules.moduleStat.like!.status!
|
widget.item!.modules.moduleStat.like!.status!
|
||||||
? FontAwesomeIcons.solidThumbsUp
|
? FontAwesomeIcons.solidThumbsUp
|
||||||
|
|||||||
@@ -152,14 +152,12 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
|
|||||||
|
|
||||||
late final _horizontalMemberPage = GStorage.horizontalMemberPage;
|
late final _horizontalMemberPage = GStorage.horizontalMemberPage;
|
||||||
|
|
||||||
void Function()? handleState(Future Function() action) {
|
void handleState(Future Function() action) async {
|
||||||
return isProcessing
|
if (isProcessing.not) {
|
||||||
? null
|
isProcessing = true;
|
||||||
: () async {
|
await action();
|
||||||
setState(() => isProcessing = true);
|
isProcessing = false;
|
||||||
await action();
|
}
|
||||||
setState(() => isProcessing = false);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -738,8 +736,9 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
|
|||||||
() => ActionItem(
|
() => ActionItem(
|
||||||
icon: const Icon(FontAwesomeIcons.thumbsUp),
|
icon: const Icon(FontAwesomeIcons.thumbsUp),
|
||||||
selectIcon: const Icon(FontAwesomeIcons.solidThumbsUp),
|
selectIcon: const Icon(FontAwesomeIcons.solidThumbsUp),
|
||||||
onTap: handleState(videoIntroController.actionLikeVideo),
|
onTap: () => handleState(videoIntroController.actionLikeVideo),
|
||||||
onLongPress: handleState(videoIntroController.actionOneThree),
|
onLongPress: () =>
|
||||||
|
handleState(videoIntroController.actionOneThree),
|
||||||
selectStatus: videoIntroController.hasLike.value,
|
selectStatus: videoIntroController.hasLike.value,
|
||||||
loadingStatus: widget.loadingStatus,
|
loadingStatus: widget.loadingStatus,
|
||||||
semanticsLabel: '点赞',
|
semanticsLabel: '点赞',
|
||||||
@@ -765,7 +764,8 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
|
|||||||
() => ActionItem(
|
() => ActionItem(
|
||||||
icon: const Icon(FontAwesomeIcons.thumbsDown),
|
icon: const Icon(FontAwesomeIcons.thumbsDown),
|
||||||
selectIcon: const Icon(FontAwesomeIcons.solidThumbsDown),
|
selectIcon: const Icon(FontAwesomeIcons.solidThumbsDown),
|
||||||
onTap: handleState(videoIntroController.actionDislikeVideo),
|
onTap: () =>
|
||||||
|
handleState(videoIntroController.actionDislikeVideo),
|
||||||
selectStatus: videoIntroController.hasDislike.value,
|
selectStatus: videoIntroController.hasDislike.value,
|
||||||
loadingStatus: widget.loadingStatus,
|
loadingStatus: widget.loadingStatus,
|
||||||
semanticsLabel: '点踩',
|
semanticsLabel: '点踩',
|
||||||
@@ -782,7 +782,7 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
|
|||||||
key: _coinKey,
|
key: _coinKey,
|
||||||
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,
|
||||||
loadingStatus: widget.loadingStatus,
|
loadingStatus: widget.loadingStatus,
|
||||||
semanticsLabel: '投币',
|
semanticsLabel: '投币',
|
||||||
@@ -838,7 +838,7 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
|
|||||||
Obx(
|
Obx(
|
||||||
() => ActionRowItem(
|
() => ActionRowItem(
|
||||||
icon: const Icon(FontAwesomeIcons.thumbsUp),
|
icon: const Icon(FontAwesomeIcons.thumbsUp),
|
||||||
onTap: handleState(videoIntroController.actionLikeVideo),
|
onTap: () => handleState(videoIntroController.actionLikeVideo),
|
||||||
selectStatus: videoIntroController.hasLike.value,
|
selectStatus: videoIntroController.hasLike.value,
|
||||||
loadingStatus: widget.loadingStatus,
|
loadingStatus: widget.loadingStatus,
|
||||||
text: !widget.loadingStatus
|
text: !widget.loadingStatus
|
||||||
@@ -850,7 +850,7 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
|
|||||||
Obx(
|
Obx(
|
||||||
() => ActionRowItem(
|
() => ActionRowItem(
|
||||||
icon: const Icon(FontAwesomeIcons.b),
|
icon: const Icon(FontAwesomeIcons.b),
|
||||||
onTap: handleState(videoIntroController.actionCoinVideo),
|
onTap: () => handleState(videoIntroController.actionCoinVideo),
|
||||||
selectStatus: videoIntroController.hasCoin.value,
|
selectStatus: videoIntroController.hasCoin.value,
|
||||||
loadingStatus: widget.loadingStatus,
|
loadingStatus: widget.loadingStatus,
|
||||||
text: !widget.loadingStatus
|
text: !widget.loadingStatus
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import 'package:PiliPalaX/utils/extension.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:font_awesome_flutter/font_awesome_flutter.dart';
|
||||||
@@ -81,14 +82,12 @@ class _ZanButtonState extends State<ZanButton> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool isProcessing = false;
|
bool isProcessing = false;
|
||||||
void Function()? handleState(Future Function() action) {
|
void handleState(Future Function() action) async {
|
||||||
return isProcessing
|
if (isProcessing.not) {
|
||||||
? null
|
isProcessing = true;
|
||||||
: () async {
|
await action();
|
||||||
setState(() => isProcessing = true);
|
isProcessing = false;
|
||||||
await action();
|
}
|
||||||
setState(() => isProcessing = false);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -102,7 +101,7 @@ class _ZanButtonState extends State<ZanButton> {
|
|||||||
SizedBox(
|
SizedBox(
|
||||||
height: 32,
|
height: 32,
|
||||||
child: TextButton(
|
child: TextButton(
|
||||||
onPressed: handleState(onHateReply),
|
onPressed: () => handleState(onHateReply),
|
||||||
child: Icon(
|
child: Icon(
|
||||||
widget.replyItem!.action == 2
|
widget.replyItem!.action == 2
|
||||||
? FontAwesomeIcons.solidThumbsDown
|
? FontAwesomeIcons.solidThumbsDown
|
||||||
@@ -116,7 +115,7 @@ class _ZanButtonState extends State<ZanButton> {
|
|||||||
SizedBox(
|
SizedBox(
|
||||||
height: 32,
|
height: 32,
|
||||||
child: TextButton(
|
child: TextButton(
|
||||||
onPressed: handleState(onLikeReply),
|
onPressed: () => handleState(onLikeReply),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Icon(
|
Icon(
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import 'package:PiliPalaX/grpc/app/main/community/reply/v1/reply.pb.dart';
|
import 'package:PiliPalaX/grpc/app/main/community/reply/v1/reply.pb.dart';
|
||||||
|
import 'package:PiliPalaX/utils/extension.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:font_awesome_flutter/font_awesome_flutter.dart';
|
||||||
@@ -91,14 +92,12 @@ class _ZanButtonGrpcState extends State<ZanButtonGrpc> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool isProcessing = false;
|
bool isProcessing = false;
|
||||||
void Function()? handleState(Future Function() action) {
|
void handleState(Future Function() action) async {
|
||||||
return isProcessing
|
if (isProcessing.not) {
|
||||||
? null
|
isProcessing = true;
|
||||||
: () async {
|
await action();
|
||||||
setState(() => isProcessing = true);
|
isProcessing = false;
|
||||||
await action();
|
}
|
||||||
setState(() => isProcessing = false);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get _style => TextButton.styleFrom(
|
get _style => TextButton.styleFrom(
|
||||||
@@ -119,7 +118,7 @@ class _ZanButtonGrpcState extends State<ZanButtonGrpc> {
|
|||||||
height: 32,
|
height: 32,
|
||||||
child: TextButton(
|
child: TextButton(
|
||||||
style: _style,
|
style: _style,
|
||||||
onPressed: handleState(onHateReply),
|
onPressed: () => handleState(onHateReply),
|
||||||
child: Icon(
|
child: Icon(
|
||||||
widget.replyItem.replyControl.action.toInt() == 2
|
widget.replyItem.replyControl.action.toInt() == 2
|
||||||
? FontAwesomeIcons.solidThumbsDown
|
? FontAwesomeIcons.solidThumbsDown
|
||||||
@@ -138,7 +137,7 @@ class _ZanButtonGrpcState extends State<ZanButtonGrpc> {
|
|||||||
height: 32,
|
height: 32,
|
||||||
child: TextButton(
|
child: TextButton(
|
||||||
style: _style,
|
style: _style,
|
||||||
onPressed: handleState(onLikeReply),
|
onPressed: () => handleState(onLikeReply),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Icon(
|
Icon(
|
||||||
|
|||||||
Reference in New Issue
Block a user