mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
common dyn page
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -12,27 +12,29 @@ import 'package:PiliPlus/models/dynamics/result.dart';
|
|||||||
import 'package:PiliPlus/models/model_avatar.dart';
|
import 'package:PiliPlus/models/model_avatar.dart';
|
||||||
import 'package:PiliPlus/models_new/article/article_info/data.dart';
|
import 'package:PiliPlus/models_new/article/article_info/data.dart';
|
||||||
import 'package:PiliPlus/models_new/article/article_view/data.dart';
|
import 'package:PiliPlus/models_new/article/article_view/data.dart';
|
||||||
import 'package:PiliPlus/pages/common/reply_controller.dart';
|
import 'package:PiliPlus/pages/common/dyn/common_dyn_controller.dart';
|
||||||
import 'package:PiliPlus/utils/accounts.dart';
|
import 'package:PiliPlus/utils/accounts.dart';
|
||||||
import 'package:PiliPlus/utils/storage_pref.dart';
|
import 'package:PiliPlus/utils/storage_pref.dart';
|
||||||
import 'package:PiliPlus/utils/url_utils.dart';
|
import 'package:PiliPlus/utils/url_utils.dart';
|
||||||
|
import 'package:flutter/rendering.dart' show ScrollDirection;
|
||||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
class ArticleController extends ReplyController<MainListReply> {
|
class ArticleController extends CommonDynController<MainListReply> {
|
||||||
late String id;
|
late String id;
|
||||||
late String type;
|
late String type;
|
||||||
|
|
||||||
late String url;
|
late String url;
|
||||||
late int commentType;
|
|
||||||
late int commentId;
|
late int commentId;
|
||||||
|
@override
|
||||||
|
int get oid => commentId;
|
||||||
|
late int commentType;
|
||||||
|
@override
|
||||||
|
int get replyType => commentType;
|
||||||
final summary = Summary();
|
final summary = Summary();
|
||||||
|
|
||||||
RxBool showTitle = false.obs;
|
|
||||||
|
|
||||||
late final RxInt topIndex = 0.obs;
|
late final RxInt topIndex = 0.obs;
|
||||||
|
|
||||||
late final horizontalPreview = Pref.horizontalPreview;
|
|
||||||
late final showDynActionBar = Pref.showDynActionBar;
|
late final showDynActionBar = Pref.showDynActionBar;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -186,19 +188,20 @@ class ArticleController extends ReplyController<MainListReply> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> onFav() async {
|
Future<void> onFav() async {
|
||||||
bool isFav = stats.value?.favorite?.status == true;
|
final favorite = stats.value?.favorite;
|
||||||
|
bool isFav = favorite?.status == true;
|
||||||
final res = type == 'read'
|
final res = type == 'read'
|
||||||
? isFav
|
? isFav
|
||||||
? await FavHttp.delFavArticle(id: commentId)
|
? await FavHttp.delFavArticle(id: commentId)
|
||||||
: await FavHttp.addFavArticle(id: commentId)
|
: await FavHttp.addFavArticle(id: commentId)
|
||||||
: await FavHttp.communityAction(opusId: id, action: isFav ? 4 : 3);
|
: await FavHttp.communityAction(opusId: id, action: isFav ? 4 : 3);
|
||||||
if (res['status']) {
|
if (res['status']) {
|
||||||
stats.value?.favorite?.status = !isFav;
|
favorite?.status = !isFav;
|
||||||
var count = stats.value?.favorite?.count ?? 0;
|
var count = favorite?.count ?? 0;
|
||||||
if (isFav) {
|
if (isFav) {
|
||||||
stats.value?.favorite?.count = count - 1;
|
favorite?.count = count - 1;
|
||||||
} else {
|
} else {
|
||||||
stats.value?.favorite?.count = count + 1;
|
favorite?.count = count + 1;
|
||||||
}
|
}
|
||||||
stats.refresh();
|
stats.refresh();
|
||||||
SmartDialog.showToast('${isFav ? '取消' : ''}收藏成功');
|
SmartDialog.showToast('${isFav ? '取消' : ''}收藏成功');
|
||||||
@@ -208,18 +211,19 @@ class ArticleController extends ReplyController<MainListReply> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> onLike() async {
|
Future<void> onLike() async {
|
||||||
bool isLike = stats.value?.like?.status == true;
|
final like = stats.value?.like;
|
||||||
|
bool isLike = like?.status == true;
|
||||||
final res = await DynamicsHttp.thumbDynamic(
|
final res = await DynamicsHttp.thumbDynamic(
|
||||||
dynamicId: opusData?.idStr ?? articleData?.dynIdStr,
|
dynamicId: opusData?.idStr ?? articleData?.dynIdStr,
|
||||||
up: isLike ? 2 : 1,
|
up: isLike ? 2 : 1,
|
||||||
);
|
);
|
||||||
if (res['status']) {
|
if (res['status']) {
|
||||||
stats.value?.like?.status = !isLike;
|
like?.status = !isLike;
|
||||||
int count = stats.value?.like?.count ?? 0;
|
int count = like?.count ?? 0;
|
||||||
if (isLike) {
|
if (isLike) {
|
||||||
stats.value?.like?.count = count - 1;
|
like?.count = count - 1;
|
||||||
} else {
|
} else {
|
||||||
stats.value?.like?.count = count + 1;
|
like?.count = count + 1;
|
||||||
}
|
}
|
||||||
stats.refresh();
|
stats.refresh();
|
||||||
SmartDialog.showToast(!isLike ? '点赞成功' : '取消赞');
|
SmartDialog.showToast(!isLike ? '点赞成功' : '取消赞');
|
||||||
@@ -227,6 +231,22 @@ class ArticleController extends ReplyController<MainListReply> {
|
|||||||
SmartDialog.showToast(res['msg']);
|
SmartDialog.showToast(res['msg']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void listener() {
|
||||||
|
showTitle.value = scrollController.positions.last.pixels >= 45;
|
||||||
|
final ScrollDirection direction1 =
|
||||||
|
scrollController.positions.first.userScrollDirection;
|
||||||
|
late final ScrollDirection direction2 =
|
||||||
|
scrollController.positions.last.userScrollDirection;
|
||||||
|
if (direction1 == ScrollDirection.forward ||
|
||||||
|
direction2 == ScrollDirection.forward) {
|
||||||
|
showFab();
|
||||||
|
} else if (direction1 == ScrollDirection.reverse ||
|
||||||
|
direction2 == ScrollDirection.reverse) {
|
||||||
|
hideFab();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Summary {
|
class Summary {
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
80
lib/pages/common/dyn/common_dyn_controller.dart
Normal file
80
lib/pages/common/dyn/common_dyn_controller.dart
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
import 'package:PiliPlus/pages/common/reply_controller.dart';
|
||||||
|
import 'package:PiliPlus/utils/storage_pref.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/rendering.dart' show ScrollDirection;
|
||||||
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
|
abstract class CommonDynController<R> extends ReplyController<R>
|
||||||
|
with GetSingleTickerProviderStateMixin {
|
||||||
|
int get oid;
|
||||||
|
int get replyType;
|
||||||
|
|
||||||
|
bool _showFab = true;
|
||||||
|
late final AnimationController fabAnimationCtr;
|
||||||
|
late final Animation<Offset> fabAnim;
|
||||||
|
|
||||||
|
final RxBool showTitle = false.obs;
|
||||||
|
|
||||||
|
late final horizontalPreview = Pref.horizontalPreview;
|
||||||
|
late final List<double> ratio = Pref.dynamicDetailRatio;
|
||||||
|
|
||||||
|
double offsetDy = 1;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void onInit() {
|
||||||
|
fabAnimationCtr = AnimationController(
|
||||||
|
vsync: this,
|
||||||
|
duration: const Duration(milliseconds: 300),
|
||||||
|
);
|
||||||
|
fabAnim =
|
||||||
|
Tween<Offset>(
|
||||||
|
begin: Offset(0, offsetDy),
|
||||||
|
end: Offset.zero,
|
||||||
|
).animate(
|
||||||
|
CurvedAnimation(
|
||||||
|
parent: fabAnimationCtr,
|
||||||
|
curve: Curves.easeInOut,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
fabAnimationCtr.forward();
|
||||||
|
scrollController.addListener(listener);
|
||||||
|
super.onInit();
|
||||||
|
}
|
||||||
|
|
||||||
|
void listener() {
|
||||||
|
showTitle.value = scrollController.positions.first.pixels > 55;
|
||||||
|
|
||||||
|
final ScrollDirection direction1 =
|
||||||
|
scrollController.positions.first.userScrollDirection;
|
||||||
|
late final ScrollDirection direction2 =
|
||||||
|
scrollController.positions.last.userScrollDirection;
|
||||||
|
if (direction1 == ScrollDirection.forward ||
|
||||||
|
direction2 == ScrollDirection.forward) {
|
||||||
|
showFab();
|
||||||
|
} else if (direction1 == ScrollDirection.reverse ||
|
||||||
|
direction2 == ScrollDirection.reverse) {
|
||||||
|
hideFab();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void showFab() {
|
||||||
|
if (!_showFab) {
|
||||||
|
_showFab = true;
|
||||||
|
fabAnimationCtr.forward();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void hideFab() {
|
||||||
|
if (_showFab) {
|
||||||
|
_showFab = false;
|
||||||
|
fabAnimationCtr.reverse();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void onClose() {
|
||||||
|
fabAnimationCtr.dispose();
|
||||||
|
scrollController.removeListener(listener);
|
||||||
|
super.onClose();
|
||||||
|
}
|
||||||
|
}
|
||||||
219
lib/pages/common/dyn/common_dyn_page.dart
Normal file
219
lib/pages/common/dyn/common_dyn_page.dart
Normal file
@@ -0,0 +1,219 @@
|
|||||||
|
import 'package:PiliPlus/common/skeleton/video_reply.dart';
|
||||||
|
import 'package:PiliPlus/common/widgets/custom_sliver_persistent_header_delegate.dart';
|
||||||
|
import 'package:PiliPlus/common/widgets/loading_widget/http_error.dart';
|
||||||
|
import 'package:PiliPlus/grpc/bilibili/main/community/reply/v1.pb.dart'
|
||||||
|
show ReplyInfo;
|
||||||
|
import 'package:PiliPlus/http/loading_state.dart';
|
||||||
|
import 'package:PiliPlus/pages/common/dyn/common_dyn_controller.dart';
|
||||||
|
import 'package:PiliPlus/pages/video/reply/widgets/reply_item_grpc.dart';
|
||||||
|
import 'package:PiliPlus/pages/video/reply_reply/view.dart';
|
||||||
|
import 'package:PiliPlus/utils/num_util.dart';
|
||||||
|
import 'package:PiliPlus/utils/page_utils.dart';
|
||||||
|
import 'package:easy_debounce/easy_throttle.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
|
abstract class CommonDynPage extends StatefulWidget {
|
||||||
|
const CommonDynPage({super.key});
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class CommonDynPageState<T extends CommonDynPage> extends State<T>
|
||||||
|
with TickerProviderStateMixin {
|
||||||
|
CommonDynController get controller;
|
||||||
|
|
||||||
|
late final scaffoldKey = GlobalKey<ScaffoldState>();
|
||||||
|
|
||||||
|
bool get horizontalPreview =>
|
||||||
|
context.orientation == Orientation.landscape &&
|
||||||
|
controller.horizontalPreview;
|
||||||
|
Function(List<String> imgList, int index)? imageCallback;
|
||||||
|
|
||||||
|
dynamic get arguments;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void didChangeDependencies() {
|
||||||
|
super.didChangeDependencies();
|
||||||
|
imageCallback = horizontalPreview
|
||||||
|
? (imgList, index) {
|
||||||
|
controller.hideFab();
|
||||||
|
PageUtils.onHorizontalPreview(
|
||||||
|
scaffoldKey,
|
||||||
|
this,
|
||||||
|
imgList,
|
||||||
|
index,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
: null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget buildReplyHeader(ThemeData theme) {
|
||||||
|
final secondary = theme.colorScheme.secondary;
|
||||||
|
return SliverPersistentHeader(
|
||||||
|
pinned: true,
|
||||||
|
delegate: CustomSliverPersistentHeaderDelegate(
|
||||||
|
extent: 45,
|
||||||
|
bgColor: theme.colorScheme.surface,
|
||||||
|
child: Container(
|
||||||
|
height: 45,
|
||||||
|
padding: const EdgeInsets.only(left: 12, right: 6),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Obx(
|
||||||
|
() => Text(
|
||||||
|
'${controller.count.value == -1 ? 0 : NumUtil.numFormat(controller.count.value)}条回复',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 35,
|
||||||
|
child: TextButton.icon(
|
||||||
|
onPressed: controller.queryBySort,
|
||||||
|
icon: Icon(
|
||||||
|
Icons.sort,
|
||||||
|
size: 16,
|
||||||
|
color: secondary,
|
||||||
|
),
|
||||||
|
label: Obx(
|
||||||
|
() => Text(
|
||||||
|
controller.sortType.value.label,
|
||||||
|
style: TextStyle(fontSize: 13, color: secondary),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget replyList(
|
||||||
|
ThemeData theme,
|
||||||
|
LoadingState<List<ReplyInfo>?> loadingState,
|
||||||
|
) {
|
||||||
|
return switch (loadingState) {
|
||||||
|
Loading() => SliverList.builder(
|
||||||
|
itemCount: 12,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
return const VideoReplySkeleton();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
Success(:var response) =>
|
||||||
|
response?.isNotEmpty == true
|
||||||
|
? SliverList.builder(
|
||||||
|
itemCount: response!.length + 1,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
if (index == response.length) {
|
||||||
|
controller.onLoadMore();
|
||||||
|
return Container(
|
||||||
|
alignment: Alignment.center,
|
||||||
|
margin: EdgeInsets.only(
|
||||||
|
bottom: MediaQuery.paddingOf(context).bottom,
|
||||||
|
),
|
||||||
|
height: 125,
|
||||||
|
child: Text(
|
||||||
|
controller.isEnd ? '没有更多了' : '加载中...',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 12,
|
||||||
|
color: theme.colorScheme.outline,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return ReplyItemGrpc(
|
||||||
|
replyItem: response[index],
|
||||||
|
replyLevel: 1,
|
||||||
|
replyReply: (replyItem, id) =>
|
||||||
|
replyReply(context, replyItem, id),
|
||||||
|
onReply: (replyItem) => controller.onReply(
|
||||||
|
context,
|
||||||
|
replyItem: replyItem,
|
||||||
|
),
|
||||||
|
onDelete: (item, subIndex) =>
|
||||||
|
controller.onRemove(index, item, subIndex),
|
||||||
|
upMid: controller.upMid,
|
||||||
|
callback: imageCallback,
|
||||||
|
onCheckReply: (item) =>
|
||||||
|
controller.onCheckReply(item, isManual: true),
|
||||||
|
onToggleTop: (item) => controller.onToggleTop(
|
||||||
|
item,
|
||||||
|
index,
|
||||||
|
controller.oid,
|
||||||
|
controller.replyType,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
|
: HttpError(onReload: controller.onReload),
|
||||||
|
Error(:var errMsg) => HttpError(
|
||||||
|
errMsg: errMsg,
|
||||||
|
onReload: controller.onReload,
|
||||||
|
),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
void replyReply(BuildContext context, ReplyInfo replyItem, int? id) {
|
||||||
|
EasyThrottle.throttle('replyReply', const Duration(milliseconds: 500), () {
|
||||||
|
int oid = replyItem.oid.toInt();
|
||||||
|
int rpid = replyItem.id.toInt();
|
||||||
|
Widget replyReplyPage({bool showBackBtn = true}) => Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
toolbarHeight: showBackBtn ? null : 45,
|
||||||
|
title: const Text('评论详情'),
|
||||||
|
titleSpacing: showBackBtn ? null : 12,
|
||||||
|
automaticallyImplyLeading: showBackBtn,
|
||||||
|
actions: showBackBtn
|
||||||
|
? null
|
||||||
|
: [
|
||||||
|
IconButton(
|
||||||
|
tooltip: '关闭',
|
||||||
|
icon: const Icon(Icons.close, size: 20),
|
||||||
|
onPressed: Get.back,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
body: SafeArea(
|
||||||
|
top: false,
|
||||||
|
bottom: false,
|
||||||
|
child: VideoReplyReplyPanel(
|
||||||
|
enableSlide: false,
|
||||||
|
id: id,
|
||||||
|
oid: oid,
|
||||||
|
rpid: rpid,
|
||||||
|
isVideoDetail: false,
|
||||||
|
replyType: controller.replyType,
|
||||||
|
firstFloor: replyItem,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
if (this.context.orientation == Orientation.portrait) {
|
||||||
|
Get.to(
|
||||||
|
replyReplyPage,
|
||||||
|
routeName: 'dynamicDetail-Copy',
|
||||||
|
arguments: arguments,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
ScaffoldState? scaffoldState = Scaffold.maybeOf(context);
|
||||||
|
if (scaffoldState != null) {
|
||||||
|
controller.hideFab();
|
||||||
|
scaffoldState.showBottomSheet(
|
||||||
|
backgroundColor: Colors.transparent,
|
||||||
|
(context) => MediaQuery.removePadding(
|
||||||
|
context: context,
|
||||||
|
removeLeft: true,
|
||||||
|
child: replyReplyPage(showBackBtn: false),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
Get.to(
|
||||||
|
replyReplyPage,
|
||||||
|
routeName: 'dynamicDetail-Copy',
|
||||||
|
arguments: arguments,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,173 +1,104 @@
|
|||||||
import 'package:PiliPlus/http/dynamics.dart';
|
|
||||||
import 'package:PiliPlus/models/dynamics/result.dart';
|
import 'package:PiliPlus/models/dynamics/result.dart';
|
||||||
import 'package:PiliPlus/pages/dynamics_repost/view.dart';
|
import 'package:PiliPlus/pages/dynamics_repost/view.dart';
|
||||||
import 'package:PiliPlus/utils/feed_back.dart';
|
|
||||||
import 'package:PiliPlus/utils/num_util.dart';
|
import 'package:PiliPlus/utils/num_util.dart';
|
||||||
import 'package:PiliPlus/utils/page_utils.dart';
|
import 'package:PiliPlus/utils/page_utils.dart';
|
||||||
|
import 'package:PiliPlus/utils/request_utils.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.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';
|
||||||
|
|
||||||
class ActionPanel extends StatefulWidget {
|
class ActionPanel extends StatelessWidget {
|
||||||
const ActionPanel({
|
const ActionPanel({
|
||||||
super.key,
|
super.key,
|
||||||
required this.item,
|
required this.item,
|
||||||
});
|
});
|
||||||
final DynamicItemModel item;
|
final DynamicItemModel item;
|
||||||
|
|
||||||
@override
|
|
||||||
State<ActionPanel> createState() => _ActionPanelState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _ActionPanelState extends State<ActionPanel> {
|
|
||||||
bool isProcessing = false;
|
|
||||||
Future<void> handleState(Future Function() action) async {
|
|
||||||
if (!isProcessing) {
|
|
||||||
isProcessing = true;
|
|
||||||
await action();
|
|
||||||
isProcessing = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 动态点赞
|
|
||||||
Future<void> onLikeDynamic() async {
|
|
||||||
feedBack();
|
|
||||||
final item = widget.item;
|
|
||||||
String dynamicId = item.idStr!;
|
|
||||||
// 1 已点赞 2 不喜欢 0 未操作
|
|
||||||
DynamicStat? like = item.modules.moduleStat?.like;
|
|
||||||
int count = like?.count ?? 0;
|
|
||||||
bool status = like?.status == true;
|
|
||||||
int up = status ? 2 : 1;
|
|
||||||
var res = await DynamicsHttp.thumbDynamic(dynamicId: dynamicId, up: up);
|
|
||||||
if (res['status']) {
|
|
||||||
SmartDialog.showToast(!status ? '点赞成功' : '取消赞');
|
|
||||||
if (up == 1) {
|
|
||||||
item.modules.moduleStat?.like
|
|
||||||
?..count = count + 1
|
|
||||||
..status = true;
|
|
||||||
} else {
|
|
||||||
item.modules.moduleStat?.like
|
|
||||||
?..count = count - 1
|
|
||||||
..status = false;
|
|
||||||
}
|
|
||||||
if (mounted) {
|
|
||||||
setState(() {});
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
SmartDialog.showToast(res['msg']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final theme = Theme.of(context);
|
final theme = Theme.of(context);
|
||||||
final color = theme.colorScheme.outline;
|
|
||||||
final primary = theme.colorScheme.primary;
|
final primary = theme.colorScheme.primary;
|
||||||
final outline = theme.colorScheme.outline;
|
final outline = theme.colorScheme.outline;
|
||||||
|
final moduleStat = item.modules.moduleStat!;
|
||||||
|
final forward = moduleStat.forward!;
|
||||||
|
final comment = moduleStat.comment!;
|
||||||
|
final like = moduleStat.like!;
|
||||||
|
final btnStyle = TextButton.styleFrom(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 15),
|
||||||
|
foregroundColor: outline,
|
||||||
|
);
|
||||||
return Row(
|
return Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: 1,
|
|
||||||
child: TextButton.icon(
|
child: TextButton.icon(
|
||||||
onPressed: () => showModalBottomSheet(
|
onPressed: () => showModalBottomSheet(
|
||||||
context: context,
|
context: context,
|
||||||
isScrollControlled: true,
|
isScrollControlled: true,
|
||||||
useSafeArea: true,
|
useSafeArea: true,
|
||||||
builder: (context) => RepostPanel(
|
builder: (_) => RepostPanel(
|
||||||
item: widget.item,
|
item: item,
|
||||||
callback: () {
|
callback: () {
|
||||||
int count =
|
int count = forward.count ?? 0;
|
||||||
widget.item.modules.moduleStat?.forward?.count ?? 0;
|
forward.count = count + 1;
|
||||||
widget.item.modules.moduleStat!.forward!.count = count + 1;
|
if (context.mounted) {
|
||||||
setState(() {});
|
(context as Element?)?.markNeedsBuild();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
icon: Icon(
|
icon: Icon(
|
||||||
FontAwesomeIcons.shareFromSquare,
|
FontAwesomeIcons.shareFromSquare,
|
||||||
size: 16,
|
size: 16,
|
||||||
color: color,
|
color: outline,
|
||||||
semanticLabel: "转发",
|
semanticLabel: "转发",
|
||||||
),
|
),
|
||||||
style: TextButton.styleFrom(
|
style: btnStyle,
|
||||||
padding: const EdgeInsets.fromLTRB(15, 0, 15, 0),
|
|
||||||
foregroundColor: outline,
|
|
||||||
),
|
|
||||||
label: Text(
|
label: Text(
|
||||||
widget.item.modules.moduleStat!.forward!.count != null
|
forward.count != null ? NumUtil.numFormat(forward.count) : '转发',
|
||||||
? NumUtil.numFormat(
|
|
||||||
widget.item.modules.moduleStat!.forward!.count,
|
|
||||||
)
|
|
||||||
: '转发',
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: 1,
|
|
||||||
child: TextButton.icon(
|
child: TextButton.icon(
|
||||||
onPressed: () =>
|
onPressed: () =>
|
||||||
PageUtils.pushDynDetail(widget.item, 1, action: 'comment'),
|
PageUtils.pushDynDetail(item, 1, action: 'comment'),
|
||||||
icon: Icon(
|
icon: Icon(
|
||||||
FontAwesomeIcons.comment,
|
FontAwesomeIcons.comment,
|
||||||
size: 16,
|
size: 16,
|
||||||
color: color,
|
color: outline,
|
||||||
semanticLabel: "评论",
|
semanticLabel: "评论",
|
||||||
),
|
),
|
||||||
style: TextButton.styleFrom(
|
style: btnStyle,
|
||||||
padding: const EdgeInsets.fromLTRB(15, 0, 15, 0),
|
|
||||||
foregroundColor: outline,
|
|
||||||
),
|
|
||||||
label: Text(
|
label: Text(
|
||||||
widget.item.modules.moduleStat!.comment!.count != null
|
comment.count != null ? NumUtil.numFormat(comment.count) : '评论',
|
||||||
? NumUtil.numFormat(
|
|
||||||
widget.item.modules.moduleStat!.comment!.count,
|
|
||||||
)
|
|
||||||
: '评论',
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: 1,
|
|
||||||
child: TextButton.icon(
|
child: TextButton.icon(
|
||||||
onPressed: () => handleState(onLikeDynamic),
|
onPressed: () => RequestUtils.onLikeDynamic(item, () {
|
||||||
|
if (context.mounted) {
|
||||||
|
(context as Element?)?.markNeedsBuild();
|
||||||
|
}
|
||||||
|
}),
|
||||||
icon: Icon(
|
icon: Icon(
|
||||||
widget.item.modules.moduleStat!.like!.status!
|
like.status!
|
||||||
? FontAwesomeIcons.solidThumbsUp
|
? FontAwesomeIcons.solidThumbsUp
|
||||||
: FontAwesomeIcons.thumbsUp,
|
: FontAwesomeIcons.thumbsUp,
|
||||||
size: 16,
|
size: 16,
|
||||||
color: widget.item.modules.moduleStat!.like!.status!
|
color: like.status! ? primary : outline,
|
||||||
? primary
|
semanticLabel: like.status! ? "已赞" : "点赞",
|
||||||
: color,
|
|
||||||
semanticLabel: widget.item.modules.moduleStat!.like!.status!
|
|
||||||
? "已赞"
|
|
||||||
: "点赞",
|
|
||||||
),
|
|
||||||
style: TextButton.styleFrom(
|
|
||||||
padding: const EdgeInsets.fromLTRB(15, 0, 15, 0),
|
|
||||||
foregroundColor: outline,
|
|
||||||
),
|
),
|
||||||
|
style: btnStyle,
|
||||||
label: AnimatedSwitcher(
|
label: AnimatedSwitcher(
|
||||||
duration: const Duration(milliseconds: 400),
|
duration: const Duration(milliseconds: 400),
|
||||||
transitionBuilder: (Widget child, Animation<double> animation) {
|
transitionBuilder: (Widget child, Animation<double> animation) {
|
||||||
return ScaleTransition(scale: animation, child: child);
|
return ScaleTransition(scale: animation, child: child);
|
||||||
},
|
},
|
||||||
child: Text(
|
child: Text(
|
||||||
widget.item.modules.moduleStat!.like!.count != null
|
like.count != null ? NumUtil.numFormat(like.count) : '点赞',
|
||||||
? NumUtil.numFormat(
|
key: ValueKey<String>(like.count?.toString() ?? '点赞'),
|
||||||
widget.item.modules.moduleStat!.like!.count,
|
style: TextStyle(color: like.status! ? primary : outline),
|
||||||
)
|
|
||||||
: '点赞',
|
|
||||||
key: ValueKey<String>(
|
|
||||||
widget.item.modules.moduleStat!.like!.count?.toString() ??
|
|
||||||
'点赞',
|
|
||||||
),
|
|
||||||
style: TextStyle(
|
|
||||||
color: widget.item.modules.moduleStat!.like!.status!
|
|
||||||
? primary
|
|
||||||
: color,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -4,18 +4,19 @@ import 'package:PiliPlus/grpc/reply.dart';
|
|||||||
import 'package:PiliPlus/http/dynamics.dart';
|
import 'package:PiliPlus/http/dynamics.dart';
|
||||||
import 'package:PiliPlus/http/loading_state.dart';
|
import 'package:PiliPlus/http/loading_state.dart';
|
||||||
import 'package:PiliPlus/models/dynamics/result.dart';
|
import 'package:PiliPlus/models/dynamics/result.dart';
|
||||||
import 'package:PiliPlus/pages/common/reply_controller.dart';
|
import 'package:PiliPlus/pages/common/dyn/common_dyn_controller.dart';
|
||||||
import 'package:PiliPlus/utils/id_utils.dart';
|
import 'package:PiliPlus/utils/id_utils.dart';
|
||||||
import 'package:PiliPlus/utils/storage_pref.dart';
|
import 'package:PiliPlus/utils/storage_pref.dart';
|
||||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
class DynamicDetailController extends ReplyController<MainListReply> {
|
class DynamicDetailController extends CommonDynController<MainListReply> {
|
||||||
|
@override
|
||||||
late int oid;
|
late int oid;
|
||||||
|
@override
|
||||||
late int replyType;
|
late int replyType;
|
||||||
late DynamicItemModel dynItem;
|
late DynamicItemModel dynItem;
|
||||||
|
|
||||||
late final horizontalPreview = Pref.horizontalPreview;
|
|
||||||
late final showDynActionBar = Pref.showDynActionBar;
|
late final showDynActionBar = Pref.showDynActionBar;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
@@ -1,222 +1,58 @@
|
|||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
|
|
||||||
import 'package:PiliPlus/common/skeleton/video_reply.dart';
|
|
||||||
import 'package:PiliPlus/common/widgets/custom_icon.dart';
|
import 'package:PiliPlus/common/widgets/custom_icon.dart';
|
||||||
import 'package:PiliPlus/common/widgets/custom_sliver_persistent_header_delegate.dart';
|
|
||||||
import 'package:PiliPlus/common/widgets/loading_widget/http_error.dart';
|
|
||||||
import 'package:PiliPlus/common/widgets/refresh_indicator.dart';
|
import 'package:PiliPlus/common/widgets/refresh_indicator.dart';
|
||||||
import 'package:PiliPlus/grpc/bilibili/main/community/reply/v1.pb.dart'
|
|
||||||
show ReplyInfo;
|
|
||||||
import 'package:PiliPlus/http/constants.dart';
|
import 'package:PiliPlus/http/constants.dart';
|
||||||
import 'package:PiliPlus/http/loading_state.dart';
|
|
||||||
import 'package:PiliPlus/models/dynamics/result.dart';
|
import 'package:PiliPlus/models/dynamics/result.dart';
|
||||||
|
import 'package:PiliPlus/pages/common/dyn/common_dyn_page.dart';
|
||||||
import 'package:PiliPlus/pages/dynamics/widgets/author_panel.dart';
|
import 'package:PiliPlus/pages/dynamics/widgets/author_panel.dart';
|
||||||
import 'package:PiliPlus/pages/dynamics/widgets/dynamic_panel.dart';
|
import 'package:PiliPlus/pages/dynamics/widgets/dynamic_panel.dart';
|
||||||
import 'package:PiliPlus/pages/dynamics_detail/controller.dart';
|
import 'package:PiliPlus/pages/dynamics_detail/controller.dart';
|
||||||
import 'package:PiliPlus/pages/dynamics_repost/view.dart';
|
import 'package:PiliPlus/pages/dynamics_repost/view.dart';
|
||||||
import 'package:PiliPlus/pages/video/reply/widgets/reply_item_grpc.dart';
|
|
||||||
import 'package:PiliPlus/pages/video/reply_reply/view.dart';
|
|
||||||
import 'package:PiliPlus/utils/feed_back.dart';
|
import 'package:PiliPlus/utils/feed_back.dart';
|
||||||
import 'package:PiliPlus/utils/grid.dart';
|
import 'package:PiliPlus/utils/grid.dart';
|
||||||
import 'package:PiliPlus/utils/num_util.dart';
|
import 'package:PiliPlus/utils/num_util.dart';
|
||||||
import 'package:PiliPlus/utils/page_utils.dart';
|
|
||||||
import 'package:PiliPlus/utils/request_utils.dart';
|
import 'package:PiliPlus/utils/request_utils.dart';
|
||||||
import 'package:PiliPlus/utils/storage.dart';
|
import 'package:PiliPlus/utils/storage.dart';
|
||||||
import 'package:PiliPlus/utils/storage_key.dart';
|
import 'package:PiliPlus/utils/storage_key.dart';
|
||||||
import 'package:PiliPlus/utils/storage_pref.dart';
|
|
||||||
import 'package:PiliPlus/utils/utils.dart';
|
import 'package:PiliPlus/utils/utils.dart';
|
||||||
import 'package:easy_debounce/easy_throttle.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/rendering.dart';
|
|
||||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
class DynamicDetailPage extends StatefulWidget {
|
class DynamicDetailPage extends CommonDynPage {
|
||||||
const DynamicDetailPage({super.key});
|
const DynamicDetailPage({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<DynamicDetailPage> createState() => _DynamicDetailPageState();
|
State<DynamicDetailPage> createState() => _DynamicDetailPageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _DynamicDetailPageState extends State<DynamicDetailPage>
|
class _DynamicDetailPageState extends CommonDynPageState<DynamicDetailPage> {
|
||||||
with TickerProviderStateMixin {
|
@override
|
||||||
final _controller = Get.put(
|
final DynamicDetailController controller = Get.put(
|
||||||
DynamicDetailController(),
|
DynamicDetailController(),
|
||||||
tag: Utils.generateRandomString(8),
|
tag: Utils.generateRandomString(8),
|
||||||
);
|
);
|
||||||
late final AnimationController _fabAnimationCtr;
|
|
||||||
late final Animation<Offset> _anim;
|
|
||||||
|
|
||||||
final RxBool _visibleTitle = false.obs;
|
|
||||||
bool _isFabVisible = true;
|
|
||||||
|
|
||||||
late final List<double> _ratio = Pref.dynamicDetailRatio;
|
|
||||||
|
|
||||||
bool get _horizontalPreview =>
|
|
||||||
context.orientation == Orientation.landscape &&
|
|
||||||
_controller.horizontalPreview;
|
|
||||||
|
|
||||||
late final _key = GlobalKey<ScaffoldState>();
|
|
||||||
|
|
||||||
late Function(List<String> imgList, int index)? _imageCallback;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
dynamic get arguments => {
|
||||||
super.initState();
|
'item': controller.dynItem,
|
||||||
_fabAnimationCtr = AnimationController(
|
};
|
||||||
vsync: this,
|
|
||||||
duration: const Duration(milliseconds: 300),
|
|
||||||
);
|
|
||||||
_anim =
|
|
||||||
Tween<Offset>(
|
|
||||||
begin: const Offset(0, 1),
|
|
||||||
end: Offset.zero,
|
|
||||||
).animate(
|
|
||||||
CurvedAnimation(
|
|
||||||
parent: _fabAnimationCtr,
|
|
||||||
curve: Curves.easeInOut,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
_fabAnimationCtr.forward();
|
|
||||||
_controller.scrollController.addListener(listener);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 查看二级评论
|
|
||||||
void replyReply(BuildContext context, ReplyInfo replyItem, int? id) {
|
|
||||||
EasyThrottle.throttle('replyReply', const Duration(milliseconds: 500), () {
|
|
||||||
int oid = replyItem.oid.toInt();
|
|
||||||
int rpid = replyItem.id.toInt();
|
|
||||||
Widget replyReplyPage({bool showBackBtn = true}) => Scaffold(
|
|
||||||
appBar: AppBar(
|
|
||||||
toolbarHeight: showBackBtn ? null : 45,
|
|
||||||
title: const Text('评论详情'),
|
|
||||||
titleSpacing: showBackBtn ? null : 12,
|
|
||||||
automaticallyImplyLeading: showBackBtn,
|
|
||||||
actions: showBackBtn
|
|
||||||
? null
|
|
||||||
: [
|
|
||||||
IconButton(
|
|
||||||
tooltip: '关闭',
|
|
||||||
icon: const Icon(Icons.close, size: 20),
|
|
||||||
onPressed: Get.back,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
body: SafeArea(
|
|
||||||
top: false,
|
|
||||||
bottom: false,
|
|
||||||
child: VideoReplyReplyPanel(
|
|
||||||
enableSlide: false,
|
|
||||||
id: id,
|
|
||||||
oid: oid,
|
|
||||||
rpid: rpid,
|
|
||||||
isVideoDetail: false,
|
|
||||||
replyType: _controller.replyType,
|
|
||||||
firstFloor: replyItem,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
if (this.context.orientation == Orientation.portrait) {
|
|
||||||
Get.to(
|
|
||||||
replyReplyPage,
|
|
||||||
routeName: 'dynamicDetail-Copy',
|
|
||||||
arguments: {
|
|
||||||
'item': _controller.dynItem,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
ScaffoldState? scaffoldState = Scaffold.maybeOf(context);
|
|
||||||
if (scaffoldState != null) {
|
|
||||||
bool isFabVisible = _isFabVisible;
|
|
||||||
if (isFabVisible) {
|
|
||||||
_hideFab();
|
|
||||||
}
|
|
||||||
scaffoldState.showBottomSheet(
|
|
||||||
backgroundColor: Colors.transparent,
|
|
||||||
(context) => MediaQuery.removePadding(
|
|
||||||
context: context,
|
|
||||||
removeLeft: true,
|
|
||||||
child: replyReplyPage(showBackBtn: false),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
Get.to(
|
|
||||||
replyReplyPage,
|
|
||||||
routeName: 'dynamicDetail-Copy',
|
|
||||||
arguments: {
|
|
||||||
'item': _controller.dynItem,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void didChangeDependencies() {
|
void didChangeDependencies() {
|
||||||
super.didChangeDependencies();
|
super.didChangeDependencies();
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
if (_controller.scrollController.hasClients) {
|
if (controller.scrollController.hasClients) {
|
||||||
_visibleTitle.value =
|
controller.showTitle.value =
|
||||||
_controller.scrollController.positions.first.pixels > 55;
|
controller.scrollController.positions.first.pixels > 55;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void listener() {
|
|
||||||
// 标题
|
|
||||||
_visibleTitle.value =
|
|
||||||
_controller.scrollController.positions.first.pixels > 55;
|
|
||||||
|
|
||||||
// fab按钮
|
|
||||||
final ScrollDirection direction1 =
|
|
||||||
_controller.scrollController.positions.first.userScrollDirection;
|
|
||||||
late final ScrollDirection direction2 =
|
|
||||||
_controller.scrollController.positions.last.userScrollDirection;
|
|
||||||
if (direction1 == ScrollDirection.forward ||
|
|
||||||
direction2 == ScrollDirection.forward) {
|
|
||||||
_showFab();
|
|
||||||
} else if (direction1 == ScrollDirection.reverse ||
|
|
||||||
direction2 == ScrollDirection.reverse) {
|
|
||||||
_hideFab();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void _showFab() {
|
|
||||||
if (!_isFabVisible) {
|
|
||||||
_isFabVisible = true;
|
|
||||||
_fabAnimationCtr.forward();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void _hideFab() {
|
|
||||||
if (_isFabVisible) {
|
|
||||||
_isFabVisible = false;
|
|
||||||
_fabAnimationCtr.reverse();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
_fabAnimationCtr.dispose();
|
|
||||||
_controller.scrollController.removeListener(listener);
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final theme = Theme.of(context);
|
final theme = Theme.of(context);
|
||||||
_imageCallback = _horizontalPreview
|
|
||||||
? (imgList, index) {
|
|
||||||
_hideFab();
|
|
||||||
PageUtils.onHorizontalPreview(
|
|
||||||
_key,
|
|
||||||
this,
|
|
||||||
imgList,
|
|
||||||
index,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
: null;
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
resizeToAvoidBottomInset: false,
|
resizeToAvoidBottomInset: false,
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
@@ -225,12 +61,12 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
|
|||||||
child: Obx(
|
child: Obx(
|
||||||
() {
|
() {
|
||||||
return AnimatedOpacity(
|
return AnimatedOpacity(
|
||||||
opacity: _visibleTitle.value ? 1 : 0,
|
opacity: controller.showTitle.value ? 1 : 0,
|
||||||
duration: const Duration(milliseconds: 300),
|
duration: const Duration(milliseconds: 300),
|
||||||
child: IgnorePointer(
|
child: IgnorePointer(
|
||||||
ignoring: !_visibleTitle.value,
|
ignoring: !controller.showTitle.value,
|
||||||
child: AuthorPanel(
|
child: AuthorPanel(
|
||||||
item: _controller.dynItem,
|
item: controller.dynItem,
|
||||||
isDetail: true,
|
isDetail: true,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -257,14 +93,15 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
|
|||||||
builder: (context) => Slider(
|
builder: (context) => Slider(
|
||||||
min: 1,
|
min: 1,
|
||||||
max: 100,
|
max: 100,
|
||||||
value: _ratio.first,
|
value: controller.ratio.first,
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
if (value >= 10 && value <= 90) {
|
if (value >= 10 && value <= 90) {
|
||||||
_ratio[0] = value.toPrecision(2);
|
controller.ratio
|
||||||
_ratio[1] = 100 - value;
|
..[0] = value.toPrecision(2)
|
||||||
|
..[1] = 100 - value;
|
||||||
GStorage.setting.put(
|
GStorage.setting.put(
|
||||||
SettingBoxKey.dynamicDetailRatio,
|
SettingBoxKey.dynamicDetailRatio,
|
||||||
_ratio,
|
controller.ratio,
|
||||||
);
|
);
|
||||||
(context as Element).markNeedsBuild();
|
(context as Element).markNeedsBuild();
|
||||||
setState(() {});
|
setState(() {});
|
||||||
@@ -289,7 +126,7 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
|
|||||||
bottom: false,
|
bottom: false,
|
||||||
child: context.orientation == Orientation.portrait
|
child: context.orientation == Orientation.portrait
|
||||||
? refreshIndicator(
|
? refreshIndicator(
|
||||||
onRefresh: _controller.onRefresh,
|
onRefresh: controller.onRefresh,
|
||||||
child: _buildBody(context.orientation, theme),
|
child: _buildBody(context.orientation, theme),
|
||||||
)
|
)
|
||||||
: _buildBody(context.orientation, theme),
|
: _buildBody(context.orientation, theme),
|
||||||
@@ -305,21 +142,20 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
|
|||||||
double padding = max(context.width / 2 - Grid.smallCardWidth, 0);
|
double padding = max(context.width / 2 - Grid.smallCardWidth, 0);
|
||||||
if (orientation == Orientation.portrait) {
|
if (orientation == Orientation.portrait) {
|
||||||
return CustomScrollView(
|
return CustomScrollView(
|
||||||
controller: _controller.scrollController,
|
controller: controller.scrollController,
|
||||||
physics: const AlwaysScrollableScrollPhysics(),
|
physics: const AlwaysScrollableScrollPhysics(),
|
||||||
slivers:
|
slivers:
|
||||||
[
|
[
|
||||||
SliverToBoxAdapter(
|
SliverToBoxAdapter(
|
||||||
child: DynamicPanel(
|
child: DynamicPanel(
|
||||||
item: _controller.dynItem,
|
item: controller.dynItem,
|
||||||
isDetail: true,
|
isDetail: true,
|
||||||
callback: _imageCallback,
|
callback: imageCallback,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
replyPersistentHeader(theme),
|
buildReplyHeader(theme),
|
||||||
Obx(
|
Obx(
|
||||||
() =>
|
() => replyList(theme, controller.loadingState.value),
|
||||||
replyList(theme, _controller.loadingState.value),
|
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
.map<Widget>(
|
.map<Widget>(
|
||||||
@@ -334,9 +170,9 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
|
|||||||
return Row(
|
return Row(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: _ratio[0].toInt(),
|
flex: controller.ratio[0].toInt(),
|
||||||
child: CustomScrollView(
|
child: CustomScrollView(
|
||||||
controller: _controller.scrollController,
|
controller: controller.scrollController,
|
||||||
physics: const AlwaysScrollableScrollPhysics(),
|
physics: const AlwaysScrollableScrollPhysics(),
|
||||||
slivers: [
|
slivers: [
|
||||||
SliverPadding(
|
SliverPadding(
|
||||||
@@ -346,9 +182,9 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
|
|||||||
),
|
),
|
||||||
sliver: SliverToBoxAdapter(
|
sliver: SliverToBoxAdapter(
|
||||||
child: DynamicPanel(
|
child: DynamicPanel(
|
||||||
item: _controller.dynItem,
|
item: controller.dynItem,
|
||||||
isDetail: true,
|
isDetail: true,
|
||||||
callback: _imageCallback,
|
callback: imageCallback,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -356,26 +192,26 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: _ratio[1].toInt(),
|
flex: controller.ratio[1].toInt(),
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
key: _key,
|
key: scaffoldKey,
|
||||||
backgroundColor: Colors.transparent,
|
backgroundColor: Colors.transparent,
|
||||||
body: refreshIndicator(
|
body: refreshIndicator(
|
||||||
onRefresh: _controller.onRefresh,
|
onRefresh: controller.onRefresh,
|
||||||
child: CustomScrollView(
|
child: CustomScrollView(
|
||||||
controller: _controller.scrollController,
|
controller: controller.scrollController,
|
||||||
physics: const AlwaysScrollableScrollPhysics(),
|
physics: const AlwaysScrollableScrollPhysics(),
|
||||||
slivers: [
|
slivers: [
|
||||||
SliverPadding(
|
SliverPadding(
|
||||||
padding: EdgeInsets.only(right: padding / 4),
|
padding: EdgeInsets.only(right: padding / 4),
|
||||||
sliver: replyPersistentHeader(theme),
|
sliver: buildReplyHeader(theme),
|
||||||
),
|
),
|
||||||
SliverPadding(
|
SliverPadding(
|
||||||
padding: EdgeInsets.only(right: padding / 4),
|
padding: EdgeInsets.only(right: padding / 4),
|
||||||
sliver: Obx(
|
sliver: Obx(
|
||||||
() => replyList(
|
() => replyList(
|
||||||
theme,
|
theme,
|
||||||
_controller.loadingState.value,
|
controller.loadingState.value,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -389,396 +225,170 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
Positioned(
|
_buildBottom(theme),
|
||||||
left: 0,
|
|
||||||
right: 0,
|
|
||||||
bottom: 0,
|
|
||||||
child: SlideTransition(
|
|
||||||
position: _anim,
|
|
||||||
child: Builder(
|
|
||||||
builder: (context) {
|
|
||||||
Widget button() => FloatingActionButton(
|
|
||||||
heroTag: null,
|
|
||||||
onPressed: () {
|
|
||||||
feedBack();
|
|
||||||
_controller.onReply(
|
|
||||||
context,
|
|
||||||
oid: _controller.oid,
|
|
||||||
replyType: _controller.replyType,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
tooltip: '评论动态',
|
|
||||||
child: const Icon(Icons.reply),
|
|
||||||
);
|
|
||||||
return !_controller.showDynActionBar
|
|
||||||
? Align(
|
|
||||||
alignment: Alignment.bottomRight,
|
|
||||||
child: Padding(
|
|
||||||
padding: EdgeInsets.only(
|
|
||||||
right: 14,
|
|
||||||
bottom: MediaQuery.paddingOf(context).bottom + 14,
|
|
||||||
),
|
|
||||||
child: button(),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
: Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.end,
|
|
||||||
children: [
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(right: 14, bottom: 14),
|
|
||||||
child: button(),
|
|
||||||
),
|
|
||||||
Container(
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: theme.colorScheme.surface,
|
|
||||||
border: Border(
|
|
||||||
top: BorderSide(
|
|
||||||
color: theme.colorScheme.outline.withValues(
|
|
||||||
alpha: 0.08,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
padding: EdgeInsets.only(
|
|
||||||
bottom: MediaQuery.paddingOf(context).bottom,
|
|
||||||
),
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: Builder(
|
|
||||||
builder: (btnContext) => TextButton.icon(
|
|
||||||
onPressed: () => showModalBottomSheet(
|
|
||||||
context: context,
|
|
||||||
isScrollControlled: true,
|
|
||||||
useSafeArea: true,
|
|
||||||
builder: (context) => RepostPanel(
|
|
||||||
item: _controller.dynItem,
|
|
||||||
callback: () {
|
|
||||||
int count =
|
|
||||||
_controller
|
|
||||||
.dynItem
|
|
||||||
.modules
|
|
||||||
.moduleStat
|
|
||||||
?.forward
|
|
||||||
?.count ??
|
|
||||||
0;
|
|
||||||
_controller
|
|
||||||
.dynItem
|
|
||||||
.modules
|
|
||||||
.moduleStat ??=
|
|
||||||
ModuleStatModel();
|
|
||||||
_controller
|
|
||||||
.dynItem
|
|
||||||
.modules
|
|
||||||
.moduleStat
|
|
||||||
?.forward ??=
|
|
||||||
DynamicStat();
|
|
||||||
_controller
|
|
||||||
.dynItem
|
|
||||||
.modules
|
|
||||||
.moduleStat!
|
|
||||||
.forward!
|
|
||||||
.count =
|
|
||||||
count + 1;
|
|
||||||
if (btnContext.mounted) {
|
|
||||||
(btnContext as Element?)
|
|
||||||
?.markNeedsBuild();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
icon: Icon(
|
|
||||||
FontAwesomeIcons.shareFromSquare,
|
|
||||||
size: 16,
|
|
||||||
color: theme.colorScheme.outline,
|
|
||||||
semanticLabel: "转发",
|
|
||||||
),
|
|
||||||
style: TextButton.styleFrom(
|
|
||||||
padding: const EdgeInsets.fromLTRB(
|
|
||||||
15,
|
|
||||||
0,
|
|
||||||
15,
|
|
||||||
0,
|
|
||||||
),
|
|
||||||
foregroundColor:
|
|
||||||
theme.colorScheme.outline,
|
|
||||||
),
|
|
||||||
label: Text(
|
|
||||||
_controller
|
|
||||||
.dynItem
|
|
||||||
.modules
|
|
||||||
.moduleStat
|
|
||||||
?.forward
|
|
||||||
?.count !=
|
|
||||||
null
|
|
||||||
? NumUtil.numFormat(
|
|
||||||
_controller
|
|
||||||
.dynItem
|
|
||||||
.modules
|
|
||||||
.moduleStat!
|
|
||||||
.forward!
|
|
||||||
.count,
|
|
||||||
)
|
|
||||||
: '转发',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
child: TextButton.icon(
|
|
||||||
onPressed: () => Utils.shareText(
|
|
||||||
'${HttpString.dynamicShareBaseUrl}/${_controller.dynItem.idStr}',
|
|
||||||
),
|
|
||||||
icon: Icon(
|
|
||||||
CustomIcon.share_node,
|
|
||||||
size: 16,
|
|
||||||
color: theme.colorScheme.outline,
|
|
||||||
semanticLabel: "分享",
|
|
||||||
),
|
|
||||||
style: TextButton.styleFrom(
|
|
||||||
padding: const EdgeInsets.fromLTRB(
|
|
||||||
15,
|
|
||||||
0,
|
|
||||||
15,
|
|
||||||
0,
|
|
||||||
),
|
|
||||||
foregroundColor: theme.colorScheme.outline,
|
|
||||||
),
|
|
||||||
label: const Text('分享'),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
child: Builder(
|
|
||||||
builder: (context) => TextButton.icon(
|
|
||||||
onPressed: () => RequestUtils.onLikeDynamic(
|
|
||||||
_controller.dynItem,
|
|
||||||
() {
|
|
||||||
if (context.mounted) {
|
|
||||||
(context as Element?)
|
|
||||||
?.markNeedsBuild();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
icon: Icon(
|
|
||||||
_controller
|
|
||||||
.dynItem
|
|
||||||
.modules
|
|
||||||
.moduleStat
|
|
||||||
?.like
|
|
||||||
?.status ==
|
|
||||||
true
|
|
||||||
? FontAwesomeIcons.solidThumbsUp
|
|
||||||
: FontAwesomeIcons.thumbsUp,
|
|
||||||
size: 16,
|
|
||||||
color:
|
|
||||||
_controller
|
|
||||||
.dynItem
|
|
||||||
.modules
|
|
||||||
.moduleStat
|
|
||||||
?.like
|
|
||||||
?.status ==
|
|
||||||
true
|
|
||||||
? theme.colorScheme.primary
|
|
||||||
: theme.colorScheme.outline,
|
|
||||||
semanticLabel:
|
|
||||||
_controller
|
|
||||||
.dynItem
|
|
||||||
.modules
|
|
||||||
.moduleStat
|
|
||||||
?.like
|
|
||||||
?.status ==
|
|
||||||
true
|
|
||||||
? "已赞"
|
|
||||||
: "点赞",
|
|
||||||
),
|
|
||||||
style: TextButton.styleFrom(
|
|
||||||
padding: const EdgeInsets.fromLTRB(
|
|
||||||
15,
|
|
||||||
0,
|
|
||||||
15,
|
|
||||||
0,
|
|
||||||
),
|
|
||||||
foregroundColor:
|
|
||||||
theme.colorScheme.outline,
|
|
||||||
),
|
|
||||||
label: AnimatedSwitcher(
|
|
||||||
duration: const Duration(
|
|
||||||
milliseconds: 400,
|
|
||||||
),
|
|
||||||
transitionBuilder:
|
|
||||||
(
|
|
||||||
Widget child,
|
|
||||||
Animation<double> animation,
|
|
||||||
) {
|
|
||||||
return ScaleTransition(
|
|
||||||
scale: animation,
|
|
||||||
child: child,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
child: Text(
|
|
||||||
_controller
|
|
||||||
.dynItem
|
|
||||||
.modules
|
|
||||||
.moduleStat
|
|
||||||
?.like
|
|
||||||
?.count !=
|
|
||||||
null
|
|
||||||
? NumUtil.numFormat(
|
|
||||||
_controller
|
|
||||||
.dynItem
|
|
||||||
.modules
|
|
||||||
.moduleStat!
|
|
||||||
.like!
|
|
||||||
.count,
|
|
||||||
)
|
|
||||||
: '点赞',
|
|
||||||
style: TextStyle(
|
|
||||||
color:
|
|
||||||
_controller
|
|
||||||
.dynItem
|
|
||||||
.modules
|
|
||||||
.moduleStat
|
|
||||||
?.like
|
|
||||||
?.status ==
|
|
||||||
true
|
|
||||||
? theme.colorScheme.primary
|
|
||||||
: theme.colorScheme.outline,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
SliverPersistentHeader replyPersistentHeader(ThemeData theme) {
|
Widget _buildBottom(ThemeData theme) {
|
||||||
return SliverPersistentHeader(
|
return Positioned(
|
||||||
delegate: CustomSliverPersistentHeaderDelegate(
|
left: 0,
|
||||||
bgColor: theme.colorScheme.surface,
|
right: 0,
|
||||||
child: Container(
|
bottom: 0,
|
||||||
height: 45,
|
child: SlideTransition(
|
||||||
padding: const EdgeInsets.only(left: 12, right: 6),
|
position: controller.fabAnim,
|
||||||
child: Row(
|
child: Builder(
|
||||||
children: [
|
builder: (context) {
|
||||||
Obx(
|
Widget button() => FloatingActionButton(
|
||||||
() => AnimatedSwitcher(
|
heroTag: null,
|
||||||
duration: const Duration(milliseconds: 400),
|
onPressed: () {
|
||||||
transitionBuilder:
|
feedBack();
|
||||||
(Widget child, Animation<double> animation) {
|
controller.onReply(
|
||||||
return ScaleTransition(scale: animation, child: child);
|
context,
|
||||||
},
|
oid: controller.oid,
|
||||||
child: Text(
|
replyType: controller.replyType,
|
||||||
'${_controller.count.value == -1 ? 0 : NumUtil.numFormat(_controller.count.value)}条回复',
|
);
|
||||||
key: ValueKey<int>(_controller.count.value),
|
},
|
||||||
|
tooltip: '评论动态',
|
||||||
|
child: const Icon(Icons.reply),
|
||||||
|
);
|
||||||
|
|
||||||
|
final bottom = MediaQuery.paddingOf(context).bottom;
|
||||||
|
if (!controller.showDynActionBar) {
|
||||||
|
return Align(
|
||||||
|
alignment: Alignment.bottomRight,
|
||||||
|
child: Padding(
|
||||||
|
padding: EdgeInsets.only(
|
||||||
|
right: 14,
|
||||||
|
bottom: bottom + 14,
|
||||||
),
|
),
|
||||||
|
child: button(),
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
const Spacer(),
|
}
|
||||||
SizedBox(
|
|
||||||
height: 35,
|
final moduleStat = controller.dynItem.modules.moduleStat;
|
||||||
child: TextButton.icon(
|
final primary = theme.colorScheme.primary;
|
||||||
onPressed: _controller.queryBySort,
|
final outline = theme.colorScheme.outline;
|
||||||
icon: Icon(
|
final btnStyle = TextButton.styleFrom(
|
||||||
Icons.sort,
|
padding: const EdgeInsets.symmetric(horizontal: 15),
|
||||||
size: 16,
|
foregroundColor: outline,
|
||||||
color: theme.colorScheme.secondary,
|
);
|
||||||
),
|
|
||||||
label: Obx(
|
Widget textIconButton({
|
||||||
() => Text(
|
required IconData icon,
|
||||||
_controller.sortType.value.label,
|
required String text,
|
||||||
style: TextStyle(
|
required DynamicStat? stat,
|
||||||
fontSize: 13,
|
required VoidCallback onPressed,
|
||||||
color: theme.colorScheme.secondary,
|
IconData? activitedIcon,
|
||||||
|
}) {
|
||||||
|
final status = stat?.status == true;
|
||||||
|
final color = status ? primary : outline;
|
||||||
|
return TextButton.icon(
|
||||||
|
onPressed: onPressed,
|
||||||
|
icon: Icon(
|
||||||
|
status ? activitedIcon : icon,
|
||||||
|
size: 16,
|
||||||
|
color: color,
|
||||||
|
),
|
||||||
|
style: btnStyle,
|
||||||
|
label: Text(
|
||||||
|
stat?.count != null ? NumUtil.numFormat(stat!.count) : text,
|
||||||
|
style: TextStyle(color: color),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(right: 14, bottom: 14),
|
||||||
|
child: button(),
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: theme.colorScheme.surface,
|
||||||
|
border: Border(
|
||||||
|
top: BorderSide(
|
||||||
|
color: theme.colorScheme.outline.withValues(
|
||||||
|
alpha: 0.08,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
padding: EdgeInsets.only(bottom: bottom),
|
||||||
),
|
child: Row(
|
||||||
],
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||||
),
|
children: [
|
||||||
),
|
Expanded(
|
||||||
),
|
child: Builder(
|
||||||
pinned: true,
|
builder: (btnContext) {
|
||||||
);
|
final forward = moduleStat?.forward;
|
||||||
}
|
return textIconButton(
|
||||||
|
icon: FontAwesomeIcons.shareFromSquare,
|
||||||
Widget replyList(
|
text: '转发',
|
||||||
ThemeData theme,
|
stat: forward,
|
||||||
LoadingState<List<ReplyInfo>?> loadingState,
|
onPressed: () => showModalBottomSheet(
|
||||||
) {
|
context: context,
|
||||||
return switch (loadingState) {
|
isScrollControlled: true,
|
||||||
Loading() => SliverList.builder(
|
useSafeArea: true,
|
||||||
itemBuilder: (context, index) {
|
builder: (context) => RepostPanel(
|
||||||
return const VideoReplySkeleton();
|
item: controller.dynItem,
|
||||||
},
|
callback: () {
|
||||||
itemCount: 8,
|
if (forward != null) {
|
||||||
),
|
int count = forward.count ?? 0;
|
||||||
Success(:var response) =>
|
forward.count = count + 1;
|
||||||
response?.isNotEmpty == true
|
if (btnContext.mounted) {
|
||||||
? SliverList.builder(
|
(btnContext as Element?)
|
||||||
itemBuilder: (context, index) {
|
?.markNeedsBuild();
|
||||||
if (index == response.length) {
|
}
|
||||||
_controller.onLoadMore();
|
}
|
||||||
return Container(
|
},
|
||||||
alignment: Alignment.center,
|
),
|
||||||
margin: EdgeInsets.only(
|
),
|
||||||
bottom: MediaQuery.paddingOf(context).bottom,
|
);
|
||||||
),
|
},
|
||||||
height: 125,
|
|
||||||
child: Text(
|
|
||||||
_controller.isEnd ? '没有更多了' : '加载中...',
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 12,
|
|
||||||
color: theme.colorScheme.outline,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
Expanded(
|
||||||
} else {
|
child: textIconButton(
|
||||||
return ReplyItemGrpc(
|
icon: CustomIcon.share_node,
|
||||||
replyItem: response[index],
|
text: '分享',
|
||||||
replyLevel: 1,
|
stat: null,
|
||||||
replyReply: (replyItem, id) =>
|
onPressed: () => Utils.shareText(
|
||||||
replyReply(context, replyItem, id),
|
'${HttpString.dynamicShareBaseUrl}/${controller.dynItem.idStr}',
|
||||||
onReply: (replyItem) => _controller.onReply(
|
),
|
||||||
context,
|
),
|
||||||
replyItem: replyItem,
|
|
||||||
),
|
),
|
||||||
onDelete: (item, subIndex) =>
|
Expanded(
|
||||||
_controller.onRemove(index, item, subIndex),
|
child: Builder(
|
||||||
upMid: _controller.upMid,
|
builder: (context) {
|
||||||
callback: _imageCallback,
|
return textIconButton(
|
||||||
onCheckReply: (item) =>
|
icon: FontAwesomeIcons.thumbsUp,
|
||||||
_controller.onCheckReply(item, isManual: true),
|
activitedIcon: FontAwesomeIcons.solidThumbsUp,
|
||||||
onToggleTop: (item) => _controller.onToggleTop(
|
text: '点赞',
|
||||||
item,
|
stat: moduleStat?.like,
|
||||||
index,
|
onPressed: () => RequestUtils.onLikeDynamic(
|
||||||
_controller.oid,
|
controller.dynItem,
|
||||||
_controller.replyType,
|
() {
|
||||||
|
if (context.mounted) {
|
||||||
|
(context as Element?)?.markNeedsBuild();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
],
|
||||||
}
|
),
|
||||||
},
|
),
|
||||||
itemCount: response!.length + 1,
|
],
|
||||||
)
|
);
|
||||||
: HttpError(
|
},
|
||||||
onReload: _controller.onReload,
|
),
|
||||||
),
|
|
||||||
Error(:var errMsg) => HttpError(
|
|
||||||
errMsg: errMsg,
|
|
||||||
onReload: _controller.onReload,
|
|
||||||
),
|
),
|
||||||
};
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,28 +3,30 @@ import 'package:PiliPlus/grpc/reply.dart';
|
|||||||
import 'package:PiliPlus/http/loading_state.dart';
|
import 'package:PiliPlus/http/loading_state.dart';
|
||||||
import 'package:PiliPlus/http/match.dart';
|
import 'package:PiliPlus/http/match.dart';
|
||||||
import 'package:PiliPlus/models_new/match/match_info/contest.dart';
|
import 'package:PiliPlus/models_new/match/match_info/contest.dart';
|
||||||
import 'package:PiliPlus/pages/common/reply_controller.dart';
|
import 'package:PiliPlus/pages/common/dyn/common_dyn_controller.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
class MatchInfoController extends ReplyController<MainListReply> {
|
class MatchInfoController extends CommonDynController<MainListReply> {
|
||||||
final int cid = int.parse(Get.parameters['cid']!);
|
@override
|
||||||
|
final int oid = int.parse(Get.parameters['cid']!);
|
||||||
|
@override
|
||||||
int get replyType => 27;
|
int get replyType => 27;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
dynamic get sourceId => cid.toString();
|
dynamic get sourceId => oid.toString();
|
||||||
|
|
||||||
final Rx<LoadingState<MatchContest?>> infoState =
|
final Rx<LoadingState<MatchContest?>> infoState =
|
||||||
LoadingState<MatchContest?>.loading().obs;
|
LoadingState<MatchContest?>.loading().obs;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() {
|
||||||
|
offsetDy = 2;
|
||||||
super.onInit();
|
super.onInit();
|
||||||
getMatchInfo();
|
getMatchInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> getMatchInfo() async {
|
Future<void> getMatchInfo() async {
|
||||||
var res = await MatchHttp.matchInfo(cid);
|
var res = await MatchHttp.matchInfo(oid);
|
||||||
if (res.isSuccess) {
|
if (res.isSuccess) {
|
||||||
queryData();
|
queryData();
|
||||||
}
|
}
|
||||||
@@ -39,7 +41,7 @@ class MatchInfoController extends ReplyController<MainListReply> {
|
|||||||
@override
|
@override
|
||||||
Future<LoadingState<MainListReply>> customGetData() => ReplyGrpc.mainList(
|
Future<LoadingState<MainListReply>> customGetData() => ReplyGrpc.mainList(
|
||||||
type: replyType,
|
type: replyType,
|
||||||
oid: cid,
|
oid: oid,
|
||||||
mode: mode.value,
|
mode: mode.value,
|
||||||
cursorNext: cursorNext,
|
cursorNext: cursorNext,
|
||||||
offset: paginationReply?.nextOffset,
|
offset: paginationReply?.nextOffset,
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import 'package:PiliPlus/common/skeleton/video_reply.dart';
|
import 'package:PiliPlus/common/skeleton/video_reply.dart';
|
||||||
import 'package:PiliPlus/common/widgets/custom_sliver_persistent_header_delegate.dart';
|
|
||||||
import 'package:PiliPlus/common/widgets/image/network_img_layer.dart';
|
import 'package:PiliPlus/common/widgets/image/network_img_layer.dart';
|
||||||
import 'package:PiliPlus/common/widgets/loading_widget/http_error.dart';
|
import 'package:PiliPlus/common/widgets/loading_widget/http_error.dart';
|
||||||
import 'package:PiliPlus/common/widgets/refresh_indicator.dart';
|
import 'package:PiliPlus/common/widgets/refresh_indicator.dart';
|
||||||
@@ -9,31 +8,35 @@ import 'package:PiliPlus/http/loading_state.dart';
|
|||||||
import 'package:PiliPlus/models/common/image_type.dart';
|
import 'package:PiliPlus/models/common/image_type.dart';
|
||||||
import 'package:PiliPlus/models_new/match/match_info/contest.dart';
|
import 'package:PiliPlus/models_new/match/match_info/contest.dart';
|
||||||
import 'package:PiliPlus/models_new/match/match_info/team.dart';
|
import 'package:PiliPlus/models_new/match/match_info/team.dart';
|
||||||
|
import 'package:PiliPlus/pages/common/dyn/common_dyn_page.dart';
|
||||||
import 'package:PiliPlus/pages/match_info/controller.dart';
|
import 'package:PiliPlus/pages/match_info/controller.dart';
|
||||||
import 'package:PiliPlus/pages/video/reply/widgets/reply_item_grpc.dart';
|
import 'package:PiliPlus/pages/video/reply/widgets/reply_item_grpc.dart';
|
||||||
import 'package:PiliPlus/pages/video/reply_reply/view.dart';
|
import 'package:PiliPlus/pages/video/reply_reply/view.dart';
|
||||||
import 'package:PiliPlus/utils/date_util.dart';
|
import 'package:PiliPlus/utils/date_util.dart';
|
||||||
import 'package:PiliPlus/utils/feed_back.dart';
|
import 'package:PiliPlus/utils/feed_back.dart';
|
||||||
import 'package:PiliPlus/utils/num_util.dart';
|
|
||||||
import 'package:PiliPlus/utils/utils.dart';
|
import 'package:PiliPlus/utils/utils.dart';
|
||||||
import 'package:easy_debounce/easy_throttle.dart';
|
import 'package:easy_debounce/easy_throttle.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
|
|
||||||
class MatchInfoPage extends StatefulWidget {
|
class MatchInfoPage extends CommonDynPage {
|
||||||
const MatchInfoPage({super.key});
|
const MatchInfoPage({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<MatchInfoPage> createState() => _MatchInfoPageState();
|
State<MatchInfoPage> createState() => _MatchInfoPageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _MatchInfoPageState extends State<MatchInfoPage> {
|
class _MatchInfoPageState extends CommonDynPageState<MatchInfoPage> {
|
||||||
final _controller = Get.put(
|
@override
|
||||||
|
final MatchInfoController controller = Get.put(
|
||||||
MatchInfoController(),
|
MatchInfoController(),
|
||||||
tag: Utils.generateRandomString(8),
|
tag: Utils.generateRandomString(8),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@override
|
||||||
|
dynamic get arguments => null;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final theme = Theme.of(context);
|
final theme = Theme.of(context);
|
||||||
@@ -42,36 +45,39 @@ class _MatchInfoPageState extends State<MatchInfoPage> {
|
|||||||
body: SafeArea(
|
body: SafeArea(
|
||||||
bottom: false,
|
bottom: false,
|
||||||
child: refreshIndicator(
|
child: refreshIndicator(
|
||||||
onRefresh: _controller.onRefresh,
|
onRefresh: controller.onRefresh,
|
||||||
child: CustomScrollView(
|
child: CustomScrollView(
|
||||||
controller: _controller.scrollController,
|
controller: controller.scrollController,
|
||||||
physics: const AlwaysScrollableScrollPhysics(),
|
physics: const AlwaysScrollableScrollPhysics(),
|
||||||
slivers: [
|
slivers: [
|
||||||
Obx(() => _buildInfo(theme, _controller.infoState.value)),
|
Obx(() => _buildInfo(theme, controller.infoState.value)),
|
||||||
SliverPadding(
|
SliverPadding(
|
||||||
padding: EdgeInsets.only(
|
padding: EdgeInsets.only(
|
||||||
bottom: MediaQuery.paddingOf(context).bottom + 80,
|
bottom: MediaQuery.paddingOf(context).bottom + 80,
|
||||||
),
|
),
|
||||||
sliver: Obx(
|
sliver: Obx(
|
||||||
() => _buildReply(theme, _controller.loadingState.value),
|
() => _buildReply(theme, controller.loadingState.value),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
floatingActionButton: FloatingActionButton(
|
floatingActionButton: SlideTransition(
|
||||||
heroTag: null,
|
position: controller.fabAnim,
|
||||||
onPressed: () {
|
child: FloatingActionButton(
|
||||||
feedBack();
|
heroTag: null,
|
||||||
_controller.onReply(
|
onPressed: () {
|
||||||
context,
|
feedBack();
|
||||||
oid: _controller.cid,
|
controller.onReply(
|
||||||
replyType: _controller.replyType,
|
context,
|
||||||
);
|
oid: controller.oid,
|
||||||
},
|
replyType: controller.replyType,
|
||||||
tooltip: '评论动态',
|
);
|
||||||
child: const Icon(Icons.reply),
|
},
|
||||||
|
tooltip: '评论动态',
|
||||||
|
child: const Icon(Icons.reply),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -214,46 +220,47 @@ class _MatchInfoPageState extends State<MatchInfoPage> {
|
|||||||
response?.isNotEmpty == true
|
response?.isNotEmpty == true
|
||||||
? SliverMainAxisGroup(
|
? SliverMainAxisGroup(
|
||||||
slivers: [
|
slivers: [
|
||||||
_buildHeader(theme),
|
buildReplyHeader(theme),
|
||||||
SliverList.builder(
|
SliverList.builder(
|
||||||
itemCount: response!.length,
|
itemCount: response!.length,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
if (index == response.length - 1) {
|
if (index == response.length - 1) {
|
||||||
_controller.onLoadMore();
|
controller.onLoadMore();
|
||||||
}
|
}
|
||||||
return ReplyItemGrpc(
|
return ReplyItemGrpc(
|
||||||
replyItem: response[index],
|
replyItem: response[index],
|
||||||
replyLevel: 1,
|
replyLevel: 1,
|
||||||
replyReply: (replyItem, id) =>
|
replyReply: (replyItem, id) =>
|
||||||
replyReply(context, replyItem, id),
|
replyReply(context, replyItem, id),
|
||||||
onReply: (replyItem) => _controller.onReply(
|
onReply: (replyItem) => controller.onReply(
|
||||||
context,
|
context,
|
||||||
replyItem: replyItem,
|
replyItem: replyItem,
|
||||||
),
|
),
|
||||||
onDelete: (item, subIndex) =>
|
onDelete: (item, subIndex) =>
|
||||||
_controller.onRemove(index, item, subIndex),
|
controller.onRemove(index, item, subIndex),
|
||||||
upMid: _controller.upMid,
|
upMid: controller.upMid,
|
||||||
onCheckReply: (item) =>
|
onCheckReply: (item) =>
|
||||||
_controller.onCheckReply(item, isManual: true),
|
controller.onCheckReply(item, isManual: true),
|
||||||
onToggleTop: (item) => _controller.onToggleTop(
|
onToggleTop: (item) => controller.onToggleTop(
|
||||||
item,
|
item,
|
||||||
index,
|
index,
|
||||||
_controller.cid,
|
controller.oid,
|
||||||
_controller.replyType,
|
controller.replyType,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
: HttpError(onReload: _controller.onReload),
|
: HttpError(onReload: controller.onReload),
|
||||||
Error(:var errMsg) => HttpError(
|
Error(:var errMsg) => HttpError(
|
||||||
errMsg: errMsg,
|
errMsg: errMsg,
|
||||||
onReload: _controller.onReload,
|
onReload: controller.onReload,
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
void replyReply(BuildContext context, ReplyInfo replyItem, int? id) {
|
void replyReply(BuildContext context, ReplyInfo replyItem, int? id) {
|
||||||
EasyThrottle.throttle('replyReply', const Duration(milliseconds: 500), () {
|
EasyThrottle.throttle('replyReply', const Duration(milliseconds: 500), () {
|
||||||
int oid = replyItem.oid.toInt();
|
int oid = replyItem.oid.toInt();
|
||||||
@@ -270,7 +277,7 @@ class _MatchInfoPageState extends State<MatchInfoPage> {
|
|||||||
oid: oid,
|
oid: oid,
|
||||||
rpid: rpid,
|
rpid: rpid,
|
||||||
isVideoDetail: false,
|
isVideoDetail: false,
|
||||||
replyType: _controller.replyType,
|
replyType: controller.replyType,
|
||||||
firstFloor: replyItem,
|
firstFloor: replyItem,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -278,61 +285,4 @@ class _MatchInfoPageState extends State<MatchInfoPage> {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildHeader(ThemeData theme) {
|
|
||||||
return SliverPersistentHeader(
|
|
||||||
delegate: CustomSliverPersistentHeaderDelegate(
|
|
||||||
bgColor: theme.colorScheme.surface,
|
|
||||||
child: Container(
|
|
||||||
height: 45,
|
|
||||||
padding: const EdgeInsets.only(left: 12, right: 6),
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
Obx(
|
|
||||||
() {
|
|
||||||
final count = _controller.count.value;
|
|
||||||
return AnimatedSwitcher(
|
|
||||||
duration: const Duration(milliseconds: 400),
|
|
||||||
transitionBuilder:
|
|
||||||
(Widget child, Animation<double> animation) {
|
|
||||||
return ScaleTransition(
|
|
||||||
scale: animation,
|
|
||||||
child: child,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
child: Text(
|
|
||||||
'${count == -1 ? 0 : NumUtil.numFormat(count)}条回复',
|
|
||||||
key: ValueKey<int>(count),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
const Spacer(),
|
|
||||||
SizedBox(
|
|
||||||
height: 35,
|
|
||||||
child: TextButton.icon(
|
|
||||||
onPressed: _controller.queryBySort,
|
|
||||||
icon: Icon(
|
|
||||||
Icons.sort,
|
|
||||||
size: 16,
|
|
||||||
color: theme.colorScheme.secondary,
|
|
||||||
),
|
|
||||||
label: Obx(
|
|
||||||
() => Text(
|
|
||||||
_controller.sortType.value.label,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 13,
|
|
||||||
color: theme.colorScheme.secondary,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
pinned: true,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ 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';
|
||||||
|
|
||||||
class ZanButtonGrpc extends StatefulWidget {
|
class ZanButtonGrpc extends StatelessWidget {
|
||||||
const ZanButtonGrpc({
|
const ZanButtonGrpc({
|
||||||
super.key,
|
super.key,
|
||||||
required this.replyItem,
|
required this.replyItem,
|
||||||
@@ -16,23 +16,24 @@ class ZanButtonGrpc extends StatefulWidget {
|
|||||||
|
|
||||||
final ReplyInfo replyItem;
|
final ReplyInfo replyItem;
|
||||||
|
|
||||||
@override
|
Future<void> onHateReply(
|
||||||
State<ZanButtonGrpc> createState() => _ZanButtonGrpcState();
|
BuildContext context,
|
||||||
}
|
bool isProcessing,
|
||||||
|
VoidCallback onDone, {
|
||||||
class _ZanButtonGrpcState extends State<ZanButtonGrpc> {
|
required bool isLike,
|
||||||
bool get isLike => widget.replyItem.replyControl.action == $fixnum.Int64.ONE;
|
required bool isDislike,
|
||||||
bool get isDislike =>
|
}) async {
|
||||||
widget.replyItem.replyControl.action == $fixnum.Int64.TWO;
|
if (isProcessing) {
|
||||||
|
return;
|
||||||
Future<void> onHateReply() async {
|
}
|
||||||
|
isProcessing = true;
|
||||||
feedBack();
|
feedBack();
|
||||||
final int oid = widget.replyItem.oid.toInt();
|
final int oid = replyItem.oid.toInt();
|
||||||
final int rpid = widget.replyItem.id.toInt();
|
final int rpid = replyItem.id.toInt();
|
||||||
// 1 已点赞 2 不喜欢 0 未操作
|
// 1 已点赞 2 不喜欢 0 未操作
|
||||||
final int action = isDislike ? 0 : 2;
|
final int action = isDislike ? 0 : 2;
|
||||||
final res = await ReplyHttp.hateReply(
|
final res = await ReplyHttp.hateReply(
|
||||||
type: widget.replyItem.type.toInt(),
|
type: replyItem.type.toInt(),
|
||||||
action: action == 2 ? 1 : 0,
|
action: action == 2 ? 1 : 0,
|
||||||
oid: oid,
|
oid: oid,
|
||||||
rpid: rpid,
|
rpid: rpid,
|
||||||
@@ -41,28 +42,39 @@ class _ZanButtonGrpcState extends State<ZanButtonGrpc> {
|
|||||||
if (res['status']) {
|
if (res['status']) {
|
||||||
SmartDialog.showToast(isDislike ? '取消踩' : '点踩成功');
|
SmartDialog.showToast(isDislike ? '取消踩' : '点踩成功');
|
||||||
if (action == 2) {
|
if (action == 2) {
|
||||||
if (isLike) widget.replyItem.like -= $fixnum.Int64.ONE;
|
if (isLike) replyItem.like -= $fixnum.Int64.ONE;
|
||||||
widget.replyItem.replyControl.action = $fixnum.Int64.TWO;
|
replyItem.replyControl.action = $fixnum.Int64.TWO;
|
||||||
} else {
|
} else {
|
||||||
widget.replyItem.replyControl.action = $fixnum.Int64.ZERO;
|
replyItem.replyControl.action = $fixnum.Int64.ZERO;
|
||||||
}
|
}
|
||||||
if (mounted) {
|
if (context.mounted) {
|
||||||
setState(() {});
|
(context as Element?)?.markNeedsBuild();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
SmartDialog.showToast(res['msg']);
|
SmartDialog.showToast(res['msg']);
|
||||||
}
|
}
|
||||||
|
onDone();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 评论点赞
|
// 评论点赞
|
||||||
Future<void> onLikeReply() async {
|
Future<void> onLikeReply(
|
||||||
|
BuildContext context,
|
||||||
|
bool isProcessing,
|
||||||
|
VoidCallback onDone, {
|
||||||
|
required bool isLike,
|
||||||
|
required bool isDislike,
|
||||||
|
}) async {
|
||||||
|
if (isProcessing) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
isProcessing = true;
|
||||||
feedBack();
|
feedBack();
|
||||||
final int oid = widget.replyItem.oid.toInt();
|
final int oid = replyItem.oid.toInt();
|
||||||
final int rpid = widget.replyItem.id.toInt();
|
final int rpid = replyItem.id.toInt();
|
||||||
// 1 已点赞 2 不喜欢 0 未操作
|
// 1 已点赞 2 不喜欢 0 未操作
|
||||||
final int action = isLike ? 0 : 1;
|
final int action = isLike ? 0 : 1;
|
||||||
final res = await ReplyHttp.likeReply(
|
final res = await ReplyHttp.likeReply(
|
||||||
type: widget.replyItem.type.toInt(),
|
type: replyItem.type.toInt(),
|
||||||
oid: oid,
|
oid: oid,
|
||||||
rpid: rpid,
|
rpid: rpid,
|
||||||
action: action,
|
action: action,
|
||||||
@@ -70,36 +82,32 @@ class _ZanButtonGrpcState extends State<ZanButtonGrpc> {
|
|||||||
if (res['status']) {
|
if (res['status']) {
|
||||||
SmartDialog.showToast(isLike ? '取消赞' : '点赞成功');
|
SmartDialog.showToast(isLike ? '取消赞' : '点赞成功');
|
||||||
if (action == 1) {
|
if (action == 1) {
|
||||||
widget.replyItem
|
replyItem
|
||||||
..like += $fixnum.Int64.ONE
|
..like += $fixnum.Int64.ONE
|
||||||
..replyControl.action = $fixnum.Int64.ONE;
|
..replyControl.action = $fixnum.Int64.ONE;
|
||||||
} else {
|
} else {
|
||||||
widget.replyItem
|
replyItem
|
||||||
..like -= $fixnum.Int64.ONE
|
..like -= $fixnum.Int64.ONE
|
||||||
..replyControl.action = $fixnum.Int64.ZERO;
|
..replyControl.action = $fixnum.Int64.ZERO;
|
||||||
}
|
}
|
||||||
if (mounted) {
|
if (context.mounted) {
|
||||||
setState(() {});
|
(context as Element?)?.markNeedsBuild();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
SmartDialog.showToast(res['msg']);
|
SmartDialog.showToast(res['msg']);
|
||||||
}
|
}
|
||||||
}
|
onDone();
|
||||||
|
|
||||||
bool isProcessing = false;
|
|
||||||
Future<void> handleState(Future Function() action) async {
|
|
||||||
if (!isProcessing) {
|
|
||||||
isProcessing = true;
|
|
||||||
await action();
|
|
||||||
isProcessing = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final ThemeData theme = Theme.of(context);
|
final ThemeData theme = Theme.of(context);
|
||||||
final Color color = theme.colorScheme.outline;
|
late bool isProcessing = false;
|
||||||
final Color primary = theme.colorScheme.primary;
|
final action = replyItem.replyControl.action;
|
||||||
|
final isLike = action == $fixnum.Int64.ONE;
|
||||||
|
final isDislike = action == $fixnum.Int64.TWO;
|
||||||
|
final outline = theme.colorScheme.outline;
|
||||||
|
final primary = theme.colorScheme.primary;
|
||||||
final ButtonStyle style = TextButton.styleFrom(
|
final ButtonStyle style = TextButton.styleFrom(
|
||||||
padding: EdgeInsets.zero,
|
padding: EdgeInsets.zero,
|
||||||
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||||
@@ -112,13 +120,19 @@ class _ZanButtonGrpcState extends State<ZanButtonGrpc> {
|
|||||||
height: 32,
|
height: 32,
|
||||||
child: TextButton(
|
child: TextButton(
|
||||||
style: style,
|
style: style,
|
||||||
onPressed: () => handleState(onHateReply),
|
onPressed: () => onHateReply(
|
||||||
|
context,
|
||||||
|
isProcessing,
|
||||||
|
() => isProcessing = false,
|
||||||
|
isLike: isLike,
|
||||||
|
isDislike: isDislike,
|
||||||
|
),
|
||||||
child: Icon(
|
child: Icon(
|
||||||
isDislike
|
isDislike
|
||||||
? FontAwesomeIcons.solidThumbsDown
|
? FontAwesomeIcons.solidThumbsDown
|
||||||
: FontAwesomeIcons.thumbsDown,
|
: FontAwesomeIcons.thumbsDown,
|
||||||
size: 16,
|
size: 16,
|
||||||
color: isDislike ? primary : color,
|
color: isDislike ? primary : outline,
|
||||||
semanticLabel: isDislike ? '已踩' : '点踩',
|
semanticLabel: isDislike ? '已踩' : '点踩',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -127,30 +141,29 @@ class _ZanButtonGrpcState extends State<ZanButtonGrpc> {
|
|||||||
height: 32,
|
height: 32,
|
||||||
child: TextButton(
|
child: TextButton(
|
||||||
style: style,
|
style: style,
|
||||||
onPressed: () => handleState(onLikeReply),
|
onPressed: () => onLikeReply(
|
||||||
|
context,
|
||||||
|
isProcessing,
|
||||||
|
() => isProcessing = false,
|
||||||
|
isLike: isLike,
|
||||||
|
isDislike: isDislike,
|
||||||
|
),
|
||||||
child: Row(
|
child: Row(
|
||||||
|
spacing: 4,
|
||||||
children: [
|
children: [
|
||||||
Icon(
|
Icon(
|
||||||
isLike
|
isLike
|
||||||
? FontAwesomeIcons.solidThumbsUp
|
? FontAwesomeIcons.solidThumbsUp
|
||||||
: FontAwesomeIcons.thumbsUp,
|
: FontAwesomeIcons.thumbsUp,
|
||||||
size: 16,
|
size: 16,
|
||||||
color: isLike ? primary : color,
|
color: isLike ? primary : outline,
|
||||||
semanticLabel: isLike ? '已赞' : '点赞',
|
semanticLabel: isLike ? '已赞' : '点赞',
|
||||||
),
|
),
|
||||||
const SizedBox(width: 4),
|
Text(
|
||||||
AnimatedSwitcher(
|
NumUtil.numFormat(replyItem.like.toInt()),
|
||||||
duration: const Duration(milliseconds: 400),
|
style: TextStyle(
|
||||||
transitionBuilder:
|
color: isLike ? primary : outline,
|
||||||
(Widget child, Animation<double> animation) {
|
fontSize: theme.textTheme.labelSmall!.fontSize,
|
||||||
return ScaleTransition(scale: animation, child: child);
|
|
||||||
},
|
|
||||||
child: Text(
|
|
||||||
NumUtil.numFormat(widget.replyItem.like.toInt()),
|
|
||||||
style: TextStyle(
|
|
||||||
color: isLike ? primary : color,
|
|
||||||
fontSize: theme.textTheme.labelSmall!.fontSize,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -341,7 +341,7 @@ class RequestUtils {
|
|||||||
// 动态点赞
|
// 动态点赞
|
||||||
static Future<void> onLikeDynamic(
|
static Future<void> onLikeDynamic(
|
||||||
DynamicItemModel item,
|
DynamicItemModel item,
|
||||||
VoidCallback callback,
|
VoidCallback onSuccess,
|
||||||
) async {
|
) async {
|
||||||
feedBack();
|
feedBack();
|
||||||
String dynamicId = item.idStr!;
|
String dynamicId = item.idStr!;
|
||||||
@@ -362,7 +362,7 @@ class RequestUtils {
|
|||||||
?..count = count - 1
|
?..count = count - 1
|
||||||
..status = false;
|
..status = false;
|
||||||
}
|
}
|
||||||
callback();
|
onSuccess();
|
||||||
} else {
|
} else {
|
||||||
SmartDialog.showToast(res['msg']);
|
SmartDialog.showToast(res['msg']);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user