mod: 动态内容完善

This commit is contained in:
guozhigq
2023-07-10 13:42:04 +08:00
parent f305e0864f
commit 98ef6876ce
6 changed files with 205 additions and 11 deletions

View File

@ -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<String, dynamic> 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({

View File

@ -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<dynamic, dynamic> 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,
),
)
],
),
),
],
),
),
);
}

View File

@ -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: [

View File

@ -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,
),
)
],
),
),
],
);
}

View File

@ -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:

View File

@ -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: