diff --git a/lib/http/api.dart b/lib/http/api.dart index 9b86ca05..16f3e912 100644 --- a/lib/http/api.dart +++ b/lib/http/api.dart @@ -348,13 +348,13 @@ class Api { static const String msgFeedAt = '/x/msgfeed/at'; //https://api.bilibili.com/x/msgfeed/like?platform=web&build=0&mobi_app=web static const String msgFeedLike = '/x/msgfeed/like'; - //https://message.bilibili.com/x/sys-msg/query_user_notify?csrf=31b0caa533cea4d1a1bd2e921f045ec6&csrf=31b0caa533cea4d1a1bd2e921f045ec6&page_size=20&build=0&mobi_app=web + //https://message.bilibili.com/x/sys-msg/query_user_notify?csrf=xxxx&csrf=xxxx&page_size=20&build=0&mobi_app=web static const String msgSysUserNotify = '${HttpString.messageBaseUrl}/x/sys-msg/query_user_notify'; - //https://message.bilibili.com/x/sys-msg/query_unified_notify?csrf=31b0caa533cea4d1a1bd2e921f045ec6&csrf=31b0caa533cea4d1a1bd2e921f045ec6&page_size=10&build=0&mobi_app=web + //https://message.bilibili.com/x/sys-msg/query_unified_notify?csrf=xxxx&csrf=xxxx&page_size=10&build=0&mobi_app=web static const String msgSysUnifiedNotify = '${HttpString.messageBaseUrl}/x/sys-msg/query_unified_notify'; // 系统信息光标更新(已读标记) - //https://message.bilibili.com/x/sys-msg/update_cursor?csrf=31b0caa533cea4d1a1bd2e921f045ec6&csrf=31b0caa533cea4d1a1bd2e921f045ec6&cursor=1705288500000000000&has_up=0&build=0&mobi_app=web + //https://message.bilibili.com/x/sys-msg/update_cursor?csrf=xxxx&csrf=xxxx&cursor=1705288500000000000&has_up=0&build=0&mobi_app=web static const String msgSysUpdateCursor = '${HttpString.messageBaseUrl}/x/sys-msg/update_cursor'; /// 私聊 diff --git a/lib/http/msg.dart b/lib/http/msg.dart index 010ec851..a33c1f8d 100644 --- a/lib/http/msg.dart +++ b/lib/http/msg.dart @@ -100,6 +100,26 @@ class MsgHttp { }; } } + + static Future msgSysUpdateCursor(int cursor) async { + String csrf = await Request.getCsrf(); + var res = await Request().get(Api.msgSysUpdateCursor, data: { + 'csrf': csrf, + 'csrf': csrf, + 'cursor': cursor, + }); + if (res.data['code'] == 0) { + return { + 'status': true, + }; + } else { + return { + 'status': false, + 'msg': res.data['message'], + }; + } + } + static Future msgFeedUnread() async { var res = await Request().get(Api.msgFeedUnread); if (res.data['code'] == 0) { diff --git a/lib/models/msg/msgfeed_sys_msg.dart b/lib/models/msg/msgfeed_sys_msg.dart new file mode 100644 index 00000000..3af72e78 --- /dev/null +++ b/lib/models/msg/msgfeed_sys_msg.dart @@ -0,0 +1,155 @@ +class MsgFeedSysMsg { + List? systemNotifyList; + + MsgFeedSysMsg({this.systemNotifyList}); + + MsgFeedSysMsg.fromJson(Map json) { + if (json['system_notify_list'] != null) { + systemNotifyList = []; + json['system_notify_list'].forEach((v) { + systemNotifyList!.add(SystemNotifyList.fromJson(v)); + }); + } + } + + Map toJson() { + final Map data = {}; + if (systemNotifyList != null) { + data['system_notify_list'] = + systemNotifyList!.map((v) => v.toJson()).toList(); + } + return data; + } +} + +class SystemNotifyList { + int? id; + int? cursor; + Publisher? publisher; + int? type; + String? title; + String? content; + Source? source; + String? timeAt; + int? cardType; + String? cardBrief; + String? cardMsgBrief; + String? cardCover; + String? cardStoryTitle; + String? cardLink; + String? mc; + int? isStation; + int? isSend; + int? notifyCursor; + + SystemNotifyList( + {this.id, + this.cursor, + this.publisher, + this.type, + this.title, + this.content, + this.source, + this.timeAt, + this.cardType, + this.cardBrief, + this.cardMsgBrief, + this.cardCover, + this.cardStoryTitle, + this.cardLink, + this.mc, + this.isStation, + this.isSend, + this.notifyCursor}); + + SystemNotifyList.fromJson(Map json) { + id = json['id']; + cursor = json['cursor']; + publisher = json['publisher'] != null + ? Publisher.fromJson(json['publisher']) + : null; + type = json['type']; + title = json['title']; + content = json['content']; + source = json['source'] != null ? Source.fromJson(json['source']) : null; + timeAt = json['time_at']; + cardType = json['card_type']; + cardBrief = json['card_brief']; + cardMsgBrief = json['card_msg_brief']; + cardCover = json['card_cover']; + cardStoryTitle = json['card_story_title']; + cardLink = json['card_link']; + mc = json['mc']; + isStation = json['is_station']; + isSend = json['is_send']; + notifyCursor = json['notify_cursor']; + } + + Map toJson() { + final Map data = {}; + data['id'] = id; + data['cursor'] = cursor; + if (publisher != null) { + data['publisher'] = publisher!.toJson(); + } + data['type'] = type; + data['title'] = title; + data['content'] = content; + if (source != null) { + data['source'] = source!.toJson(); + } + data['time_at'] = timeAt; + data['card_type'] = cardType; + data['card_brief'] = cardBrief; + data['card_msg_brief'] = cardMsgBrief; + data['card_cover'] = cardCover; + data['card_story_title'] = cardStoryTitle; + data['card_link'] = cardLink; + data['mc'] = mc; + data['is_station'] = isStation; + data['is_send'] = isSend; + data['notify_cursor'] = notifyCursor; + return data; + } +} + +class Publisher { + String? name; + int? mid; + String? face; + + Publisher({this.name, this.mid, this.face}); + + Publisher.fromJson(Map json) { + name = json['name']; + mid = json['mid']; + face = json['face']; + } + + Map toJson() { + final Map data = {}; + data['name'] = name; + data['mid'] = mid; + data['face'] = face; + return data; + } +} + +class Source { + String? name; + String? logo; + + Source({this.name, this.logo}); + + Source.fromJson(Map json) { + name = json['name']; + logo = json['logo']; + } + + Map toJson() { + final Map data = {}; + data['name'] = name; + data['logo'] = logo; + return data; + } +} diff --git a/lib/pages/msg_feed_top/at_me/view.dart b/lib/pages/msg_feed_top/at_me/view.dart index 3778433e..558ad0ca 100644 --- a/lib/pages/msg_feed_top/at_me/view.dart +++ b/lib/pages/msg_feed_top/at_me/view.dart @@ -74,22 +74,33 @@ class _AtMePageState extends State { src: _atMeController.msgFeedAtMeList[i].user?.avatar, ), title: Text( - "${_atMeController.msgFeedAtMeList[i].user?.nickname} " - "在${_atMeController.msgFeedAtMeList[i].item?.business}中@了我", - style: Theme.of(context).textTheme.bodyMedium!, - ), - subtitle: Text( - _atMeController - .msgFeedAtMeList[i].item?.sourceContent ?? - "", - maxLines: 2, - overflow: TextOverflow.ellipsis, + "${_atMeController.msgFeedAtMeList[i].user?.nickname} " + "在${_atMeController.msgFeedAtMeList[i].item?.business}中@了我", style: Theme.of(context) .textTheme - .labelMedium! + .titleMedium! .copyWith( - color: - Theme.of(context).colorScheme.outline)), + color: Theme.of(context).colorScheme.primary, + )), + subtitle: + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const SizedBox(height: 4), + Text( + _atMeController + .msgFeedAtMeList[i].item?.sourceContent ?? + "", + maxLines: 3, + overflow: TextOverflow.ellipsis, + style: Theme.of(context) + .textTheme + .bodyMedium! + .copyWith( + color: + Theme.of(context).colorScheme.outline)) + ], + ), trailing: _atMeController .msgFeedAtMeList[i].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 ea1f3c63..3970d48f 100644 --- a/lib/pages/msg_feed_top/like_me/view.dart +++ b/lib/pages/msg_feed_top/like_me/view.dart @@ -115,45 +115,61 @@ class LikeMeList extends StatelessWidget { String nativeUri = msgFeedLikeMeList[i].item?.nativeUri ?? ""; SmartDialog.showToast("跳转至:$nativeUri(暂未实现)"); }, - leading: SizedBox( - width: 50, - height: 50, - child: Stack( - children: [ - for (var j = 0; - j < msgFeedLikeMeList[i].users!.length && j < 4; - j++) ...[ - Positioned( - left: 15 * (j % 2).toDouble(), - top: 15 * (j ~/ 2).toDouble(), - child: NetworkImgLayer( - width: - msgFeedLikeMeList[i].users!.length > 1 ? 30 : 45, - height: - msgFeedLikeMeList[i].users!.length > 1 ? 30 : 45, - type: 'avatar', - src: msgFeedLikeMeList[i].users![j].avatar, - )), - ] - ], - )), + leading: Column( + children: [ + const Spacer(), + SizedBox( + width: 50, + height: 50, + child: Stack( + children: [ + for (var j = 0; + j < msgFeedLikeMeList[i].users!.length && j < 4; + j++) ...[ + Positioned( + left: 15 * (j % 2).toDouble(), + top: 15 * (j ~/ 2).toDouble(), + child: NetworkImgLayer( + width: msgFeedLikeMeList[i].users!.length > 1 + ? 30 + : 45, + height: msgFeedLikeMeList[i].users!.length > 1 + ? 30 + : 45, + type: 'avatar', + src: msgFeedLikeMeList[i].users![j].avatar, + )), + ] + ], + )), + const Spacer(), + ], + ), title: Text( - "${msgFeedLikeMeList[i].users!.map((e) => e.nickname).join("/")}" - "等共 ${msgFeedLikeMeList[i].counts} 人" + // "${msgFeedLikeMeList[i].users!.map((e) => e.nickname).join("/")}" + "${msgFeedLikeMeList[i].users?[0].nickname}" + "${msgFeedLikeMeList[i].users!.length > 1 ? '、' + msgFeedLikeMeList[i].users![1].nickname.toString() + ' 等' : ''} " + "${msgFeedLikeMeList[i].counts! > 1 ? '共 ' + msgFeedLikeMeList[i].counts.toString() + ' 人' : ''}" "赞了我的${msgFeedLikeMeList[i].item?.business}", - style: - Theme.of(context).textTheme.labelMedium!.copyWith(height: 1.5), + style: Theme.of(context).textTheme.titleSmall!.copyWith( + height: 1.5, color: Theme.of(context).colorScheme.primary), maxLines: 2, overflow: TextOverflow.ellipsis, ), subtitle: msgFeedLikeMeList[i].item?.title != null && msgFeedLikeMeList[i].item?.title != "" - ? Text(msgFeedLikeMeList[i].item?.title ?? "", - maxLines: 2, - overflow: TextOverflow.ellipsis, - style: Theme.of(context).textTheme.labelMedium!.copyWith( - color: Theme.of(context).colorScheme.outline, - height: 1.5)) + ? Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const SizedBox(height: 4), + Text(msgFeedLikeMeList[i].item?.title ?? "", + maxLines: 3, + overflow: TextOverflow.ellipsis, + style: Theme.of(context).textTheme.bodyMedium!.copyWith( + color: Theme.of(context).colorScheme.outline, + height: 1.5)) + ], + ) : null, trailing: msgFeedLikeMeList[i].item?.image != null && msgFeedLikeMeList[i].item?.image != "" diff --git a/lib/pages/msg_feed_top/reply_me/view.dart b/lib/pages/msg_feed_top/reply_me/view.dart index f52be4ac..82b5f0f6 100644 --- a/lib/pages/msg_feed_top/reply_me/view.dart +++ b/lib/pages/msg_feed_top/reply_me/view.dart @@ -78,7 +78,8 @@ class _ReplyMePageState extends State { title: Text( "${_replyMeController.msgFeedReplyMeList[i].user?.nickname} " "回复了我的${_replyMeController.msgFeedReplyMeList[i].item?.business}", - style: Theme.of(context).textTheme.bodyMedium!, + style: Theme.of(context).textTheme.bodyMedium!.copyWith( + color: Theme.of(context).colorScheme.primary), ), subtitle: Column( mainAxisAlignment: MainAxisAlignment.start, @@ -126,7 +127,7 @@ class _ReplyMePageState extends State { color: Theme.of(context) .colorScheme .outline, - height: 1.5)), + height: 1.5)), ]), ); }, diff --git a/lib/pages/msg_feed_top/sys_msg/controller.dart b/lib/pages/msg_feed_top/sys_msg/controller.dart new file mode 100644 index 00000000..c2acafa4 --- /dev/null +++ b/lib/pages/msg_feed_top/sys_msg/controller.dart @@ -0,0 +1,63 @@ +import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; +import 'package:get/get.dart'; +import 'package:PiliPalaX/http/msg.dart'; + +import '../../../models/msg/msgfeed_sys_msg.dart'; + +class SysMsgController extends GetxController { + RxList msgFeedSysMsgList = [].obs; + bool isLoading = false; + int cursor = -1; + int cursorTime = -1; + bool isEnd = false; + + Future queryMsgFeedSysMsg() async { + if (isLoading) return; + isLoading = true; + var resUserNotify = await MsgHttp.msgFeedSysUserNotify(); + var resUnifiedNotify = await MsgHttp.msgFeedSysUnifiedNotify(); + isLoading = false; + List systemNotifyList = []; + if (resUserNotify['status']) { + MsgFeedSysMsg data = MsgFeedSysMsg.fromJson(resUserNotify['data']); + if (data.systemNotifyList != null) { + systemNotifyList.addAll(data.systemNotifyList!); + } + } + if (resUnifiedNotify['status']) { + MsgFeedSysMsg data = MsgFeedSysMsg.fromJson(resUnifiedNotify['data']); + if (data.systemNotifyList != null) { + systemNotifyList.addAll(data.systemNotifyList!); + } + } + if (systemNotifyList.isNotEmpty) { + systemNotifyList.sort((a, b) => b.cursor!.compareTo(a.cursor!)); + msgFeedSysMsgList.assignAll(systemNotifyList); + msgSysUpdateCursor(msgFeedSysMsgList.first.cursor!); + } else { + SmartDialog.showToast( + "UserNotify: ${resUserNotify['msg']} UnifiedNotify: ${resUnifiedNotify['msg']}"); + } + } + + Future msgSysUpdateCursor(int cursor) async { + var res = await MsgHttp.msgSysUpdateCursor(cursor); + if (res['status']) { + SmartDialog.showToast('已读成功'); + return true; + } else { + SmartDialog.showToast(res['msg']); + return false; + } + } + Future onLoad() async { + if (isEnd) return; + queryMsgFeedSysMsg(); + } + + Future onRefresh() async { + cursor = -1; + cursorTime = -1; + queryMsgFeedSysMsg(); + } +} diff --git a/lib/pages/msg_feed_top/sys_msg/index.dart b/lib/pages/msg_feed_top/sys_msg/index.dart new file mode 100644 index 00000000..6d2ce533 --- /dev/null +++ b/lib/pages/msg_feed_top/sys_msg/index.dart @@ -0,0 +1,4 @@ +library whisper; + +export './controller.dart'; +export './view.dart'; diff --git a/lib/pages/msg_feed_top/sys_msg/view.dart b/lib/pages/msg_feed_top/sys_msg/view.dart new file mode 100644 index 00000000..bf23dc36 --- /dev/null +++ b/lib/pages/msg_feed_top/sys_msg/view.dart @@ -0,0 +1,123 @@ +import 'dart:convert'; + +import 'package:easy_debounce/easy_throttle.dart'; +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; + +import 'controller.dart'; + +class SysMsgPage extends StatefulWidget { + const SysMsgPage({super.key}); + + @override + State createState() => _SysMsgPageState(); +} + +class _SysMsgPageState extends State { + late final SysMsgController _sysMsgController = Get.put(SysMsgController()); + final ScrollController _scrollController = ScrollController(); + + @override + void initState() { + _sysMsgController.queryMsgFeedSysMsg(); + super.initState(); + _scrollController.addListener(_scrollListener); + } + + Future _scrollListener() async { + if (_scrollController.position.pixels >= + _scrollController.position.maxScrollExtent - 200) { + EasyThrottle.throttle('my-throttler', const Duration(milliseconds: 800), + () async { + await _sysMsgController.onLoad(); + }); + } + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('系统通知'), + ), + body: RefreshIndicator( + onRefresh: () async { + await _sysMsgController.onRefresh(); + }, + child: SingleChildScrollView( + controller: _scrollController, + child: LayoutBuilder( + builder: (BuildContext context, BoxConstraints constraints) { + return Obx( + () { + if (_sysMsgController.msgFeedSysMsgList.isEmpty) { + return const Center( + child: CircularProgressIndicator(), + ); + } + return ListView.separated( + itemCount: _sysMsgController.msgFeedSysMsgList.length, + shrinkWrap: true, + physics: const NeverScrollableScrollPhysics(), + itemBuilder: (_, int i) { + String? content = _sysMsgController.msgFeedSysMsgList[i].content; + if (content != null) { + try { + dynamic jsonContent = json.decode(content); + if (jsonContent != null && jsonContent['web'] != null) { + content = jsonContent['web']; + } + } catch (_) {} + } + return ListTile( + onTap: () {}, + title: Text( + "${_sysMsgController.msgFeedSysMsgList[i].title}", + style: Theme.of(context).textTheme.titleMedium!.copyWith( + color: Theme.of(context).colorScheme.primary + ), + ), + subtitle: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const SizedBox(height: 4), + Text( + "$content", + style: Theme.of(context) + .textTheme + .bodySmall! + .copyWith( + color: Theme.of(context) + .colorScheme + .outline)), + const SizedBox(height: 4), + Text( + "${_sysMsgController.msgFeedSysMsgList[i].timeAt}", + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: Theme.of(context) + .textTheme + .bodySmall! + .copyWith( + color: Theme.of(context) + .colorScheme + .outline.withOpacity(0.8))), + ])); + }, + separatorBuilder: (BuildContext context, int index) { + return Divider( + indent: 72, + endIndent: 20, + height: 6, + color: Colors.grey.withOpacity(0.1), + ); + }, + ); + }, + ); + }), + ), + ), + ); + } +} diff --git a/lib/pages/whisper/view.dart b/lib/pages/whisper/view.dart index 569a8455..c32a6355 100644 --- a/lib/pages/whisper/view.dart +++ b/lib/pages/whisper/view.dart @@ -46,6 +46,7 @@ class _WhisperPageState extends State { ), body: RefreshIndicator( onRefresh: () async { + await _whisperController.queryMsgFeedUnread(); await _whisperController.onRefresh(); }, child: SingleChildScrollView( @@ -58,27 +59,32 @@ class _WhisperPageState extends State { return Padding( padding: const EdgeInsets.only(left: 20, right: 20), child: SizedBox( - height: constraints.maxWidth / 4, + height: constraints.maxWidth / 4 + 10, child: Obx( () => GridView.count( primary: false, crossAxisCount: 4, - padding: const EdgeInsets.all(0), - childAspectRatio: 1.25, - children: _whisperController.msgFeedTop.map((item) { + padding: const EdgeInsets.fromLTRB(0, 7, 0, 0), + childAspectRatio: 1.2, + children: Iterable.generate( + _whisperController.msgFeedTop.length) + .map((idx) { return GestureDetector( child: Column( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, children: [ Badge( - isLabelVisible: item['value'] > 0, + isLabelVisible: _whisperController + .msgFeedTop[idx]['value'] > + 0, backgroundColor: Theme.of(context).colorScheme.primary, textColor: Theme.of(context) .colorScheme .onInverseSurface, - label: Text(" ${item['value']} "), + label: Text( + " ${_whisperController.msgFeedTop[idx]['value']} "), alignment: Alignment.topRight, child: CircleAvatar( radius: 22, @@ -86,7 +92,8 @@ class _WhisperPageState extends State { .colorScheme .onInverseSurface, child: Icon( - item['icon'], + _whisperController.msgFeedTop[idx] + ['icon'], size: 20, color: Theme.of(context).colorScheme.primary, @@ -94,11 +101,17 @@ class _WhisperPageState extends State { ), ), const SizedBox(height: 6), - Text(item['name'], + Text(_whisperController.msgFeedTop[idx]['name'], style: const TextStyle(fontSize: 13)) ], ), - onTap: () => Get.toNamed(item['route']), + onTap: () { + setState(() { + _whisperController.msgFeedTop[idx]['value'] = 0; + }); + Get.toNamed( + _whisperController.msgFeedTop[idx]['route']); + }, ); }).toList(), ), @@ -123,19 +136,27 @@ class _WhisperPageState extends State { physics: const NeverScrollableScrollPhysics(), itemBuilder: (_, int i) { return ListTile( - onTap: () => Get.toNamed( - '/whisperDetail', - parameters: { - 'talkerId': - sessionList[i].talkerId.toString(), - 'name': sessionList[i].accountInfo.name, - 'face': sessionList[i].accountInfo.face, - 'mid': sessionList[i] - .accountInfo - .mid - .toString(), - }, - ), + onTap: () { + setState(() { + sessionList[i].unreadCount = 0; + }); + Get.toNamed( + '/whisperDetail', + parameters: { + 'talkerId': sessionList[i] + .talkerId + .toString(), + 'name': + sessionList[i].accountInfo.name, + 'face': + sessionList[i].accountInfo.face, + 'mid': sessionList[i] + .accountInfo + .mid + .toString(), + }, + ); + }, leading: Badge( isLabelVisible: sessionList[i].unreadCount > 0, @@ -181,7 +202,7 @@ class _WhisperPageState extends State { .outline)), trailing: Text( Utils.dateFormat( - sessionList[i].lastMsg.timestamp), + sessionList[i].lastMsg.timestamp, formatType: "day"), style: Theme.of(context) .textTheme .labelSmall! diff --git a/lib/pages/whisper_detail/controller.dart b/lib/pages/whisper_detail/controller.dart index 821b5abd..efbbde1f 100644 --- a/lib/pages/whisper_detail/controller.dart +++ b/lib/pages/whisper_detail/controller.dart @@ -25,15 +25,19 @@ class WhisperDetailController extends GetxController { var res = await MsgHttp.sessionMsg(talkerId: talkerId); if (res['status']) { messageList.value = res['data'].messages; - if (messageList.isNotEmpty && res['data'].eInfos != null) { - eInfos = res['data'].eInfos; + if (messageList.isNotEmpty) { + ackSessionMsg(); + if (res['data'].eInfos != null) { + eInfos = res['data'].eInfos; + } } + } else { + SmartDialog.showToast(res['msg']); } - return res; } Future ackSessionMsg() async { - if (messageList.isEmpty){ + if (messageList.isEmpty) { return; } var res = await MsgHttp.ackSessionMsg( diff --git a/lib/pages/whisper_detail/view.dart b/lib/pages/whisper_detail/view.dart index b688b8e2..4c39f581 100644 --- a/lib/pages/whisper_detail/view.dart +++ b/lib/pages/whisper_detail/view.dart @@ -16,12 +16,11 @@ class WhisperDetailPage extends StatefulWidget { class _WhisperDetailPageState extends State { final WhisperDetailController _whisperDetailController = Get.put(WhisperDetailController()); - late Future _futureBuilderFuture; @override void initState() { super.initState(); - _futureBuilderFuture = _whisperDetailController.querySessionMsg(); + _whisperDetailController.querySessionMsg(); } @override @@ -89,53 +88,23 @@ class _WhisperDetailPageState extends State { ), ), ), - body: FutureBuilder( - future: _futureBuilderFuture, - builder: (BuildContext context, snapshot) { - if (snapshot.connectionState == ConnectionState.done) { - if (snapshot.data == null) { - return const SizedBox(); - } - final Map data = snapshot.data as Map; - if (data['status']) { - List messageList = _whisperDetailController.messageList; - _whisperDetailController.ackSessionMsg(); - return Obx( - () => messageList.isEmpty - ? const SizedBox() - : ListView.builder( - itemCount: messageList.length, - shrinkWrap: true, - reverse: true, - itemBuilder: (_, int i) { - if (i == 0) { - return Column( - children: [ - ChatItem( - item: messageList[i], - e_infos: _whisperDetailController.eInfos), - const SizedBox(height: 12), - ], - ); - } else { - return ChatItem( - item: messageList[i], - e_infos: _whisperDetailController.eInfos); - } - }, - ), - ); - } else { - // 请求错误 - return const SizedBox(); - } - } else { - // 骨架屏 - return const SizedBox(); - } - }, - ), - // resizeToAvoidBottomInset: true, + body: Obx(() { + List messageList = _whisperDetailController.messageList; + if (messageList.isEmpty) { + return const Center( + child: CircularProgressIndicator(), + ); + } + return ListView.builder( + itemCount: messageList.length, + shrinkWrap: true, + reverse: true, + itemBuilder: (_, int i) { + return ChatItem( + item: messageList[i], e_infos: _whisperDetailController.eInfos); + }, + ); + }), bottomNavigationBar: Container( width: double.infinity, height: MediaQuery.of(context).padding.bottom + 70, diff --git a/lib/router/app_pages.dart b/lib/router/app_pages.dart index 12b164c3..121ffd51 100644 --- a/lib/router/app_pages.dart +++ b/lib/router/app_pages.dart @@ -34,6 +34,7 @@ import '../pages/member_dynamics/index.dart'; import '../pages/member_like/index.dart'; import '../pages/member_search/index.dart'; import '../pages/member_seasons/index.dart'; +import '../pages/msg_feed_top/sys_msg/view.dart'; import '../pages/search/index.dart'; import '../pages/search_result/index.dart'; import '../pages/setting/extra_setting.dart'; @@ -154,7 +155,7 @@ class Routes { // 收到的赞 CustomGetPage(name: '/likeMe', page: () => const LikeMePage()), // 系统消息 - CustomGetPage(name: '/sysMsg', page: () => const WhisperPage()), + CustomGetPage(name: '/sysMsg', page: () => const SysMsgPage()), // 登录页面 CustomGetPage(name: '/loginPage', page: () => const LoginPage()), // 用户动态 diff --git a/lib/utils/utils.dart b/lib/utils/utils.dart index 8b935033..c73a94a7 100644 --- a/lib/utils/utils.dart +++ b/lib/utils/utils.dart @@ -170,13 +170,13 @@ class Utils { .replaceAll('hh', hh) .replaceAll('mm', mm) .replaceAll('ss', ss); - if (int.parse(YY) == DateTime.now().year && - int.parse(MM) == DateTime.now().month) { - // 当天 - if (int.parse(DD) == DateTime.now().day) { - return '今天'; - } - } + // if (int.parse(YY) == DateTime.now().year && + // int.parse(MM) == DateTime.now().month) { + // // 当天 + // if (int.parse(DD) == DateTime.now().day) { + // return '今天'; + // } + // } return date; }