From 6c87e9eebf24e7c85452ab8d9f4091157e014f54 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Sat, 15 Jul 2023 14:26:40 +0800 Subject: [PATCH] =?UTF-8?q?mod:=20=E5=8A=A8=E6=80=81=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E5=86=85=E5=AE=B9=E8=A1=A5=E5=85=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/models/dynamics/result.dart | 104 +++++++++++ .../dynamics/widgets/additional_panel.dart | 176 ++++++++++++++---- lib/pages/dynamics/widgets/forward_panel.dart | 7 + 3 files changed, 251 insertions(+), 36 deletions(-) diff --git a/lib/models/dynamics/result.dart b/lib/models/dynamics/result.dart index ec845871..ea799b60 100644 --- a/lib/models/dynamics/result.dart +++ b/lib/models/dynamics/result.dart @@ -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 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 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? items; + String? jumpUrl; + + Good.fromJson(Map json) { + headIcon = json['head_icon']; + headText = json['head_text']; + items = json['items'].map((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 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, diff --git a/lib/pages/dynamics/widgets/additional_panel.dart b/lib/pages/dynamics/widgets/additional_panel.dart index da781bfe..0396f219 100644 --- a/lib/pages/dynamics/widgets/additional_panel.dart +++ b/lib/pages/dynamics/widgets/additional_panel.dart @@ -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 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'); + } } diff --git a/lib/pages/dynamics/widgets/forward_panel.dart b/lib/pages/dynamics/widgets/forward_panel.dart index d713ec61..d277245b 100644 --- a/lib/pages/dynamics/widgets/forward_panel.dart +++ b/lib/pages/dynamics/widgets/forward_panel.dart @@ -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, + ) ], ); // 视频