opt: avatar model (#814)

This commit is contained in:
My-Responsitories
2025-05-05 00:45:24 +08:00
committed by GitHub
parent 07d2b3b464
commit cdeb843a84
30 changed files with 137 additions and 506 deletions

View File

@@ -1,8 +1,8 @@
import 'dart:convert';
import 'package:PiliPlus/common/widgets/avatar.dart';
import 'package:PiliPlus/common/widgets/pendant_avatar.dart';
import 'package:PiliPlus/models/dynamics/article_content_model.dart';
import 'package:PiliPlus/models/model_owner.dart';
import 'package:PiliPlus/models/model_avatar.dart';
class DynamicsDataModel {
bool? hasMore;
@@ -218,7 +218,7 @@ class Basic {
}
// 单个动态详情 - 作者信息
class ModuleAuthorModel extends Owner {
class ModuleAuthorModel extends Avatar {
bool? following;
String? jumpUrl;
String? label;
@@ -226,25 +226,21 @@ class ModuleAuthorModel extends Owner {
String? pubTime;
int? pubTs;
String? type;
Map? vip;
Map? decorate;
Map? pendant;
ModuleAuthorModel.fromJson(Map<String, dynamic> json) {
face = json['face'];
ModuleAuthorModel.fromJson(Map<String, dynamic> json) : super.fromJson(json) {
if (json['official'] != null) {
officialVerify ??= BaseOfficialVerify.fromJson(json['official']); // opus
}
following = json['following'];
jumpUrl = json['jump_url'];
label = json['label'];
mid = json['mid'];
name = json['name'];
pubAction = json['pub_action'];
pubTime = json['pub_time'];
pubTs = json['pub_ts'] == 0 ? null : json['pub_ts'];
type = json['type'];
vip = json['vip'];
if (Avatar.showDynDecorate) {
if (PendantAvatar.showDynDecorate) {
decorate = json['decorate'];
pendant = json['pendant'];
}
}
}

View File

@@ -1,3 +1,5 @@
import 'package:PiliPlus/models/model_avatar.dart';
class MemberInfoModel {
MemberInfoModel({
this.mid,
@@ -44,27 +46,6 @@ class MemberInfoModel {
}
}
class Vip {
Vip({
this.type,
this.status,
this.dueDate,
this.label,
});
int? type;
int? status;
int? dueDate;
Map? label;
Vip.fromJson(Map<String, dynamic> json) {
type = json['type'];
status = json['status'];
dueDate = json['due_date'];
label = json['label'];
}
}
class LiveRoom {
LiveRoom({
this.roomStatus,

View File

@@ -0,0 +1,73 @@
import 'package:PiliPlus/models/model_owner.dart';
class Avatar extends Owner {
Pendant? pendant;
BaseOfficialVerify? officialVerify;
Vip? vip;
Avatar.fromJson(Map<String, dynamic> json) : super.fromJson(json) {
if (json['pendant'] != null) pendant = Pendant.fromJson(json['pendant']);
if (json['official_verify'] != null) {
officialVerify = BaseOfficialVerify.fromJson(json['official_verify']);
}
if (json['vip'] != null) vip = Vip.fromJson(json['vip']);
}
}
class Pendant {
int? pid;
String? name;
String? image;
Pendant.fromJson(Map<String, dynamic> json) {
pid = json['pid'];
name = json['name'];
image = json['image'];
}
}
class BaseOfficialVerify {
int? type;
String? desc;
BaseOfficialVerify.fromJson(Map<String, dynamic> json) {
type = json['type'];
desc = json['desc'];
}
}
class Vip {
int? type;
late int status;
int? dueDate;
Label? label;
Vip.fromJson(Map<String, dynamic> json) {
type = json['type'];
status = json['status'] ?? 0;
dueDate = json['due_date'];
if (json['label'] != null) label = Label.fromJson(json['label']);
}
}
class Label {
String? path;
String? text;
String? labelTheme;
String? textColor;
int? bgStyle;
String? bgColor;
String? borderColor;
String? image;
Label.fromJson(Map<String, dynamic> json) {
path = json['path'];
text = json['text'];
labelTheme = json['label_theme'];
textColor = json['text_color'];
bgStyle = json['bg_style'];
bgColor = json['bg_color'];
borderColor = json['border_color'];
image = json['image'];
}
}

View File

@@ -1,7 +1,4 @@
import 'package:PiliPlus/models/space/pr_info.dart';
import 'package:PiliPlus/models/space/space_tag_bottom.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:PiliPlus/models/model_avatar.dart' hide Avatar;
import 'package:PiliPlus/models/space/achieve.dart';
import 'package:PiliPlus/models/space/avatar.dart';
import 'package:PiliPlus/models/space/entrance.dart';
@@ -11,10 +8,11 @@ import 'package:PiliPlus/models/space/likes.dart';
import 'package:PiliPlus/models/space/nameplate.dart';
import 'package:PiliPlus/models/space/nft_certificate.dart';
import 'package:PiliPlus/models/space/official_verify.dart';
import 'package:PiliPlus/models/space/pendant.dart';
import 'package:PiliPlus/models/space/pr_info.dart';
import 'package:PiliPlus/models/space/profession_verify.dart';
import 'package:PiliPlus/models/space/relation.dart';
import 'package:PiliPlus/models/space/vip.dart';
import 'package:PiliPlus/models/space/space_tag_bottom.dart';
import 'package:json_annotation/json_annotation.dart';
part 'card.g.dart';

View File

@@ -1,35 +0,0 @@
import 'package:json_annotation/json_annotation.dart';
part 'label.g.dart';
@JsonSerializable()
class Label {
String? path;
String? text;
@JsonKey(name: 'label_theme')
String? labelTheme;
@JsonKey(name: 'text_color')
String? textColor;
@JsonKey(name: 'bg_style')
int? bgStyle;
@JsonKey(name: 'bg_color')
String? bgColor;
@JsonKey(name: 'border_color')
String? borderColor;
String? image;
Label({
this.path,
this.text,
this.labelTheme,
this.textColor,
this.bgStyle,
this.bgColor,
this.borderColor,
this.image,
});
factory Label.fromJson(Map<String, dynamic> json) => _$LabelFromJson(json);
Map<String, dynamic> toJson() => _$LabelToJson(this);
}

View File

@@ -1,29 +0,0 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'label.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
Label _$LabelFromJson(Map<String, dynamic> json) => Label(
path: json['path'] as String?,
text: json['text'] as String?,
labelTheme: json['label_theme'] as String?,
textColor: json['text_color'] as String?,
bgStyle: (json['bg_style'] as num?)?.toInt(),
bgColor: json['bg_color'] as String?,
borderColor: json['border_color'] as String?,
image: json['image'] as String?,
);
Map<String, dynamic> _$LabelToJson(Label instance) => <String, dynamic>{
'path': instance.path,
'text': instance.text,
'label_theme': instance.labelTheme,
'text_color': instance.textColor,
'bg_style': instance.bgStyle,
'bg_color': instance.bgColor,
'border_color': instance.borderColor,
'image': instance.image,
};

View File

@@ -1,29 +1,15 @@
import 'package:json_annotation/json_annotation.dart';
import 'package:PiliPlus/models/model_avatar.dart';
part 'official_verify.g.dart';
class OfficialVerify extends BaseOfficialVerify {
int? role;
String? title;
String? icon;
String? spliceTitle;
@JsonSerializable()
class OfficialVerify {
int? type;
String? desc;
int? role;
String? title;
String? icon;
@JsonKey(name: 'splice_title')
String? spliceTitle;
OfficialVerify({
this.type,
this.desc,
this.role,
this.title,
this.icon,
this.spliceTitle,
});
factory OfficialVerify.fromJson(Map<String, dynamic> json) {
return _$OfficialVerifyFromJson(json);
}
Map<String, dynamic> toJson() => _$OfficialVerifyToJson(this);
OfficialVerify.fromJson(Map<String, dynamic> json) : super.fromJson(json) {
role = json['role'];
title = json['title'];
icon = json['icon'];
spliceTitle = json['splice_title'];
}
}

View File

@@ -1,27 +0,0 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'official_verify.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
OfficialVerify _$OfficialVerifyFromJson(Map<String, dynamic> json) =>
OfficialVerify(
type: (json['type'] as num?)?.toInt(),
desc: json['desc'] as String?,
role: (json['role'] as num?)?.toInt(),
title: json['title'] as String?,
icon: json['icon'] as String?,
spliceTitle: json['splice_title'] as String?,
);
Map<String, dynamic> _$OfficialVerifyToJson(OfficialVerify instance) =>
<String, dynamic>{
'type': instance.type,
'desc': instance.desc,
'role': instance.role,
'title': instance.title,
'icon': instance.icon,
'splice_title': instance.spliceTitle,
};

View File

@@ -1,33 +0,0 @@
import 'package:json_annotation/json_annotation.dart';
part 'pendant.g.dart';
@JsonSerializable()
class Pendant {
int? pid;
String? name;
String? image;
int? expire;
@JsonKey(name: 'image_enhance')
String? imageEnhance;
@JsonKey(name: 'image_enhance_frame')
String? imageEnhanceFrame;
@JsonKey(name: 'n_pid')
int? nPid;
Pendant({
this.pid,
this.name,
this.image,
this.expire,
this.imageEnhance,
this.imageEnhanceFrame,
this.nPid,
});
factory Pendant.fromJson(Map<String, dynamic> json) {
return _$PendantFromJson(json);
}
Map<String, dynamic> toJson() => _$PendantToJson(this);
}

View File

@@ -1,27 +0,0 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'pendant.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
Pendant _$PendantFromJson(Map<String, dynamic> json) => Pendant(
pid: (json['pid'] as num?)?.toInt(),
name: json['name'] as String?,
image: json['image'] as String?,
expire: (json['expire'] as num?)?.toInt(),
imageEnhance: json['image_enhance'] as String?,
imageEnhanceFrame: json['image_enhance_frame'] as String?,
nPid: (json['n_pid'] as num?)?.toInt(),
);
Map<String, dynamic> _$PendantToJson(Pendant instance) => <String, dynamic>{
'pid': instance.pid,
'name': instance.name,
'image': instance.image,
'expire': instance.expire,
'image_enhance': instance.imageEnhance,
'image_enhance_frame': instance.imageEnhanceFrame,
'n_pid': instance.nPid,
};

View File

@@ -1,32 +0,0 @@
import 'package:json_annotation/json_annotation.dart';
import 'package:PiliPlus/models/space/label.dart';
part 'vip.g.dart';
@JsonSerializable()
class Vip {
int? vipType;
int? vipDueDate;
String? dueRemark;
int? accessStatus;
int? vipStatus;
String? vipStatusWarn;
int? themeType;
Label? label;
Vip({
this.vipType,
this.vipDueDate,
this.dueRemark,
this.accessStatus,
this.vipStatus,
this.vipStatusWarn,
this.themeType,
this.label,
});
factory Vip.fromJson(Map<String, dynamic> json) => _$VipFromJson(json);
Map<String, dynamic> toJson() => _$VipToJson(this);
}

View File

@@ -1,31 +0,0 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'vip.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
Vip _$VipFromJson(Map<String, dynamic> json) => Vip(
vipType: (json['vipType'] as num?)?.toInt(),
vipDueDate: (json['vipDueDate'] as num?)?.toInt(),
dueRemark: json['dueRemark'] as String?,
accessStatus: (json['accessStatus'] as num?)?.toInt(),
vipStatus: (json['vipStatus'] as num?)?.toInt(),
vipStatusWarn: json['vipStatusWarn'] as String?,
themeType: (json['themeType'] as num?)?.toInt(),
label: json['label'] == null
? null
: Label.fromJson(json['label'] as Map<String, dynamic>),
);
Map<String, dynamic> _$VipToJson(Vip instance) => <String, dynamic>{
'vipType': instance.vipType,
'vipDueDate': instance.vipDueDate,
'dueRemark': instance.dueRemark,
'accessStatus': instance.accessStatus,
'vipStatus': instance.vipStatus,
'vipStatusWarn': instance.vipStatusWarn,
'themeType': instance.themeType,
'label': instance.label,
};

View File

@@ -1,27 +1,12 @@
import 'package:PiliPlus/models/model_owner.dart';
import 'package:PiliPlus/models/model_avatar.dart';
import 'package:PiliPlus/models/space_article/nameplate.dart';
import 'package:PiliPlus/models/space_article/official_verify.dart';
import 'package:PiliPlus/models/space_article/pendant.dart';
import 'package:PiliPlus/models/space_article/vip.dart';
class Author extends Owner {
Pendant? pendant;
OfficialVerify? officialVerify;
class Author extends Avatar {
Nameplate? nameplate;
Vip? vip;
Author.fromJson(Map<String, dynamic> json) {
mid = json['mid'];
name = json['name'] as String?;
face = json['face'] as String?;
pendant =
json['pendant'] == null ? null : Pendant.fromJson(json['pendant']);
officialVerify = json['official_verify'] == null
? null
: OfficialVerify.fromJson(json['official_verify']);
Author.fromJson(Map<String, dynamic> json) : super.fromJson(json) {
nameplate = json['nameplate'] == null
? null
: Nameplate.fromJson(json['nameplate']);
vip = json['vip'] == null ? null : Vip.fromJson(json['vip']);
}
}

View File

@@ -1,17 +0,0 @@
import 'package:json_annotation/json_annotation.dart';
part 'official_verify.g.dart';
@JsonSerializable()
class OfficialVerify {
int? type;
String? desc;
OfficialVerify({this.type, this.desc});
factory OfficialVerify.fromJson(Map<String, dynamic> json) {
return _$OfficialVerifyFromJson(json);
}
Map<String, dynamic> toJson() => _$OfficialVerifyToJson(this);
}

View File

@@ -1,19 +0,0 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'official_verify.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
OfficialVerify _$OfficialVerifyFromJson(Map<String, dynamic> json) =>
OfficialVerify(
type: (json['type'] as num?)?.toInt(),
desc: json['desc'] as String?,
);
Map<String, dynamic> _$OfficialVerifyToJson(OfficialVerify instance) =>
<String, dynamic>{
'type': instance.type,
'desc': instance.desc,
};

View File

@@ -1,19 +0,0 @@
import 'package:json_annotation/json_annotation.dart';
part 'pendant.g.dart';
@JsonSerializable()
class Pendant {
int? pid;
String? name;
String? image;
int? expire;
Pendant({this.pid, this.name, this.image, this.expire});
factory Pendant.fromJson(Map<String, dynamic> json) {
return _$PendantFromJson(json);
}
Map<String, dynamic> toJson() => _$PendantToJson(this);
}

View File

@@ -1,21 +0,0 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'pendant.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
Pendant _$PendantFromJson(Map<String, dynamic> json) => Pendant(
pid: (json['pid'] as num?)?.toInt(),
name: json['name'] as String?,
image: json['image'] as String?,
expire: (json['expire'] as num?)?.toInt(),
);
Map<String, dynamic> _$PendantToJson(Pendant instance) => <String, dynamic>{
'pid': instance.pid,
'name': instance.name,
'image': instance.image,
'expire': instance.expire,
};

View File

@@ -1,37 +0,0 @@
import 'package:json_annotation/json_annotation.dart';
import 'package:PiliPlus/models/space_article/label.dart';
part 'vip.g.dart';
@JsonSerializable()
class Vip {
int? type;
int? status;
@JsonKey(name: 'due_date')
int? dueDate;
@JsonKey(name: 'vip_pay_type')
int? vipPayType;
@JsonKey(name: 'theme_type')
int? themeType;
Label? label;
@JsonKey(name: 'avatar_subscript')
int? avatarSubscript;
@JsonKey(name: 'nickname_color')
String? nicknameColor;
Vip({
this.type,
this.status,
this.dueDate,
this.vipPayType,
this.themeType,
this.label,
this.avatarSubscript,
this.nicknameColor,
});
factory Vip.fromJson(Map<String, dynamic> json) => _$VipFromJson(json);
Map<String, dynamic> toJson() => _$VipToJson(this);
}

View File

@@ -1,31 +0,0 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'vip.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
Vip _$VipFromJson(Map<String, dynamic> json) => Vip(
type: (json['type'] as num?)?.toInt(),
status: (json['status'] as num?)?.toInt(),
dueDate: (json['due_date'] as num?)?.toInt(),
vipPayType: (json['vip_pay_type'] as num?)?.toInt(),
themeType: (json['theme_type'] as num?)?.toInt(),
label: json['label'] == null
? null
: Label.fromJson(json['label'] as Map<String, dynamic>),
avatarSubscript: (json['avatar_subscript'] as num?)?.toInt(),
nicknameColor: json['nickname_color'] as String?,
);
Map<String, dynamic> _$VipToJson(Vip instance) => <String, dynamic>{
'type': instance.type,
'status': instance.status,
'due_date': instance.dueDate,
'vip_pay_type': instance.vipPayType,
'theme_type': instance.themeType,
'label': instance.label,
'avatar_subscript': instance.avatarSubscript,
'nickname_color': instance.nicknameColor,
};

View File

@@ -1,3 +1,5 @@
import 'package:PiliPlus/models/model_avatar.dart';
class ReplyMember {
ReplyMember({
this.mid,
@@ -39,24 +41,6 @@ class ReplyMember {
}
}
class Pendant {
Pendant({
this.pid,
this.name,
this.image,
});
int? pid;
String? name;
String? image;
Pendant.fromJson(Map<String, dynamic> json) {
pid = json['pid'];
name = json['name'];
image = json['image'];
}
}
class UserSailing {
UserSailing({this.pendant, this.cardbg});

View File

@@ -1,5 +1,7 @@
import 'dart:convert';
import 'package:PiliPlus/models/model_avatar.dart';
class VideoDetailResponse {
int? code;
String? message;
@@ -308,21 +310,6 @@ class Staff {
}
}
class Vip {
dynamic type;
dynamic status;
Vip({
this.type,
this.status,
});
Vip.fromJson(Map<String, dynamic> json) {
type = json["type"];
status = json["status"];
}
}
class HonorReply {
List<Honor>? honor;