mod: 动态页面内容补充

This commit is contained in:
guozhigq
2023-07-15 14:26:40 +08:00
parent 967676dd19
commit 6c87e9eebf
3 changed files with 251 additions and 36 deletions

View File

@ -189,16 +189,29 @@ class DynamicAddModel {
this.type,
this.vote,
this.ugc,
this.reserve,
this.goods,
});
String? type;
Vote? vote;
Ugc? ugc;
Reserve? reserve;
Good? goods;
/// TODO 比赛vs
String? match;
/// TODO 游戏信息
String? common;
DynamicAddModel.fromJson(Map<String, dynamic> json) {
type = json['type'];
vote = json['vote'] != null ? Vote.fromJson(json['vote']) : null;
ugc = json['ugc'] != null ? Ugc.fromJson(json['ugc']) : null;
reserve =
json['reserve'] != null ? Reserve.fromJson(json['reserve']) : null;
goods = json['goods'] != null ? Good.fromJson(json['goods']) : null;
}
}
@ -271,6 +284,97 @@ class Ugc {
}
}
class Reserve {
Reserve({
this.button,
this.desc1,
this.desc2,
this.jumpUrl,
this.reserveTotal,
this.rid,
this.state,
this.stype,
this.title,
this.upMid,
});
Map? button;
Map? desc1;
Map? desc2;
String? jumpUrl;
int? reserveTotal;
int? rid;
int? state;
int? stype;
String? title;
int? upMid;
Reserve.fromJson(Map<String, dynamic> json) {
button = json['button'];
desc1 = json['desc1'];
desc2 = json['desc2'];
jumpUrl = json['jump_url'];
reserveTotal = json['reserve_total'];
rid = json['rid'];
state = json['state'];
state = json['state'];
stype = json['stype'];
title = json['title'];
upMid = json['up_mid'];
}
}
class Good {
Good({
this.headIcon,
this.headText,
this.items,
this.jumpUrl,
});
String? headIcon;
String? headText;
List<GoodItem>? items;
String? jumpUrl;
Good.fromJson(Map<String, dynamic> json) {
headIcon = json['head_icon'];
headText = json['head_text'];
items = json['items'].map<GoodItem>((e) => GoodItem.fromJson(e)).toList();
jumpUrl = json['jump_url'];
}
}
class GoodItem {
GoodItem({
this.brief,
this.cover,
this.id,
this.jumpDesc,
this.jumpUrl,
this.name,
this.price,
});
String? brief;
String? cover;
String? id;
String? jumpDesc;
String? jumpUrl;
String? name;
String? price;
GoodItem.fromJson(Map<String, dynamic> json) {
brief = json['brief'];
cover = json['cover'];
id = json['id'];
jumpDesc = json['jump_desc'];
jumpUrl = json['jump_url'];
name = json['name'];
price = json['price'];
}
}
class DynamicDescModel {
DynamicDescModel({
this.richTextNodes,

View File

@ -1,46 +1,150 @@
import 'package:flutter/material.dart';
import 'package:pilipala/common/widgets/network_img_layer.dart';
/// TODO 点击跳转
Widget addWidget(item, context, type, {floor = 1}) {
Map<dynamic, dynamic> dynamicProperty = {
'ADDITIONAL_TYPE_UGC': item.modules.moduleDynamic.additional.ugc,
// 直播预约
'ADDITIONAL_TYPE_RESERVE': item.modules.moduleDynamic.additional.reserve,
// 商品
'ADDITIONAL_TYPE_GOODS': item.modules.moduleDynamic.additional.goods,
// 比赛信息
'ADDITIONAL_TYPE_MATCH': item.modules.moduleDynamic.additional.match,
// 游戏信息
'ADDITIONAL_TYPE_COMMON': item.modules.moduleDynamic.additional.common,
};
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,
Color bgColor = floor == 1
? Theme.of(context).dividerColor.withOpacity(0.08)
: Theme.of(context).colorScheme.background;
switch (type) {
case 'ADDITIONAL_TYPE_UGC':
return InkWell(
onTap: () {},
child: Container(
padding:
const EdgeInsets.only(left: 15, top: 10, right: 15, bottom: 8),
color: bgColor,
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,
),
)
],
),
const SizedBox(height: 4),
Text(
dynamicProperty[type].descSecond,
style: TextStyle(
color: Theme.of(context).colorScheme.outline,
fontSize: Theme.of(context).textTheme.labelMedium!.fontSize,
),
)
],
),
),
],
),
],
),
),
);
),
);
case 'ADDITIONAL_TYPE_RESERVE':
return InkWell(
onTap: () {},
child: Container(
margin: const EdgeInsets.only(top: 8),
padding:
const EdgeInsets.only(left: 15, top: 12, right: 15, bottom: 10),
color: bgColor,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(dynamicProperty[type].title),
Text.rich(TextSpan(
style: TextStyle(
color: Theme.of(context).colorScheme.outline,
fontSize: Theme.of(context)
.textTheme
.labelMedium!
.fontSize),
children: [
TextSpan(text: dynamicProperty[type].desc1['text']),
TextSpan(text: dynamicProperty[type].desc2['text']),
]))
],
),
// TextButton(onPressed: () {}, child: Text('123'))
],
),
),
);
case 'ADDITIONAL_TYPE_GOODS':
return Container(
margin: const EdgeInsets.only(top: 6),
padding: const EdgeInsets.only(left: 15, top: 10, right: 15, bottom: 8),
decoration: BoxDecoration(
color: bgColor,
borderRadius: BorderRadius.all(Radius.circular(6)),
),
child: Row(
children: [
NetworkImgLayer(
width: 75,
height: 75,
src: dynamicProperty[type].items.first.cover,
),
const SizedBox(width: 10),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
dynamicProperty[type].items.first.name,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
Text(
dynamicProperty[type].items.first.brief,
maxLines: 1,
style: TextStyle(
color: Theme.of(context).colorScheme.outline,
fontSize:
Theme.of(context).textTheme.labelMedium!.fontSize,
),
),
const SizedBox(height: 2),
Text(
dynamicProperty[type].items.first.price,
style: TextStyle(
color: Theme.of(context).colorScheme.primary,
),
),
],
),
),
],
),
);
case 'ADDITIONAL_TYPE_MATCH':
return SizedBox();
case 'ADDITIONAL_TYPE_COMMON':
return SizedBox();
default:
return Text('11');
}
}

View File

@ -68,6 +68,13 @@ Widget forWard(item, context, ctr, source, {floor = 1}) {
: const EdgeInsets.only(left: 12, right: 12),
child: picWidget(item, context),
),
if (item.modules.moduleDynamic.additional != null)
addWidget(
item,
context,
item.modules.moduleDynamic.additional.type,
floor: floor,
)
],
);
// 视频