show sc start time

Signed-off-by: dom <githubaccount56556@proton.me>
This commit is contained in:
dom
2026-07-18 12:02:36 +08:00
parent 01eca30575
commit 8e4824ab6f
2 changed files with 62 additions and 43 deletions

View File

@@ -14,6 +14,7 @@ class SuperChatItem {
String backgroundBottomColor; String backgroundBottomColor;
String backgroundPriceColor; String backgroundPriceColor;
String messageFontColor; String messageFontColor;
int startSime;
int endTime; int endTime;
String message; String message;
String token; String token;
@@ -32,6 +33,7 @@ class SuperChatItem {
required this.backgroundBottomColor, required this.backgroundBottomColor,
required this.backgroundPriceColor, required this.backgroundPriceColor,
required this.messageFontColor, required this.messageFontColor,
required this.startSime,
required this.endTime, required this.endTime,
required this.message, required this.message,
required this.token, required this.token,
@@ -40,29 +42,33 @@ class SuperChatItem {
this.medalInfo, this.medalInfo,
}); });
static SuperChatItem get random => SuperChatItem.fromJson({ static SuperChatItem get random {
"id": Utils.random.nextInt(2147483647), final now = DateTime.now().millisecondsSinceEpoch ~/ 1000;
"uid": 0, return SuperChatItem.fromJson({
"price": 66, "id": Utils.random.nextInt(2147483647),
"end_time": DateTime.now().millisecondsSinceEpoch ~/ 1000 + 5, "uid": 0,
"message": Utils.generateRandomString(55), "price": 66,
"user_info": { "start_time": now,
"face": "", "end_time": now + 5,
"uname": "UNAME", "message": Utils.generateRandomString(55),
}, "user_info": {
'token': '', "face": "",
'ts': 0, "uname": "UNAME",
'uinfo': {
'medal': {
"name": "Medal",
"level": Utils.random.nextInt(40),
"id": 123,
"ruid": 456,
"v2_medal_color_start": "#4C7DFF99",
"v2_medal_color_text": "#FFFFFF",
}, },
}, '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<String, dynamic> json) => SuperChatItem( factory SuperChatItem.fromJson(Map<String, dynamic> json) => SuperChatItem(
id: safeToInt(json['id']) ?? Utils.random.nextInt(2147483647), id: safeToInt(json['id']) ?? Utils.random.nextInt(2147483647),
@@ -73,6 +79,7 @@ class SuperChatItem {
backgroundBottomColor: json['background_bottom_color'] ?? '#2A60B2', backgroundBottomColor: json['background_bottom_color'] ?? '#2A60B2',
backgroundPriceColor: json['background_price_color'] ?? '#7497CD', backgroundPriceColor: json['background_price_color'] ?? '#7497CD',
messageFontColor: json['message_font_color'] ?? '#FFFFFF', messageFontColor: json['message_font_color'] ?? '#FFFFFF',
startSime: safeToInt(json['start_time'])!,
endTime: safeToInt(json['end_time'])!, endTime: safeToInt(json['end_time'])!,
message: json['message'], message: json['message'],
token: json['token'], token: json['token'],
@@ -91,6 +98,7 @@ class SuperChatItem {
String? backgroundBottomColor, String? backgroundBottomColor,
String? backgroundPriceColor, String? backgroundPriceColor,
String? messageFontColor, String? messageFontColor,
int? startSime,
int? endTime, int? endTime,
String? message, String? message,
String? token, String? token,
@@ -108,6 +116,7 @@ class SuperChatItem {
backgroundBottomColor ?? this.backgroundBottomColor, backgroundBottomColor ?? this.backgroundBottomColor,
backgroundPriceColor: backgroundPriceColor ?? this.backgroundPriceColor, backgroundPriceColor: backgroundPriceColor ?? this.backgroundPriceColor,
messageFontColor: messageFontColor ?? this.messageFontColor, messageFontColor: messageFontColor ?? this.messageFontColor,
startSime: startSime ?? this.startSime,
endTime: endTime ?? this.endTime, endTime: endTime ?? this.endTime,
message: message ?? this.message, message: message ?? this.message,
token: token ?? this.token, token: token ?? this.token,
@@ -126,6 +135,7 @@ class SuperChatItem {
'background_bottom_color': backgroundBottomColor, 'background_bottom_color': backgroundBottomColor,
'background_price_color': backgroundPriceColor, 'background_price_color': backgroundPriceColor,
'message_font_color': messageFontColor, 'message_font_color': messageFontColor,
'start_time': startSime,
'end_time': endTime, 'end_time': endTime,
'message': message, 'message': message,
'token': token, 'token': token,

View File

@@ -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/models_new/live/live_superchat/item.dart';
import 'package:PiliPlus/pages/member/widget/medal_widget.dart'; import 'package:PiliPlus/pages/member/widget/medal_widget.dart';
import 'package:PiliPlus/utils/color_utils.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/image_utils.dart';
import 'package:PiliPlus/utils/page_utils.dart'; import 'package:PiliPlus/utils/page_utils.dart';
import 'package:PiliPlus/utils/platform_utils.dart'; import 'package:PiliPlus/utils/platform_utils.dart';
@@ -168,6 +169,32 @@ class _SuperChatCardState extends State<SuperChatCard> {
} }
} }
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( return Column(
mainAxisSize: .min, mainAxisSize: .min,
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
@@ -203,29 +230,10 @@ class _SuperChatCardState extends State<SuperChatCard> {
child: Column( child: Column(
mainAxisSize: .min, mainAxisSize: .min,
crossAxisAlignment: .start, crossAxisAlignment: .start,
children: [ children: [name, price],
name,
Text(
"${item.price}",
style: TextStyle(
color: ColourUtils.parseColor(
item.backgroundPriceColor,
),
),
),
],
), ),
), ),
if (_remains != null) ?remains,
Obx(
() => Text(
_remains.toString(),
style: const TextStyle(
fontSize: 14,
color: Colors.grey,
),
),
),
], ],
), ),
), ),
@@ -238,6 +246,7 @@ class _SuperChatCardState extends State<SuperChatCard> {
padding: const .all(8), padding: const .all(8),
child: SelectableText( child: SelectableText(
item.message, item.message,
selectionColor: Colors.black26,
scrollPhysics: const NeverSelectableScrollPhysics(), scrollPhysics: const NeverSelectableScrollPhysics(),
style: TextStyle( style: TextStyle(
color: ColourUtils.parseColor(item.messageFontColor), color: ColourUtils.parseColor(item.messageFontColor),