mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
mod: member card: show prInfo
Closes #571 Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import 'package:PiliPlus/models/space/pr_info.dart';
|
||||||
import 'package:PiliPlus/models/space/space_tag_bottom.dart';
|
import 'package:PiliPlus/models/space/space_tag_bottom.dart';
|
||||||
import 'package:json_annotation/json_annotation.dart';
|
import 'package:json_annotation/json_annotation.dart';
|
||||||
|
|
||||||
@@ -58,8 +59,8 @@ class Card {
|
|||||||
String? pendantUrl;
|
String? pendantUrl;
|
||||||
@JsonKey(name: 'pendant_title')
|
@JsonKey(name: 'pendant_title')
|
||||||
String? pendantTitle;
|
String? pendantTitle;
|
||||||
// @JsonKey(name: 'pr_info')
|
@JsonKey(name: 'pr_info')
|
||||||
// PrInfo? prInfo;
|
PrInfo? prInfo;
|
||||||
Relation? relation;
|
Relation? relation;
|
||||||
@JsonKey(name: 'is_deleted')
|
@JsonKey(name: 'is_deleted')
|
||||||
int? isDeleted;
|
int? isDeleted;
|
||||||
@@ -120,7 +121,7 @@ class Card {
|
|||||||
this.achieve,
|
this.achieve,
|
||||||
this.pendantUrl,
|
this.pendantUrl,
|
||||||
this.pendantTitle,
|
this.pendantTitle,
|
||||||
// this.prInfo,
|
this.prInfo,
|
||||||
this.relation,
|
this.relation,
|
||||||
this.isDeleted,
|
this.isDeleted,
|
||||||
this.honours,
|
this.honours,
|
||||||
|
|||||||
@@ -58,9 +58,9 @@ Card _$CardFromJson(Map<String, dynamic> json) => Card(
|
|||||||
: Achieve.fromJson(json['achieve'] as Map<String, dynamic>),
|
: Achieve.fromJson(json['achieve'] as Map<String, dynamic>),
|
||||||
pendantUrl: json['pendant_url'] as String?,
|
pendantUrl: json['pendant_url'] as String?,
|
||||||
pendantTitle: json['pendant_title'] as String?,
|
pendantTitle: json['pendant_title'] as String?,
|
||||||
// prInfo: json['pr_info'] == null
|
prInfo: json['pr_info'] == null
|
||||||
// ? null
|
? null
|
||||||
// : PrInfo.fromJson(json['pr_info'] as Map<String, dynamic>),
|
: PrInfo.fromJson(json['pr_info'] as Map<String, dynamic>),
|
||||||
relation: json['relation'] == null
|
relation: json['relation'] == null
|
||||||
? null
|
? null
|
||||||
: Relation.fromJson(json['relation'] as Map<String, dynamic>),
|
: Relation.fromJson(json['relation'] as Map<String, dynamic>),
|
||||||
@@ -131,7 +131,7 @@ Map<String, dynamic> _$CardToJson(Card instance) => <String, dynamic>{
|
|||||||
'achieve': instance.achieve,
|
'achieve': instance.achieve,
|
||||||
'pendant_url': instance.pendantUrl,
|
'pendant_url': instance.pendantUrl,
|
||||||
'pendant_title': instance.pendantTitle,
|
'pendant_title': instance.pendantTitle,
|
||||||
// 'pr_info': instance.prInfo,
|
'pr_info': instance.prInfo,
|
||||||
'relation': instance.relation,
|
'relation': instance.relation,
|
||||||
'is_deleted': instance.isDeleted,
|
'is_deleted': instance.isDeleted,
|
||||||
'honours': instance.honours,
|
'honours': instance.honours,
|
||||||
|
|||||||
@@ -1,14 +1,34 @@
|
|||||||
|
|
||||||
class PrInfo {
|
class PrInfo {
|
||||||
PrInfo();
|
PrInfo(
|
||||||
|
this.content,
|
||||||
|
this.url,
|
||||||
|
this.icon,
|
||||||
|
this.iconNight,
|
||||||
|
this.textColor,
|
||||||
|
this.bgColor,
|
||||||
|
this.textColorNight,
|
||||||
|
this.bgColorNight,
|
||||||
|
);
|
||||||
|
|
||||||
factory PrInfo.fromJson(Map<String, dynamic> json) {
|
String? content;
|
||||||
// TODO: implement fromJson
|
String? url;
|
||||||
throw UnimplementedError('PrInfo.fromJson($json) is not implemented');
|
String? icon;
|
||||||
|
String? iconNight;
|
||||||
|
String? textColor;
|
||||||
|
String? bgColor;
|
||||||
|
String? textColorNight;
|
||||||
|
String? bgColorNight;
|
||||||
|
|
||||||
|
PrInfo.fromJson(Map<String, dynamic> json) {
|
||||||
|
content = json['content'];
|
||||||
|
if (content?.isNotEmpty == true) {
|
||||||
|
url = json['url'];
|
||||||
|
icon = json['icon'];
|
||||||
|
iconNight = json['icon_night'];
|
||||||
|
textColor = json['text_color'] ?? "#999999";
|
||||||
|
bgColor = json['bg_color'] ?? "#e7e7e7";
|
||||||
|
textColorNight = json['text_color_night'] ?? "#727272";
|
||||||
|
bgColorNight = json['bg_color_night'] ?? "#2A2A2A";
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
|
||||||
// TODO: implement toJson
|
|
||||||
throw UnimplementedError();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -535,6 +535,66 @@ class UserInfoCard extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
..._buildLeft(context),
|
..._buildLeft(context),
|
||||||
|
if (card.prInfo?.content?.isNotEmpty == true)
|
||||||
|
Builder(builder: (context) {
|
||||||
|
final isDark = Theme.of(context).brightness == Brightness.dark;
|
||||||
|
final textColor = isDark
|
||||||
|
? Color(int.parse(
|
||||||
|
'FF${card.prInfo?.textColorNight?.substring(1)}',
|
||||||
|
radix: 16))
|
||||||
|
: Color(int.parse('FF${card.prInfo?.textColor?.substring(1)}',
|
||||||
|
radix: 16));
|
||||||
|
return GestureDetector(
|
||||||
|
onTap: () {
|
||||||
|
if (card.prInfo?.url?.isNotEmpty == true) {
|
||||||
|
Utils.handleWebview(card.prInfo!.url!);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: Container(
|
||||||
|
margin: const EdgeInsets.only(top: 8),
|
||||||
|
padding:
|
||||||
|
const EdgeInsets.symmetric(horizontal: 16, vertical: 10),
|
||||||
|
color: isDark
|
||||||
|
? Color(int.parse(
|
||||||
|
'FF${card.prInfo?.bgColorNight?.substring(1)}',
|
||||||
|
radix: 16))
|
||||||
|
: Color(int.parse(
|
||||||
|
'FF${card.prInfo?.bgColor?.substring(1)}',
|
||||||
|
radix: 16)),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
if (isDark &&
|
||||||
|
card.prInfo?.iconNight?.isNotEmpty == true) ...[
|
||||||
|
CachedNetworkImage(
|
||||||
|
imageUrl: card.prInfo!.iconNight!,
|
||||||
|
height: 20,
|
||||||
|
),
|
||||||
|
const SizedBox(width: 16),
|
||||||
|
] else if (card.prInfo?.icon?.isNotEmpty == true) ...[
|
||||||
|
CachedNetworkImage(
|
||||||
|
imageUrl: card.prInfo!.icon!,
|
||||||
|
height: 20,
|
||||||
|
),
|
||||||
|
const SizedBox(width: 16),
|
||||||
|
],
|
||||||
|
Expanded(
|
||||||
|
child: Text(
|
||||||
|
card.prInfo!.content!,
|
||||||
|
style: TextStyle(fontSize: 15, color: textColor),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (card.prInfo?.url?.isNotEmpty == true) ...[
|
||||||
|
const SizedBox(width: 10),
|
||||||
|
Icon(
|
||||||
|
Icons.keyboard_arrow_right,
|
||||||
|
color: textColor,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}),
|
||||||
const SizedBox(height: 5),
|
const SizedBox(height: 5),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user