From 8e4824ab6fd5bfeedc59f59172aa8a4b1f8e2aa0 Mon Sep 17 00:00:00 2001 From: dom Date: Sat, 18 Jul 2026 12:02:36 +0800 Subject: [PATCH] show sc start time Signed-off-by: dom --- lib/models_new/live/live_superchat/item.dart | 54 +++++++++++-------- .../live_room/superchat/superchat_card.dart | 51 ++++++++++-------- 2 files changed, 62 insertions(+), 43 deletions(-) diff --git a/lib/models_new/live/live_superchat/item.dart b/lib/models_new/live/live_superchat/item.dart index 3862d8592..8da66fd55 100644 --- a/lib/models_new/live/live_superchat/item.dart +++ b/lib/models_new/live/live_superchat/item.dart @@ -14,6 +14,7 @@ class SuperChatItem { String backgroundBottomColor; String backgroundPriceColor; String messageFontColor; + int startSime; int endTime; String message; String token; @@ -32,6 +33,7 @@ class SuperChatItem { required this.backgroundBottomColor, required this.backgroundPriceColor, required this.messageFontColor, + required this.startSime, required this.endTime, required this.message, required this.token, @@ -40,29 +42,33 @@ class SuperChatItem { this.medalInfo, }); - static SuperChatItem get random => SuperChatItem.fromJson({ - "id": Utils.random.nextInt(2147483647), - "uid": 0, - "price": 66, - "end_time": DateTime.now().millisecondsSinceEpoch ~/ 1000 + 5, - "message": Utils.generateRandomString(55), - "user_info": { - "face": "", - "uname": "UNAME", - }, - 'token': '', - 'ts': 0, - 'uinfo': { - 'medal': { - "name": "Medal", - "level": Utils.random.nextInt(40), - "id": 123, - "ruid": 456, - "v2_medal_color_start": "#4C7DFF99", - "v2_medal_color_text": "#FFFFFF", + static SuperChatItem get random { + final now = DateTime.now().millisecondsSinceEpoch ~/ 1000; + return SuperChatItem.fromJson({ + "id": Utils.random.nextInt(2147483647), + "uid": 0, + "price": 66, + "start_time": now, + "end_time": now + 5, + "message": Utils.generateRandomString(55), + "user_info": { + "face": "", + "uname": "UNAME", }, - }, - }); + 'token': '', + 'ts': now, + 'uinfo': { + 'medal': { + "name": "Medal", + "level": Utils.random.nextInt(40), + "id": 123, + "ruid": 456, + "v2_medal_color_start": "#4C7DFF99", + "v2_medal_color_text": "#FFFFFF", + }, + }, + }); + } factory SuperChatItem.fromJson(Map json) => SuperChatItem( id: safeToInt(json['id']) ?? Utils.random.nextInt(2147483647), @@ -73,6 +79,7 @@ class SuperChatItem { backgroundBottomColor: json['background_bottom_color'] ?? '#2A60B2', backgroundPriceColor: json['background_price_color'] ?? '#7497CD', messageFontColor: json['message_font_color'] ?? '#FFFFFF', + startSime: safeToInt(json['start_time'])!, endTime: safeToInt(json['end_time'])!, message: json['message'], token: json['token'], @@ -91,6 +98,7 @@ class SuperChatItem { String? backgroundBottomColor, String? backgroundPriceColor, String? messageFontColor, + int? startSime, int? endTime, String? message, String? token, @@ -108,6 +116,7 @@ class SuperChatItem { backgroundBottomColor ?? this.backgroundBottomColor, backgroundPriceColor: backgroundPriceColor ?? this.backgroundPriceColor, messageFontColor: messageFontColor ?? this.messageFontColor, + startSime: startSime ?? this.startSime, endTime: endTime ?? this.endTime, message: message ?? this.message, token: token ?? this.token, @@ -126,6 +135,7 @@ class SuperChatItem { 'background_bottom_color': backgroundBottomColor, 'background_price_color': backgroundPriceColor, 'message_font_color': messageFontColor, + 'start_time': startSime, 'end_time': endTime, 'message': message, 'token': token, diff --git a/lib/pages/live_room/superchat/superchat_card.dart b/lib/pages/live_room/superchat/superchat_card.dart index b3f8afdac..ee2392360 100644 --- a/lib/pages/live_room/superchat/superchat_card.dart +++ b/lib/pages/live_room/superchat/superchat_card.dart @@ -6,6 +6,7 @@ import 'package:PiliPlus/common/widgets/scroll_physics.dart' import 'package:PiliPlus/models_new/live/live_superchat/item.dart'; import 'package:PiliPlus/pages/member/widget/medal_widget.dart'; import 'package:PiliPlus/utils/color_utils.dart'; +import 'package:PiliPlus/utils/date_utils.dart'; import 'package:PiliPlus/utils/image_utils.dart'; import 'package:PiliPlus/utils/page_utils.dart'; import 'package:PiliPlus/utils/platform_utils.dart'; @@ -168,6 +169,32 @@ class _SuperChatCardState extends State { } } + Widget price = Text("¥${item.price}", style: TextStyle(color: bottomColor)); + Widget? remains; + if (_remains != null) { + remains = Obx( + () => Text( + _remains.toString(), + style: const TextStyle(fontSize: 14, color: Colors.grey), + ), + ); + } else { + price = Row( + crossAxisAlignment: .end, + mainAxisAlignment: .spaceBetween, + children: [ + price, + Text( + DateFormatUtils.format( + item.startSime, + format: DateFormatUtils.longFormatDs, + ), + style: TextStyle(color: bottomColor, fontSize: 13.5), + ), + ], + ); + } + return Column( mainAxisSize: .min, crossAxisAlignment: CrossAxisAlignment.stretch, @@ -203,29 +230,10 @@ class _SuperChatCardState extends State { child: Column( mainAxisSize: .min, crossAxisAlignment: .start, - children: [ - name, - Text( - "¥${item.price}", - style: TextStyle( - color: ColourUtils.parseColor( - item.backgroundPriceColor, - ), - ), - ), - ], + children: [name, price], ), ), - if (_remains != null) - Obx( - () => Text( - _remains.toString(), - style: const TextStyle( - fontSize: 14, - color: Colors.grey, - ), - ), - ), + ?remains, ], ), ), @@ -238,6 +246,7 @@ class _SuperChatCardState extends State { padding: const .all(8), child: SelectableText( item.message, + selectionColor: Colors.black26, scrollPhysics: const NeverSelectableScrollPhysics(), style: TextStyle( color: ColourUtils.parseColor(item.messageFontColor),