From 5e1fac31a1b0a741a6195ff49a525c6355c3727b Mon Sep 17 00:00:00 2001 From: PH2 <1293456824@qq.com> Date: Mon, 26 Oct 2020 10:22:36 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E6=B6=88=E6=81=AF=E7=9A=84=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F=E5=AE=9E=E7=8E=B0=202=E3=80=81=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E7=AD=9B=E9=80=89=E7=9A=84ios=E4=B8=8D=E8=83=BD=E7=82=B9?= =?UTF-8?q?=E5=87=BB=20bug=E4=BF=AE=E5=A4=8D=203=E3=80=81=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E5=95=86=E5=93=81=E5=88=97=E8=A1=A8=E7=9A=84=E6=B2=A1?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=83=85=E5=86=B5=E8=A7=86=E5=9B=BE=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bloc/message_notice_bloc.dart | 16 +- .../bloc/message_notice_repository.dart | 45 ++- .../bloc/message_notice_state.dart | 16 +- .../message_notice_page.dart | 290 +++++++++++----- .../model/message_notice_style_model.dart | 311 ++++++++++++++++++ .../item/search_result_item_page.dart | 6 +- .../search_result_goods_list_widget.dart | 15 +- .../tarbar/search_result_tab_widget.dart | 39 ++- 8 files changed, 628 insertions(+), 110 deletions(-) create mode 100644 lib/pages/message_notice_page/model/message_notice_style_model.dart diff --git a/lib/pages/message_notice_page/bloc/message_notice_bloc.dart b/lib/pages/message_notice_page/bloc/message_notice_bloc.dart index 38d0c2a..c25a87f 100644 --- a/lib/pages/message_notice_page/bloc/message_notice_bloc.dart +++ b/lib/pages/message_notice_page/bloc/message_notice_bloc.dart @@ -3,6 +3,9 @@ import 'dart:async'; import 'package:bloc/bloc.dart'; import 'package:equatable/equatable.dart'; import 'package:zhiying_base_widget/pages/message_notice_page/bloc/message_notice_repository.dart'; +import 'package:zhiying_base_widget/pages/message_notice_page/model/message_notice_style_model.dart'; +import 'package:zhiying_comm/util/empty_util.dart'; +import 'package:zhiying_comm/util/log/let_log.dart'; part 'message_notice_event.dart'; @@ -39,7 +42,18 @@ class MessageNoticeBloc extends Bloc { } /// 初始化 - Stream _mapInitEventToState(MessageNoticeInitEvent event) async* {} + Stream _mapInitEventToState(MessageNoticeInitEvent event) async* { + var cacheStyle = await repository.fetchCachedStyle(); + if(!EmptyUtil.isEmpty(cacheStyle)){ + yield MessageNoticeLoadedState(cacheStyle); + } + var netStyle = await repository.fetchNetStyle(); + if(!EmptyUtil.isEmpty(netStyle)){ + yield MessageNoticeLoadedState(netStyle); + Logger.log(netStyle.toJson().toString()); + } + + } /// 下拉刷新 Stream _mapOnRefreshEventToState(MessageNoticeOnRefreshEvent event) async* {} diff --git a/lib/pages/message_notice_page/bloc/message_notice_repository.dart b/lib/pages/message_notice_page/bloc/message_notice_repository.dart index 6e0dee9..05801b6 100644 --- a/lib/pages/message_notice_page/bloc/message_notice_repository.dart +++ b/lib/pages/message_notice_page/bloc/message_notice_repository.dart @@ -1,3 +1,6 @@ +import 'dart:convert'; + +import 'package:zhiying_base_widget/pages/message_notice_page/model/message_notice_style_model.dart'; import 'package:zhiying_comm/util/empty_util.dart'; import 'package:zhiying_comm/util/global_config.dart'; import 'package:zhiying_comm/util/log/let_log.dart'; @@ -7,8 +10,43 @@ class MessageNoticeRepository { final int _maxSize = 5; int _currentPage = 1; bool _hasMoreData = true; + MessageNoticeStyleModel _styleModel; List _oldData = []; + /// 样式初始化(获取网络) + Future fetchNetStyle() async { + try { + var result = await NetUtil.post('/api/v1/mod/pub.flutter.message_center', cache: true, method: NetMethod.GET); + if (NetUtil.isSuccess(result) && !EmptyUtil.isEmpty(result[GlobalConfig.HTTP_RESPONSE_KEY_DATA])) { + var modListData = result[GlobalConfig.HTTP_RESPONSE_KEY_DATA]['mod_list'][0]['data']; + if (!EmptyUtil.isEmpty(modListData)) { + _styleModel = MessageNoticeStyleModel.fromJson(jsonDecode(modListData.toString())); + return _styleModel; + } + } + } catch (e, s) { + Logger.error(e, s); + } + return null; + } + + /// 样式初始化(获取缓存) + Future fetchCachedStyle() async { + try { + var result = await NetUtil.getRequestCachedData('/api/v1/mod/pub.flutter.message_center'); + if (!EmptyUtil.isEmpty(result)) { + var modListData = result['mod_list'][0]['data']; + if (!EmptyUtil.isEmpty(modListData)) { + _styleModel = MessageNoticeStyleModel.fromJson(jsonDecode(modListData.toString())); + return _styleModel; + } + } + } catch (e, s) { + Logger.error(e, s); + } + return null; + } + /// 下拉刷新 Future fetchRefreshData() async { return fetchInitData(); @@ -32,12 +70,7 @@ class MessageNoticeRepository { /// 基础请求 Future _baseRequest() async { - try { - var result = await NetUtil.post('', params: {'size': _maxSize.toString()}); - if (NetUtil.isSuccess(result) && !EmptyUtil.isEmpty(result[GlobalConfig.HTTP_RESPONSE_KEY_DATA])) { - ++_currentPage; - } - } catch (e, s) { + try {} catch (e, s) { Logger.error(e, s); } return null; diff --git a/lib/pages/message_notice_page/bloc/message_notice_state.dart b/lib/pages/message_notice_page/bloc/message_notice_state.dart index 36b4b1f..4d1c23c 100644 --- a/lib/pages/message_notice_page/bloc/message_notice_state.dart +++ b/lib/pages/message_notice_page/bloc/message_notice_state.dart @@ -10,13 +10,27 @@ abstract class MessageNoticeState extends Equatable { class MessageNoticeInitial extends MessageNoticeState {} /// 数据加载成功 -class MessageNoticeLoadedState extends MessageNoticeState {} +class MessageNoticeLoadedState extends MessageNoticeState { + MessageNoticeStyleModel styleModel; + MessageNoticeLoadedState(this.styleModel); + + @override + List get props => [this.styleModel]; +} + +/// 初始化失败 +class MessageNoticeInitErrorState extends MessageNoticeState{} /// 下拉刷新失败 class MessageNoticeOnRefreshErrorState extends MessageNoticeState {} +/// 下拉刷新成功 +class MessageNoticeOnRefreshSuccessState extends MessageNoticeState{} + /// 上拉更多失败 class MessageNoticeOnLoadErrorState extends MessageNoticeState {} +/// 上拉更多成功 +class MessageNoticeOnLoadSuccessState extends MessageNoticeState{} /// 数据初始化加载失败 class MessageNoticeErrorState extends MessageNoticeState {} diff --git a/lib/pages/message_notice_page/message_notice_page.dart b/lib/pages/message_notice_page/message_notice_page.dart index 901853b..f61d2c3 100644 --- a/lib/pages/message_notice_page/message_notice_page.dart +++ b/lib/pages/message_notice_page/message_notice_page.dart @@ -1,10 +1,14 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:zhiying_base_widget/pages/message_notice_page/bloc/message_notice_bloc.dart'; import 'package:zhiying_base_widget/pages/message_notice_page/bloc/message_notice_repository.dart'; +import 'package:zhiying_base_widget/widgets/empty/empty_widget.dart'; import 'package:zhiying_comm/zhiying_comm.dart'; +import 'model/message_notice_style_model.dart'; + /// /// 消息通知页 /// @@ -16,7 +20,7 @@ class MessageNoticePage extends StatelessWidget { @override Widget build(BuildContext context) { return BlocProvider( - create: (_) => MessageNoticeBloc(MessageNoticeRepository())..add(MessageNoticeInitEvent()), + create: (_) => MessageNoticeBloc(MessageNoticeRepository()), child: _MessageNoticePageContainer(), ); } @@ -28,33 +32,129 @@ class _MessageNoticePageContainer extends StatefulWidget { } class __MessageNoticePageContainerState extends State<_MessageNoticePageContainer> { + RefreshController _refreshController; + + /// 刷新 + void _onRefresh() async {} + + /// 下拉更多 + void _onLoad() async {} + + @override + void initState() { + _refreshController = RefreshController(); + + /// 初始化 + BlocProvider.of(context).add(MessageNoticeInitEvent()); + super.initState(); + } + @override Widget build(BuildContext context) { - return _buildMainWidget(); + return BlocConsumer( + listener: (context, state) {}, + buildWhen: (prev, current) { + /// 上拉更多成功 + if (current is MessageNoticeOnLoadSuccessState) { + _refreshController.loadComplete(); + return false; + } + + /// 下拉刷新成功 + if (current is MessageNoticeOnRefreshSuccessState) { + _refreshController.refreshCompleted(resetFooterState: true); + return false; + } + + /// 上拉更多失败 + if (current is MessageNoticeOnLoadErrorState) { + _refreshController.loadNoData(); + return false; + } + + /// 下拉刷新失败 + if (current is MessageNoticeOnRefreshErrorState) { + _refreshController.refreshFailed(); + return false; + } + + /// 数据加载失败 + if (current is MessageNoticeErrorState) { + return false; + } + return true; + }, + builder: (context, state) { + /// 数据加载成功 + if (state is MessageNoticeLoadedState) { + return _buildDataListWidget(state?.styleModel); + } + + /// 数据初始化失败 + if (state is MessageNoticeInitErrorState) { + return _buildEmptyWidget(); + } + + /// 骨架图 + return _buildSkeletonWidget(); + }, + ); } - /// 主视图 - Widget _buildMainWidget() { + /// 有数据 + Widget _buildDataListWidget(MessageNoticeStyleModel styleModel) { return Scaffold( - appBar: _buildAppBarWidget(), - backgroundColor: HexColor.fromHex('#F9F9F9'), - body: ListView.builder( + appBar: _buildAppBarWidget(), + body: SmartRefresher( + controller: _refreshController, + onRefresh: _onRefresh, + onLoading: _onLoad, + enablePullDown: true, + enablePullUp: true, + child: ListView.builder( padding: const EdgeInsets.only(left: 12.5, right: 12.5, top: 8), - // shrinkWrap: true, - itemCount: 5, + itemCount: styleModel?.main_notification?.length ?? 0, itemBuilder: (context, index) { - return _buildOfficialActivitiesStyleWidget(); - })); + return _buildMessageCenterStyleWidget(styleModel?.main_notification[index], index, styleModel?.main_notification?.length); + }), + ), + ); + } + + /// 没有数据 + Widget _buildEmptyWidget() { + return Scaffold( + appBar: _buildAppBarWidget(), + body: SmartRefresher( + controller: _refreshController, + onRefresh: _onRefresh, + enablePullDown: true, + enablePullUp: false, + child: ListView( + children: [ + EmptyWidget(), + ], + ), + ), + ); + } + + /// 骨架图 + Widget _buildSkeletonWidget() { + return Scaffold( + appBar: _buildAppBarWidget(), + body: Container(), + ); } /// 消息中心样式 - Widget _buildMessageCenterStyleWidget(int index, int length) { + Widget _buildMessageCenterStyleWidget(MainNotificationStyle styleModel, int index, int length) { var borderRadius = index == 0 ? BorderRadius.only(topLeft: Radius.circular(7.5), topRight: Radius.circular(7.5)) : index == length - 1 ? BorderRadius.only(bottomRight: Radius.circular(7.5), bottomLeft: Radius.circular(7.5)) : BorderRadius.only(); return Container( - decoration: BoxDecoration(color: HexColor.fromHex('#FFFFFF'), borderRadius: borderRadius), + decoration: BoxDecoration(color: HexColor.fromHex(styleModel?.bg_color ?? '#FFFFFF'), borderRadius: borderRadius), padding: const EdgeInsets.only(left: 15, right: 15, top: 16), child: Column( children: [ @@ -63,7 +163,7 @@ class __MessageNoticePageContainerState extends State<_MessageNoticePageContaine width: double.infinity, child: Row( children: [ - _buildCustomerAvatarWidget(), + _buildCustomerAvatarWidget(icon: styleModel?.icon), const SizedBox(width: 10), Expanded( child: Column( @@ -73,8 +173,11 @@ class __MessageNoticePageContainerState extends State<_MessageNoticePageContaine Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Text('官方活动', style: TextStyle(color: HexColor.fromHex('#333333'), fontWeight: FontWeight.bold, fontSize: 13)), - Text('04-20 16:00', style: TextStyle(color: HexColor.fromHex('#D8D8D8'), fontSize: 12)), + Text( + styleModel?.name ?? '官方活动', + style: TextStyle(color: HexColor.fromHex(styleModel?.name_color ?? '#333333'), fontWeight: FontWeight.bold, fontSize: 13), + ), + Text('04-20 16:00', style: TextStyle(color: HexColor.fromHex(styleModel?.time_color ?? '#D8D8D8'), fontSize: 12)), ], ), Padding( @@ -83,7 +186,7 @@ class __MessageNoticePageContainerState extends State<_MessageNoticePageContaine '2020年6月23日4:00至6月30日4:00关闭提现aaa', maxLines: 1, overflow: TextOverflow.ellipsis, - style: TextStyle(color: HexColor.fromHex('#999999'), fontSize: 12), + style: TextStyle(color: HexColor.fromHex(styleModel?.value_color ?? '#999999'), fontSize: 12), ), ), ], @@ -99,12 +202,12 @@ class __MessageNoticePageContainerState extends State<_MessageNoticePageContaine } /// 官方通知样式 - Widget _buildOfficialNoticeStyleWidget() { + Widget _buildOfficialNoticeStyleWidget(OfficialNotificationStyle styleModel) { return Container( padding: const EdgeInsets.only(left: 15, right: 15, top: 12.5, bottom: 10), margin: const EdgeInsets.only(bottom: 7.5), decoration: BoxDecoration( - color: HexColor.fromHex('#FFFFFF'), + color: HexColor.fromHex(styleModel?.bg_color ?? '#FFFFFF'), borderRadius: BorderRadius.circular(7.5), ), child: Column( @@ -113,19 +216,26 @@ class __MessageNoticePageContainerState extends State<_MessageNoticePageContaine Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ - _buildCustomerAvatarWidget(), + _buildCustomerAvatarWidget(icon: styleModel?.icon), const SizedBox(width: 10), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ /// 标题 - Text('关于关闭提现功能通知', style: TextStyle(color: HexColor.fromHex('#333333'), fontSize: 14, fontWeight: FontWeight.bold)), + Text( + '关于关闭提现功能通知', + style: TextStyle(color: HexColor.fromHex(styleModel?.title_value_color ?? '#333333'), fontSize: 14, fontWeight: FontWeight.bold), + ), const SizedBox(height: 5), /// 内容 - Text('由于微信官方的限制,我们暂时将嗨如意小程序内的提现功能进行关闭并进行维护,关闭功能时间为2020年6月23日4:00至6月30日4:00,请谅解', - maxLines: 3, overflow: TextOverflow.ellipsis, style: TextStyle(color: HexColor.fromHex('#999999'), fontSize: 11)) + Text( + '由于微信官方的限制,我们暂时将嗨如意小程序内的提现功能进行关闭并进行维护,关闭功能时间为2020年6月23日4:00至6月30日4:00,请谅解', + maxLines: 3, + overflow: TextOverflow.ellipsis, + style: TextStyle(color: HexColor.fromHex(styleModel?.message_value_color ?? '#999999'), fontSize: 11), + ) ], ), ) @@ -133,25 +243,30 @@ class __MessageNoticePageContainerState extends State<_MessageNoticePageContaine ), /// 时间 - Padding(padding: const EdgeInsets.only(top: 16), child: Text('2020-06-23 01:00:06', style: TextStyle(color: HexColor.fromHex('#D8D8D8'), fontSize: 11))) + Padding( + padding: const EdgeInsets.only(top: 16), + child: Text( + '2020-06-23 01:00:06', + style: TextStyle(color: HexColor.fromHex(styleModel?.time_color ?? '#D8D8D8'), fontSize: 11), + )) ], ), ); } /// 官方活动样式 - Widget _buildOfficialActivitiesStyleWidget() { + Widget _buildOfficialActivitiesStyleWidget(OfficialActivityStyle styleModel) { return Container( padding: const EdgeInsets.only(left: 15, right: 15, top: 12.5, bottom: 10), margin: const EdgeInsets.only(bottom: 7.5), - decoration: BoxDecoration(borderRadius: BorderRadius.circular(7.5), color: HexColor.fromHex('#FFFFFF')), + decoration: BoxDecoration(borderRadius: BorderRadius.circular(7.5), color: HexColor.fromHex(styleModel?.bg_color ?? '#FFFFFF')), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ /// 标题 Text( '8.8淘宝会员节大促', - style: TextStyle(color: HexColor.fromHex('#333333'), fontWeight: FontWeight.bold, fontSize: 14), + style: TextStyle(color: HexColor.fromHex(styleModel?.title_value_color ?? '#333333'), fontWeight: FontWeight.bold, fontSize: 14), maxLines: 1, overflow: TextOverflow.ellipsis, ), @@ -159,8 +274,11 @@ class __MessageNoticePageContainerState extends State<_MessageNoticePageContaine /// 图片海报 ClipRRect( - borderRadius: BorderRadius.circular(7.5), - child: CachedNetworkImage(imageUrl: 'http://ossq.izhyin.cn/index_carousel_1.png', width: double.infinity, )), + borderRadius: BorderRadius.circular(7.5), + child: CachedNetworkImage( + imageUrl: 'http://ossq.izhyin.cn/index_carousel_1.png', + width: double.infinity, + )), const SizedBox(height: 6.5), /// 活动内容 @@ -168,24 +286,24 @@ class __MessageNoticePageContainerState extends State<_MessageNoticePageContaine '京东家电815周年庆,全场家电最低五折起,买一送一等超多优惠活动,点击查看活动详情', maxLines: 2, overflow: TextOverflow.ellipsis, - style: TextStyle(fontSize: 11, color: HexColor.fromHex('#999999')), + style: TextStyle(fontSize: 11, color: HexColor.fromHex(styleModel?.message_value_color ?? '#999999')), ), /// 时间 const SizedBox(height: 7), - Text('2020-06-23 01:00:06', style: TextStyle(color: HexColor.fromHex('#D8D8D8'), fontSize: 11)) + Text('2020-06-23 01:00:06', style: TextStyle(color: HexColor.fromHex(styleModel?.time_color ?? '#D8D8D8'), fontSize: 11)) ], ), ); } /// 交易通知样式 - Widget _buildTradeNoticeStyleWidget() { + Widget _buildTradeNoticeStyleWidget(TransactionNotificationStyle styleModel) { return Container( padding: const EdgeInsets.only(left: 15, right: 15, top: 12.5, bottom: 10), margin: const EdgeInsets.only(bottom: 7.5), decoration: BoxDecoration( - color: HexColor.fromHex('#FFFFFF'), + color: HexColor.fromHex(styleModel?.bg_color ?? '#FFFFFF'), borderRadius: BorderRadius.circular(7.5), ), child: Column( @@ -194,18 +312,18 @@ class __MessageNoticePageContainerState extends State<_MessageNoticePageContaine Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ - _buildCustomerAvatarWidget(), + _buildCustomerAvatarWidget(icon: styleModel?.icon), const SizedBox(width: 10), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ /// 标题 - Text('自购订单收益', style: TextStyle(color: HexColor.fromHex('#333333'), fontSize: 14, fontWeight: FontWeight.bold)), + Text('自购订单收益', style: TextStyle(color: HexColor.fromHex(styleModel?.title_value_color ?? '#333333'), fontSize: 14, fontWeight: FontWeight.bold)), const SizedBox(height: 5), /// 内容 - _buildCustomerTradeContentWidget(), + _buildCustomerTradeContentWidget(styleModel), ], ), ) @@ -213,19 +331,21 @@ class __MessageNoticePageContainerState extends State<_MessageNoticePageContaine ), /// 时间 - Padding(padding: const EdgeInsets.only(top: 16), child: Text('2020-06-23 01:00:06', style: TextStyle(color: HexColor.fromHex('#D8D8D8'), fontSize: 11))) + Padding( + padding: const EdgeInsets.only(top: 16), + child: Text('2020-06-23 01:00:06', style: TextStyle(color: HexColor.fromHex(styleModel?.time_color ?? '#D8D8D8'), fontSize: 11))) ], ), ); } /// 推广通知样式 - Widget _buildPromoteNoticeStyleWidget() { + Widget _buildPromoteNoticeStyleWidget(PromotionNotificationStyle styleModel) { return Container( padding: const EdgeInsets.only(left: 15, right: 15, top: 12.5, bottom: 10), margin: const EdgeInsets.only(bottom: 7.5), decoration: BoxDecoration( - color: HexColor.fromHex('#FFFFFF'), + color: HexColor.fromHex(styleModel?.bg_color ?? '#FFFFFF'), borderRadius: BorderRadius.circular(7.5), ), child: Column( @@ -234,19 +354,26 @@ class __MessageNoticePageContainerState extends State<_MessageNoticePageContaine Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ - _buildCustomerAvatarWidget(), + _buildCustomerAvatarWidget(icon: styleModel?.icon), const SizedBox(width: 10), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ /// 标题 - Text('新增直推粉丝', style: TextStyle(color: HexColor.fromHex('#333333'), fontSize: 14, fontWeight: FontWeight.bold)), + Text( + '新增直推粉丝', + style: TextStyle(color: HexColor.fromHex(styleModel?.title_value_color ?? '#333333'), fontSize: 14, fontWeight: FontWeight.bold), + ), const SizedBox(height: 5), /// 内容 - Text('恭喜您成功邀请152****5887加入您的团队,快带领小伙伴走向致富之路吧!', - maxLines: 3, overflow: TextOverflow.ellipsis, style: TextStyle(color: HexColor.fromHex('#999999'), fontSize: 11)) + Text( + '恭喜您成功邀请152****5887加入您的团队,快带领小伙伴走向致富之路吧!', + maxLines: 3, + overflow: TextOverflow.ellipsis, + style: TextStyle(color: HexColor.fromHex(styleModel?.message_value_color ?? '#999999'), fontSize: 11), + ) ], ), ) @@ -254,19 +381,21 @@ class __MessageNoticePageContainerState extends State<_MessageNoticePageContaine ), /// 时间 - Padding(padding: const EdgeInsets.only(top: 16), child: Text('2020-06-23 01:00:06', style: TextStyle(color: HexColor.fromHex('#D8D8D8'), fontSize: 11))) + Padding( + padding: const EdgeInsets.only(top: 16), + child: Text('2020-06-23 01:00:06', style: TextStyle(color: HexColor.fromHex(styleModel?.time_color ?? '#D8D8D8'), fontSize: 11))) ], ), ); } /// 反馈通知样式 - Widget _buildFeedbackNoticeStyleWidget() { + Widget _buildFeedbackNoticeStyleWidget(FeedbackNotificationStyle styleModel) { return Container( padding: const EdgeInsets.only(left: 15, right: 15, top: 14, bottom: 10), margin: const EdgeInsets.only(bottom: 7.5), decoration: BoxDecoration( - color: HexColor.fromHex('#FFFFFF'), + color: HexColor.fromHex(styleModel?.bg_color ?? '#FFFFFF'), borderRadius: BorderRadius.circular(7.5), ), child: Column( @@ -275,18 +404,18 @@ class __MessageNoticePageContainerState extends State<_MessageNoticePageContaine Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ - _buildCustomerAvatarWidget(), + _buildCustomerAvatarWidget(icon: styleModel?.icon), const SizedBox(width: 10), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ /// 标题 - Text('您的反馈有回复啦', style: TextStyle(color: HexColor.fromHex('#333333'), fontSize: 14, fontWeight: FontWeight.bold)), + Text('您的反馈有回复啦', style: TextStyle(color: HexColor.fromHex(styleModel?.title_value_color ?? '#333333'), fontSize: 14, fontWeight: FontWeight.bold)), const SizedBox(height: 3), + /// 内容 - Text('点击查看回复详情', - maxLines: 1, overflow: TextOverflow.ellipsis, style: TextStyle(color: HexColor.fromHex('#999999'), fontSize: 11)) + Text('点击查看回复详情', maxLines: 1, overflow: TextOverflow.ellipsis, style: TextStyle(color: HexColor.fromHex(styleModel?.message_value_color ?? '#999999'), fontSize: 11)) ], ), ) @@ -294,7 +423,7 @@ class __MessageNoticePageContainerState extends State<_MessageNoticePageContaine ), /// 时间 - Padding(padding: const EdgeInsets.only(top: 16), child: Text('2020-06-23 01:00:06', style: TextStyle(color: HexColor.fromHex('#D8D8D8'), fontSize: 11))) + Padding(padding: const EdgeInsets.only(top: 16), child: Text(styleModel?.time_color ?? '2020-06-23 01:00:06', style: TextStyle(color: HexColor.fromHex('#D8D8D8'), fontSize: 11))) ], ), ); @@ -322,7 +451,7 @@ class __MessageNoticePageContainerState extends State<_MessageNoticePageContaine } /// ================================= 自定义View ================================= /// - Widget _buildCustomerAvatarWidget() { + Widget _buildCustomerAvatarWidget({@required String icon, String value}) { return Container( // width: 30, // height: 30, @@ -334,21 +463,26 @@ class __MessageNoticePageContainerState extends State<_MessageNoticePageContaine Container( height: 30, width: 30, - color: Colors.deepPurpleAccent, + child: CachedNetworkImage( + imageUrl: icon ?? '', + ), ), - Transform.translate( - offset: Offset(5, -4.5), - child: Container( - // width: 17, - height: 12, - padding: const EdgeInsets.only(left: 3, right: 3, top: 1, bottom: 1), - alignment: Alignment.center, - decoration: - BoxDecoration(color: HexColor.fromHex('#FF4242'), borderRadius: BorderRadius.circular(6), border: Border.all(color: HexColor.fromHex('#FFFFFF'), width: 0.5)), - child: Text( - '18', - textAlign: TextAlign.center, - style: TextStyle(fontSize: 9, color: HexColor.fromHex('#FFFFFF')), + Visibility( + visible: !EmptyUtil.isEmpty(value), + child: Transform.translate( + offset: Offset(5, -4.5), + child: Container( + // width: 17, + height: 12, + padding: const EdgeInsets.only(left: 3, right: 3, top: 1, bottom: 1), + alignment: Alignment.center, + decoration: + BoxDecoration(color: HexColor.fromHex('#FF4242'), borderRadius: BorderRadius.circular(6), border: Border.all(color: HexColor.fromHex('#FFFFFF'), width: 0.5)), + child: Text( + '18', + textAlign: TextAlign.center, + style: TextStyle(fontSize: 9, color: HexColor.fromHex('#FFFFFF')), + ), ), ), ) @@ -357,26 +491,24 @@ class __MessageNoticePageContainerState extends State<_MessageNoticePageContaine ); } - Widget _buildCustomerTradeContentWidget(){ - Map datas= { - '订单编号:':'154547896541651464788', - '订单类型:':'京东', + Widget _buildCustomerTradeContentWidget(TransactionNotificationStyle styleModel) { + Map datas = { + '订单编号:': '154547896541651464788', + '订单类型:': '京东', '预估收益:': '8.00', - '下单时间:':'2020-08-14 11:35:39', - '预估结算:':'次月25日结算', + '下单时间:': '2020-08-14 11:35:39', + '预估结算:': '次月25日结算', }; List lists = []; - datas.forEach((key, value) { + datas.forEach((key, value) { lists.add(Padding( padding: const EdgeInsets.only(bottom: 5), child: RichText( textAlign: TextAlign.start, - text: TextSpan( - children: [ - TextSpan(text: key, style: TextStyle(fontSize: 11, color: HexColor.fromHex('#999999'))), - TextSpan(text: value, style: TextStyle(fontSize: 11, color: HexColor.fromHex('#999999'))), - ] - ), + text: TextSpan(children: [ + TextSpan(text: key, style: TextStyle(fontSize: 11, color: HexColor.fromHex('#999999'))), + TextSpan(text: value, style: TextStyle(fontSize: 11, color: HexColor.fromHex('#999999'))), + ]), ), )); }); diff --git a/lib/pages/message_notice_page/model/message_notice_style_model.dart b/lib/pages/message_notice_page/model/message_notice_style_model.dart new file mode 100644 index 0000000..28456da --- /dev/null +++ b/lib/pages/message_notice_page/model/message_notice_style_model.dart @@ -0,0 +1,311 @@ +class MessageNoticeStyleModel { + String app_bar_bg_color; + String app_bar_bg_img; + String app_bar_name; + String app_bar_name_color; + List main_notification; + FeedbackNotificationStyle feedback_notification; + OfficialActivityStyle official_activity; + OfficialNotificationStyle official_notification; + PromotionNotificationStyle promotion_notification; + TransactionNotificationStyle transaction_notification; + + MessageNoticeStyleModel({ + this.app_bar_bg_color, + this.app_bar_bg_img, + this.app_bar_name, + this.app_bar_name_color, + this.feedback_notification, + this.main_notification, + this.official_activity, + this.official_notification, + this.promotion_notification, + this.transaction_notification, + }); + + factory MessageNoticeStyleModel.fromJson(Map json) { + return MessageNoticeStyleModel( + app_bar_bg_color: json['app_bar_bg_color'], + app_bar_bg_img: json['app_bar_bg_img'], + app_bar_name: json['app_bar_name'], + app_bar_name_color: json['app_bar_name_color'], + feedback_notification: json['feedback_notification'] != null ? FeedbackNotificationStyle.fromJson(json['feedback_notification']) : null, + main_notification: json['main'] != null ? (json['main'] as List).map((i) => MainNotificationStyle.fromJson(i)).toList() : null, + official_activity: json['official_activity'] != null ? OfficialActivityStyle.fromJson(json['official_activity']) : null, + official_notification: json['official_notification'] != null ? OfficialNotificationStyle.fromJson(json['official_notification']) : null, + promotion_notification: json['promotion_notification'] != null ? PromotionNotificationStyle.fromJson(json['promotion_notification']) : null, + transaction_notification: json['transaction_notification'] != null ? TransactionNotificationStyle.fromJson(json['transaction_notification']) : null, + ); + } + + Map toJson() { + final Map data = new Map(); + data['app_bar_bg_color'] = this.app_bar_bg_color; + data['app_bar_bg_img'] = this.app_bar_bg_img; + data['app_bar_name'] = this.app_bar_name; + data['app_bar_name_color'] = this.app_bar_name_color; + if (this.feedback_notification != null) { + data['feedback_notification'] = this.feedback_notification.toJson(); + } + if (this.main_notification != null) { + data['main'] = this.main_notification.map((v) => v.toJson()).toList(); + } + if (this.official_activity != null) { + data['official_activity'] = this.official_activity.toJson(); + } + if (this.official_notification != null) { + data['official_notification'] = this.official_notification.toJson(); + } + if (this.promotion_notification != null) { + data['promotion_notification'] = this.promotion_notification.toJson(); + } + if (this.transaction_notification != null) { + data['transaction_notification'] = this.transaction_notification.toJson(); + } + return data; + } +} + +class FeedbackNotificationStyle { + String bg_color; + String icon; + String message_value_color; + String skip_identifier; + String time_color; + String title_value_color; + + FeedbackNotificationStyle({ + this.bg_color, + this.icon, + this.message_value_color, + this.skip_identifier, + this.time_color, + this.title_value_color, + }); + + factory FeedbackNotificationStyle.fromJson(Map json) { + return FeedbackNotificationStyle( + bg_color: json['bg_color'], + icon: json['icon'], + message_value_color: json['message_value_color'], + skip_identifier: json['skip_identifier'], + time_color: json['time_color'], + title_value_color: json['title_value_color'], + ); + } + + Map toJson() { + final Map data = new Map(); + data['bg_color'] = this.bg_color; + data['icon'] = this.icon; + data['message_value_color'] = this.message_value_color; + data['skip_identifier'] = this.skip_identifier; + data['time_color'] = this.time_color; + data['title_value_color'] = this.title_value_color; + return data; + } +} + +class MainNotificationStyle { + String bg_color; + String icon; + String name; + String name_color; + String time_color; + String type; + String value_color; + + MainNotificationStyle({ + this.bg_color, + this.icon, + this.name, + this.name_color, + this.time_color, + this.type, + this.value_color, + }); + + factory MainNotificationStyle.fromJson(Map json) { + return MainNotificationStyle( + bg_color: json['bg_color'], + icon: json['icon'], + name: json['name'], + name_color: json['name_color'], + time_color: json['time_color'], + type: json['type'], + value_color: json['value_color'], + ); + } + + Map toJson() { + final Map data = new Map(); + data['bg_color'] = this.bg_color; + data['icon'] = this.icon; + data['name'] = this.name; + data['name_color'] = this.name_color; + data['time_color'] = this.time_color; + data['type'] = this.type; + data['value_color'] = this.value_color; + return data; + } +} + +class OfficialActivityStyle { + String bg_color; + String message_value_color; + String skip_identifier; + String time_color; + String title_value_color; + + OfficialActivityStyle({ + this.bg_color, + this.message_value_color, + this.skip_identifier, + this.time_color, + this.title_value_color, + }); + + factory OfficialActivityStyle.fromJson(Map json) { + return OfficialActivityStyle( + bg_color: json['bg_color'], + message_value_color: json['message_value_color'], + skip_identifier: json['skip_identifier'], + time_color: json['time_color'], + title_value_color: json['title_value_color'], + ); + } + + Map toJson() { + final Map data = new Map(); + data['bg_color'] = this.bg_color; + data['message_value_color'] = this.message_value_color; + data['skip_identifier'] = this.skip_identifier; + data['time_color'] = this.time_color; + data['title_value_color'] = this.title_value_color; + return data; + } +} + +class OfficialNotificationStyle { + String bg_color; + String icon; + String message_value_color; + String skip_identifier; + String time_color; + String title_value_color; + + OfficialNotificationStyle({ + this.bg_color, + this.icon, + this.message_value_color, + this.skip_identifier, + this.time_color, + this.title_value_color, + }); + + factory OfficialNotificationStyle.fromJson(Map json) { + return OfficialNotificationStyle( + bg_color: json['bg_color'], + icon: json['icon'], + message_value_color: json['message_value_color'], + skip_identifier: json['skip_identifier'], + time_color: json['time_color'], + title_value_color: json['title_value_color'], + ); + } + + Map toJson() { + final Map data = new Map(); + data['bg_color'] = this.bg_color; + data['icon'] = this.icon; + data['message_value_color'] = this.message_value_color; + data['skip_identifier'] = this.skip_identifier; + data['time_color'] = this.time_color; + data['title_value_color'] = this.title_value_color; + return data; + } +} + +class PromotionNotificationStyle { + String bg_color; + String icon; + String message_value_color; + String skip_identifier; + String time_color; + String title_value_color; + + PromotionNotificationStyle({ + this.bg_color, + this.icon, + this.message_value_color, + this.skip_identifier, + this.time_color, + this.title_value_color, + }); + + factory PromotionNotificationStyle.fromJson(Map json) { + return PromotionNotificationStyle( + bg_color: json['bg_color'], + icon: json['icon'], + message_value_color: json['message_value_color'], + skip_identifier: json['skip_identifier'], + time_color: json['time_color'], + title_value_color: json['title_value_color'], + ); + } + + Map toJson() { + final Map data = new Map(); + data['bg_color'] = this.bg_color; + data['icon'] = this.icon; + data['message_value_color'] = this.message_value_color; + data['skip_identifier'] = this.skip_identifier; + data['time_color'] = this.time_color; + data['title_value_color'] = this.title_value_color; + return data; + } +} + +class TransactionNotificationStyle { + String bg_color; + String earnings; + String icon; + String message_value_color; + String skip_identifier; + String time_color; + String title_value_color; + + TransactionNotificationStyle({ + this.bg_color, + this.earnings, + this.icon, + this.message_value_color, + this.skip_identifier, + this.time_color, + this.title_value_color, + }); + + factory TransactionNotificationStyle.fromJson(Map json) { + return TransactionNotificationStyle( + bg_color: json['bg_color'], + earnings: json['earnings'], + icon: json['icon'], + message_value_color: json['message_value_color'], + skip_identifier: json['skip_identifier'], + time_color: json['time_color'], + title_value_color: json['title_value_color'], + ); + } + + Map toJson() { + final Map data = new Map(); + data['bg_color'] = this.bg_color; + data['earnings'] = this.earnings; + data['icon'] = this.icon; + data['message_value_color'] = this.message_value_color; + data['skip_identifier'] = this.skip_identifier; + data['time_color'] = this.time_color; + data['title_value_color'] = this.title_value_color; + return data; + } +} diff --git a/lib/pages/search_result_page/item/search_result_item_page.dart b/lib/pages/search_result_page/item/search_result_item_page.dart index dd90987..915282d 100644 --- a/lib/pages/search_result_page/item/search_result_item_page.dart +++ b/lib/pages/search_result_page/item/search_result_item_page.dart @@ -124,9 +124,9 @@ class _SearchResultItemPageContianerState extends State> datas) { - return Scaffold( - backgroundColor: HexColor.fromHex('#F9F9F9'), - body: Listener( + return Container( + color: HexColor.fromHex('#F9F9F9'), + child: Listener( onPointerDown: (down) => RouterUtil.hideKeyboard(context), child: Stack( children: [ diff --git a/lib/widgets/search_result/goods_list/search_result_goods_list_widget.dart b/lib/widgets/search_result/goods_list/search_result_goods_list_widget.dart index 4a40efa..7714334 100644 --- a/lib/widgets/search_result/goods_list/search_result_goods_list_widget.dart +++ b/lib/widgets/search_result/goods_list/search_result_goods_list_widget.dart @@ -107,10 +107,14 @@ class _SearchResultGoodsListWidgetContainerState extends State { /// 联想列表 Widget _getThinkListWidget(List model){ - return Container( - height: double.infinity, - color: Colors.white, - child: ListView.builder(itemBuilder: (context, index){ - SearchThinkModel item = model[index]; - return GestureDetector( - onTap: ()=> _onThinkItemClick(item), - child: Container( - decoration: BoxDecoration( - border: Border(bottom: BorderSide(width: 0.5, color: HexColor.fromHex('#EEEEEE'))) + return Listener( + onPointerDown: (down)=> RouterUtil.hideKeyboard(context), + child: Container( + height: double.infinity, + color: Colors.white, + child: ListView.builder(itemBuilder: (context, index){ + SearchThinkModel item = model[index]; + return GestureDetector( + onTap: ()=> _onThinkItemClick(item), + child: Container( + decoration: BoxDecoration( + border: Border(bottom: BorderSide(width: 0.5, color: HexColor.fromHex('#EEEEEE'))) + ), + padding: const EdgeInsets.only(top: 13, bottom: 13), + child: Text('${item?.keywords}', style: TextStyle( color: HexColor.fromHex('#333333'), fontSize: 14),), ), - padding: const EdgeInsets.only(top: 13, bottom: 13), - child: Text('${item?.keywords}', style: TextStyle( color: HexColor.fromHex('#333333'), fontSize: 14),), - ), - ); - }, - itemCount: model?.length ?? 0, - padding: const EdgeInsets.only(left: 12.5, right: 12.5), - shrinkWrap: true, + ); + }, + itemCount: model?.length ?? 0, + padding: const EdgeInsets.only(left: 12.5, right: 12.5), + shrinkWrap: true, + ), ), ); }