From 98ef6876ceaf5e0c18c1e4254cb19022bc996dca Mon Sep 17 00:00:00 2001 From: guozhigq Date: Mon, 10 Jul 2023 13:42:04 +0800 Subject: [PATCH] =?UTF-8?q?mod:=20=E5=8A=A8=E6=80=81=E5=86=85=E5=AE=B9?= =?UTF-8?q?=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/models/dynamics/result.dart | 40 ++++++++ .../dynamics/widgets/additional_panel.dart | 46 +++++++++ lib/pages/dynamics/widgets/forward_panel.dart | 15 ++- lib/pages/dynamics/widgets/live_panel.dart | 99 +++++++++++++++++++ pubspec.lock | 8 -- pubspec.yaml | 8 +- 6 files changed, 205 insertions(+), 11 deletions(-) create mode 100644 lib/pages/dynamics/widgets/additional_panel.dart create mode 100644 lib/pages/dynamics/widgets/live_panel.dart diff --git a/lib/models/dynamics/result.dart b/lib/models/dynamics/result.dart index cddf8d80..7d5e9104 100644 --- a/lib/models/dynamics/result.dart +++ b/lib/models/dynamics/result.dart @@ -299,6 +299,7 @@ class DynamicMajorModel { this.opus, this.pgc, this.liveRcmd, + this.live, this.none, this.type, }); @@ -309,6 +310,7 @@ class DynamicMajorModel { DynamicOpusModel? opus; DynamicArchiveModel? pgc; DynamicLiveModel? liveRcmd; + DynamicLive2Model? live; DynamicNoneModel? none; // MAJOR_TYPE_DRAW 图片 // MAJOR_TYPE_ARCHIVE 视频 @@ -331,6 +333,8 @@ class DynamicMajorModel { liveRcmd = json['live_rcmd'] != null ? DynamicLiveModel.fromJson(json['live_rcmd']) : null; + live = + json['live'] != null ? DynamicLive2Model.fromJson(json['live']) : null; none = json['none'] != null ? DynamicNoneModel.fromJson(json['none']) : null; type = json['type']; @@ -594,6 +598,42 @@ class DynamicLiveModel { } } +class DynamicLive2Model { + DynamicLive2Model({ + this.badge, + this.cover, + this.descFirst, + this.descSecond, + this.id, + this.jumpUrl, + this.liveState, + this.reserveType, + this.title, + }); + + Map? badge; + String? cover; + String? descFirst; + String? descSecond; + int? id; + String? jumpUrl; + int? liveState; + int? reserveType; + String? title; + + DynamicLive2Model.fromJson(Map json) { + badge = json['badge']; + cover = json['cover']; + descFirst = json['desc_first']; + descSecond = json['desc_second']; + id = json['id']; + jumpUrl = json['jump_url']; + liveState = json['liv_state']; + reserveType = json['reserve_type']; + title = json['title']; + } +} + // 动态状态 转发、评论、点赞 class ModuleStatModel { ModuleStatModel({ diff --git a/lib/pages/dynamics/widgets/additional_panel.dart b/lib/pages/dynamics/widgets/additional_panel.dart new file mode 100644 index 00000000..da781bfe --- /dev/null +++ b/lib/pages/dynamics/widgets/additional_panel.dart @@ -0,0 +1,46 @@ +import 'package:flutter/material.dart'; +import 'package:pilipala/common/widgets/network_img_layer.dart'; + +Widget addWidget(item, context, type, {floor = 1}) { + Map dynamicProperty = { + 'ADDITIONAL_TYPE_UGC': item.modules.moduleDynamic.additional.ugc, + }; + return InkWell( + onTap: () {}, + child: Container( + padding: const EdgeInsets.only(left: 15, top: 10, right: 15, bottom: 8), + color: Theme.of(context).dividerColor.withOpacity(0.08), + child: Row( + children: [ + NetworkImgLayer( + width: 120, + height: 75, + src: dynamicProperty[type].cover, + ), + const SizedBox(width: 10), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Text( + dynamicProperty[type].title, + maxLines: 2, + overflow: TextOverflow.ellipsis, + ), + const SizedBox(height: 4), + Text( + dynamicProperty[type].descSecond, + style: TextStyle( + color: Theme.of(context).colorScheme.outline, + fontSize: Theme.of(context).textTheme.labelMedium!.fontSize, + ), + ) + ], + ), + ), + ], + ), + ), + ); +} diff --git a/lib/pages/dynamics/widgets/forward_panel.dart b/lib/pages/dynamics/widgets/forward_panel.dart index e2baa86c..d713ec61 100644 --- a/lib/pages/dynamics/widgets/forward_panel.dart +++ b/lib/pages/dynamics/widgets/forward_panel.dart @@ -3,7 +3,9 @@ import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:pilipala/utils/utils.dart'; +import 'additional_panel.dart'; import 'article_panel.dart'; +import 'live_panel.dart'; import 'live_rcmd_panel.dart'; import 'pic_panel.dart'; import 'rich_node_panel.dart'; @@ -88,6 +90,8 @@ Widget forWard(item, context, ctr, source, {floor = 1}) { // 直播 case 'DYNAMIC_TYPE_LIVE_RCMD': return liveRcmdPanel(item, context, floor: floor); + case 'DYNAMIC_TYPE_LIVE': + return livePanel(item, context, floor: floor); // 合集 case 'DYNAMIC_TYPE_UGC_SEASON': return videoSeasonWidget(item, context, 'ugcSeason'); @@ -119,9 +123,18 @@ Widget forWard(item, context, ctr, source, {floor = 1}) { Text(item.modules.moduleDynamic.desc.text) ], ) - : const SizedBox(height: 0); + : item.modules.moduleDynamic.additional != null + ? addWidget( + item, + context, + item.modules.moduleDynamic.additional.type, + floor: floor, + ) + : const SizedBox(height: 0); case 'DYNAMIC_TYPE_PGC': return videoSeasonWidget(item, context, 'pgc', floor: floor); + case 'DYNAMIC_TYPE_PGC_UNION': + return videoSeasonWidget(item, context, 'pgc', floor: floor); case 'DYNAMIC_TYPE_NONE': return Row( children: [ diff --git a/lib/pages/dynamics/widgets/live_panel.dart b/lib/pages/dynamics/widgets/live_panel.dart new file mode 100644 index 00000000..483a6ea4 --- /dev/null +++ b/lib/pages/dynamics/widgets/live_panel.dart @@ -0,0 +1,99 @@ +import 'package:flutter/material.dart'; +import 'package:pilipala/common/constants.dart'; +import 'package:pilipala/common/widgets/network_img_layer.dart'; +import 'package:pilipala/utils/utils.dart'; + +import 'rich_node_panel.dart'; + +Widget livePanel(item, context, {floor = 1}) { + dynamic content = item.modules.moduleDynamic.major; + TextStyle authorStyle = + TextStyle(color: Theme.of(context).colorScheme.primary); + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + if (floor == 2) ...[ + Row( + children: [ + GestureDetector( + onTap: () {}, + child: Text( + '@${item.modules.moduleAuthor.name}', + style: authorStyle, + ), + ), + const SizedBox(width: 6), + Text( + Utils.dateFormat(item.modules.moduleAuthor.pubTs), + style: TextStyle( + color: Theme.of(context).colorScheme.outline, + fontSize: Theme.of(context).textTheme.labelSmall!.fontSize), + ), + ], + ), + ], + const SizedBox(height: 4), + if (item.modules.moduleDynamic.topic != null) ...[ + Padding( + padding: floor == 2 + ? EdgeInsets.zero + : const EdgeInsets.only(left: 12, right: 12), + child: GestureDetector( + child: Text( + '#${item.modules.moduleDynamic.topic.name}', + style: authorStyle, + ), + ), + ), + const SizedBox(height: 6), + ], + if (floor == 2 && item.modules.moduleDynamic.desc != null) ...[ + Text.rich(richNode(item, context)), + const SizedBox(height: 6), + ], + GestureDetector( + onTap: () {}, + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + NetworkImgLayer( + width: 120, + height: 75, + src: content.live.cover, + ), + const SizedBox(width: 10), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Text( + content.live.title, + maxLines: 2, + overflow: TextOverflow.ellipsis, + ), + const SizedBox(height: 4), + Text( + content.live.descFirst, + style: TextStyle( + color: Theme.of(context).colorScheme.outline, + fontSize: + Theme.of(context).textTheme.labelMedium!.fontSize, + ), + ) + ], + ), + ), + Text( + content.live.badge['text'], + style: TextStyle( + fontSize: Theme.of(context).textTheme.labelMedium!.fontSize, + ), + ) + ], + ), + ), + ], + ); +} diff --git a/pubspec.lock b/pubspec.lock index 618b46b5..7e5d3983 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -958,14 +958,6 @@ packages: url: "https://pub.dev" source: hosted version: "0.1.6" - screenshot: - dependency: "direct main" - description: - name: screenshot - sha256: "30bb9fade6eb2578a1fc2e84f6b184141fc86883cda10988d4500ff00eb728e2" - url: "https://pub.dev" - source: hosted - version: "1.3.0" share_plus: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index 3956f7dc..4eea40fc 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -65,21 +65,25 @@ dependencies: share_plus: ^6.3.1 # webView url_launcher: ^6.1.9 + # cookie 管理 webview_cookie_manager: ^2.0.6 + # 浏览器 webview_flutter: ^4.2.0 - + # 解决sliver滑动不同步 extended_nested_scroll_view: ^6.0.0 + # 图标 font_awesome_flutter: ^10.4.0 # toast flutter_smart_dialog: ^4.9.0+6 + # 下滑关闭 dismissible_page: ^1.0.2 + # 媒体播放 flutter_meedu_media_kit: # path: /Users/rr/Desktop/code/flutter_meedu_media_kit/package git: url: https://github.com/guozhigq/flutter_meedu_media_kit.git ref: feature-custom path: package - screenshot: ^1.3.0 dev_dependencies: flutter_test: