From 08b0a93064cc63e1819b05a6b662f81fb420b67a Mon Sep 17 00:00:00 2001 From: bggRGjQaUbCoE Date: Wed, 5 Mar 2025 17:39:04 +0800 Subject: [PATCH] mod: msg top: show time Closes #387 Signed-off-by: bggRGjQaUbCoE --- lib/pages/msg_feed_top/at_me/view.dart | 11 ++- lib/pages/msg_feed_top/like_me/view.dart | 50 +++++++----- lib/pages/msg_feed_top/reply_me/view.dart | 95 ++++++++++++----------- lib/pages/msg_feed_top/sys_msg/view.dart | 2 +- lib/utils/utils.dart | 2 +- 5 files changed, 92 insertions(+), 68 deletions(-) diff --git a/lib/pages/msg_feed_top/at_me/view.dart b/lib/pages/msg_feed_top/at_me/view.dart index 58629879..2bda3147 100644 --- a/lib/pages/msg_feed_top/at_me/view.dart +++ b/lib/pages/msg_feed_top/at_me/view.dart @@ -3,6 +3,7 @@ import 'package:PiliPlus/common/widgets/network_img_layer.dart'; import 'package:PiliPlus/common/widgets/refresh_indicator.dart'; import 'package:PiliPlus/http/loading_state.dart'; import 'package:PiliPlus/utils/app_scheme.dart'; +import 'package:PiliPlus/utils/utils.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; @@ -86,7 +87,15 @@ class _AtMePageState extends State { .textTheme .bodyMedium! .copyWith( - color: Theme.of(context).colorScheme.outline)) + color: + Theme.of(context).colorScheme.outline)), + const SizedBox(height: 4), + Text( + Utils.dateFormat(loadingState.response[index].atTime), + style: Theme.of(context).textTheme.bodyMedium!.copyWith( + color: Theme.of(context).colorScheme.outline, + ), + ), ], ), trailing: loadingState.response[index].item?.image != null && diff --git a/lib/pages/msg_feed_top/like_me/view.dart b/lib/pages/msg_feed_top/like_me/view.dart index 59aeeba7..52f6e587 100644 --- a/lib/pages/msg_feed_top/like_me/view.dart +++ b/lib/pages/msg_feed_top/like_me/view.dart @@ -3,6 +3,7 @@ import 'package:PiliPlus/common/widgets/pair.dart'; import 'package:PiliPlus/common/widgets/refresh_indicator.dart'; import 'package:PiliPlus/http/loading_state.dart'; import 'package:PiliPlus/models/msg/msgfeed_like_me.dart'; +import 'package:PiliPlus/utils/utils.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:PiliPlus/common/widgets/network_img_layer.dart'; @@ -150,26 +151,35 @@ class _LikeMePageState extends State { maxLines: 2, overflow: TextOverflow.ellipsis, ), - subtitle: - item.item?.title != null && item.item?.title != "" - ? Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - const SizedBox(height: 4), - Text(item.item?.title ?? "", - maxLines: 3, - overflow: TextOverflow.ellipsis, - style: Theme.of(context) - .textTheme - .bodyMedium! - .copyWith( - color: Theme.of(context) - .colorScheme - .outline, - height: 1.5)) - ], - ) - : null, + subtitle: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + if (item.item?.title?.isNotEmpty == true) ...[ + const SizedBox(height: 4), + Text(item.item!.title!, + maxLines: 3, + overflow: TextOverflow.ellipsis, + style: Theme.of(context) + .textTheme + .bodyMedium! + .copyWith( + color: Theme.of(context) + .colorScheme + .outline, + height: 1.5)), + ], + const SizedBox(height: 4), + Text( + Utils.dateFormat(item.likeTime), + style: Theme.of(context) + .textTheme + .bodyMedium! + .copyWith( + color: Theme.of(context).colorScheme.outline, + ), + ), + ], + ), trailing: item.item?.image != null && item.item?.image != "" ? NetworkImgLayer( diff --git a/lib/pages/msg_feed_top/reply_me/view.dart b/lib/pages/msg_feed_top/reply_me/view.dart index 6c164a5b..d8411356 100644 --- a/lib/pages/msg_feed_top/reply_me/view.dart +++ b/lib/pages/msg_feed_top/reply_me/view.dart @@ -1,6 +1,7 @@ import 'package:PiliPlus/common/widgets/loading_widget.dart'; import 'package:PiliPlus/common/widgets/refresh_indicator.dart'; import 'package:PiliPlus/http/loading_state.dart'; +import 'package:PiliPlus/utils/utils.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:PiliPlus/common/widgets/network_img_layer.dart'; @@ -74,52 +75,56 @@ class _ReplyMePageState extends State { .copyWith(color: Theme.of(context).colorScheme.primary), ), subtitle: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - const SizedBox(height: 4), + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const SizedBox(height: 4), + Text( + loadingState.response[index].item?.sourceContent ?? + "", + style: Theme.of(context).textTheme.bodyMedium), + const SizedBox(height: 4), + if (loadingState + .response[index].item?.targetReplyContent != + null && + loadingState + .response[index].item?.targetReplyContent != + "") Text( - loadingState.response[index].item?.sourceContent ?? - "", - style: Theme.of(context).textTheme.bodyMedium), - const SizedBox(height: 4), - if (loadingState - .response[index].item?.targetReplyContent != - null && - loadingState - .response[index].item?.targetReplyContent != - "") - Text( - "| ${loadingState.response[index].item?.targetReplyContent}", - maxLines: 1, - overflow: TextOverflow.ellipsis, - style: Theme.of(context) - .textTheme - .labelMedium! - .copyWith( - color: - Theme.of(context).colorScheme.outline, - height: 1.5)), - if (loadingState - .response[index].item?.rootReplyContent != - null && - loadingState - .response[index].item?.rootReplyContent != - "") - Text( - " | ${loadingState.response[index].item?.rootReplyContent}", - maxLines: 1, - overflow: TextOverflow.ellipsis, - style: - Theme.of(context) - .textTheme - .labelMedium! - .copyWith( - color: Theme.of(context) - .colorScheme - .outline, - height: 1.5)), - ]), + "| ${loadingState.response[index].item?.targetReplyContent}", + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: Theme.of(context) + .textTheme + .labelMedium! + .copyWith( + color: + Theme.of(context).colorScheme.outline, + height: 1.5)), + if (loadingState.response[index].item?.rootReplyContent != + null && + loadingState.response[index].item?.rootReplyContent != + "") + Text( + " | ${loadingState.response[index].item?.rootReplyContent}", + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: Theme.of(context) + .textTheme + .labelMedium! + .copyWith( + color: + Theme.of(context).colorScheme.outline, + height: 1.5)), + Text( + Utils.dateFormat( + loadingState.response[index].replyTime), + style: Theme.of(context).textTheme.bodyMedium!.copyWith( + color: Theme.of(context).colorScheme.outline, + ), + ), + ], + ), ); }, separatorBuilder: (BuildContext context, int index) { diff --git a/lib/pages/msg_feed_top/sys_msg/view.dart b/lib/pages/msg_feed_top/sys_msg/view.dart index 70fb2db1..a8e0f2fc 100644 --- a/lib/pages/msg_feed_top/sys_msg/view.dart +++ b/lib/pages/msg_feed_top/sys_msg/view.dart @@ -119,7 +119,7 @@ class _SysMsgPageState extends State { overflow: TextOverflow.ellipsis, style: Theme.of(context) .textTheme - .bodySmall! + .bodyMedium! .copyWith( color: Theme.of(context).colorScheme.outline, ), diff --git a/lib/utils/utils.dart b/lib/utils/utils.dart index 6a9ef36b..9a42f652 100644 --- a/lib/utils/utils.dart +++ b/lib/utils/utils.dart @@ -1207,7 +1207,7 @@ class Utils { // 时间显示,刚刚,x分钟前 static String dateFormat(timeStamp, {formatType = 'list'}) { - if (timeStamp == 0 || timeStamp == null || timeStamp == '') { + if (timeStamp == null || timeStamp == 0 || timeStamp == '') { return ''; } // 当前时间