show user medal

Signed-off-by: dom <githubaccount56556@proton.me>
This commit is contained in:
dom
2026-03-22 15:01:30 +08:00
parent fc7fc18b14
commit 2bebf200df
151 changed files with 1435 additions and 1321 deletions

View File

@@ -1,10 +1,13 @@
import 'package:PiliPlus/models_new/live/live_medal_wall/uinfo_medal.dart';
import 'package:PiliPlus/models_new/live/live_superchat/user_info.dart';
import 'package:PiliPlus/utils/parse_string.dart';
import 'package:PiliPlus/utils/utils.dart';
class SuperChatItem {
int id;
int uid;
int price;
String? backgroundImage;
String backgroundColor;
String backgroundBottomColor;
String backgroundPriceColor;
@@ -16,11 +19,13 @@ class SuperChatItem {
UserInfo userInfo;
late bool expired = false;
late bool deleted = false;
UinfoMedal? medalInfo;
SuperChatItem({
required this.id,
required this.uid,
required this.price,
this.backgroundImage,
required this.backgroundColor,
required this.backgroundBottomColor,
required this.backgroundPriceColor,
@@ -30,6 +35,7 @@ class SuperChatItem {
required this.token,
required this.ts,
required this.userInfo,
this.medalInfo,
});
static SuperChatItem get random => SuperChatItem.fromJson({
@@ -50,6 +56,7 @@ class SuperChatItem {
id: Utils.safeToInt(json['id']) ?? Utils.random.nextInt(2147483647),
uid: Utils.safeToInt(json['uid'])!,
price: json['price'],
backgroundImage: noneNullOrEmptyString(json['background_image']),
backgroundColor: json['background_color'] ?? '#EDF5FF',
backgroundBottomColor: json['background_bottom_color'] ?? '#2A60B2',
backgroundPriceColor: json['background_price_color'] ?? '#7497CD',
@@ -59,6 +66,9 @@ class SuperChatItem {
token: json['token'],
ts: Utils.safeToInt(json['ts'])!,
userInfo: UserInfo.fromJson(json['user_info'] as Map<String, dynamic>),
medalInfo: json['uinfo']?['medal'] == null
? null
: UinfoMedal.fromJson(json['uinfo']['medal']),
);
SuperChatItem copyWith({
@@ -75,6 +85,7 @@ class SuperChatItem {
int? ts,
UserInfo? userInfo,
bool? expired,
UinfoMedal? medalInfo,
}) {
return SuperChatItem(
id: id ?? this.id,
@@ -90,6 +101,7 @@ class SuperChatItem {
token: token ?? this.token,
ts: ts ?? this.ts,
userInfo: userInfo ?? this.userInfo,
medalInfo: medalInfo ?? this.medalInfo,
);
}
@@ -97,6 +109,7 @@ class SuperChatItem {
'id': id,
'uid': uid,
'price': price,
'background_image': backgroundImage,
'background_color': backgroundColor,
'background_bottom_color': backgroundBottomColor,
'background_price_color': backgroundPriceColor,