diff --git a/assets/fonts/digital_id_num.ttf b/assets/fonts/digital_id_num.ttf new file mode 100644 index 00000000..2ad16f9a Binary files /dev/null and b/assets/fonts/digital_id_num.ttf differ 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