From c5877b7c5ec920accf482150fa02c80149e87bfe Mon Sep 17 00:00:00 2001 From: bggRGjQaUbCoE Date: Mon, 27 Jan 2025 21:01:15 +0800 Subject: [PATCH] feat: custom show dyn decorate Signed-off-by: bggRGjQaUbCoE --- assets/fonts/digital_id_num.ttf | Bin 0 -> 2116 bytes lib/models/dynamics/result.dart | 7 +++ lib/pages/dynamics/detail/view.dart | 12 ++--- lib/pages/dynamics/widgets/author_panel.dart | 50 +++++++++++++++++++ lib/pages/setting/widgets/model.dart | 9 ++++ lib/utils/storage.dart | 4 ++ pubspec.yaml | 8 +-- 7 files changed, 80 insertions(+), 10 deletions(-) create mode 100644 assets/fonts/digital_id_num.ttf diff --git a/assets/fonts/digital_id_num.ttf b/assets/fonts/digital_id_num.ttf new file mode 100644 index 0000000000000000000000000000000000000000..2ad16f9a2b3ceb67399cea0928f9c14b433d2bda GIT binary patch literal 2116 zcmd5-ZEO@(6g~INY?lwQ3}pd<=nkc6@uNVO3KdKYw0yJ`nu4S*O<|#h*3b{26fh?E;a+zs~I2x%a;N z&OP_+d$SM#qp%AWN)|1DVSe?#x?O<(3ZoO3EuWtA;$!RI0PHX5uUS_cX+Srw0=}vA zi#KfCvHtzWFDKI;0Mza3sz~MJqX!z8Z(>hZGvHrqWzs)Ee`Cb^eA#ByB2H?j?AR|4~^{1z~et#%a^&On4b@qW4skxE) z^)&m|E!F>KUmr^&%r)Iyqu^Tz;Sb3wR&yzsBF6~Mf#i?&{uVV>ep8f z9@O8qGu2z$=G8-nYw{gewdo2u8U0Gld0Q^;jb@S6Pz9S6Fxzp*J50`W!!ppKGo@&e z{@Yglr=s7q$fnXERKtkblJ4*mawMd>TXk1ktE_m9JRX-HqFM609+yDxVz$MuA!Lw2 z{;Dhbu8Qc8MYDJ9JG z8O%V)2}y~*Q+Gu5Hb*}<^W{Y9U_Cq%b7#XI(%%;{ncF!QOpb+V>pMWeKfJwzogX+fbnfxo$X~%Y0Y=LLK(JrI+qLm0m)G^5$AxUEgz7Ons3M_-`32&7IN}MC>sF`|y-?Ei&t`b~O2;9+;ADbJ zN0LjNySFY(Nhk+3%+NpCyZ6b*(L6bF+USx48`sgnnwXs%3gn!(PkV8a!>bs>Q(&?b z9z_bRO3xqqn#dDUgmrist@r@va0S=!myDKaGFMhggS^6(W;L?)wWign^KQbj%(=qA zr;!%#`Pm<#*v(kJooel+?`NIlB|Onq8VapR2&>x&TaR$0aRfZSjH!i|59L-WhYxEk zo(eV*wnlle3dX`RiT$y@wJMg!cZRUmk9MlZDp`j{8hQPyF7g){ruM2bMvCH3sX&hK zO{FBoPA)J#C9l$gf$xUKLoP9$s##pq1f z_B}a1e26=VcnW4o2W!@&0Xwi6HQ0b^G$M%Qd`3`5Kj>LCe3oJ>GlD$(HQrp1D>tKx zb|WKAw1VuV3R^s!I(h~<8&A?IW={Z-*5vdiX^qFK#}m@jxqA)&2a*4;YXATM literal 0 HcmV?d00001 diff --git a/lib/models/dynamics/result.dart b/lib/models/dynamics/result.dart index 6079af79..94e011d7 100644 --- a/lib/models/dynamics/result.dart +++ b/lib/models/dynamics/result.dart @@ -1,5 +1,7 @@ import 'dart:convert'; +import 'package:PiliPlus/utils/storage.dart'; + class DynamicsDataModel { DynamicsDataModel({ this.hasMore, @@ -126,6 +128,7 @@ class ModuleAuthorModel { this.pubTs, this.type, this.vip, + this.decorate, }); String? face; @@ -139,6 +142,7 @@ class ModuleAuthorModel { int? pubTs; String? type; Map? vip; + Map? decorate; ModuleAuthorModel.fromJson(Map json) { face = json['face']; @@ -152,7 +156,10 @@ class ModuleAuthorModel { pubTs = json['pub_ts'] == 0 ? null : json['pub_ts']; type = json['type']; vip = json['vip']; + if (showDynDecorate) decorate = json['decorate']; } + + static bool showDynDecorate = GStorage.showDynDecorate; } // 单个动态详情 - 动态信息 diff --git a/lib/pages/dynamics/detail/view.dart b/lib/pages/dynamics/detail/view.dart index 95db3b4d..da36e1e4 100644 --- a/lib/pages/dynamics/detail/view.dart +++ b/lib/pages/dynamics/detail/view.dart @@ -43,7 +43,7 @@ class _DynamicDetailPageState extends State AnimationController? _fabAnimationCtr; late StreamController _titleStreamC; // appBar title bool _visibleTitle = false; - String? action; + // String? action; // 回复类型 late int replyType; bool _isFabVisible = true; @@ -89,10 +89,10 @@ class _DynamicDetailPageState extends State // floor 1原创 2转发 init(); _titleStreamC = StreamController(); - if (action == 'comment') { - _visibleTitle = true; - _titleStreamC.add(true); - } + // if (action == 'comment') { + // _visibleTitle = true; + // _titleStreamC.add(true); + // } _fabAnimationCtr = AnimationController( vsync: this, @@ -109,7 +109,7 @@ class _DynamicDetailPageState extends State // 楼层 int floor = args['floor']; // 从action栏点击进入 - action = args.containsKey('action') ? args['action'] : null; + // action = args.containsKey('action') ? args['action'] : null; // 评论类型 int commentType = args['item'].basic!['comment_type'] ?? 11; replyType = (commentType == 0) ? 11 : commentType; diff --git a/lib/pages/dynamics/widgets/author_panel.dart b/lib/pages/dynamics/widgets/author_panel.dart index 024bad6f..b89057a3 100644 --- a/lib/pages/dynamics/widgets/author_panel.dart +++ b/lib/pages/dynamics/widgets/author_panel.dart @@ -126,6 +126,56 @@ class AuthorPanel extends StatelessWidget { ), ), ), + if (item.modules.moduleAuthor.decorate != null) + GestureDetector( + onTap: item.modules.moduleAuthor.decorate['jump_url'] != null + ? () { + Get.toNamed( + '/webview', + parameters: { + 'url': + '${item.modules.moduleAuthor.decorate['jump_url']}' + }, + ); + } + : null, + child: Stack( + clipBehavior: Clip.none, + alignment: Alignment.centerRight, + children: [ + Image.network( + height: 32, + item.modules.moduleAuthor.decorate['card_url'], + ), + if ((item.modules.moduleAuthor.decorate?['fan']?['num_str'] + as String?) + ?.isNotEmpty == + true) + Padding( + padding: const EdgeInsets.only(right: 32), + child: Text( + '${item.modules.moduleAuthor.decorate['fan']['num_str']}', + style: TextStyle( + fontSize: 11, + fontFamily: 'digital_id_num', + color: (item.modules.moduleAuthor.decorate?['fan'] + ?['color'] as String?) + ?.startsWith('#') == + true + ? Color( + int.parse( + item.modules.moduleAuthor + .decorate['fan']['color'] + .replaceFirst('#', '0xFF'), + ), + ) + : null, + ), + ), + ), + ], + ), + ), SizedBox( width: 32, height: 32, diff --git a/lib/pages/setting/widgets/model.dart b/lib/pages/setting/widgets/model.dart index 0365fa29..670a0c12 100644 --- a/lib/pages/setting/widgets/model.dart +++ b/lib/pages/setting/widgets/model.dart @@ -13,6 +13,7 @@ import 'package:PiliPlus/models/common/reply_sort_type.dart'; import 'package:PiliPlus/models/common/super_resolution_type.dart'; import 'package:PiliPlus/models/common/theme_type.dart'; import 'package:PiliPlus/models/common/up_panel_position.dart'; +import 'package:PiliPlus/models/dynamics/result.dart'; import 'package:PiliPlus/models/video/play/CDN.dart'; import 'package:PiliPlus/models/video/play/quality.dart'; import 'package:PiliPlus/models/video/play/subtitle.dart'; @@ -1905,6 +1906,14 @@ List get extraSettings => [ setKey: SettingBoxKey.searchSuggestion, defaultVal: true, ), + SettingsModel( + settingsType: SettingsType.sw1tch, + title: '展示动态装饰', + leading: Icon(MdiIcons.stickerCircleOutline), + setKey: SettingBoxKey.showDynDecorate, + defaultVal: true, + onChanged: (value) => ModuleAuthorModel.showDynDecorate = value, + ), SettingsModel( settingsType: SettingsType.sw1tch, enableFeedback: true, diff --git a/lib/utils/storage.dart b/lib/utils/storage.dart index 3ee6f6ab..b2fa2905 100644 --- a/lib/utils/storage.dart +++ b/lib/utils/storage.dart @@ -351,6 +351,9 @@ class GStorage { static bool get searchSuggestion => GStorage.setting.get(SettingBoxKey.searchSuggestion, defaultValue: true); + static bool get showDynDecorate => + GStorage.setting.get(SettingBoxKey.showDynDecorate, defaultValue: true); + static List get dynamicDetailRatio => List.from(setting .get(SettingBoxKey.dynamicDetailRatio, defaultValue: [60.0, 40.0])); @@ -577,6 +580,7 @@ class SettingBoxKey { preInitPlayer = 'preInitPlayer', mainTabBarView = 'mainTabBarView', searchSuggestion = 'searchSuggestion', + showDynDecorate = 'showDynDecorate', // Sponsor Block enableSponsorBlock = 'enableSponsorBlock', diff --git a/pubspec.yaml b/pubspec.yaml index f38aadad..291b6f74 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -262,10 +262,10 @@ flutter: # "family" key with the font family name, and a "fonts" key with a # list giving the asset and other descriptors for the font. For # example: - # fonts: - # - family: fansCard - # fonts: - # - asset: assets/fonts/fansCard.ttf + fonts: + - family: digital_id_num + fonts: + - asset: assets/fonts/digital_id_num.ttf # - family: Jura-Bold # fonts: # - asset: assets/fonts/Jura-Bold.ttf