mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-23 10:36:24 +08:00
feat: super chat
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
13
lib/models_new/live/live_superchat/data.dart
Normal file
13
lib/models_new/live/live_superchat/data.dart
Normal file
@@ -0,0 +1,13 @@
|
||||
import 'package:PiliPlus/models_new/live/live_superchat/item.dart';
|
||||
|
||||
class SuperChatData {
|
||||
List<SuperChatItem>? list;
|
||||
|
||||
SuperChatData({this.list});
|
||||
|
||||
factory SuperChatData.fromJson(Map<String, dynamic> json) => SuperChatData(
|
||||
list: (json['list'] as List<dynamic>?)
|
||||
?.map((e) => SuperChatItem.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
);
|
||||
}
|
||||
42
lib/models_new/live/live_superchat/item.dart
Normal file
42
lib/models_new/live/live_superchat/item.dart
Normal file
@@ -0,0 +1,42 @@
|
||||
import 'package:PiliPlus/models_new/live/live_superchat/user_info.dart';
|
||||
import 'package:PiliPlus/utils/utils.dart';
|
||||
|
||||
class SuperChatItem {
|
||||
dynamic id;
|
||||
dynamic uid;
|
||||
int? price;
|
||||
String backgroundColor;
|
||||
String backgroundBottomColor;
|
||||
String backgroundPriceColor;
|
||||
String messageFontColor;
|
||||
int endTime;
|
||||
String message;
|
||||
UserInfo userInfo;
|
||||
bool expired = false;
|
||||
|
||||
SuperChatItem({
|
||||
this.id,
|
||||
required this.uid,
|
||||
this.price,
|
||||
required this.backgroundColor,
|
||||
required this.backgroundBottomColor,
|
||||
required this.backgroundPriceColor,
|
||||
required this.messageFontColor,
|
||||
required this.endTime,
|
||||
required this.message,
|
||||
required this.userInfo,
|
||||
});
|
||||
|
||||
factory SuperChatItem.fromJson(Map<String, dynamic> json) => SuperChatItem(
|
||||
id: json['id'] ?? Utils.generateRandomString(8),
|
||||
uid: json['uid'],
|
||||
price: json['price'] as int?,
|
||||
backgroundColor: json['background_color'] ?? '#EDF5FF',
|
||||
backgroundBottomColor: json['background_bottom_color'] ?? '#2A60B2',
|
||||
backgroundPriceColor: json['background_price_color'] ?? '#7497CD',
|
||||
messageFontColor: json['message_font_color'] ?? '#FFFFFF',
|
||||
endTime: json['end_time'],
|
||||
message: json['message'],
|
||||
userInfo: UserInfo.fromJson(json['user_info'] as Map<String, dynamic>),
|
||||
);
|
||||
}
|
||||
17
lib/models_new/live/live_superchat/user_info.dart
Normal file
17
lib/models_new/live/live_superchat/user_info.dart
Normal file
@@ -0,0 +1,17 @@
|
||||
class UserInfo {
|
||||
String face;
|
||||
String uname;
|
||||
String nameColor;
|
||||
|
||||
UserInfo({
|
||||
required this.face,
|
||||
required this.uname,
|
||||
required this.nameColor,
|
||||
});
|
||||
|
||||
factory UserInfo.fromJson(Map<String, dynamic> json) => UserInfo(
|
||||
face: json['face'],
|
||||
uname: json['uname'],
|
||||
nameColor: json['name_color'] ?? '#666666',
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user