From 8b79fd5556606ed3eff59e4841c7e5d02d23f2f8 Mon Sep 17 00:00:00 2001 From: Weller <1812208341@qq.com> Date: Wed, 21 Oct 2020 09:24:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=92=B1=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wallet_page/wallet_detail_list_page.dart | 54 +++++++++ lib/pages/wallet_page/wallet_detail_page.dart | 106 ++++++++++++++++++ lib/pages/wallet_page/wallet_page.dart | 19 +--- .../widgets/wallet_tab_widget.dart | 8 ++ lib/register.dart | 13 ++- lib/widgets/others/normal_nav/normal_nav.dart | 51 ++++++--- .../others/normal_nav/normal_nav_creater.dart | 2 +- lib/widgets/wallet/wallet_bil/wallet_bil.dart | 68 ++++++----- .../wallet/wallet_data/wallet_data.dart | 26 ++++- 9 files changed, 278 insertions(+), 69 deletions(-) create mode 100644 lib/pages/wallet_page/wallet_detail_list_page.dart create mode 100644 lib/pages/wallet_page/wallet_detail_page.dart create mode 100644 lib/pages/wallet_page/widgets/wallet_tab_widget.dart diff --git a/lib/pages/wallet_page/wallet_detail_list_page.dart b/lib/pages/wallet_page/wallet_detail_list_page.dart new file mode 100644 index 0000000..4541386 --- /dev/null +++ b/lib/pages/wallet_page/wallet_detail_list_page.dart @@ -0,0 +1,54 @@ +import 'package:flutter/material.dart'; + +class WalletDetailListPage extends StatefulWidget { + @override + _WalletDetailListPageState createState() => _WalletDetailListPageState(); +} + +class _WalletDetailListPageState extends State { + @override + Widget build(BuildContext context) { + return Container( + margin: EdgeInsets.only(left: 12.5, right: 12.5), + child: Column( + children: [ + _createHeader(), + _createContent(), + ], + ), + ); + } + + Widget _createHeader() { + return Container( + height: 50, + child: Row( + children: [ + Container( + width: 80, + child: Row( + children: [ + Text( + '2020-10', + style: TextStyle( + fontSize: 14, + color: Color(0xff333333), + fontWeight: FontWeight.bold, + ), + ), + ], + ), + ), + Expanded( + child: SingleChildScrollView( + child: Row(), + )) + ], + ), + ); + } + + Widget _createContent() { + return Container(); + } +} diff --git a/lib/pages/wallet_page/wallet_detail_page.dart b/lib/pages/wallet_page/wallet_detail_page.dart new file mode 100644 index 0000000..20f51d0 --- /dev/null +++ b/lib/pages/wallet_page/wallet_detail_page.dart @@ -0,0 +1,106 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:tab_indicator_styler/tab_indicator_styler.dart'; +import 'package:zhiying_base_widget/pages/wallet_page/wallet_detail_list_page.dart'; +import 'package:zhiying_comm/util/extension/color.dart'; + +class WalletDetailPage extends StatefulWidget { + @override + _WalletDetailPageState createState() => _WalletDetailPageState(); +} + +class _WalletDetailPageState extends State + with TickerProviderStateMixin { + TabController _controller; + + @override + void initState() { + _controller = TabController(vsync: this, length: 2); + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: _createNav(), + body: SafeArea( + child: Column( + children: [ + _createTab(), + Expanded( + child: _createContent(), + ), + ], + ), + ), + ); + } + + // 导航栏 + Widget _createNav() { + return CupertinoNavigationBar( + border: Border( + bottom: BorderSide( + width: 0.0, // One physical pixel. + style: BorderStyle.none, + ), + ), + backgroundColor: Colors.white, + leading: Navigator.canPop(context) + ? GestureDetector( + child: Container( + padding: EdgeInsets.zero, + child: Icon( + Icons.arrow_back_ios, + size: 20, + ), + ), + onTap: () { + if (Navigator.canPop(context)) { + Navigator.pop(context); + } + }, + ) + : Container(), + middle: Text( + '明细', + style: TextStyle( + fontSize: 15, + color: Color(0xff333333), + ), + ), + ); + } + + Widget _createTab() { + return Container( + color: Colors.white, + child: TabBar( + isScrollable: false, + labelStyle: TextStyle(fontWeight: FontWeight.bold, fontSize: 13), + unselectedLabelStyle: TextStyle(fontSize: 13), + indicator: MaterialIndicator( + height: 2, + topLeftRadius: 8, + topRightRadius: 8, + bottomLeftRadius: 8, + bottomRightRadius: 8, + color: HexColor.fromHex('#F94B47'), + horizontalPadding: 30, + ), + controller: _controller, + tabs: List.generate(2, (index) => Tab(text: '收入明细')), + indicatorColor: Colors.red, + unselectedLabelColor: HexColor.fromHex('#999999'), + labelColor: HexColor.fromHex('#000000'), + ), + ); + } + + Widget _createContent() { + return TabBarView( + controller: _controller, + children: [WalletDetailListPage(), Container()], + ); + } +} diff --git a/lib/pages/wallet_page/wallet_page.dart b/lib/pages/wallet_page/wallet_page.dart index aaf0bf7..7b2fef3 100644 --- a/lib/pages/wallet_page/wallet_page.dart +++ b/lib/pages/wallet_page/wallet_page.dart @@ -5,15 +5,13 @@ import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:zhiying_base_widget/pages/main_page/notifier/main_page_bg_notifier.dart'; import 'package:zhiying_base_widget/pages/main_page/notifier/main_page_notifier.dart'; import 'package:zhiying_base_widget/utils/contants.dart'; -import 'package:zhiying_base_widget/widgets/others/mine_header_bg_widget.dart'; import 'package:zhiying_base_widget/widgets/wallet/wallet_appbar/wallet_appbar_sk.dart'; import 'package:zhiying_base_widget/widgets/wallet/wallet_data/wallet_data_sk.dart'; import 'package:zhiying_base_widget/widgets/wallet/wallet_detail/wallet_detail_sk.dart'; import 'package:zhiying_base_widget/widgets/wallet/wallet_income/wallet_income_sk.dart'; -import 'package:zhiying_comm/zhiying_comm.dart'; import 'package:zhiying_comm/util/base_bloc.dart'; -import 'package:zhiying_comm/util/custom_sliver_persistent_header_delegate.dart'; -import 'wallet_page_bloc.dart'; +import 'package:zhiying_comm/zhiying_comm.dart'; + import 'wallet_page_bloc.dart'; ///钱包页面 @@ -82,7 +80,7 @@ class _WalletPageContainerState extends State<_WalletPageContainer> { return SmartRefresher( controller: _refreshController, enablePullDown: true, - enablePullUp:true, + enablePullUp: true, header: WaterDropHeader(), onLoading: _onLoading, child: Container( @@ -131,17 +129,6 @@ class _WalletPageContainerState extends State<_WalletPageContainer> { for (var item in model) { WidgetModel widgetModel = WidgetModel.fromJson(Map.from(item)); - if (item.containsKey("mod_name") && - item['mod_name'] == "my_wallet_appbar") { - list.add(SliverPersistentHeader( - delegate: _SilverAppBarDelegate( - context, - WidgetFactory.create(widgetModel.modName, - isSliver: false, model: item)[0]), - pinned: true, - )); - continue; - } list.addAll(WidgetFactory.create(widgetModel.modName, isSliver: true, model: item)); } diff --git a/lib/pages/wallet_page/widgets/wallet_tab_widget.dart b/lib/pages/wallet_page/widgets/wallet_tab_widget.dart new file mode 100644 index 0000000..1d85483 --- /dev/null +++ b/lib/pages/wallet_page/widgets/wallet_tab_widget.dart @@ -0,0 +1,8 @@ +import 'package:flutter/material.dart'; + +class WalletTabWidget extends StatelessWidget { + @override + Widget build(BuildContext context) { + return Container(); + } +} diff --git a/lib/register.dart b/lib/register.dart index 453e976..6848758 100644 --- a/lib/register.dart +++ b/lib/register.dart @@ -44,7 +44,6 @@ import 'package:zhiying_base_widget/widgets/others/normal_nav/normal_nav_creater import 'package:zhiying_base_widget/widgets/search/tabbar/search_tab_creater.dart'; import 'package:zhiying_base_widget/widgets/search_result/sort/search_result_sort_widget.dart'; import 'package:zhiying_base_widget/widgets/search_result/tarbar/search_result_tab_creater.dart'; -import 'package:zhiying_base_widget/widgets/wallet/wallet_appbar/wallet_appbar.dart'; 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'; @@ -290,11 +289,13 @@ class BaseWidgetRegister { // WidgetFactory.regist('profile_carousel', HomeBannerCreater()); // ==================== 钱包 - WidgetFactory.regist( - 'my_wallet_appbar', - DefaultWidgetCreater((model) => WalletAppbar( - data: model, - ))); + // WidgetFactory.regist( + // 'my_wallet_appbar', + // DefaultWidgetCreater((model) => WalletAppbar( + // data: model, + // ))); + WidgetFactory.regist('my_wallet_appbar', NormalNavCreater()); + WidgetFactory.regist( 'my_wallet_header', DefaultWidgetCreater((model) => WalletData(model))); WidgetFactory.regist( diff --git a/lib/widgets/others/normal_nav/normal_nav.dart b/lib/widgets/others/normal_nav/normal_nav.dart index 5d64c2e..268d753 100644 --- a/lib/widgets/others/normal_nav/normal_nav.dart +++ b/lib/widgets/others/normal_nav/normal_nav.dart @@ -1,14 +1,33 @@ +import 'dart:convert' as convert; import 'dart:ui'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:zhiying_base_widget/pages/mine_page/mine_page.dart'; +import 'package:zhiying_comm/zhiying_comm.dart'; class NormalNavDelegate extends SliverPersistentHeaderDelegate { + final Map data; double _height; + Color _bgColor; + String _title; + Color _titleColor; - NormalNavDelegate() : super() { + NormalNavDelegate(this.data) : super() { _height = MediaQueryData.fromWindow(window).padding.top + 44; + + String d = data['data']; + Map json = + Map.from(convert.jsonDecode(d)); + + if (json.containsKey('app_bar_bg_color')) { + _bgColor = HexColor.fromHex(json['app_bar_bg_color'] ?? ''); + } + if (json.containsKey('app_bar_name')) { + _title = json['app_bar_name'] ?? ''; + } + if (json.containsKey('app_bar_name')) { + _titleColor = HexColor.fromHex(json['app_bar_name_color']); + } } @override @@ -17,7 +36,8 @@ class NormalNavDelegate extends SliverPersistentHeaderDelegate { print('${shrinkOffset.toString()}'); double percent = shrinkOffset / _height; print('${percent.toString()}'); - return NormalNav(Colors.red.withOpacity(percent)); + return NormalNav(_title, _titleColor, + _bgColor?.withOpacity(percent) ?? Colors.transparent); } @override @@ -32,9 +52,11 @@ class NormalNavDelegate extends SliverPersistentHeaderDelegate { } class NormalNav extends StatelessWidget { + final String title; + final Color titleColor; final Color color; - NormalNav(this.color); + NormalNav(this.title, this.titleColor, this.color); @override Widget build(BuildContext context) { @@ -73,8 +95,9 @@ class NormalNav extends StatelessWidget { child: Container( child: Center( child: Text( - '我的钱包', - style: TextStyle(fontSize: 18, color: Colors.white), + title ?? '', + style: TextStyle( + fontSize: 18, color: titleColor ?? Colors.white), ), ), ), @@ -83,16 +106,16 @@ class NormalNav extends StatelessWidget { child: Container( width: 44, height: 44, - child: Icon( - Icons.settings, - color: Colors.white, - ), + // child: Icon( + // Icons.settings, + // color: Colors.white, + // ), ), onTap: () { - Navigator.push(context, - CupertinoPageRoute(builder: (context) { - return MinePage(); - })); + // Navigator.push(context, + // CupertinoPageRoute(builder: (context) { + // return MinePage(); + // })); }, ), ], diff --git a/lib/widgets/others/normal_nav/normal_nav_creater.dart b/lib/widgets/others/normal_nav/normal_nav_creater.dart index db81c66..4a9b86d 100644 --- a/lib/widgets/others/normal_nav/normal_nav_creater.dart +++ b/lib/widgets/others/normal_nav/normal_nav_creater.dart @@ -9,7 +9,7 @@ class NormalNavCreater extends WidgetCreater { SliverPersistentHeader( pinned: true, floating: true, - delegate: NormalNavDelegate(), + delegate: NormalNavDelegate(model), ), ]; } diff --git a/lib/widgets/wallet/wallet_bil/wallet_bil.dart b/lib/widgets/wallet/wallet_bil/wallet_bil.dart index 2de0c68..430343a 100644 --- a/lib/widgets/wallet/wallet_bil/wallet_bil.dart +++ b/lib/widgets/wallet/wallet_bil/wallet_bil.dart @@ -1,14 +1,13 @@ import 'dart:convert'; -import 'package:flutter/material.dart'; 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/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'; - import 'package:zhiying_comm/zhiying_comm.dart'; -import 'package:cached_network_image/cached_network_image.dart'; - ///查看明细部件 class WalletBil extends StatelessWidget { Map data; @@ -23,29 +22,44 @@ class WalletBil extends StatelessWidget { } return data == null ? WalletIncomeSkeleton() - : Container( - decoration: BoxDecoration( - color: Colors.white, borderRadius: BorderRadius.circular(8)), - margin: EdgeInsets.only(left: 12.5, right: 12.5, top: 10), - child: ListTile( - title: Row( - mainAxisSize: MainAxisSize.min, - children: [ - CachedNetworkImage( - imageUrl: model.bilIcon, - width: 36.w, - height: 36.w, - fit: BoxFit.fill, - ), - SizedBox(width: 15.w,), - Text(model.bilText, style: TextStyle(fontSize: 24.sp),), - ], - ), - trailing: InkWell( - child: Text(model.skipText, style: TextStyle(color: Colors.grey),), + : GestureDetector( onTap: () { - ///跳转??? - },), - )); + Navigator.push( + context, + CupertinoPageRoute( + builder: (context) => WalletDetailPage(), + ), + ); + }, + child: Container( + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(8)), + margin: EdgeInsets.only(left: 12.5, right: 12.5, top: 10), + child: ListTile( + title: Row( + mainAxisSize: MainAxisSize.min, + children: [ + CachedNetworkImage( + imageUrl: model.bilIcon, + width: 36.w, + height: 36.w, + fit: BoxFit.fill, + ), + SizedBox( + width: 15.w, + ), + Text( + model.bilText, + style: TextStyle(fontSize: 24.sp), + ), + ], + ), + trailing: Text( + model.skipText, + style: TextStyle(color: Colors.grey), + ), + )), + ); } } diff --git a/lib/widgets/wallet/wallet_data/wallet_data.dart b/lib/widgets/wallet/wallet_data/wallet_data.dart index b0ccccd..c221c65 100644 --- a/lib/widgets/wallet/wallet_data/wallet_data.dart +++ b/lib/widgets/wallet/wallet_data/wallet_data.dart @@ -1,10 +1,11 @@ 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/widgets/wallet/wallet_data/model/wallet_header_model.dart'; import 'package:zhiying_base_widget/widgets/wallet/wallet_data/wallet_data_bloc.dart'; import 'package:zhiying_base_widget/widgets/wallet/wallet_data/wallet_data_sk.dart'; -import 'package:cached_network_image/cached_network_image.dart'; import 'package:zhiying_comm/zhiying_comm.dart'; class WalletData extends StatefulWidget { @@ -92,9 +93,12 @@ class _WalletDataState extends State { ? dataModel[model.headerCashOutKey] : "", style: TextStyle( - fontSize: 40.sp, - color: HexColor.fromHex( - model.headerCashOutTextColor)), + fontSize: 40.sp, + color: HexColor.fromHex( + model.headerCashOutTextColor), + fontFamily: 'Din-Bold', + package: 'zhiying_base_widget', + ), ), ], ), @@ -102,6 +106,15 @@ class _WalletDataState extends State { ], ), GestureDetector( + onTap: () { + SkipModel skipModel = SkipModel( + skipIdentifier: 'pub.flutter.cash_out', + requiredLogin: '1', + requiredTaobaoAuth: '0', + ); + RouterUtil.route( + skipModel, skipModel.toJson(), context); + }, child: Container( decoration: BoxDecoration( color: Colors.red, @@ -149,7 +162,10 @@ class _WalletDataState extends State { ? dataModel[item.valueKey] : "", style: TextStyle( - color: HexColor.fromHex(item.valueColor), fontSize: 30.sp), + color: HexColor.fromHex(item.valueColor), + fontSize: 30.sp, + fontFamily: 'Din-Bold', + package: 'zhiying_base_widget'), ), Text( item.text,