From 1d53b9ebad3a6199c2b7dff480cf07f94ee3882b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E5=8D=8E=E8=BD=A9?= <646903573@qq.com> Date: Mon, 2 Nov 2020 18:09:52 +0800 Subject: [PATCH] =?UTF-8?q?1.=E6=B7=BB=E5=8A=A0=E9=92=B1=E5=8C=85=E6=98=8E?= =?UTF-8?q?=E7=BB=86=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bil_detail_page/bil_detail_page.dart | 212 +--- .../bil_detail_page/bil_detail_page_bloc.dart | 5 +- lib/pages/home_page/home_page.dart | 1 + lib/register.dart | 14 +- .../home_slide_banner/home_slide_banner.dart | 1 - lib/widgets/wallet/wallet_bil/wallet_bil.dart | 9 +- .../model/wallet_style_model.dart | 287 ++++++ .../wallet_bil_detail/wallet_bil_detail.dart | 918 ++++++++++++++++++ .../wallet_bil_detail_widget_bloc.dart | 163 ++++ .../wallet_bil_detail/wallet_list_widget.dart | 606 ++++++++++++ 10 files changed, 2020 insertions(+), 196 deletions(-) create mode 100644 lib/widgets/wallet_bil_detail/model/wallet_style_model.dart create mode 100644 lib/widgets/wallet_bil_detail/wallet_bil_detail.dart create mode 100644 lib/widgets/wallet_bil_detail/wallet_bil_detail_widget_bloc.dart create mode 100644 lib/widgets/wallet_bil_detail/wallet_list_widget.dart diff --git a/lib/pages/bil_detail_page/bil_detail_page.dart b/lib/pages/bil_detail_page/bil_detail_page.dart index e7fb191..4da82d7 100644 --- a/lib/pages/bil_detail_page/bil_detail_page.dart +++ b/lib/pages/bil_detail_page/bil_detail_page.dart @@ -16,6 +16,7 @@ import 'package:zhiying_comm/util/custom_sliver_persistent_header_delegate.dart' import 'package:zhiying_comm/zhiying_comm.dart'; import 'package:flutter_alibc/flutter_alibc.dart'; +///钱包明细 class BilDetailPage extends StatefulWidget { final Map data; @@ -61,206 +62,45 @@ class _BilDetailPageContainerState extends State { @override void initState() { _bloc = BlocProvider.of(context); + _bloc.loadData(widget.data[Constants.SkipIdentifierName]); showDate = DateFormat('yyyy-MM').format(DateTime.now()); super.initState(); } @override Widget build(BuildContext context) { - return StreamBuilder( + stream: _bloc.outData, builder: (context, sny) { + if (sny.data == null) { + return Container(); + } + var model = sny.data; return Scaffold( - appBar: AppBar( - centerTitle: true, - title: Text("明细"), - ), body: Container( - child: ListView( - shrinkWrap: true, - children: [_buildType(), _buildBottomItem()], - ), - ), + child: Column( + children: _buildItem(model), + )), ); }, ); } - _buildType() { - return Row( - children: [ - SizedBox(width: 12.5), - InkWell( - onTap: () { - ///显示日期选择弹窗 - _selectDate(); - }, - child: Padding( - padding: const EdgeInsets.only(top: 8, bottom: 8), - child: Text(showDate ?? ""), - ), - ), - Icon(Icons.arrow_drop_down), - Expanded( - child: Container( - height: 50, - child: ListView.builder( - scrollDirection: Axis.horizontal, - shrinkWrap: true, - itemCount: 3, - itemBuilder: (context, index) { - return InkWell(child: Container( - margin: - EdgeInsets.only(top: 10, left: 8, right: 8, bottom: 10), - decoration: BoxDecoration( - color: Colors.grey[200], - borderRadius: BorderRadius.circular(50)), - child: Padding( - padding: const EdgeInsets.only(left: 16, right: 16), - child: Center( - child: Text( - "推广", - style: TextStyle(color: Colors.grey), - )), - ), - ),onTap: () async { - print("ok"); - await FlutterAlibc.loginTaoBao(); - },); - }), - )) - ], - ); - } - - void _selectDate() async { - showDialog(context: context, builder: (context) => SelectDateYMDialog()); - } - - _buildBottomItem() { - return ListView.builder( - shrinkWrap: true, itemCount: 10, itemBuilder: _buildItem); - } - - Widget _buildItem(BuildContext context, int index) { - return Container( - margin: EdgeInsets.only(left: 12.5, right: 12.5, bottom: 4, top: 4), - padding: - EdgeInsets.only(left: 25.w, right: 25.w, top: 20.h, bottom: 20.h), - child: Column( - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Row( - children: [ - Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(4), - color: Colors.red[100], - border: Border.all(color: Colors.red)), - child: Padding( - padding: const EdgeInsets.only( - left: 4, right: 4, top: 2, bottom: 2), - child: Center( - child: Text( - "自购", - style: TextStyle(color: Colors.red, fontSize: 20.sp), - ), - ), - ), - ), - Container( - width: 443.w, - margin: EdgeInsets.only(left: 15.w), - child: Text( - "Segway Ninebot mini Pro智能代的卅饭店发生的范德萨地方撒发生", - maxLines: 1, - overflow: TextOverflow.ellipsis, - style: TextStyle(fontSize: 28.sp), - )) - ], - ), - Row( - children: [ - Text( - "+", - style: TextStyle(color: Colors.red), - ), - Text( - "¥8.00", - style: TextStyle(color: Colors.red, fontSize: 30.sp), - ) - ], - ) - ], - ), - SizedBox( - height: 4, - ), - Row( - children: [ - Text( - "订单编号:", - style: TextStyle( - color: HexColor.fromHex("#FF999999"), fontSize: 22.sp), - ), - Text( - "1233333333", - style: TextStyle( - color: HexColor.fromHex("#FF999999"), fontSize: 22.sp), - ), - SizedBox( - width: 28.w, - ), - Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(4), - color: HexColor.fromHex("#FFF5F5F5"), - border: Border.all(color: HexColor.fromHex("#FFD6D6D6"))), - child: Padding( - padding: - EdgeInsets.only(left: 16, right: 16, top: 1, bottom: 1), - child: Text( - "复制", - style: TextStyle( - color: HexColor.fromHex("#FF999999"), fontSize: 22.sp), - ), - ), - ) - ], - ), - Row( - children: [ - Text( - "订单编号:", - style: TextStyle( - color: HexColor.fromHex("#FF999999"), fontSize: 22.sp), - ), - Text( - "1233333333", - style: TextStyle( - color: HexColor.fromHex("#FF999999"), fontSize: 22.sp), - ), - ], - ), - Row( - children: [ - Text( - "订单编号:", - style: TextStyle( - color: HexColor.fromHex("#FF999999"), fontSize: 22.sp), - ), - Text( - "1233333333", - style: TextStyle( - color: HexColor.fromHex("#FF999999"), fontSize: 22.sp), - ), - - ], - ) - ], - ), - ); + ///构建子模块 + _buildItem(List> model) { + List list = List(); + for (var item in model) { + WidgetModel widgetModel = + WidgetModel.fromJson(Map.from(item)); + if (widgetModel.modName == 'my_wallet_detail') { + list.add(Expanded( + child: WidgetFactory.create(widgetModel.modName, + isSliver: false, model: item)[0])); + continue; + } + list.addAll(WidgetFactory.create(widgetModel.modName, + isSliver: false, model: item)); + } + return list; } } diff --git a/lib/pages/bil_detail_page/bil_detail_page_bloc.dart b/lib/pages/bil_detail_page/bil_detail_page_bloc.dart index 9623a0e..d856976 100644 --- a/lib/pages/bil_detail_page/bil_detail_page_bloc.dart +++ b/lib/pages/bil_detail_page/bil_detail_page_bloc.dart @@ -1,5 +1,6 @@ import 'dart:async'; +import 'package:zhiying_base_widget/widgets/wallet_bil_detail/model/wallet_style_model.dart'; import 'package:zhiying_comm/util/base_bloc.dart'; import 'package:zhiying_comm/zhiying_comm.dart'; @@ -11,7 +12,7 @@ class BilDetailPageBloc extends BlocBase { Stream>> get outData => _tabController.stream; - + BilDetailStyleModel bilDetailStyleModel; @override void dispose() { @@ -21,7 +22,7 @@ class BilDetailPageBloc extends BlocBase { loadData(String skipIdentifier) { - NetUtil.request('/api/v1/mod/${skipIdentifier}', method: NetMethod.GET, + NetUtil.request('/api/v1/mod/pub.flutter.my_wallet_detail', method: NetMethod.GET, onCache: (data) { _loadData(data); }, onSuccess: (data) { diff --git a/lib/pages/home_page/home_page.dart b/lib/pages/home_page/home_page.dart index d4355a0..7c1094d 100644 --- a/lib/pages/home_page/home_page.dart +++ b/lib/pages/home_page/home_page.dart @@ -72,6 +72,7 @@ class _HomePageState extends State { String selectedIcon = ImageUtil.getUrl(model.chooseIcon ?? model.icon); String textColor = model.fontColor; String chooseColor = model.chooseColor ?? textColor; + items.add(BottomNavigationBarItem( icon: Container( width: 24, diff --git a/lib/register.dart b/lib/register.dart index 49998c6..1bf7a20 100644 --- a/lib/register.dart +++ b/lib/register.dart @@ -1,6 +1,6 @@ import 'package:sharesdk_plugin/sharesdk_interface.dart'; import 'package:sharesdk_plugin/sharesdk_register.dart'; - +import 'package:zhiying_base_widget/pages/bil_detail_page/bil_detail_page.dart'; import 'package:zhiying_base_widget/pages/feedback_page/feedback_page.dart'; import 'package:zhiying_base_widget/pages/goods_details_page/goods_details_page.dart'; import 'package:zhiying_base_widget/pages/home_page/home_page.dart'; @@ -49,6 +49,7 @@ import 'package:zhiying_base_widget/widgets/wallet/wallet_bil/wallet_bil.dart'; import 'package:zhiying_base_widget/widgets/wallet/wallet_data/wallet_data.dart'; import 'package:zhiying_base_widget/widgets/wallet/wallet_detail/wallet_detail.dart'; import 'package:zhiying_base_widget/widgets/wallet/wallet_income/wallet_income.dart'; +import 'package:zhiying_base_widget/widgets/wallet_bil_detail/wallet_bil_detail.dart'; import 'package:zhiying_comm/util/defalut_widget_creater.dart'; import 'package:zhiying_comm/zhiying_comm.dart'; @@ -155,12 +156,18 @@ class BaseWidgetRegister { /// 消息中心 PageFactory.regist( 'pub.flutter.message_center', (model) => MessageNoticePage(model)); + PageFactory.regist( + 'pub.flutter.message_notice', (model) => MessageNoticePage(model)); /// TODO 首页的消息中心标识和我的页面不一致,需要改 PageFactory.regist( 'pub.flutter.message', (model) => MessageNoticePage(model)); /// 我的收藏 PageFactory.regist('pub.flutter.my_fav', (model) => FavoritesPage()); + + + ///钱包明细 + PageFactory.regist('pub.flutter.my_bil', (model) => BilDetailPage(model)); } // 注册控件 @@ -327,6 +334,11 @@ class BaseWidgetRegister { 'wallet_income', DefaultWidgetCreater((model) => WalletIncome())); //======================= 账单明细 + WidgetFactory.regist( + 'my_wallet_detail', + DefaultWidgetCreater((model) => WalletBilDetail( + data: model, + ))); //======================== 热榜 WidgetFactory.regist('hot_rank_appbar', diff --git a/lib/widgets/home/home_slide_banner/home_slide_banner.dart b/lib/widgets/home/home_slide_banner/home_slide_banner.dart index 570676a..132583c 100644 --- a/lib/widgets/home/home_slide_banner/home_slide_banner.dart +++ b/lib/widgets/home/home_slide_banner/home_slide_banner.dart @@ -7,7 +7,6 @@ import 'package:provider/provider.dart'; import 'package:zhiying_base_widget/pages/main_page/notifier/main_page_bg_notifier.dart'; import 'package:zhiying_base_widget/pages/message_notice_page/message_notice_page.dart'; import 'package:zhiying_base_widget/pages/team_details_page/team_details_page.dart'; -import 'package:zhiying_base_widget/pages/vip_center_page/vip_center_page.dart'; import 'package:zhiying_comm/zhiying_comm.dart'; import 'bloc/bloc.dart'; diff --git a/lib/widgets/wallet/wallet_bil/wallet_bil.dart b/lib/widgets/wallet/wallet_bil/wallet_bil.dart index 430343a..e6adecb 100644 --- a/lib/widgets/wallet/wallet_bil/wallet_bil.dart +++ b/lib/widgets/wallet/wallet_bil/wallet_bil.dart @@ -3,6 +3,7 @@ import 'dart:convert'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:zhiying_base_widget/pages/bil_detail_page/bil_detail_page.dart'; import 'package:zhiying_base_widget/pages/wallet_page/wallet_detail_page.dart'; import 'package:zhiying_base_widget/widgets/wallet/wallet_bil/model/wallet_bli_model.dart'; import 'package:zhiying_base_widget/widgets/wallet/wallet_income/wallet_income_sk.dart'; @@ -24,12 +25,8 @@ class WalletBil extends StatelessWidget { ? WalletIncomeSkeleton() : GestureDetector( onTap: () { - Navigator.push( - context, - CupertinoPageRoute( - builder: (context) => WalletDetailPage(), - ), - ); + RouterUtil.route( + SkipModel.fromJson(json.decode(data['data'])), data, context); }, child: Container( decoration: BoxDecoration( diff --git a/lib/widgets/wallet_bil_detail/model/wallet_style_model.dart b/lib/widgets/wallet_bil_detail/model/wallet_style_model.dart new file mode 100644 index 0000000..0dc80b2 --- /dev/null +++ b/lib/widgets/wallet_bil_detail/model/wallet_style_model.dart @@ -0,0 +1,287 @@ +class BilDetailStyleModel { + String appBarName; + String appBarNameColor; + String appBarBgImg; + String appBarBgColor; + String tabLineColor; + String tabNoSeletedColor; + String tabSeletedColor; + List tabList; + String timeSelectColor; + String btnNoSelectedColor; + String btnSelectedColor; + List inputTabViewBtns; + List outTabViewBtns; + InputItemStyle inputItemStyle; + OutputItemStyle outputItemStyle; + + BilDetailStyleModel( + {this.appBarName, + this.appBarNameColor, + this.appBarBgImg, + this.appBarBgColor, + this.tabLineColor, + this.tabNoSeletedColor, + this.tabSeletedColor, + this.tabList, + this.timeSelectColor, + this.btnNoSelectedColor, + this.btnSelectedColor, + this.inputTabViewBtns, + this.outTabViewBtns, + this.inputItemStyle, + this.outputItemStyle}); + + BilDetailStyleModel.fromJson(Map json) { + appBarName = json['app_bar_name']; + appBarNameColor = json['app_bar_name_color']; + appBarBgImg = json['app_bar_bg_img']; + appBarBgColor = json['app_bar_bg_color']; + tabLineColor = json['tab_line_color']; + tabNoSeletedColor = json['tab_no_seleted_color']; + tabSeletedColor = json['tab_seleted_color']; + if (json['tab_list'] != null) { + tabList = new List(); + json['tab_list'].forEach((v) { + tabList.add(new TabList.fromJson(v)); + }); + } + timeSelectColor = json['time_select_color']; + btnNoSelectedColor = json['btn_no_selected_color']; + btnSelectedColor = json['btn_selected_color']; + if (json['input_tab_view_btns'] != null) { + inputTabViewBtns = new List(); + json['input_tab_view_btns'].forEach((v) { + inputTabViewBtns.add(new InputTabViewBtns.fromJson(v)); + }); + } + if (json['out_tab_view_btns'] != null) { + outTabViewBtns = new List(); + json['out_tab_view_btns'].forEach((v) { + outTabViewBtns.add(new InputTabViewBtns.fromJson(v)); + }); + } + inputItemStyle = json['input_item_style'] != null + ? new InputItemStyle.fromJson(json['input_item_style']) + : null; + outputItemStyle = json['output_item_style'] != null + ? new OutputItemStyle.fromJson(json['output_item_style']) + : null; + } + + Map toJson() { + final Map data = new Map(); + data['app_bar_name'] = this.appBarName; + data['app_bar_name_color'] = this.appBarNameColor; + data['app_bar_bg_img'] = this.appBarBgImg; + data['app_bar_bg_color'] = this.appBarBgColor; + data['tab_line_color'] = this.tabLineColor; + data['tab_no_seleted_color'] = this.tabNoSeletedColor; + data['tab_seleted_color'] = this.tabSeletedColor; + if (this.tabList != null) { + data['tab_list'] = this.tabList.map((v) => v.toJson()).toList(); + } + data['time_select_color'] = this.timeSelectColor; + data['btn_no_selected_color'] = this.btnNoSelectedColor; + data['btn_selected_color'] = this.btnSelectedColor; + if (this.inputTabViewBtns != null) { + data['input_tab_view_btns'] = + this.inputTabViewBtns.map((v) => v.toJson()).toList(); + } + if (this.outTabViewBtns != null) { + data['out_tab_view_btns'] = + this.outTabViewBtns.map((v) => v.toJson()).toList(); + } + if (this.inputItemStyle != null) { + data['input_item_style'] = this.inputItemStyle.toJson(); + } + if (this.outputItemStyle != null) { + data['output_item_style'] = this.outputItemStyle.toJson(); + } + return data; + } +} + +class TabList { + String type; + String name; + + TabList({this.type, this.name}); + + TabList.fromJson(Map json) { + type = json['type']; + name = json['name']; + } + + Map toJson() { + final Map data = new Map(); + data['type'] = this.type; + data['name'] = this.name; + return data; + } +} + +class InputItemStyle { + String typeNameColor; + String titleColor; + String amountColor; + String contentColor; + String copyBtnText; + String copyBtnTextColor; + String copyBtnBgColor; + String orderIdText; + String orderTypeText; + String amountText; + String timeText; + String settleTimeText; + List keys; + + InputItemStyle( + {this.typeNameColor, + this.titleColor, + this.amountColor, + this.contentColor, + this.copyBtnText, + this.copyBtnTextColor, + this.copyBtnBgColor, + this.orderIdText, + this.orderTypeText, + this.amountText, + this.timeText, + this.settleTimeText, + this.keys}); + + InputItemStyle.fromJson(Map json) { + typeNameColor = json['type_name_color']; + titleColor = json['title_color']; + amountColor = json['amount_color']; + contentColor = json['content_color']; + copyBtnText = json['copy_btn_text']; + copyBtnTextColor = json['copy_btn_text_color']; + copyBtnBgColor = json['copy_btn_bg_color']; + orderIdText = json['order_id_text']; + orderTypeText = json['order_type_text']; + amountText = json['amount_text']; + timeText = json['time_text']; + settleTimeText = json['settle_time_text']; + keys = json['keys'].cast(); + } + + Map toJson() { + final Map data = new Map(); + data['type_name_color'] = this.typeNameColor; + data['title_color'] = this.titleColor; + data['amount_color'] = this.amountColor; + data['content_color'] = this.contentColor; + data['copy_btn_text'] = this.copyBtnText; + data['copy_btn_text_color'] = this.copyBtnTextColor; + data['copy_btn_bg_color'] = this.copyBtnBgColor; + data['order_id_text'] = this.orderIdText; + data['order_type_text'] = this.orderTypeText; + data['amount_text'] = this.amountText; + data['time_text'] = this.timeText; + data['settle_time_text'] = this.settleTimeText; + data['keys'] = this.keys; + return data; + } +} + +class OutputItemStyle { + String typeNameColor; + String titleColor; + String amountColor; + String contentColor; + String copyBtnTextColor; + String copyBtnText; + String copyBtnBgColor; + String orderIdText; + String withdrawAccountText; + String withdrawAmountText; + String withdrawTimeText; + String withdrawOrderStatusText; + String consumeOrderTypeText; + String consumeAmountText; + String consumeTimeText; + List withdrawKeys; + List consumeKeys; + + OutputItemStyle( + {this.typeNameColor, + this.titleColor, + this.amountColor, + this.contentColor, + this.copyBtnTextColor, + this.copyBtnBgColor, + this.orderIdText, + this.withdrawAccountText, + this.withdrawAmountText, + this.withdrawTimeText, + this.withdrawOrderStatusText, + this.consumeOrderTypeText, + this.consumeAmountText, + this.consumeTimeText, + this.withdrawKeys, + this.consumeKeys}); + + OutputItemStyle.fromJson(Map json) { + typeNameColor = json['type_name_color']; + titleColor = json['title_color']; + amountColor = json['amount_color']; + contentColor = json['content_color']; + copyBtnTextColor = json['copy_btn_text_color']; + copyBtnText=json['copy_btn_text']; + copyBtnBgColor = json['copy_btn_bg_color']; + orderIdText = json['order_id_text']; + withdrawAccountText = json['withdraw_account_text']; + withdrawAmountText = json['withdraw_amount_text']; + withdrawTimeText = json['withdraw_time_text']; + withdrawOrderStatusText = json['withdraw_order_status_text']; + consumeOrderTypeText = json['consume_order_type_text']; + consumeAmountText = json['consume_amount_text']; + consumeTimeText = json['consume_time_text']; + withdrawKeys = json['withdraw_keys'].cast(); + consumeKeys = json['consume_keys'].cast(); + } + + Map toJson() { + final Map data = new Map(); + data['type_name_color'] = this.typeNameColor; + data['title_color'] = this.titleColor; + data['amount_color'] = this.amountColor; + data['content_color'] = this.contentColor; + data['copy_btn_text_color'] = this.copyBtnTextColor; + data['copy_btn_bg_color'] = this.copyBtnBgColor; + data['order_id_text'] = this.orderIdText; + data['withdraw_account_text'] = this.withdrawAccountText; + data['withdraw_amount_text'] = this.withdrawAmountText; + data['withdraw_time_text'] = this.withdrawTimeText; + data['withdraw_order_status_text'] = this.withdrawOrderStatusText; + data['consume_order_type_text'] = this.consumeOrderTypeText; + data['consume_amount_text'] = this.consumeAmountText; + data['consume_time_text'] = this.consumeTimeText; + data['withdraw_keys'] = this.withdrawKeys; + data['consume_keys'] = this.consumeKeys; + return data; + } +} + +class InputTabViewBtns { + String type; + String name; + + + InputTabViewBtns( + {this.type,this.name}); + + InputTabViewBtns.fromJson(Map json) { + type=json['type']; + name=json['name']; + } + + Map toJson() { + final Map data = new Map(); + data['name']=name; + data['type']=type; + return data; + } +} \ No newline at end of file diff --git a/lib/widgets/wallet_bil_detail/wallet_bil_detail.dart b/lib/widgets/wallet_bil_detail/wallet_bil_detail.dart new file mode 100644 index 0000000..49babe7 --- /dev/null +++ b/lib/widgets/wallet_bil_detail/wallet_bil_detail.dart @@ -0,0 +1,918 @@ +import 'dart:convert'; + +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:intl/intl.dart'; +import 'package:pull_to_refresh/pull_to_refresh.dart'; +import 'package:zhiying_base_widget/dialog/select_date_ym_dialog/select_date_ym_dialog.dart'; +import 'package:zhiying_base_widget/widgets/wallet/wallet_detail/wallet_detail_bloc.dart'; +import 'package:zhiying_base_widget/widgets/wallet_bil_detail/wallet_bil_detail_widget_bloc.dart'; +import 'package:zhiying_comm/util/base_bloc.dart'; +import 'package:zhiying_comm/util/extension/color.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; + +import 'model/wallet_style_model.dart'; +import 'package:fluttertoast/fluttertoast.dart'; + +////钱包明细页面 +class WalletBilDetail extends StatefulWidget { + final Map data; + + const WalletBilDetail({Key key, this.data}) : super(key: key); + + @override + _WalletBilDetailState createState() => _WalletBilDetailState(); +} + +class _WalletBilDetailState extends State + with TickerProviderStateMixin, AutomaticKeepAliveClientMixin { + WalletBilDetailWidgetBloc _bloc; + + TabController _tabController; + + @override + void initState() { + _bloc = WalletBilDetailWidgetBloc(); + _bloc.initStyleData(json.decode(widget.data['data'])); + _tabController = + TabController(length: _bloc.styleData.tabList.length, vsync: this); + _bloc.loadInputData(_bloc.inPutCurrentPage, _bloc.inputShowDate); + _bloc.loadOutputData(_bloc.outPutCurrentPage, _bloc.outputShowDate); + + super.initState(); + } + + @override + Widget build(BuildContext context) { + return BlocProvider( + bloc: _bloc, + child: Container( + child: Column( + children: [ + AppBar( + brightness: Brightness.light, + backgroundColor: + HexColor.fromHex(_bloc.styleData.appBarBgColor), + centerTitle: true, + leading: IconButton( + icon: Icon( + Icons.arrow_back_ios, + size: 18, + color: HexColor.fromHex(_bloc.styleData.appBarNameColor), + ), + onPressed: () { + Navigator.pop(context); + }), + title: Text( + _bloc.styleData.appBarName ?? "", + style: TextStyle( + color: HexColor.fromHex(_bloc.styleData.appBarNameColor)), + ), + ), + Container( + color: Colors.white, + child: TabBar( + controller: _tabController, + tabs: _buildTabBarItem(), + indicatorWeight: 3, + labelStyle: TextStyle(fontSize: 30.sp), + labelColor: HexColor.fromHex(_bloc.styleData.tabSeletedColor), + unselectedLabelColor: + HexColor.fromHex(_bloc.styleData.tabNoSeletedColor), + indicatorColor: + HexColor.fromHex(_bloc.styleData.tabLineColor), + indicatorSize: TabBarIndicatorSize.label, + ), + ), + Expanded( + child: TabBarView( + controller: _tabController, + children: _buildTabViewPage())) + ], + ), + )); + } + + ///创建tabbar按键 + _buildTabBarItem() { + List listWidget = List(); + for (var item in _bloc.styleData.tabList) { + listWidget.add(Tab( + text: item.name ?? "", + )); + } + return listWidget; + } + + _buildType(List tabViewBtns, TabList tabList) { + var selectType; + if (tabList.type == 'input') { + selectType = _bloc.inputSelectType; + } else { + selectType = _bloc.outputSelectType; + ; + } + return Row( + children: [ + SizedBox(width: 12.5), + InkWell( + onTap: () { + ///显示日期选择弹窗 + _selectDate(tabList); + }, + child: Padding( + padding: const EdgeInsets.only(top: 8, bottom: 8), + child: Text( + tabList.type == "input" + ? _bloc.inputShowDate + : _bloc.outputShowDate, + style: TextStyle( + fontSize: 28.sp, + color: + HexColor.fromHex(_bloc.styleData.timeSelectColor)))), + ), + Icon( + Icons.arrow_drop_down, + color: HexColor.fromHex(_bloc.styleData.timeSelectColor), + ), + Expanded( + child: Container( + height: 50, + child: ListView.builder( + scrollDirection: Axis.horizontal, + shrinkWrap: true, + itemCount: tabViewBtns.length, + itemBuilder: (context, index) { + return InkWell( + onTap: () async { + if (tabList.type == 'input') { + _bloc.inputSelectType = tabViewBtns[index].type; + _bloc.inPutCurrentPage=1; + _bloc.loadInputData( + _bloc.inPutCurrentPage, _bloc.inputShowDate, + type: _bloc.inputSelectType); + } else { + _bloc.outputSelectType = tabViewBtns[index].type; + _bloc.outPutCurrentPage=1; + _bloc.loadOutputData( + _bloc.outPutCurrentPage, _bloc.outputShowDate, + type: _bloc.outputSelectType); + } + _bloc.refresh(); + }, + child: Container( + margin: EdgeInsets.only( + top: 10, left: 8, right: 8, bottom: 10), + decoration: BoxDecoration( + border: Border.all( + color: HexColor.fromHex( + selectType == tabViewBtns[index].type + ? _bloc.styleData.btnSelectedColor + : _bloc.styleData.btnNoSelectedColor), + ), + borderRadius: BorderRadius.circular(50)), + child: Padding( + padding: EdgeInsets.only(left: 16, right: 16), + child: Center( + child: Text( + tabViewBtns[index].name ?? "", + style: TextStyle( + color: HexColor.fromHex( + selectType == tabViewBtns[index].type + ? _bloc.styleData.btnSelectedColor + : _bloc.styleData.btnNoSelectedColor)), + )), + ), + )); + }), + )) + ], + ); + } + + _selectDate(TabList tabList) async { + var result = await showDialog( + context: context, builder: (context) => SelectDateYMDialog()); + if (result != null) { + var dataTime = DateFormat('yyyy-MM').format( + DateTime(int.parse(result['year']), int.parse(result['month']))); + if (tabList.type == "input") { + _bloc.inputShowDate = dataTime; + _bloc.loadInputData(_bloc.inPutCurrentPage, _bloc.inputShowDate); + } else { + _bloc.outputShowDate = dataTime; + _bloc.loadOutputData(_bloc.outPutCurrentPage, _bloc.outputShowDate); + } + _bloc.refresh(); + } + } + + _buildBottomItem(TabList tabList) { + return ListView.builder( + shrinkWrap: true, + itemCount: tabList.type == 'input' + ? _bloc.inputDataVM.length + : _bloc.outputDataVM.length, + itemBuilder: (context, index) { + return _buildItem(context, index, tabList); + }); + } + + Widget _buildItem(BuildContext context, int index, TabList tabList) { + if (tabList.type == 'input') { + InputItemStyle inputItemStyle = _bloc.styleData.inputItemStyle; + var modelItem = _bloc.inputDataVM[index]; + return Container( + margin: EdgeInsets.only(left: 12.5, right: 12.5, bottom: 4, top: 4), + padding: + EdgeInsets.only(left: 25.w, right: 25.w, top: 20.h, bottom: 20.h), + decoration: BoxDecoration( + color: HexColor.fromHex("#FFFFFF"), + borderRadius: BorderRadius.circular(8)), + child: Column( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + children: [ + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(4), + color: HexColor.fromHex("#FFFFF3F3"), + border: Border.all( + color: HexColor.fromHex( + inputItemStyle.typeNameColor))), + child: Padding( + padding: const EdgeInsets.only( + left: 4, right: 4, top: 2, bottom: 2), + child: Center( + child: Text( + modelItem['type'] ?? "", + style: TextStyle( + color: HexColor.fromHex( + inputItemStyle.typeNameColor), + fontSize: 20.sp), + ), + ), + ), + ), + Container( + width: 353.w, + margin: EdgeInsets.only(left: 15.w), + child: Text( + modelItem['title'] ?? "", + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: TextStyle(fontSize: 28.sp), + )) + ], + ), + Row( + children: [ + Text( + "+ ", + style: TextStyle( + color: HexColor.fromHex(inputItemStyle.amountColor)), + ), + Text( + "¥ " + modelItem['amount'], + style: TextStyle( + color: HexColor.fromHex(inputItemStyle.amountColor), + fontSize: 30.sp), + ) + ], + ) + ], + ), + SizedBox( + height: 4, + ), + + ///订单编号 + Row( + children: [ + Text( + inputItemStyle.orderIdText, + style: TextStyle( + color: HexColor.fromHex(inputItemStyle.contentColor), + fontSize: 22.sp), + ), + SizedBox( + width: 4, + ), + Text( + modelItem['order_id'], + style: TextStyle( + color: HexColor.fromHex(inputItemStyle.contentColor), + fontSize: 22.sp), + ), + SizedBox( + width: 28.w, + ), + GestureDetector( + onTap: () { + Clipboard.setData( + ClipboardData(text: modelItem['order_id'])); + Fluttertoast.showToast(msg: "已复制"); + }, + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(4), + color: HexColor.fromHex(inputItemStyle.copyBtnBgColor), + border: Border.all( + color: + HexColor.fromHex(inputItemStyle.contentColor))), + child: Padding( + padding: EdgeInsets.only( + left: 16, right: 16, top: 1, bottom: 1), + child: Text( + inputItemStyle.copyBtnText, + style: TextStyle( + color: + HexColor.fromHex(inputItemStyle.contentColor), + fontSize: 22.sp), + ), + ), + ), + ) + ], + ), + SizedBox( + height: 4, + ), + Row( + children: [ + Expanded( + child: Row( + children: [ + Text( + inputItemStyle.orderTypeText, + style: TextStyle( + color: HexColor.fromHex(inputItemStyle.contentColor), + fontSize: 22.sp), + ), + SizedBox( + width: 4, + ), + Text( + modelItem['order_type'] ?? "", + style: TextStyle( + color: HexColor.fromHex("#FF999999"), + fontSize: 22.sp), + ), + ], + )), + Expanded( + child: Row( + children: [ + Text( + inputItemStyle.amountText + " ¥" + modelItem['amount'], + style: TextStyle( + color: HexColor.fromHex(inputItemStyle.contentColor), + fontSize: 22.sp), + ), + ], + )) + ], + ), + SizedBox( + height: 4, + ), + Row( + children: [ + Expanded( + child: Row( + children: [ + Text( + inputItemStyle.timeText, + style: TextStyle( + color: HexColor.fromHex(inputItemStyle.contentColor), + fontSize: 22.sp), + ), + SizedBox( + width: 4, + ), + Text( + modelItem['time'] ?? "", + style: TextStyle( + color: HexColor.fromHex("#FF999999"), + fontSize: 22.sp), + ), + ], + )), + Expanded( + child: Row( + children: [ + Text( + inputItemStyle.settleTimeText + + " " + + modelItem['settle_time'] ?? + "", + style: TextStyle( + color: HexColor.fromHex(inputItemStyle.contentColor), + fontSize: 22.sp), + ), + ], + )) + ], + ), + ], + ), + ); + } else if (tabList.type == 'output') { + OutputItemStyle outputItemStyle = _bloc.styleData.outputItemStyle; + var modelItem = _bloc.outputDataVM[index]; + if (modelItem['type'] == '消费') { + ///消费返回的Item + return Container( + margin: EdgeInsets.only(left: 12.5, right: 12.5, bottom: 4, top: 4), + padding: + EdgeInsets.only(left: 25.w, right: 25.w, top: 20.h, bottom: 20.h), + decoration: BoxDecoration( + color: HexColor.fromHex("#FFFFFF"), + borderRadius: BorderRadius.circular(8)), + child: Column( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + children: [ + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(4), + color: HexColor.fromHex("#FFFFF3F3"), + border: Border.all( + color: HexColor.fromHex( + outputItemStyle.typeNameColor))), + child: Padding( + padding: const EdgeInsets.only( + left: 4, right: 4, top: 2, bottom: 2), + child: Center( + child: Text( + modelItem['type'] ?? "", + style: TextStyle( + color: HexColor.fromHex( + outputItemStyle.typeNameColor), + fontSize: 20.sp), + ), + ), + ), + ), + Container( + width: 353.w, + margin: EdgeInsets.only(left: 15.w), + child: Text( + modelItem['title'] ?? "", + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: TextStyle(fontSize: 28.sp), + )) + ], + ), + Row( + children: [ + Text( + "- ", + style: TextStyle( + color: + HexColor.fromHex(outputItemStyle.amountColor)), + ), + Text( + "¥ " + modelItem['amount'], + style: TextStyle( + color: + HexColor.fromHex(outputItemStyle.amountColor), + fontSize: 30.sp), + ) + ], + ) + ], + ), + SizedBox( + height: 4, + ), + + ///订单编号 + Row( + children: [ + Text( + outputItemStyle.orderIdText, + style: TextStyle( + color: HexColor.fromHex(outputItemStyle.contentColor), + fontSize: 22.sp), + ), + SizedBox( + width: 4, + ), + Text( + modelItem['order_id'], + style: TextStyle( + color: HexColor.fromHex(outputItemStyle.contentColor), + fontSize: 22.sp), + ), + SizedBox( + width: 28.w, + ), + GestureDetector( + onTap: () { + Clipboard.setData( + ClipboardData(text: modelItem['order_id'])); + Fluttertoast.showToast(msg: "已复制"); + }, + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(4), + color: HexColor.fromHex(outputItemStyle.copyBtnBgColor), + border: Border.all( + color: HexColor.fromHex( + outputItemStyle.contentColor))), + child: Padding( + padding: EdgeInsets.only( + left: 16, right: 16, top: 1, bottom: 1), + child: Text( + outputItemStyle.copyBtnText ?? "", + style: TextStyle( + color: + HexColor.fromHex(outputItemStyle.contentColor), + fontSize: 22.sp), + ), + ), + ), + ) + ], + ), + SizedBox( + height: 4, + ), + Row( + children: [ + Expanded( + child: Row( + children: [ + Text( + outputItemStyle.consumeOrderTypeText, + style: TextStyle( + color: + HexColor.fromHex(outputItemStyle.contentColor), + fontSize: 22.sp), + ), + SizedBox( + width: 4, + ), + Text( + modelItem['order_type'] ?? "", + style: TextStyle( + color: HexColor.fromHex("#FF999999"), + fontSize: 22.sp), + ), + ], + )), + Expanded( + child: Row( + children: [ + Text( + outputItemStyle.consumeAmountText + + " ¥" + + modelItem['amount'], + style: TextStyle( + color: + HexColor.fromHex(outputItemStyle.contentColor), + fontSize: 22.sp), + ), + ], + )) + ], + ), + SizedBox( + height: 4, + ), + Row( + children: [ + Expanded( + child: Row( + children: [ + Text( + outputItemStyle.consumeTimeText, + style: TextStyle( + color: + HexColor.fromHex(outputItemStyle.contentColor), + fontSize: 22.sp), + ), + SizedBox( + width: 4, + ), + Text( + modelItem['time'] ?? "", + style: TextStyle( + color: HexColor.fromHex("#FF999999"), + fontSize: 22.sp), + ), + ], + )), + // Expanded( + // child: Row( + // children: [ + // Text( + // inputItemStyle.consumeTimeText + + // " " + + // modelItem['settle_time'] ?? + // "", + // style: TextStyle( + // color: HexColor.fromHex(inputItemStyle.contentColor), + // fontSize: 22.sp), + // ), + // ], + // )) + ], + ), + ], + ), + ); + } else if (modelItem['type'] == '提现') { + return Container( + margin: EdgeInsets.only(left: 12.5, right: 12.5, bottom: 4, top: 4), + padding: + EdgeInsets.only(left: 25.w, right: 25.w, top: 20.h, bottom: 20.h), + decoration: BoxDecoration( + color: HexColor.fromHex("#FFFFFF"), + borderRadius: BorderRadius.circular(8)), + child: Column( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + children: [ + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(4), + color: HexColor.fromHex("#FFFFF3F3"), + border: Border.all( + color: HexColor.fromHex( + outputItemStyle.typeNameColor))), + child: Padding( + padding: const EdgeInsets.only( + left: 4, right: 4, top: 2, bottom: 2), + child: Center( + child: Text( + modelItem['type'] ?? "", + style: TextStyle( + color: HexColor.fromHex( + outputItemStyle.typeNameColor), + fontSize: 20.sp), + ), + ), + ), + ), + Container( + width: 353.w, + margin: EdgeInsets.only(left: 15.w), + child: Text( + modelItem['title'] ?? "", + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: TextStyle(fontSize: 28.sp), + )) + ], + ), + Row( + children: [ + Text( + "- ", + style: TextStyle( + color: + HexColor.fromHex(outputItemStyle.amountColor)), + ), + Text( + "¥ " + modelItem['amount'], + style: TextStyle( + color: + HexColor.fromHex(outputItemStyle.amountColor), + fontSize: 30.sp), + ) + ], + ) + ], + ), + SizedBox( + height: 4, + ), + + ///订单编号 + Row( + children: [ + Text( + outputItemStyle.orderIdText, + style: TextStyle( + color: HexColor.fromHex(outputItemStyle.contentColor), + fontSize: 22.sp), + ), + SizedBox( + width: 4, + ), + Text( + modelItem['order_id'], + style: TextStyle( + color: HexColor.fromHex(outputItemStyle.contentColor), + fontSize: 22.sp), + ), + SizedBox( + width: 28.w, + ), + GestureDetector( + onTap: () { + Clipboard.setData( + ClipboardData(text: modelItem['order_id'])); + Fluttertoast.showToast(msg: "已复制"); + }, + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(4), + color: HexColor.fromHex(outputItemStyle.copyBtnBgColor), + border: Border.all( + color: HexColor.fromHex( + outputItemStyle.contentColor))), + child: Padding( + padding: EdgeInsets.only( + left: 16, right: 16, top: 1, bottom: 1), + child: Text( + outputItemStyle.copyBtnText ?? "", + style: TextStyle( + color: + HexColor.fromHex(outputItemStyle.contentColor), + fontSize: 22.sp), + ), + ), + ), + ) + ], + ), + SizedBox( + height: 4, + ), + Row( + children: [ + Expanded( + child: Row( + children: [ + Text( + outputItemStyle.withdrawAccountText, + style: TextStyle( + color: + HexColor.fromHex(outputItemStyle.contentColor), + fontSize: 22.sp), + ), + SizedBox( + width: 4, + ), + Text( + modelItem['account'] ?? "", + style: TextStyle( + color: + HexColor.fromHex(outputItemStyle.contentColor), + fontSize: 22.sp), + ), + ], + )), + Expanded( + child: Row( + children: [ + Text( + outputItemStyle.withdrawAmountText + + " ¥" + + modelItem['amount'], + style: TextStyle( + color: + HexColor.fromHex(outputItemStyle.contentColor), + fontSize: 22.sp), + ), + ], + )) + ], + ), + SizedBox( + height: 4, + ), + Row( + children: [ + Expanded( + child: Row( + children: [ + Text( + outputItemStyle.withdrawTimeText, + style: TextStyle( + color: + HexColor.fromHex(outputItemStyle.contentColor), + fontSize: 22.sp), + ), + SizedBox( + width: 4, + ), + Text( + modelItem['time'] ?? "", + style: TextStyle( + color: HexColor.fromHex("#FF999999"), + fontSize: 22.sp), + ), + ], + )), + Expanded( + child: Row( + children: [ + Text( + outputItemStyle.withdrawOrderStatusText + + " " + + modelItem['order_status'] ?? + "", + style: TextStyle( + color: + HexColor.fromHex(outputItemStyle.contentColor), + fontSize: 22.sp), + ), + ], + )) + ], + ), + ], + ), + ); + } + } + } + + _buildTabViewPage() { + List listWidget = List(); + for (var item in _bloc.styleData.tabList) { + List tabViewBtns; + + if (item.type == 'input') { + tabViewBtns = _bloc.styleData.inputTabViewBtns; + listWidget.add(StreamBuilder( + stream: _bloc.inputOutData, + builder: (context, asny) { + // dataVM = asny.data; + + return Container( + child: Column( + children: [ + _buildType(tabViewBtns, item), + Expanded( + child: SmartRefresher( + controller: _bloc.inputRefreshController, + enablePullDown: true, + enablePullUp: true, + onLoading: () { + _bloc.inputLoad(); + }, + onRefresh: () { + _bloc.inputRefresh(); + }, + child: _bloc.inputDataVM == null + ? Container() + : _buildBottomItem(item)), + ) + ], + ), + ); + })); + } else { + tabViewBtns = _bloc.styleData.outTabViewBtns; + listWidget.add(StreamBuilder( + stream: _bloc.outputOutData, + builder: (context, asny) { + // dataVM = asny.data; + + return Container( + child: Column( + children: [ + _buildType(tabViewBtns, item), + Expanded( + child: SmartRefresher( + controller: _bloc.outputRefreshController, + enablePullDown: true, + enablePullUp: true, + onLoading: () { + _bloc.outputLoad(); + }, + onRefresh: () { + _bloc.outputRefresh(); + }, + child: _bloc.outputDataVM == null + ? Container() + : _buildBottomItem(item)), + ) + ], + ), + ); + })); + } + } + return listWidget; + } + + @override + // TODO: implement wantKeepAlive + bool get wantKeepAlive => true; +} diff --git a/lib/widgets/wallet_bil_detail/wallet_bil_detail_widget_bloc.dart b/lib/widgets/wallet_bil_detail/wallet_bil_detail_widget_bloc.dart new file mode 100644 index 0000000..196318d --- /dev/null +++ b/lib/widgets/wallet_bil_detail/wallet_bil_detail_widget_bloc.dart @@ -0,0 +1,163 @@ +import 'dart:async'; + +import 'package:intl/intl.dart'; +import 'package:pull_to_refresh/pull_to_refresh.dart'; +import 'package:zhiying_comm/util/base_bloc.dart'; +import 'package:zhiying_comm/zhiying_comm.dart'; + +import 'model/wallet_style_model.dart'; + +class WalletBilDetailWidgetBloc extends BlocBase { + StreamController>> inputDataController = + StreamController.broadcast(); + + Stream get inputOutData => inputDataController.stream; + + StreamController>> outputDataController = + StreamController.broadcast(); + + Stream get outputOutData => outputDataController.stream; + + List> inputDataVM; + List> outputDataVM; + + ///样式model + BilDetailStyleModel styleData; + + ///支出当前页数 + int outPutCurrentPage = 1; + + ///收入当前页数 + int inPutCurrentPage = 1; + + ///收入显示时间 + String inputShowDate; + + ///支出显示时间 + String outputShowDate; + + //收入显示类型 + String inputSelectType = 'all'; + + ///支出显示类型 + String outputSelectType = 'all'; + + ///收入下啦刷新 + RefreshController inputRefreshController = RefreshController(); + + ///支出页面下拉刷新 + RefreshController outputRefreshController = RefreshController(); + + @override + void dispose() { + inputDataController.close(); + outputDataController.close(); + inputRefreshController.dispose(); + outputRefreshController.dispose(); + } + + initStyleData(Map data) { + try { + inputShowDate = DateFormat("yyyy-MM").format(DateTime.now()); + outputShowDate = DateFormat("yyyy-MM").format(DateTime.now()); + styleData = BilDetailStyleModel.fromJson(data); + } catch (e, s) { + print(e); + print(s); + } + } + + ///加载收入数据 + loadInputData(int page, String date, {String type}) async { + type = inputSelectType; + String paramsStr = "?page=" + page.toString() + "&time=" + date; + if (type != null && type != "all") { + paramsStr += "&type=" + type; + } + NetUtil.request("/api/v1/user/wallet_detail/input" + paramsStr, + method: NetMethod.GET, onSuccess: (data) { + inputRefreshController.refreshCompleted(); + inputRefreshController.loadComplete(); + var listmap = List.from(data).map((e) { + return e as Map; + }).toList(); + if (inputDataVM == null) { + inputDataVM = List>(); + } + + if (listmap == null || listmap.length == 0) { + inputRefreshController.loadNoData(); + } + + if (inPutCurrentPage == 1) { + inputDataVM.clear(); + inputDataVM.addAll(listmap); + } else { + inputDataVM.addAll(listmap); + } + + refresh(); + }); + } + + ///加载支出数据 + loadOutputData(int page, String date, {String type}) async { + type = outputSelectType; + String paramsStr = "?page=" + page.toString() + "&time=" + date; + if (type != null && type != "all") { + paramsStr += "&type=" + type; + } + NetUtil.request("/api/v1/user/wallet_detail/output" + paramsStr, + method: NetMethod.GET, onSuccess: (data) { + outputRefreshController.refreshCompleted(); + outputRefreshController.loadComplete(); + + var listMap = List.from(data).map((e) { + return e as Map; + }).toList(); + + if (listMap == null || listMap.length == 0) { + outputRefreshController.loadNoData(); + } + if (outputDataVM == null) { + outputDataVM = List(); + } + if (outPutCurrentPage == 1) { + outputDataVM.clear(); + outputDataVM.addAll(listMap); + } else { + outputDataVM.addAll(listMap); + } + refresh(); + }, onError: (e) { + outputRefreshController.refreshCompleted(); + outputRefreshController.loadComplete(); + }); + } + + inputRefresh() { + inPutCurrentPage = 1; + loadInputData(inPutCurrentPage, inputShowDate); + } + + inputLoad() { + inPutCurrentPage++; + loadInputData(inPutCurrentPage, inputShowDate); + } + + outputRefresh() { + outPutCurrentPage = 1; + loadOutputData(outPutCurrentPage, outputShowDate); + } + + outputLoad() { + outPutCurrentPage++; + loadOutputData(outPutCurrentPage, outputShowDate); + } + + ///全刷新 + refresh() { + inputDataController.add(inputDataVM); + outputDataController.add(outputDataVM); + } +} diff --git a/lib/widgets/wallet_bil_detail/wallet_list_widget.dart b/lib/widgets/wallet_bil_detail/wallet_list_widget.dart new file mode 100644 index 0000000..d87aab1 --- /dev/null +++ b/lib/widgets/wallet_bil_detail/wallet_list_widget.dart @@ -0,0 +1,606 @@ +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; +import 'package:pull_to_refresh/pull_to_refresh.dart'; +import 'package:zhiying_base_widget/dialog/select_date_ym_dialog/select_date_ym_dialog.dart'; +import 'package:zhiying_base_widget/widgets/wallet/wallet_detail/wallet_detail_bloc.dart'; +import 'package:zhiying_base_widget/widgets/wallet_bil_detail/wallet_bil_detail_widget_bloc.dart'; +import 'package:zhiying_comm/util/base_bloc.dart'; +import 'package:zhiying_comm/zhiying_comm.dart'; + +import 'model/wallet_style_model.dart'; + +class WalletListWidget extends StatefulWidget { + final TabList tabList; + final List tabViewBtns; + const WalletListWidget({Key key,this.tabViewBtns, this.tabList}) : super(key: key); + @override + _WalletListWidgetState createState() => _WalletListWidgetState(); +} + +class _WalletListWidgetState extends State with AutomaticKeepAliveClientMixin { + WalletBilDetailWidgetBloc _bloc; + List tabViewBtns; + TabList item; + + @override + void initState() { + item=widget.tabList; + tabViewBtns=widget.tabViewBtns; + super.initState(); + } + + @override + Widget build(BuildContext context) { + _bloc = BlocProvider.of(context); + if(item.type=='input'){ + return StreamBuilder( + stream: _bloc.inputOutData, + builder: (context, asny) { + // dataVM = asny.data; + + return Container( + child: Column( + children: [ + _buildType(tabViewBtns, item), + Expanded( + child: SmartRefresher( + controller: _bloc.inputRefreshController, + enablePullDown: true, + enablePullUp: true, + onLoading: _bloc.outputLoad(), + onRefresh: _bloc.outputRefresh(), + child: _bloc.inputDataVM == null + ? Container() + : _buildBottomItem(item)), + ) + ], + ), + ); + }); + }else{ + return StreamBuilder( + stream: _bloc.outputOutData, + builder: (context, asny) { + // dataVM = asny.data; + + return Container( + child: Column( + children: [ + _buildType(tabViewBtns, item), + Expanded( + child: SmartRefresher( + controller: _bloc.outputRefreshController, + enablePullDown: true, + enablePullUp: true, + onLoading: _bloc.outputLoad(), + onRefresh: _bloc.outputRefresh(), + child: _bloc.outputDataVM == null + ? Container() + : _buildBottomItem(item)), + ) + ], + ), + ); + }); + } + + + } + + + + _buildType(List tabViewBtns, TabList tabList) { + var selectType; + if (tabList.type == 'input') { + selectType = _bloc.inputSelectType; + } else { + selectType = _bloc.outputSelectType; + ; + } + return Row( + children: [ + SizedBox(width: 12.5), + InkWell( + onTap: () { + ///显示日期选择弹窗 + _selectDate(tabList); + }, + child: Padding( + padding: const EdgeInsets.only(top: 8, bottom: 8), + child: Text( + tabList.type == "input" + ? _bloc.inputShowDate + : _bloc.outputShowDate, + style: TextStyle( + fontSize: 28.sp, + color: + HexColor.fromHex(_bloc.styleData.timeSelectColor)))), + ), + Icon( + Icons.arrow_drop_down, + color: HexColor.fromHex(_bloc.styleData.timeSelectColor), + ), + Expanded( + child: Container( + height: 50, + child: ListView.builder( + scrollDirection: Axis.horizontal, + shrinkWrap: true, + itemCount: tabViewBtns.length, + itemBuilder: (context, index) { + return InkWell( + onTap: () async { + if (tabList.type == 'input') { + _bloc.inputSelectType = tabViewBtns[index].type; + _bloc.loadInputData( + _bloc.inPutCurrentPage, _bloc.inputShowDate, + type: _bloc.inputSelectType); + } else { + _bloc.outputSelectType = tabViewBtns[index].type; + _bloc.loadOutputData( + _bloc.outPutCurrentPage, _bloc.outputShowDate, + type: _bloc.outputSelectType); + } + _bloc.refresh(); + }, + child: Container( + margin: EdgeInsets.only( + top: 10, left: 8, right: 8, bottom: 10), + decoration: BoxDecoration( + border: Border.all( + color: HexColor.fromHex( + selectType == tabViewBtns[index].type + ? _bloc.styleData.btnSelectedColor + : _bloc.styleData.btnNoSelectedColor), + ), + borderRadius: BorderRadius.circular(50)), + child: Padding( + padding: EdgeInsets.only(left: 16, right: 16), + child: Center( + child: Text( + tabViewBtns[index].name ?? "", + style: TextStyle( + color: HexColor.fromHex( + selectType == tabViewBtns[index].type + ? _bloc.styleData.btnSelectedColor + : _bloc.styleData.btnNoSelectedColor)), + )), + ), + )); + }), + )) + ], + ); + } + + _selectDate(TabList tabList) async { + var result = await showDialog( + context: context, builder: (context) => SelectDateYMDialog()); + if (result != null) { + var dataTime = DateFormat('yyyy-MM').format( + DateTime(int.parse(result['year']), int.parse(result['month']))); + if (tabList.type == "input") { + _bloc.inputShowDate = dataTime; + _bloc.loadInputData(_bloc.inPutCurrentPage, _bloc.inputShowDate); + } else { + _bloc.outputShowDate = dataTime; + _bloc.loadInputData(_bloc.outPutCurrentPage, _bloc.outputShowDate); + } + _bloc.refresh(); + } + } + + + + + _buildBottomItem(TabList tabList) { + return ListView.builder( + shrinkWrap: true, + itemCount: tabList.type == 'input' + ? _bloc.inputDataVM?.length??0 + : _bloc.outputDataVM?.length??0, + itemBuilder: (context, index) { + return _buildItem(context, index, tabList); + }); + } + + Widget _buildItem(BuildContext context, int index, TabList tabList) { + if (tabList.type == 'input') { + InputItemStyle inputItemStyle = _bloc.styleData.inputItemStyle; + var modelItem = _bloc.inputDataVM[index]; + return Container( + margin: EdgeInsets.only(left: 12.5, right: 12.5, bottom: 4, top: 4), + padding: + EdgeInsets.only(left: 25.w, right: 25.w, top: 20.h, bottom: 20.h), + decoration: BoxDecoration( + color: HexColor.fromHex("#FFFFFF"), + borderRadius: BorderRadius.circular(8)), + child: Column( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + children: [ + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(4), + color: HexColor.fromHex("#FFFFF3F3"), + border: Border.all( + color: HexColor.fromHex( + inputItemStyle.typeNameColor))), + child: Padding( + padding: const EdgeInsets.only( + left: 4, right: 4, top: 2, bottom: 2), + child: Center( + child: Text( + modelItem['type'] ?? "", + style: TextStyle( + color: HexColor.fromHex( + inputItemStyle.typeNameColor), + fontSize: 20.sp), + ), + ), + ), + ), + Container( + width: 353.w, + margin: EdgeInsets.only(left: 15.w), + child: Text( + modelItem['title'] ?? "", + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: TextStyle(fontSize: 28.sp), + )) + ], + ), + Row( + children: [ + Text( + "+ ", + style: TextStyle( + color: HexColor.fromHex(inputItemStyle.amountColor)), + ), + Text( + "¥ " + modelItem['amount'], + style: TextStyle( + color: HexColor.fromHex(inputItemStyle.amountColor), + fontSize: 30.sp), + ) + ], + ) + ], + ), + SizedBox( + height: 4, + ), + + ///订单编号 + Row( + children: [ + Text( + inputItemStyle.orderIdText, + style: TextStyle( + color: HexColor.fromHex(inputItemStyle.contentColor), + fontSize: 22.sp), + ), + SizedBox( + width: 4, + ), + Text( + modelItem['order_id'], + style: TextStyle( + color: HexColor.fromHex(inputItemStyle.contentColor), + fontSize: 22.sp), + ), + SizedBox( + width: 28.w, + ), + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(4), + color: HexColor.fromHex(inputItemStyle.copyBtnBgColor), + border: Border.all( + color: + HexColor.fromHex(inputItemStyle.contentColor))), + child: Padding( + padding: + EdgeInsets.only(left: 16, right: 16, top: 1, bottom: 1), + child: Text( + inputItemStyle.copyBtnText, + style: TextStyle( + color: HexColor.fromHex(inputItemStyle.contentColor), + fontSize: 22.sp), + ), + ), + ) + ], + ), + SizedBox( + height: 4, + ), + Row( + children: [ + Expanded( + child: Row( + children: [ + Text( + inputItemStyle.orderTypeText, + style: TextStyle( + color: HexColor.fromHex(inputItemStyle.contentColor), + fontSize: 22.sp), + ), + SizedBox( + width: 4, + ), + Text( + modelItem['order_type'] ?? "", + style: TextStyle( + color: HexColor.fromHex("#FF999999"), + fontSize: 22.sp), + ), + ], + )), + Expanded( + child: Row( + children: [ + Text( + inputItemStyle.amountText + " ¥" + modelItem['amount'], + style: TextStyle( + color: HexColor.fromHex(inputItemStyle.contentColor), + fontSize: 22.sp), + ), + ], + )) + ], + ), + SizedBox( + height: 4, + ), + Row( + children: [ + Expanded( + child: Row( + children: [ + Text( + inputItemStyle.timeText, + style: TextStyle( + color: HexColor.fromHex(inputItemStyle.contentColor), + fontSize: 22.sp), + ), + SizedBox( + width: 4, + ), + Text( + modelItem['time'] ?? "", + style: TextStyle( + color: HexColor.fromHex("#FF999999"), + fontSize: 22.sp), + ), + ], + )), + Expanded( + child: Row( + children: [ + Text( + inputItemStyle.settleTimeText + + " " + + modelItem['settle_time'] ?? + "", + style: TextStyle( + color: HexColor.fromHex(inputItemStyle.contentColor), + fontSize: 22.sp), + ), + ], + )) + ], + ), + ], + ), + ); + } else if (tabList.type == 'output') { + OutputItemStyle inputItemStyle = _bloc.styleData.outputItemStyle; + var modelItem = _bloc.outputDataVM[index]; + if (modelItem['type'] == '消费') { + ///消费返回的Item + return Container( + margin: EdgeInsets.only(left: 12.5, right: 12.5, bottom: 4, top: 4), + padding: + EdgeInsets.only(left: 25.w, right: 25.w, top: 20.h, bottom: 20.h), + decoration: BoxDecoration( + color: HexColor.fromHex("#FFFFFF"), + borderRadius: BorderRadius.circular(8)), + child: Column( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + children: [ + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(4), + color: HexColor.fromHex("#FFFFF3F3"), + border: Border.all( + color: HexColor.fromHex( + inputItemStyle.typeNameColor))), + child: Padding( + padding: const EdgeInsets.only( + left: 4, right: 4, top: 2, bottom: 2), + child: Center( + child: Text( + modelItem['type'] ?? "", + style: TextStyle( + color: HexColor.fromHex( + inputItemStyle.typeNameColor), + fontSize: 20.sp), + ), + ), + ), + ), + Container( + width: 353.w, + margin: EdgeInsets.only(left: 15.w), + child: Text( + modelItem['title'] ?? "", + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: TextStyle(fontSize: 28.sp), + )) + ], + ), + Row( + children: [ + Text( + "- ", + style: TextStyle(color: Colors.red), + ), + Text( + "¥ " + modelItem['amount'], + style: TextStyle(color: Colors.red, fontSize: 30.sp), + ) + ], + ) + ], + ), + SizedBox( + height: 4, + ), + + ///订单编号 + Row( + children: [ + Text( + inputItemStyle.orderIdText, + style: TextStyle( + color: HexColor.fromHex(inputItemStyle.contentColor), + fontSize: 22.sp), + ), + SizedBox( + width: 4, + ), + Text( + modelItem['order_id'], + style: TextStyle( + color: HexColor.fromHex(inputItemStyle.contentColor), + fontSize: 22.sp), + ), + SizedBox( + width: 28.w, + ), + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(4), + color: HexColor.fromHex(inputItemStyle.copyBtnBgColor), + border: Border.all( + color: + HexColor.fromHex(inputItemStyle.contentColor))), + child: Padding( + padding: EdgeInsets.only( + left: 16, right: 16, top: 1, bottom: 1), + child: Text( + inputItemStyle.copyBtnText ?? "", + style: TextStyle( + color: + HexColor.fromHex(inputItemStyle.contentColor), + fontSize: 22.sp), + ), + ), + ) + ], + ), + SizedBox( + height: 4, + ), + Row( + children: [ + Expanded( + child: Row( + children: [ + Text( + inputItemStyle.consumeOrderTypeText, + style: TextStyle( + color: + HexColor.fromHex(inputItemStyle.contentColor), + fontSize: 22.sp), + ), + SizedBox( + width: 4, + ), + Text( + modelItem['order_type'] ?? "", + style: TextStyle( + color: HexColor.fromHex("#FF999999"), + fontSize: 22.sp), + ), + ], + )), + Expanded( + child: Row( + children: [ + Text( + inputItemStyle.consumeAmountText + + " ¥" + + modelItem['amount'], + style: TextStyle( + color: + HexColor.fromHex(inputItemStyle.contentColor), + fontSize: 22.sp), + ), + ], + )) + ], + ), + SizedBox( + height: 4, + ), + Row( + children: [ + Expanded( + child: Row( + children: [ + Text( + inputItemStyle.consumeTimeText, + style: TextStyle( + color: + HexColor.fromHex(inputItemStyle.contentColor), + fontSize: 22.sp), + ), + SizedBox( + width: 4, + ), + Text( + modelItem['time'] ?? "", + style: TextStyle( + color: HexColor.fromHex("#FF999999"), + fontSize: 22.sp), + ), + ], + )), + // Expanded( + // child: Row( + // children: [ + // Text( + // inputItemStyle.consumeTimeText + + // " " + + // modelItem['settle_time'] ?? + // "", + // style: TextStyle( + // color: HexColor.fromHex(inputItemStyle.contentColor), + // fontSize: 22.sp), + // ), + // ], + // )) + ], + ), + ], + ), + ); + } else {} + } + } + + @override + // TODO: implement wantKeepAlive + bool get wantKeepAlive => true; +}