From 6154f10eb007a5f5bb7026d57686b392c5421dc2 Mon Sep 17 00:00:00 2001 From: Weller <1812208341@qq.com> Date: Fri, 11 Sep 2020 10:06:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=B8=AA=E4=BA=BA=E4=B8=AD?= =?UTF-8?q?=E5=BF=83=EF=BC=8C=E9=92=B1=E5=8C=85=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .dart_tool/package_config.json | 2 +- lib/pages/main_page/main_page.dart | 8 -- lib/pages/mine_page/mine_page.dart | 110 +++++++++++++++- lib/pages/wallet_page/wallet_page.dart | 121 +++++++++++++++++ lib/pages/wallet_page/wallet_page_bloc.dart | 29 +++++ .../withdraw_page/bloc/withdraw_bloc.dart | 26 ++++ lib/pages/withdraw_page/withdraw_model.dart | 1 + lib/pages/withdraw_page/withdraw_page.dart | 72 +++++++++++ lib/register.dart | 34 +++-- .../{ => home}/home_banner/bloc/bloc.dart | 0 .../home_banner/bloc/home_banner_bloc.dart | 9 +- .../home_banner/bloc/home_banner_event.dart | 0 .../bloc/home_banner_repository.dart | 12 +- .../home_banner/bloc/home_banner_state.dart | 0 .../home_banner/home_banner_creater.dart | 8 +- .../home_banner/home_banner_sk.dart | 0 .../home_banner/home_banner_widget.dart | 28 ++-- .../home_banner/model/HomeBannerModel.dart | 0 .../home_goods/bloc/home_goods_bloc.dart | 8 +- .../bloc/home_goods_header_bloc.dart | 35 +++-- .../{ => home}/home_goods/home_goods.dart | 11 +- .../home_goods/home_goods_creater.dart | 6 +- .../home_goods/home_goods_header.dart | 8 +- .../home_goods/home_goods_item.dart | 16 +-- .../models/home_goods_header_model.dart | 0 .../models/home_goods_header_model.g.dart | 0 .../home_goods/models/home_goods_model.dart | 0 .../home_goods/models/home_goods_model.g.dart | 0 .../models/home_goods_style_model.dart | 0 .../models/home_goods_style_model.g.dart | 0 .../skeleton/home_goods_header_sk.dart | 0 .../skeleton/home_goods_item_sk.dart | 0 .../home_goods/skeleton/home_goods_sk.dart | 2 +- .../home/home_goods_tab/home_goods_tab.dart | 100 ++++++++++++++ .../home_goods_tab_creater.dart | 21 +++ .../home_quick_entry/bloc/bloc.dart | 0 .../bloc/home_quick_entry_bloc.dart | 15 ++- .../bloc/home_quick_entry_event.dart | 0 .../bloc/home_quick_entry_repository.dart | 0 .../bloc/home_quick_entry_state.dart | 0 .../cached_network_image_util.dart | 0 .../home_quick_entry_creater.dart | 0 .../home_quick_entry/home_quick_entry_sk.dart | 0 .../home_quick_entry_widget.dart | 0 .../model/home_quick_entry_model.dart | 0 .../home_slide_banner/bloc/bloc.dart | 0 .../bloc/home_slide_banner_bloc.dart | 24 ++-- .../bloc/home_slide_banner_event.dart | 0 .../bloc/home_slide_banner_repository.dart | 37 ++++++ .../bloc/home_slide_banner_state.dart | 5 +- .../home_slide_banner/home_slide_banner.dart | 0 .../home_slide_banner_creater.dart | 0 .../home_slide_banner_sk.dart | 0 .../model/home_slide_banner_model.dart | 0 .../bloc/home_slide_banner_repository.dart | 34 ----- lib/widgets/mine/mine_data/mine_data.dart | 14 ++ .../mine/mine_data/mine_data_creater.dart | 12 ++ lib/widgets/mine/mine_data/mine_data_sk.dart | 122 ++++++++++++++++++ lib/widgets/mine/mine_header/mine_header.dart | 14 ++ .../mine/mine_header/mine_header_creater.dart | 12 ++ .../mine/mine_header/mine_header_sk.dart | 45 +++++++ .../mine_nav/mine_nav.dart} | 10 +- .../mine_nav/mine_nav_creater.dart} | 6 +- .../mine_nav/mine_nav_sk.dart} | 0 .../bloc/mine_quick_entry_bloc.dart | 2 +- .../mine_quick_entry/mine_quick_entry.dart | 6 +- .../mine_quick_entry_creater.dart | 2 +- .../mine_quick_entry/mine_quick_entry_sk.dart | 6 + .../models/mine_quick_entry_model.dart | 0 lib/widgets/mine_data/mine_data_creater.dart | 0 lib/widgets/mine_data/mine_data_sk.dart | 0 lib/widgets/mine_header/mine_header_sk.dart | 0 lib/widgets/others/mine_header_bg_widget.dart | 2 +- lib/widgets/others/normal_nav/normal_nav.dart | 104 +++++++++++++++ .../others/normal_nav/normal_nav_creater.dart | 21 +++ .../wallet/wallet_data/wallet_data.dart | 13 ++ .../wallet_data/wallet_data_creater.dart | 12 ++ .../wallet/wallet_data/wallet_data_sk.dart | 111 ++++++++++++++++ .../wallet/wallet_detail/wallet_detail.dart | 18 +++ .../wallet_detail/wallet_detail_sk.dart | 34 +++++ .../wallet/wallet_income/wallet_income.dart | 9 ++ .../wallet_income/wallet_income_sk.dart | 104 +++++++++++++++ 82 files changed, 1311 insertions(+), 150 deletions(-) create mode 100644 lib/pages/wallet_page/wallet_page.dart create mode 100644 lib/pages/wallet_page/wallet_page_bloc.dart create mode 100644 lib/pages/withdraw_page/bloc/withdraw_bloc.dart create mode 100644 lib/pages/withdraw_page/withdraw_model.dart create mode 100644 lib/pages/withdraw_page/withdraw_page.dart rename lib/widgets/{ => home}/home_banner/bloc/bloc.dart (100%) rename lib/widgets/{ => home}/home_banner/bloc/home_banner_bloc.dart (83%) rename lib/widgets/{ => home}/home_banner/bloc/home_banner_event.dart (100%) rename lib/widgets/{ => home}/home_banner/bloc/home_banner_repository.dart (73%) rename lib/widgets/{ => home}/home_banner/bloc/home_banner_state.dart (100%) rename lib/widgets/{ => home}/home_banner/home_banner_creater.dart (64%) rename lib/widgets/{ => home}/home_banner/home_banner_sk.dart (100%) rename lib/widgets/{ => home}/home_banner/home_banner_widget.dart (76%) rename lib/widgets/{ => home}/home_banner/model/HomeBannerModel.dart (100%) rename lib/widgets/{ => home}/home_goods/bloc/home_goods_bloc.dart (82%) rename lib/widgets/{ => home}/home_goods/bloc/home_goods_header_bloc.dart (52%) rename lib/widgets/{ => home}/home_goods/home_goods.dart (85%) rename lib/widgets/{ => home}/home_goods/home_goods_creater.dart (78%) rename lib/widgets/{ => home}/home_goods/home_goods_header.dart (93%) rename lib/widgets/{ => home}/home_goods/home_goods_item.dart (92%) rename lib/widgets/{ => home}/home_goods/models/home_goods_header_model.dart (100%) rename lib/widgets/{ => home}/home_goods/models/home_goods_header_model.g.dart (100%) rename lib/widgets/{ => home}/home_goods/models/home_goods_model.dart (100%) rename lib/widgets/{ => home}/home_goods/models/home_goods_model.g.dart (100%) rename lib/widgets/{ => home}/home_goods/models/home_goods_style_model.dart (100%) rename lib/widgets/{ => home}/home_goods/models/home_goods_style_model.g.dart (100%) rename lib/widgets/{ => home}/home_goods/skeleton/home_goods_header_sk.dart (100%) rename lib/widgets/{ => home}/home_goods/skeleton/home_goods_item_sk.dart (100%) rename lib/widgets/{ => home}/home_goods/skeleton/home_goods_sk.dart (83%) create mode 100644 lib/widgets/home/home_goods_tab/home_goods_tab.dart create mode 100644 lib/widgets/home/home_goods_tab/home_goods_tab_creater.dart rename lib/widgets/{ => home}/home_quick_entry/bloc/bloc.dart (100%) rename lib/widgets/{ => home}/home_quick_entry/bloc/home_quick_entry_bloc.dart (69%) rename lib/widgets/{ => home}/home_quick_entry/bloc/home_quick_entry_event.dart (100%) rename lib/widgets/{ => home}/home_quick_entry/bloc/home_quick_entry_repository.dart (100%) rename lib/widgets/{ => home}/home_quick_entry/bloc/home_quick_entry_state.dart (100%) rename lib/widgets/{ => home}/home_quick_entry/cached_network_image_util.dart (100%) rename lib/widgets/{ => home}/home_quick_entry/home_quick_entry_creater.dart (100%) rename lib/widgets/{ => home}/home_quick_entry/home_quick_entry_sk.dart (100%) rename lib/widgets/{ => home}/home_quick_entry/home_quick_entry_widget.dart (100%) rename lib/widgets/{ => home}/home_quick_entry/model/home_quick_entry_model.dart (100%) rename lib/widgets/{ => home}/home_slide_banner/bloc/bloc.dart (100%) rename lib/widgets/{ => home}/home_slide_banner/bloc/home_slide_banner_bloc.dart (51%) rename lib/widgets/{ => home}/home_slide_banner/bloc/home_slide_banner_event.dart (100%) create mode 100644 lib/widgets/home/home_slide_banner/bloc/home_slide_banner_repository.dart rename lib/widgets/{ => home}/home_slide_banner/bloc/home_slide_banner_state.dart (82%) rename lib/widgets/{ => home}/home_slide_banner/home_slide_banner.dart (100%) rename lib/widgets/{ => home}/home_slide_banner/home_slide_banner_creater.dart (100%) rename lib/widgets/{ => home}/home_slide_banner/home_slide_banner_sk.dart (100%) rename lib/widgets/{ => home}/home_slide_banner/model/home_slide_banner_model.dart (100%) delete mode 100644 lib/widgets/home_slide_banner/bloc/home_slide_banner_repository.dart create mode 100644 lib/widgets/mine/mine_data/mine_data.dart create mode 100644 lib/widgets/mine/mine_data/mine_data_creater.dart create mode 100644 lib/widgets/mine/mine_data/mine_data_sk.dart create mode 100644 lib/widgets/mine/mine_header/mine_header.dart create mode 100644 lib/widgets/mine/mine_header/mine_header_creater.dart create mode 100644 lib/widgets/mine/mine_header/mine_header_sk.dart rename lib/widgets/{mine_header/mine_header.dart => mine/mine_nav/mine_nav.dart} (86%) rename lib/widgets/{mine_header/mine_header_creater.dart => mine/mine_nav/mine_nav_creater.dart} (67%) rename lib/widgets/{mine_data/mine_data.dart => mine/mine_nav/mine_nav_sk.dart} (100%) rename lib/widgets/{ => mine}/mine_quick_entry/bloc/mine_quick_entry_bloc.dart (91%) rename lib/widgets/{ => mine}/mine_quick_entry/mine_quick_entry.dart (80%) rename lib/widgets/{ => mine}/mine_quick_entry/mine_quick_entry_creater.dart (74%) rename lib/widgets/{ => mine}/mine_quick_entry/mine_quick_entry_sk.dart (93%) rename lib/widgets/{ => mine}/mine_quick_entry/models/mine_quick_entry_model.dart (100%) delete mode 100644 lib/widgets/mine_data/mine_data_creater.dart delete mode 100644 lib/widgets/mine_data/mine_data_sk.dart delete mode 100644 lib/widgets/mine_header/mine_header_sk.dart create mode 100644 lib/widgets/others/normal_nav/normal_nav.dart create mode 100644 lib/widgets/others/normal_nav/normal_nav_creater.dart create mode 100644 lib/widgets/wallet/wallet_data/wallet_data.dart create mode 100644 lib/widgets/wallet/wallet_data/wallet_data_creater.dart create mode 100644 lib/widgets/wallet/wallet_data/wallet_data_sk.dart create mode 100644 lib/widgets/wallet/wallet_detail/wallet_detail.dart create mode 100644 lib/widgets/wallet/wallet_detail/wallet_detail_sk.dart create mode 100644 lib/widgets/wallet/wallet_income/wallet_income.dart create mode 100644 lib/widgets/wallet/wallet_income/wallet_income_sk.dart diff --git a/.dart_tool/package_config.json b/.dart_tool/package_config.json index fe58bac..2573ab5 100644 --- a/.dart_tool/package_config.json +++ b/.dart_tool/package_config.json @@ -680,7 +680,7 @@ "languageVersion": "2.1" } ], - "generated": "2020-09-08T07:00:40.458603Z", + "generated": "2020-09-10T07:09:00.863118Z", "generator": "pub", "generatorVersion": "2.7.2" } diff --git a/lib/pages/main_page/main_page.dart b/lib/pages/main_page/main_page.dart index ef125ec..1a7af63 100644 --- a/lib/pages/main_page/main_page.dart +++ b/lib/pages/main_page/main_page.dart @@ -26,13 +26,6 @@ class _MainPageState extends State { Widget build(BuildContext context) { return Scaffold( backgroundColor: Color(0xfff9f9f9), -// body: ChangeNotifierProvider( -// create: (context) => MainPageNotifier(), -// child: BlocProvider( -// bloc: MainPageBloc(), -// child: _MainPageContainer(widget.data), -// ), -// ), body: MultiProvider( providers: [ ChangeNotifierProvider.value(value: MainPageNotifier()), @@ -141,7 +134,6 @@ class _MainPageContainerState extends State<_MainPageContainer> { list.addAll(WidgetFactory.create( item.modName, - type: WidgetType.skeleton, isSliver: true, model: data, )); diff --git a/lib/pages/mine_page/mine_page.dart b/lib/pages/mine_page/mine_page.dart index f21b6a1..d03e364 100644 --- a/lib/pages/mine_page/mine_page.dart +++ b/lib/pages/mine_page/mine_page.dart @@ -1,14 +1,120 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:zhiying_base_widget/pages/main_page/main_page.dart'; class MinePage extends StatefulWidget { @override _MinePageState createState() => _MinePageState(); } -class _MinePageState extends State { +class _MinePageState extends State with TickerProviderStateMixin { + TabController _tabController; + Map _datas = Map(); + + @override + void initState() { + _tabController = TabController(length: 3, vsync: this); + // 模拟数据 + List> list = List(); + list.add( + Map.from({'mod_name': 'index_search', 'mod_id': 5})); + list.add( + Map.from({'mod_name': 'index_carousel', 'mod_id': 6})); + list.add(Map.from({'mod_name': 'multi_nav', 'mod_id': 7})); + list.add(Map.from( + {'mod_name': 'index_banner_one', 'mod_id': 8})); + list.add(Map.from( + {'mod_name': 'index_banner_two', 'mod_id': 9})); + list.add(Map.from( + {'mod_name': 'index_recommend_list', 'mod_id': 10})); + _datas['components'] = list; + super.initState(); + } + + @override + void dispose() { + _tabController.dispose(); + super.dispose(); + } + @override Widget build(BuildContext context) { - return Container(); + List _silverBuilder(BuildContext context, bool innerBoxIsScrolled) { + return [ + SliverAppBar(), + SliverPersistentHeader( + pinned: true, + delegate: _SilverAppBarDelegate( + Container( + color: Colors.amber, + child: TabBar( + labelColor: Colors.blue, + unselectedLabelColor: Colors.black, + controller: _tabController, + tabs: [ + new Tab( + text: "tab10", + ), + new Tab( + text: "tab2", + ), + new Tab( + text: "tab3", + ), + ], + ), + ), + ), + ), + ]; + } + + return Scaffold( + body: SafeArea( + child: NestedScrollView( + headerSliverBuilder: _silverBuilder, + body: TabBarView( + controller: _tabController, + children: [ + MainPage(_datas), + ListView.builder( + itemCount: 50, + itemBuilder: (context, count) { + return Container( + height: 50, + color: Colors.primaries[count % Colors.primaries.length], + child: Text('aaaaa ${count.toString()}'), + ); + }), + MainPage(_datas), + ], + ), + )), + ); + } +} + +class _SilverAppBarDelegate extends SliverPersistentHeaderDelegate { + _SilverAppBarDelegate(this.child); + + final Widget child; + + @override + double get minExtent => 44; + + @override + double get maxExtent => 44; + + @override + Widget build( + BuildContext context, double shrinkOffset, bool overlapsContent) { + return new Container( + child: child, + ); + } + + @override + bool shouldRebuild(SliverPersistentHeaderDelegate oldDelegate) { + return false; } } diff --git a/lib/pages/wallet_page/wallet_page.dart b/lib/pages/wallet_page/wallet_page.dart new file mode 100644 index 0000000..ba71a1a --- /dev/null +++ b/lib/pages/wallet_page/wallet_page.dart @@ -0,0 +1,121 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; +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/widgets/others/mine_header_bg_widget.dart'; +import 'package:zhiying_comm/zhiying_comm.dart'; + +class WalletPage extends StatefulWidget { + @override + _WalletPageState createState() => _WalletPageState(); +} + +class _WalletPageState extends State { + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: Color(0xfff9f9f9), + body: MultiProvider( + providers: [ + ChangeNotifierProvider.value(value: MainPageNotifier()), + ChangeNotifierProvider.value(value: MainPageBgNotifier()), + ], + child: _WalletPageContainer(), + ), + ); + } +} + +class _WalletPageContainer extends StatefulWidget { + _WalletPageContainer({Key key}) : super(key: key); + + @override + _WalletPageContainerState createState() => _WalletPageContainerState(); +} + +class _WalletPageContainerState extends State<_WalletPageContainer> { + final ScrollController _controller = ScrollController(); + final RefreshController _refreshController = + RefreshController(initialRefresh: false); + + @override + void initState() { + super.initState(); + } + + void _onLoading() async { + // await Future.delayed(Duration(milliseconds: 1000)); + // if (mounted) setState(() {}); + // _refreshController.loadComplete(); + } + + @override + Widget build(BuildContext context) { + return SmartRefresher( + controller: _refreshController, + enablePullDown: false, + enablePullUp: false, + header: WaterDropHeader(), + onLoading: _onLoading, + child: Container( + width: double.infinity, + child: Stack( + fit: StackFit.passthrough, + children: [ + MineHeaderBgWidget( + controller: _controller, + ), + CustomScrollView( + slivers: _createContent(context), + ), + Center( + child: FlatButton( + child: Text( + 'aaaaaa', + style: TextStyle(color: Colors.black), + ), + onPressed: () { + Provider.of(context, listen: false) + .switchBg(Container( + width: double.infinity, + height: 200, + color: Colors.purpleAccent, + )); + }, + ), + ) + ], + ), + ), + ); + } + + List _createContent(BuildContext context) { + List list = List(); + + list.addAll(WidgetFactory.create( + 'normal_nav', + isSliver: true, + model: Map(), + )); + list.addAll(WidgetFactory.create( + 'wallet_data', + isSliver: true, + model: Map(), + )); + list.addAll(WidgetFactory.create( + 'wallet_detail', + isSliver: true, + model: Map(), + )); + + list.addAll(WidgetFactory.create( + 'wallet_income', + isSliver: true, + model: Map(), + )); + return list; + } +} diff --git a/lib/pages/wallet_page/wallet_page_bloc.dart b/lib/pages/wallet_page/wallet_page_bloc.dart new file mode 100644 index 0000000..af99197 --- /dev/null +++ b/lib/pages/wallet_page/wallet_page_bloc.dart @@ -0,0 +1,29 @@ +import 'dart:async'; + +import 'package:zhiying_comm/util/base_bloc.dart'; +import 'package:zhiying_comm/zhiying_comm.dart'; + +class WalletPageBloc extends BlocBase { + List> _tabs = List(); + + StreamController>> _tabController = + StreamController>>(); + + Stream>> get outData => _tabController.stream; + + @override + void dispose() { + _tabController.close(); + _tabController = null; + } + + void refresh() { + NetUtil.request('/api/v1/config.json', onSuccess: (data) { + List list = data; + _tabs = list.map((item) { + return Map.from(item); + }).toList(); + _tabController.add(_tabs); + }); + } +} diff --git a/lib/pages/withdraw_page/bloc/withdraw_bloc.dart b/lib/pages/withdraw_page/bloc/withdraw_bloc.dart new file mode 100644 index 0000000..41593aa --- /dev/null +++ b/lib/pages/withdraw_page/bloc/withdraw_bloc.dart @@ -0,0 +1,26 @@ +import 'dart:async'; + +import 'package:zhiying_base_widget/pages/withdraw_page/withdraw_model.dart'; +import 'package:zhiying_comm/util/base_bloc.dart'; +import 'package:zhiying_comm/zhiying_comm.dart'; + +class WithdrawBloc extends BlocBase { + WithdrawModel model; + + StreamController _dataController = + StreamController(); + + Stream get outData => _dataController.stream; + + @override + void dispose() { + _dataController.close(); + _dataController = null; + } + + void refresh() { + NetUtil.request('/api/v1/config.json', onSuccess: (data) { + _dataController.add(model); + }); + } +} diff --git a/lib/pages/withdraw_page/withdraw_model.dart b/lib/pages/withdraw_page/withdraw_model.dart new file mode 100644 index 0000000..5c7dfc1 --- /dev/null +++ b/lib/pages/withdraw_page/withdraw_model.dart @@ -0,0 +1 @@ +class WithdrawModel {} diff --git a/lib/pages/withdraw_page/withdraw_page.dart b/lib/pages/withdraw_page/withdraw_page.dart new file mode 100644 index 0000000..dd30c91 --- /dev/null +++ b/lib/pages/withdraw_page/withdraw_page.dart @@ -0,0 +1,72 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + +/*提现页面*/ +class WithdrawPage extends StatefulWidget { + @override + _WithdrawPageState createState() => _WithdrawPageState(); +} + +class _WithdrawPageState extends State { + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: _createNav(), + body: SafeArea( + child: _WithdrawContainer(), + ), + ); + } + + // 导航栏 + Widget _createNav() { + return CupertinoNavigationBar( + 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), + ), + ), + trailing: GestureDetector( + child: Text( + '明细', + style: TextStyle(fontSize: 13, color: Color(0xff333333)), + ), + onTap: () {}, + ), + ); + } +} + +class _WithdrawContainer extends StatefulWidget { + @override + _WithdrawContainerState createState() => _WithdrawContainerState(); +} + +class _WithdrawContainerState extends State<_WithdrawContainer> { + @override + Widget build(BuildContext context) { + return SingleChildScrollView( + child: Column( + children: [], + ), + ); + } +} diff --git a/lib/register.dart b/lib/register.dart index 6248770..b14d4ff 100644 --- a/lib/register.dart +++ b/lib/register.dart @@ -1,11 +1,16 @@ import 'package:zhiying_base_widget/pages/home_page/home_page.dart'; import 'package:zhiying_base_widget/pages/login_page/login_page.dart'; import 'package:zhiying_base_widget/pages/main_page/main_page.dart'; -import 'package:zhiying_base_widget/widgets/home_banner/home_banner_creater.dart'; -import 'package:zhiying_base_widget/widgets/home_goods/home_goods_creater.dart'; -import 'package:zhiying_base_widget/widgets/home_quick_entry/home_quick_entry_creater.dart'; -import 'package:zhiying_base_widget/widgets/home_slide_banner/home_slide_banner_creater.dart'; -import 'package:zhiying_base_widget/widgets/mine_header/mine_header_creater.dart'; +import 'package:zhiying_base_widget/pages/wallet_page/wallet_page.dart'; +import 'package:zhiying_base_widget/widgets/home/home_banner/home_banner_creater.dart'; +import 'package:zhiying_base_widget/widgets/home/home_goods/home_goods_creater.dart'; +import 'package:zhiying_base_widget/widgets/home/home_quick_entry/home_quick_entry_creater.dart'; +import 'package:zhiying_base_widget/widgets/home/home_slide_banner/home_slide_banner_creater.dart'; +import 'package:zhiying_base_widget/widgets/mine/mine_header/mine_header.dart'; +import 'package:zhiying_base_widget/widgets/others/normal_nav/normal_nav_creater.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_comm/zhiying_comm.dart'; class BaseWidgetRegister { @@ -20,10 +25,15 @@ class BaseWidgetRegister { PageFactory.regist('homePage', (model) => HomePage()); PageFactory.regist('index', (model) => MainPage(model)); PageFactory.regist('login', (model) => LoginPage(model)); + PageFactory.regist('category', (model) => WalletPage()); } // 注册控件 static void registWidgets() { + // ==================== 通用组件 + // 导航栏 + WidgetFactory.regist('normal_nav', NormalNavCreater()); + // ==================== 首页 /// 可滚动banner WidgetFactory.regist('index_carousel', HomeSlideBannerCreater()); @@ -39,8 +49,16 @@ class BaseWidgetRegister { WidgetFactory.regist('index_banner_two', HomeBannerCreater()); // ==================== 个人中心 - WidgetFactory.regist('index_title', MineHeaderCreater()); -// WidgetFactory.regist('index_search', MineHeaderBgCreater()); -// WidgetFactory.regist('index_search', MineQuickEntryCreater()); + WidgetFactory.regist( + 'index_title', DefaultWidgetCreater((model) => MineHeader())); + + // ==================== 钱包 + WidgetFactory.regist( + 'wallet_data', DefaultWidgetCreater((model) => WalletData())); + WidgetFactory.regist( + 'wallet_detail', DefaultWidgetCreater((model) => WalletDetail())); + + WidgetFactory.regist( + 'wallet_income', DefaultWidgetCreater((model) => WalletIncome())); } } diff --git a/lib/widgets/home_banner/bloc/bloc.dart b/lib/widgets/home/home_banner/bloc/bloc.dart similarity index 100% rename from lib/widgets/home_banner/bloc/bloc.dart rename to lib/widgets/home/home_banner/bloc/bloc.dart diff --git a/lib/widgets/home_banner/bloc/home_banner_bloc.dart b/lib/widgets/home/home_banner/bloc/home_banner_bloc.dart similarity index 83% rename from lib/widgets/home_banner/bloc/home_banner_bloc.dart rename to lib/widgets/home/home_banner/bloc/home_banner_bloc.dart index c36ad57..99deb0a 100644 --- a/lib/widgets/home_banner/bloc/home_banner_bloc.dart +++ b/lib/widgets/home/home_banner/bloc/home_banner_bloc.dart @@ -1,10 +1,12 @@ import 'dart:async'; + import 'package:bloc/bloc.dart'; import 'package:flutter/cupertino.dart'; -import 'package:zhiying_base_widget/widgets/home_banner/bloc/home_banner_repository.dart'; -import './bloc.dart'; +import 'package:zhiying_base_widget/widgets/home/home_banner/bloc/home_banner_repository.dart'; import 'package:zhiying_comm/util/empty_util.dart'; +import './bloc.dart'; + class HomeBannerBloc extends Bloc { HomeBannerRepository repository; @@ -24,7 +26,8 @@ class HomeBannerBloc extends Bloc { } /// 初始化 - Stream _mapHomeBannerInitEventToState(HomeBannerInitEvent event) async* { + Stream _mapHomeBannerInitEventToState( + HomeBannerInitEvent event) async* { var cache = await repository.fetchCacheData(modId: event.model['mod_id']); if (!EmptyUtil.isEmpty(cache)) yield HomeBannerCacheState(); var result = await repository.fetchNetData(modId: event.model['mod_id']); diff --git a/lib/widgets/home_banner/bloc/home_banner_event.dart b/lib/widgets/home/home_banner/bloc/home_banner_event.dart similarity index 100% rename from lib/widgets/home_banner/bloc/home_banner_event.dart rename to lib/widgets/home/home_banner/bloc/home_banner_event.dart diff --git a/lib/widgets/home_banner/bloc/home_banner_repository.dart b/lib/widgets/home/home_banner/bloc/home_banner_repository.dart similarity index 73% rename from lib/widgets/home_banner/bloc/home_banner_repository.dart rename to lib/widgets/home/home_banner/bloc/home_banner_repository.dart index 89292b3..701488a 100644 --- a/lib/widgets/home_banner/bloc/home_banner_repository.dart +++ b/lib/widgets/home/home_banner/bloc/home_banner_repository.dart @@ -1,12 +1,14 @@ import 'package:flutter/cupertino.dart'; -import 'package:zhiying_base_widget/widgets/home_banner/model/HomeBannerModel.dart'; -import 'package:zhiying_comm/util/net_util.dart'; +import 'package:zhiying_base_widget/widgets/home/home_banner/model/HomeBannerModel.dart'; import 'package:zhiying_comm/util/empty_util.dart'; +import 'package:zhiying_comm/util/net_util.dart'; class HomeBannerRepository { /// 读取缓存数据 Future fetchCacheData({@required int modId}) async { - var reult = await NetUtil.getRequestCachedData('/api/v1/mod', params: {'ids': [modId]}); + var reult = await NetUtil.getRequestCachedData('/api/v1/mod', params: { + 'ids': [modId] + }); if (!EmptyUtil.isEmpty(reult)) { return HomeBannerModel(); } @@ -15,7 +17,9 @@ class HomeBannerRepository { /// 获取网路数据 Future fetchNetData({@required int modId}) async { - var result = await NetUtil.post('/api/v1/mod', params: {'ids': [modId]}); + var result = await NetUtil.post('/api/v1/mod', params: { + 'ids': [modId] + }); if (NetUtil.isSuccess(result)) { return HomeBannerModel(); } diff --git a/lib/widgets/home_banner/bloc/home_banner_state.dart b/lib/widgets/home/home_banner/bloc/home_banner_state.dart similarity index 100% rename from lib/widgets/home_banner/bloc/home_banner_state.dart rename to lib/widgets/home/home_banner/bloc/home_banner_state.dart diff --git a/lib/widgets/home_banner/home_banner_creater.dart b/lib/widgets/home/home_banner/home_banner_creater.dart similarity index 64% rename from lib/widgets/home_banner/home_banner_creater.dart rename to lib/widgets/home/home_banner/home_banner_creater.dart index 187932e..c5e1309 100644 --- a/lib/widgets/home_banner/home_banner_creater.dart +++ b/lib/widgets/home/home_banner/home_banner_creater.dart @@ -1,15 +1,13 @@ - import 'package:flutter/src/widgets/framework.dart'; -import 'package:zhiying_base_widget/widgets/home_banner/home_banner_widget.dart'; +import 'package:zhiying_base_widget/widgets/home/home_banner/home_banner_widget.dart'; import 'package:zhiying_comm/zhiying_comm.dart'; - /// /// 不可滚动Banner /// -class HomeBannerCreater extends WidgetCreater{ +class HomeBannerCreater extends WidgetCreater { @override List createWidgets(Map model) { return [HomeBannerWidget(model)]; } -} \ No newline at end of file +} diff --git a/lib/widgets/home_banner/home_banner_sk.dart b/lib/widgets/home/home_banner/home_banner_sk.dart similarity index 100% rename from lib/widgets/home_banner/home_banner_sk.dart rename to lib/widgets/home/home_banner/home_banner_sk.dart diff --git a/lib/widgets/home_banner/home_banner_widget.dart b/lib/widgets/home/home_banner/home_banner_widget.dart similarity index 76% rename from lib/widgets/home_banner/home_banner_widget.dart rename to lib/widgets/home/home_banner/home_banner_widget.dart index ea8a928..008fea0 100644 --- a/lib/widgets/home_banner/home_banner_widget.dart +++ b/lib/widgets/home/home_banner/home_banner_widget.dart @@ -1,8 +1,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:zhiying_base_widget/widgets/home_banner/bloc/bloc.dart'; -import 'package:zhiying_base_widget/widgets/home_banner/bloc/home_banner_repository.dart'; -import 'package:zhiying_base_widget/widgets/home_banner/home_banner_sk.dart'; +import 'package:zhiying_base_widget/widgets/home/home_banner/bloc/bloc.dart'; +import 'package:zhiying_base_widget/widgets/home/home_banner/bloc/home_banner_repository.dart'; +import 'package:zhiying_base_widget/widgets/home/home_banner/home_banner_sk.dart'; import 'package:zhiying_comm/zhiying_comm.dart'; /// @@ -21,7 +21,8 @@ class _HomeBannerWidgetState extends State { @override Widget build(BuildContext context) { return BlocProvider( - create: (_) => HomeBannerBloc(repository: HomeBannerRepository())..add(HomeBannerInitEvent(widget.model)), + create: (_) => HomeBannerBloc(repository: HomeBannerRepository()) + ..add(HomeBannerInitEvent(widget.model)), child: HomeBannerContainer( model: widget.model, ), @@ -50,13 +51,16 @@ class _HomeBannerContainerState extends State { return true; }, builder: (context, state) { - print(state); if (state is HomeBannerLoadedState) { - return ItemWidget(data: [1,2,3],); + return ItemWidget( + data: [1, 2, 3], + ); } if (state is HomeBannerCacheState) { - return ItemWidget(data: [1,2],); + return ItemWidget( + data: [1, 2], + ); } return HomeBannerSkeleton(widget.model); @@ -66,8 +70,8 @@ class _HomeBannerContainerState extends State { } class ItemWidget extends StatelessWidget { - final List data; + ItemWidget({this.data}); @override @@ -76,15 +80,14 @@ class ItemWidget extends StatelessWidget { height: 180.h, margin: EdgeInsets.only(top: 7.5, left: 2.5, right: 2.5), child: Row( - children:data.map((index){ + children: data.map((index) { return Flexible( flex: 1, child: Container( - margin: EdgeInsets.only( left: 5, right: 5), + margin: EdgeInsets.only(left: 5, right: 5), decoration: BoxDecoration( color: Colors.lightBlue, - borderRadius: BorderRadius.circular(7.5) - ), + borderRadius: BorderRadius.circular(7.5)), ), ); }).toList(), @@ -92,4 +95,3 @@ class ItemWidget extends StatelessWidget { ); } } - diff --git a/lib/widgets/home_banner/model/HomeBannerModel.dart b/lib/widgets/home/home_banner/model/HomeBannerModel.dart similarity index 100% rename from lib/widgets/home_banner/model/HomeBannerModel.dart rename to lib/widgets/home/home_banner/model/HomeBannerModel.dart diff --git a/lib/widgets/home_goods/bloc/home_goods_bloc.dart b/lib/widgets/home/home_goods/bloc/home_goods_bloc.dart similarity index 82% rename from lib/widgets/home_goods/bloc/home_goods_bloc.dart rename to lib/widgets/home/home_goods/bloc/home_goods_bloc.dart index 9682e79..bb74290 100644 --- a/lib/widgets/home_goods/bloc/home_goods_bloc.dart +++ b/lib/widgets/home/home_goods/bloc/home_goods_bloc.dart @@ -1,13 +1,12 @@ import 'dart:async'; -import 'package:zhiying_base_widget/widgets/home_goods/models/home_goods_model.dart'; -import 'package:zhiying_base_widget/widgets/home_goods/models/home_goods_style_model.dart'; +import 'package:zhiying_base_widget/widgets/home/home_goods/models/home_goods_model.dart'; +import 'package:zhiying_base_widget/widgets/home/home_goods/models/home_goods_style_model.dart'; import 'package:zhiying_comm/util/base_bloc.dart'; import 'package:zhiying_comm/zhiying_comm.dart'; class HomeGoodsBloc extends BlocBase { List _goods = List(); - String storeName = ''; HomeGoodsStyleModel style; String _provider = ''; @@ -54,9 +53,6 @@ class HomeGoodsBloc extends BlocBase { style = HomeGoodsStyleModel.fromJson( Map.from(json['style'])); } - if (json.containsKey('provider_name')) { - storeName = json['provider_name'].toString(); - } _goodsController.add(_goods); }); diff --git a/lib/widgets/home_goods/bloc/home_goods_header_bloc.dart b/lib/widgets/home/home_goods/bloc/home_goods_header_bloc.dart similarity index 52% rename from lib/widgets/home_goods/bloc/home_goods_header_bloc.dart rename to lib/widgets/home/home_goods/bloc/home_goods_header_bloc.dart index accece6..b2e79d7 100644 --- a/lib/widgets/home_goods/bloc/home_goods_header_bloc.dart +++ b/lib/widgets/home/home_goods/bloc/home_goods_header_bloc.dart @@ -1,14 +1,15 @@ import 'dart:async'; -import 'package:zhiying_base_widget/widgets/home_goods/models/home_goods_header_model.dart'; -import 'package:zhiying_comm/zhiying_comm.dart'; +import 'package:zhiying_base_widget/widgets/home/home_goods/models/home_goods_header_model.dart'; import 'package:zhiying_comm/util/base_bloc.dart'; +import 'package:zhiying_comm/zhiying_comm.dart'; class HomeGoodsHeaderBloc extends BlocBase { List _tabs = List(); StreamController> _tabController = StreamController>(); + Stream> get outData => _tabController.stream; @override @@ -22,19 +23,25 @@ class HomeGoodsHeaderBloc extends BlocBase { method: NetMethod.POST, params: Map.from({ 'ids': [id] - }), - onCache: (data) {}, onSuccess: (data) { - String key = id.toString(); - - Map json = Map.from(data); - if (json.containsKey(key)) { - List list = json[key]; - _tabs = list.map((item) { - return HomeGoodsHeaderModel.fromJson(Map.from(item)); - }).toList(); + }), onCache: (data) { + if (data != null) { + _loadData(id, data); } - - _tabController.add(_tabs); + }, onSuccess: (data) { + _loadData(id, data); }); } + + void _loadData(int id, dynamic data) { + String key = id.toString(); + Map json = Map.from(data); + if (json.containsKey(key)) { + List list = json[key]; + _tabs = list.map((item) { + return HomeGoodsHeaderModel.fromJson(Map.from(item)); + }).toList(); + } + + _tabController.add(_tabs); + } } diff --git a/lib/widgets/home_goods/home_goods.dart b/lib/widgets/home/home_goods/home_goods.dart similarity index 85% rename from lib/widgets/home_goods/home_goods.dart rename to lib/widgets/home/home_goods/home_goods.dart index d0369f6..f72860d 100644 --- a/lib/widgets/home_goods/home_goods.dart +++ b/lib/widgets/home/home_goods/home_goods.dart @@ -3,11 +3,11 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:zhiying_base_widget/pages/main_page/notifier/main_page_notifier.dart'; -import 'package:zhiying_base_widget/widgets/home_goods/bloc/home_goods_bloc.dart'; -import 'package:zhiying_base_widget/widgets/home_goods/home_goods_creater.dart'; -import 'package:zhiying_base_widget/widgets/home_goods/home_goods_item.dart'; -import 'package:zhiying_base_widget/widgets/home_goods/models/home_goods_model.dart'; -import 'package:zhiying_base_widget/widgets/home_goods/skeleton/home_goods_sk.dart'; +import 'package:zhiying_base_widget/widgets/home/home_goods/bloc/home_goods_bloc.dart'; +import 'package:zhiying_base_widget/widgets/home/home_goods/home_goods_creater.dart'; +import 'package:zhiying_base_widget/widgets/home/home_goods/home_goods_item.dart'; +import 'package:zhiying_base_widget/widgets/home/home_goods/models/home_goods_model.dart'; +import 'package:zhiying_base_widget/widgets/home/home_goods/skeleton/home_goods_sk.dart'; import 'package:zhiying_comm/util/base_bloc.dart'; class HomeGoods extends StatefulWidget { @@ -92,7 +92,6 @@ class _HomeGoodsContainerState extends State<_HomeGoodsContainer> { goods[index], _bloc.style, data: widget.data, - shop: _bloc.storeName, ); }); }, diff --git a/lib/widgets/home_goods/home_goods_creater.dart b/lib/widgets/home/home_goods/home_goods_creater.dart similarity index 78% rename from lib/widgets/home_goods/home_goods_creater.dart rename to lib/widgets/home/home_goods/home_goods_creater.dart index 235c2a7..2e2e5c3 100644 --- a/lib/widgets/home_goods/home_goods_creater.dart +++ b/lib/widgets/home/home_goods/home_goods_creater.dart @@ -1,8 +1,8 @@ import 'package:event_bus/event_bus.dart'; import 'package:flutter/material.dart'; -import 'package:zhiying_base_widget/widgets/home_goods/bloc/home_goods_header_bloc.dart'; -import 'package:zhiying_base_widget/widgets/home_goods/home_goods.dart'; -import 'package:zhiying_base_widget/widgets/home_goods/home_goods_header.dart'; +import 'package:zhiying_base_widget/widgets/home/home_goods/bloc/home_goods_header_bloc.dart'; +import 'package:zhiying_base_widget/widgets/home/home_goods/home_goods.dart'; +import 'package:zhiying_base_widget/widgets/home/home_goods/home_goods_header.dart'; import 'package:zhiying_comm/util/base_bloc.dart'; import 'package:zhiying_comm/zhiying_comm.dart'; diff --git a/lib/widgets/home_goods/home_goods_header.dart b/lib/widgets/home/home_goods/home_goods_header.dart similarity index 93% rename from lib/widgets/home_goods/home_goods_header.dart rename to lib/widgets/home/home_goods/home_goods_header.dart index 6c8a35d..1ecfd48 100644 --- a/lib/widgets/home_goods/home_goods_header.dart +++ b/lib/widgets/home/home_goods/home_goods_header.dart @@ -1,10 +1,10 @@ import 'package:event_bus/event_bus.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:zhiying_base_widget/widgets/home_goods/bloc/home_goods_header_bloc.dart'; -import 'package:zhiying_base_widget/widgets/home_goods/home_goods_creater.dart'; -import 'package:zhiying_base_widget/widgets/home_goods/models/home_goods_header_model.dart'; -import 'package:zhiying_base_widget/widgets/home_goods/skeleton/home_goods_header_sk.dart'; +import 'package:zhiying_base_widget/widgets/home/home_goods/bloc/home_goods_header_bloc.dart'; +import 'package:zhiying_base_widget/widgets/home/home_goods/home_goods_creater.dart'; +import 'package:zhiying_base_widget/widgets/home/home_goods/models/home_goods_header_model.dart'; +import 'package:zhiying_base_widget/widgets/home/home_goods/skeleton/home_goods_header_sk.dart'; import 'package:zhiying_comm/util/base_bloc.dart'; import 'package:zhiying_comm/zhiying_comm.dart'; diff --git a/lib/widgets/home_goods/home_goods_item.dart b/lib/widgets/home/home_goods/home_goods_item.dart similarity index 92% rename from lib/widgets/home_goods/home_goods_item.dart rename to lib/widgets/home/home_goods/home_goods_item.dart index 745ab4e..78a2b38 100644 --- a/lib/widgets/home_goods/home_goods_item.dart +++ b/lib/widgets/home/home_goods/home_goods_item.dart @@ -2,18 +2,17 @@ import 'dart:convert'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; -import 'package:zhiying_base_widget/widgets/home_goods/models/home_goods_model.dart'; -import 'package:zhiying_base_widget/widgets/home_goods/models/home_goods_style_model.dart'; +import 'package:zhiying_base_widget/widgets/home/home_goods/models/home_goods_model.dart'; +import 'package:zhiying_base_widget/widgets/home/home_goods/models/home_goods_style_model.dart'; import 'package:zhiying_comm/zhiying_comm.dart'; // ignore: must_be_immutable class HomeGoodsItem extends StatelessWidget { final HomeGoodsModel goods; final HomeGoodsStyleModel style; - final String shop; Map data; - HomeGoodsItem(this.goods, this.style, {Key key, this.data, this.shop}) + HomeGoodsItem(this.goods, this.style, {Key key, this.data}) : super(key: key) { if (this.data != null && this.data.containsKey('data')) { String data = this.data['data']; @@ -71,21 +70,22 @@ class HomeGoodsItem extends StatelessWidget { Widget _createTitle() { List list = List(); - if (shop != null && shop != '') { + if (goods.providerName != null && goods.providerName != '') { list.add(WidgetSpan( child: Container( padding: EdgeInsets.only(left: 2, right: 2, top: 3, bottom: 3), margin: EdgeInsets.only(right: 4), child: Text( - shop, + goods.providerName, style: TextStyle( fontSize: 9, height: 1, - color: HexColor.fromHex('#ffffff'), + color: HexColor.fromHex(style.providerNameColor), ), ), decoration: BoxDecoration( - color: Colors.red, borderRadius: BorderRadius.circular(2.5)), + color: HexColor.fromHex(style.providerNameBackgroundColor), + borderRadius: BorderRadius.circular(2.5)), ), )); } diff --git a/lib/widgets/home_goods/models/home_goods_header_model.dart b/lib/widgets/home/home_goods/models/home_goods_header_model.dart similarity index 100% rename from lib/widgets/home_goods/models/home_goods_header_model.dart rename to lib/widgets/home/home_goods/models/home_goods_header_model.dart diff --git a/lib/widgets/home_goods/models/home_goods_header_model.g.dart b/lib/widgets/home/home_goods/models/home_goods_header_model.g.dart similarity index 100% rename from lib/widgets/home_goods/models/home_goods_header_model.g.dart rename to lib/widgets/home/home_goods/models/home_goods_header_model.g.dart diff --git a/lib/widgets/home_goods/models/home_goods_model.dart b/lib/widgets/home/home_goods/models/home_goods_model.dart similarity index 100% rename from lib/widgets/home_goods/models/home_goods_model.dart rename to lib/widgets/home/home_goods/models/home_goods_model.dart diff --git a/lib/widgets/home_goods/models/home_goods_model.g.dart b/lib/widgets/home/home_goods/models/home_goods_model.g.dart similarity index 100% rename from lib/widgets/home_goods/models/home_goods_model.g.dart rename to lib/widgets/home/home_goods/models/home_goods_model.g.dart diff --git a/lib/widgets/home_goods/models/home_goods_style_model.dart b/lib/widgets/home/home_goods/models/home_goods_style_model.dart similarity index 100% rename from lib/widgets/home_goods/models/home_goods_style_model.dart rename to lib/widgets/home/home_goods/models/home_goods_style_model.dart diff --git a/lib/widgets/home_goods/models/home_goods_style_model.g.dart b/lib/widgets/home/home_goods/models/home_goods_style_model.g.dart similarity index 100% rename from lib/widgets/home_goods/models/home_goods_style_model.g.dart rename to lib/widgets/home/home_goods/models/home_goods_style_model.g.dart diff --git a/lib/widgets/home_goods/skeleton/home_goods_header_sk.dart b/lib/widgets/home/home_goods/skeleton/home_goods_header_sk.dart similarity index 100% rename from lib/widgets/home_goods/skeleton/home_goods_header_sk.dart rename to lib/widgets/home/home_goods/skeleton/home_goods_header_sk.dart diff --git a/lib/widgets/home_goods/skeleton/home_goods_item_sk.dart b/lib/widgets/home/home_goods/skeleton/home_goods_item_sk.dart similarity index 100% rename from lib/widgets/home_goods/skeleton/home_goods_item_sk.dart rename to lib/widgets/home/home_goods/skeleton/home_goods_item_sk.dart diff --git a/lib/widgets/home_goods/skeleton/home_goods_sk.dart b/lib/widgets/home/home_goods/skeleton/home_goods_sk.dart similarity index 83% rename from lib/widgets/home_goods/skeleton/home_goods_sk.dart rename to lib/widgets/home/home_goods/skeleton/home_goods_sk.dart index 6f31e6d..9fa3f8c 100644 --- a/lib/widgets/home_goods/skeleton/home_goods_sk.dart +++ b/lib/widgets/home/home_goods/skeleton/home_goods_sk.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:zhiying_base_widget/widgets/home_goods/skeleton/home_goods_item_sk.dart'; +import 'package:zhiying_base_widget/widgets/home/home_goods/skeleton/home_goods_item_sk.dart'; class HomeGoodsSkeleton extends StatelessWidget { const HomeGoodsSkeleton({Key key}) : super(key: key); diff --git a/lib/widgets/home/home_goods_tab/home_goods_tab.dart b/lib/widgets/home/home_goods_tab/home_goods_tab.dart new file mode 100644 index 0000000..43cdf49 --- /dev/null +++ b/lib/widgets/home/home_goods_tab/home_goods_tab.dart @@ -0,0 +1,100 @@ +import 'package:flutter/material.dart'; + +class HomeGoodsTab extends StatefulWidget { + @override + _HomeGoodsTabState createState() => _HomeGoodsTabState(); +} + +class _HomeGoodsTabState extends State + with TickerProviderStateMixin { + TabController _tabController; + + @override + void initState() { + _tabController = TabController(length: 3, vsync: this); + super.initState(); + } + + @override + Widget build(BuildContext context) { + List _silverBuilder(BuildContext context, bool innerBoxIsScrolled) { + return [ + SliverAppBar(), + SliverPersistentHeader( + pinned: true, + delegate: _SilverAppBarDelegate( + Container( + color: Colors.amber, + child: TabBar( + labelColor: Colors.blue, + unselectedLabelColor: Colors.black, + controller: _tabController, + tabs: [ + new Tab( + text: "tab1", + ), + new Tab( + text: "tab2", + ), + new Tab( + text: "tab3", + ), + ], + ), + ), + ), + ), + ]; + } + + return SliverPersistentHeader( + pinned: true, + delegate: _SilverAppBarDelegate( + Container( + color: Colors.amber, + child: TabBar( + labelColor: Colors.blue, + unselectedLabelColor: Colors.black, + controller: _tabController, + tabs: [ + new Tab( + text: "tab1", + ), + new Tab( + text: "tab2", + ), + new Tab( + text: "tab3", + ), + ], + ), + ), + ), + ); + } +} + +class _SilverAppBarDelegate extends SliverPersistentHeaderDelegate { + _SilverAppBarDelegate(this.child); + + final Widget child; + + @override + double get minExtent => 44; + + @override + double get maxExtent => 44; + + @override + Widget build( + BuildContext context, double shrinkOffset, bool overlapsContent) { + return new Container( + child: child, + ); + } + + @override + bool shouldRebuild(SliverPersistentHeaderDelegate oldDelegate) { + return false; + } +} diff --git a/lib/widgets/home/home_goods_tab/home_goods_tab_creater.dart b/lib/widgets/home/home_goods_tab/home_goods_tab_creater.dart new file mode 100644 index 0000000..5636c0d --- /dev/null +++ b/lib/widgets/home/home_goods_tab/home_goods_tab_creater.dart @@ -0,0 +1,21 @@ +import 'package:event_bus/event_bus.dart'; +import 'package:flutter/material.dart'; +import 'package:zhiying_comm/zhiying_comm.dart'; + +class HomeGoodsTabCreater extends WidgetCreater { + final EventBus _eventBus = EventBus(); + + @override + List createWidgets(Map model) { + print('创建商品列表'); + + return [ +// TestPage(), + ]; + } + + @override + bool isSliverChild() { + return false; + } +} diff --git a/lib/widgets/home_quick_entry/bloc/bloc.dart b/lib/widgets/home/home_quick_entry/bloc/bloc.dart similarity index 100% rename from lib/widgets/home_quick_entry/bloc/bloc.dart rename to lib/widgets/home/home_quick_entry/bloc/bloc.dart diff --git a/lib/widgets/home_quick_entry/bloc/home_quick_entry_bloc.dart b/lib/widgets/home/home_quick_entry/bloc/home_quick_entry_bloc.dart similarity index 69% rename from lib/widgets/home_quick_entry/bloc/home_quick_entry_bloc.dart rename to lib/widgets/home/home_quick_entry/bloc/home_quick_entry_bloc.dart index 76fc8d9..55245d4 100644 --- a/lib/widgets/home_quick_entry/bloc/home_quick_entry_bloc.dart +++ b/lib/widgets/home/home_quick_entry/bloc/home_quick_entry_bloc.dart @@ -1,11 +1,14 @@ import 'dart:async'; + import 'package:bloc/bloc.dart'; import 'package:flutter/cupertino.dart'; -import 'package:zhiying_base_widget/widgets/home_quick_entry/bloc/home_quick_entry_repository.dart'; -import './bloc.dart'; +import 'package:zhiying_base_widget/widgets/home/home_quick_entry/bloc/home_quick_entry_repository.dart'; import 'package:zhiying_comm/util/empty_util.dart'; -class HomeQuickEntryBloc extends Bloc { +import './bloc.dart'; + +class HomeQuickEntryBloc + extends Bloc { HomeQuickEntryRepository repository; HomeQuickEntryBloc({@required this.repository}); @@ -14,7 +17,8 @@ class HomeQuickEntryBloc extends Bloc HomeQuickEntryState get initialState => InitialHomeQuickEntryState(); @override - Stream mapEventToState(HomeQuickEntryEvent event) async* { + Stream mapEventToState( + HomeQuickEntryEvent event) async* { final currentState = state; if (event is HomeQuickEntryInitEvent) { yield* _mapHomeQuickEntryInitToState(event); @@ -22,7 +26,8 @@ class HomeQuickEntryBloc extends Bloc } /// 初始化 - Stream _mapHomeQuickEntryInitToState(HomeQuickEntryInitEvent event) async* { + Stream _mapHomeQuickEntryInitToState( + HomeQuickEntryInitEvent event) async* { /// 获取缓存数据 var cached = await repository.fetchCachedData(); if (!EmptyUtil.isEmpty(cached)) { diff --git a/lib/widgets/home_quick_entry/bloc/home_quick_entry_event.dart b/lib/widgets/home/home_quick_entry/bloc/home_quick_entry_event.dart similarity index 100% rename from lib/widgets/home_quick_entry/bloc/home_quick_entry_event.dart rename to lib/widgets/home/home_quick_entry/bloc/home_quick_entry_event.dart diff --git a/lib/widgets/home_quick_entry/bloc/home_quick_entry_repository.dart b/lib/widgets/home/home_quick_entry/bloc/home_quick_entry_repository.dart similarity index 100% rename from lib/widgets/home_quick_entry/bloc/home_quick_entry_repository.dart rename to lib/widgets/home/home_quick_entry/bloc/home_quick_entry_repository.dart diff --git a/lib/widgets/home_quick_entry/bloc/home_quick_entry_state.dart b/lib/widgets/home/home_quick_entry/bloc/home_quick_entry_state.dart similarity index 100% rename from lib/widgets/home_quick_entry/bloc/home_quick_entry_state.dart rename to lib/widgets/home/home_quick_entry/bloc/home_quick_entry_state.dart diff --git a/lib/widgets/home_quick_entry/cached_network_image_util.dart b/lib/widgets/home/home_quick_entry/cached_network_image_util.dart similarity index 100% rename from lib/widgets/home_quick_entry/cached_network_image_util.dart rename to lib/widgets/home/home_quick_entry/cached_network_image_util.dart diff --git a/lib/widgets/home_quick_entry/home_quick_entry_creater.dart b/lib/widgets/home/home_quick_entry/home_quick_entry_creater.dart similarity index 100% rename from lib/widgets/home_quick_entry/home_quick_entry_creater.dart rename to lib/widgets/home/home_quick_entry/home_quick_entry_creater.dart diff --git a/lib/widgets/home_quick_entry/home_quick_entry_sk.dart b/lib/widgets/home/home_quick_entry/home_quick_entry_sk.dart similarity index 100% rename from lib/widgets/home_quick_entry/home_quick_entry_sk.dart rename to lib/widgets/home/home_quick_entry/home_quick_entry_sk.dart diff --git a/lib/widgets/home_quick_entry/home_quick_entry_widget.dart b/lib/widgets/home/home_quick_entry/home_quick_entry_widget.dart similarity index 100% rename from lib/widgets/home_quick_entry/home_quick_entry_widget.dart rename to lib/widgets/home/home_quick_entry/home_quick_entry_widget.dart diff --git a/lib/widgets/home_quick_entry/model/home_quick_entry_model.dart b/lib/widgets/home/home_quick_entry/model/home_quick_entry_model.dart similarity index 100% rename from lib/widgets/home_quick_entry/model/home_quick_entry_model.dart rename to lib/widgets/home/home_quick_entry/model/home_quick_entry_model.dart diff --git a/lib/widgets/home_slide_banner/bloc/bloc.dart b/lib/widgets/home/home_slide_banner/bloc/bloc.dart similarity index 100% rename from lib/widgets/home_slide_banner/bloc/bloc.dart rename to lib/widgets/home/home_slide_banner/bloc/bloc.dart diff --git a/lib/widgets/home_slide_banner/bloc/home_slide_banner_bloc.dart b/lib/widgets/home/home_slide_banner/bloc/home_slide_banner_bloc.dart similarity index 51% rename from lib/widgets/home_slide_banner/bloc/home_slide_banner_bloc.dart rename to lib/widgets/home/home_slide_banner/bloc/home_slide_banner_bloc.dart index 694f4d8..5b6b786 100644 --- a/lib/widgets/home_slide_banner/bloc/home_slide_banner_bloc.dart +++ b/lib/widgets/home/home_slide_banner/bloc/home_slide_banner_bloc.dart @@ -1,13 +1,16 @@ import 'dart:async'; + import 'package:bloc/bloc.dart'; import 'package:flutter/cupertino.dart'; -import 'package:zhiying_base_widget/widgets/home_slide_banner/bloc/home_slide_banner_event.dart'; -import 'package:zhiying_base_widget/widgets/home_slide_banner/bloc/home_slide_banner_repository.dart'; -import 'package:zhiying_base_widget/widgets/home_slide_banner/bloc/home_slide_banner_state.dart'; -import './bloc.dart'; +import 'package:zhiying_base_widget/widgets/home/home_slide_banner/bloc/home_slide_banner_event.dart'; +import 'package:zhiying_base_widget/widgets/home/home_slide_banner/bloc/home_slide_banner_repository.dart'; +import 'package:zhiying_base_widget/widgets/home/home_slide_banner/bloc/home_slide_banner_state.dart'; import 'package:zhiying_comm/util/empty_util.dart'; -class HomeSlideBannerBloc extends Bloc { +import './bloc.dart'; + +class HomeSlideBannerBloc + extends Bloc { HomeSlideBannerRepository repository; HomeSlideBannerBloc({@required this.repository}); @@ -16,7 +19,8 @@ class HomeSlideBannerBloc extends Bloc InitialHomeSlideBannerState(); @override - Stream mapEventToState(HomeSlideBannerEvent event) async* { + Stream mapEventToState( + HomeSlideBannerEvent event) async* { final currentState = state; /// 初始化 @@ -27,10 +31,12 @@ class HomeSlideBannerBloc extends Bloc _mapInitEventToState(HomeBannerInitEvent event) async* { + Stream _mapInitEventToState( + HomeBannerInitEvent event) async* { var cached = await repository.fetchCachedDate(id: event.model['mod_id']); - if (!EmptyUtil.isEmpty(cached)) yield HomeSlideBannerCachedState(datas: cached); - var param = await repository.fetchData( id: event.model['mod_id']); + if (!EmptyUtil.isEmpty(cached)) + yield HomeSlideBannerCachedState(datas: cached); + var param = await repository.fetchData(id: event.model['mod_id']); if (!EmptyUtil.isEmpty(param)) yield HomeSlideBannerLoadedState(datas: param); else diff --git a/lib/widgets/home_slide_banner/bloc/home_slide_banner_event.dart b/lib/widgets/home/home_slide_banner/bloc/home_slide_banner_event.dart similarity index 100% rename from lib/widgets/home_slide_banner/bloc/home_slide_banner_event.dart rename to lib/widgets/home/home_slide_banner/bloc/home_slide_banner_event.dart diff --git a/lib/widgets/home/home_slide_banner/bloc/home_slide_banner_repository.dart b/lib/widgets/home/home_slide_banner/bloc/home_slide_banner_repository.dart new file mode 100644 index 0000000..868829d --- /dev/null +++ b/lib/widgets/home/home_slide_banner/bloc/home_slide_banner_repository.dart @@ -0,0 +1,37 @@ +import 'package:flutter/cupertino.dart'; +import 'package:zhiying_base_widget/widgets/home/home_slide_banner/model/home_slide_banner_model.dart'; +import 'package:zhiying_comm/util/empty_util.dart'; +import 'package:zhiying_comm/util/global_config.dart'; +import 'package:zhiying_comm/util/net_util.dart'; + +class HomeSlideBannerRepository { + /// 获取缓存数据 + Future> fetchCachedDate( + {@required int id}) async { + var cached = await NetUtil.getRequestCachedData('/api/v1/mod', params: { + 'ids': [id] + }); + if (!EmptyUtil.isEmpty(cached)) { + HomeSlideBannerModel model = HomeSlideBannerModel.fromJson(cached); + if (null != model && !EmptyUtil.isEmpty(model.items)) { + return model.items; + } + } + return null; + } + + /// 获取数据 + Future> fetchData({@required int id}) async { + var params = await NetUtil.post('/api/v1/mod', params: { + 'ids': [id] + }); + if (!EmptyUtil.isEmpty(params) && NetUtil.isSuccess(params)) { + HomeSlideBannerModel model = HomeSlideBannerModel.fromJson( + params[GlobalConfig.HTTP_RESPONSE_KEY_DATA]); + if (null != model && !EmptyUtil.isEmpty(model.items)) { + return model.items; + } + } + return null; + } +} diff --git a/lib/widgets/home_slide_banner/bloc/home_slide_banner_state.dart b/lib/widgets/home/home_slide_banner/bloc/home_slide_banner_state.dart similarity index 82% rename from lib/widgets/home_slide_banner/bloc/home_slide_banner_state.dart rename to lib/widgets/home/home_slide_banner/bloc/home_slide_banner_state.dart index 122b4ef..5765ab1 100644 --- a/lib/widgets/home_slide_banner/bloc/home_slide_banner_state.dart +++ b/lib/widgets/home/home_slide_banner/bloc/home_slide_banner_state.dart @@ -1,5 +1,5 @@ import 'package:equatable/equatable.dart'; -import 'package:zhiying_base_widget/widgets/home_slide_banner/model/home_slide_banner_model.dart'; +import 'package:zhiying_base_widget/widgets/home/home_slide_banner/model/home_slide_banner_model.dart'; abstract class HomeSlideBannerState extends Equatable { const HomeSlideBannerState(); @@ -30,7 +30,8 @@ class HomeSlideBannerLoadedState extends HomeSlideBannerState { HomeSlideBannerLoadedState({this.datas}); - HomeSlideBannerLoadedState copyWith({List newData}) { + HomeSlideBannerLoadedState copyWith( + {List newData}) { return HomeSlideBannerLoadedState( datas: newData ?? datas, ); diff --git a/lib/widgets/home_slide_banner/home_slide_banner.dart b/lib/widgets/home/home_slide_banner/home_slide_banner.dart similarity index 100% rename from lib/widgets/home_slide_banner/home_slide_banner.dart rename to lib/widgets/home/home_slide_banner/home_slide_banner.dart diff --git a/lib/widgets/home_slide_banner/home_slide_banner_creater.dart b/lib/widgets/home/home_slide_banner/home_slide_banner_creater.dart similarity index 100% rename from lib/widgets/home_slide_banner/home_slide_banner_creater.dart rename to lib/widgets/home/home_slide_banner/home_slide_banner_creater.dart diff --git a/lib/widgets/home_slide_banner/home_slide_banner_sk.dart b/lib/widgets/home/home_slide_banner/home_slide_banner_sk.dart similarity index 100% rename from lib/widgets/home_slide_banner/home_slide_banner_sk.dart rename to lib/widgets/home/home_slide_banner/home_slide_banner_sk.dart diff --git a/lib/widgets/home_slide_banner/model/home_slide_banner_model.dart b/lib/widgets/home/home_slide_banner/model/home_slide_banner_model.dart similarity index 100% rename from lib/widgets/home_slide_banner/model/home_slide_banner_model.dart rename to lib/widgets/home/home_slide_banner/model/home_slide_banner_model.dart diff --git a/lib/widgets/home_slide_banner/bloc/home_slide_banner_repository.dart b/lib/widgets/home_slide_banner/bloc/home_slide_banner_repository.dart deleted file mode 100644 index 4a2ac42..0000000 --- a/lib/widgets/home_slide_banner/bloc/home_slide_banner_repository.dart +++ /dev/null @@ -1,34 +0,0 @@ - -import 'package:flutter/cupertino.dart'; -import 'package:zhiying_base_widget/widgets/home_slide_banner/model/home_slide_banner_model.dart'; -import 'package:zhiying_comm/util/net_util.dart'; -import 'package:zhiying_comm/util/empty_util.dart'; -import 'package:zhiying_comm/util/global_config.dart'; - -class HomeSlideBannerRepository{ - - /// 获取缓存数据 - Future> fetchCachedDate({@required int id}) async{ - var cached = await NetUtil.getRequestCachedData('/api/v1/mod', params: {'ids': [id]}); - if(!EmptyUtil.isEmpty(cached)){ - HomeSlideBannerModel model = HomeSlideBannerModel.fromJson(cached); - if(null != model && !EmptyUtil.isEmpty(model.items)){ - return model.items; - } - } - return null; - } - - /// 获取数据 - Future> fetchData({@required int id}) async{ - var params = await NetUtil.post('/api/v1/mod', params: {'ids': [id]}); - if(!EmptyUtil.isEmpty(params) && NetUtil.isSuccess(params)){ - HomeSlideBannerModel model = HomeSlideBannerModel.fromJson(params[GlobalConfig.HTTP_RESPONSE_KEY_DATA]); - if(null != model && !EmptyUtil.isEmpty(model.items)){ - return model.items; - } - } - return null; - } - -} diff --git a/lib/widgets/mine/mine_data/mine_data.dart b/lib/widgets/mine/mine_data/mine_data.dart new file mode 100644 index 0000000..b24b94c --- /dev/null +++ b/lib/widgets/mine/mine_data/mine_data.dart @@ -0,0 +1,14 @@ +import 'package:flutter/material.dart'; +import 'package:zhiying_base_widget/widgets/mine/mine_data/mine_data_sk.dart'; + +class MineData extends StatefulWidget { + @override + _MineDataState createState() => _MineDataState(); +} + +class _MineDataState extends State { + @override + Widget build(BuildContext context) { + return MineDataSkeleton(); + } +} diff --git a/lib/widgets/mine/mine_data/mine_data_creater.dart b/lib/widgets/mine/mine_data/mine_data_creater.dart new file mode 100644 index 0000000..91cfe8b --- /dev/null +++ b/lib/widgets/mine/mine_data/mine_data_creater.dart @@ -0,0 +1,12 @@ +import 'package:flutter/material.dart'; +import 'package:zhiying_base_widget/widgets/mine/mine_data/mine_data.dart'; +import 'package:zhiying_comm/zhiying_comm.dart'; + +class MineDataCreater extends WidgetCreater { + @override + List createWidgets(Map model) { + return [ + MineData(), + ]; + } +} diff --git a/lib/widgets/mine/mine_data/mine_data_sk.dart b/lib/widgets/mine/mine_data/mine_data_sk.dart new file mode 100644 index 0000000..008ebd2 --- /dev/null +++ b/lib/widgets/mine/mine_data/mine_data_sk.dart @@ -0,0 +1,122 @@ +import 'package:flutter/material.dart'; +import 'package:shimmer/shimmer.dart'; + +class MineDataSkeleton extends StatefulWidget { + @override + _MineDataSkeletonState createState() => _MineDataSkeletonState(); +} + +class _MineDataSkeletonState extends State { + @override + Widget build(BuildContext context) { + return Container( + margin: EdgeInsets.only(left: 12.5, right: 12.5), + decoration: BoxDecoration( + color: Colors.white, borderRadius: BorderRadius.circular(7.5)), + child: Shimmer.fromColors( + baseColor: Colors.grey[300], + highlightColor: Colors.grey[100], + child: Column( + children: [ + Container( + width: double.infinity, + height: 62, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Expanded( + child: _createText1(), + ) + ], + ) + ], + ), + ), + Container( + width: double.infinity, + height: 72, + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Expanded( + child: _createText2(), + ), + Expanded( + child: _createText2(), + ) + ], + ), + ), + Container( + width: double.infinity, + height: 46, + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Expanded( + child: Container( + margin: EdgeInsets.only(left: 15, right: 15), + height: 15, + color: Colors.white, + ), + ), + Expanded( + child: Container( + margin: EdgeInsets.only(left: 15, right: 15), + height: 15, + color: Colors.white, + ), + ) + ], + ), + ) + ], + ), + ), + ); + } + + Widget _createText1() { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + margin: EdgeInsets.only(left: 15, right: 15), + height: 15, + color: Colors.white, + ), + Container( + margin: EdgeInsets.only(left: 15, top: 4), + height: 15, + width: 120, + color: Colors.white, + ), + ], + ); + } + + Widget _createText2() { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Container( + margin: EdgeInsets.only(left: 15), + height: 15, + width: 44, + color: Colors.white, + ), + Container( + margin: EdgeInsets.only(left: 15, top: 6), + height: 15, + width: 64, + color: Colors.white, + ), + ], + ); + } +} diff --git a/lib/widgets/mine/mine_header/mine_header.dart b/lib/widgets/mine/mine_header/mine_header.dart new file mode 100644 index 0000000..2114779 --- /dev/null +++ b/lib/widgets/mine/mine_header/mine_header.dart @@ -0,0 +1,14 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + +import 'mine_header_sk.dart'; + +class MineHeader extends StatelessWidget { + @override + Widget build(BuildContext context) { + return Container( + width: double.infinity, + child: MineHeaderSkeleton(), + ); + } +} diff --git a/lib/widgets/mine/mine_header/mine_header_creater.dart b/lib/widgets/mine/mine_header/mine_header_creater.dart new file mode 100644 index 0000000..1a08672 --- /dev/null +++ b/lib/widgets/mine/mine_header/mine_header_creater.dart @@ -0,0 +1,12 @@ +import 'package:flutter/material.dart'; +import 'package:zhiying_base_widget/widgets/mine/mine_header/mine_header.dart'; +import 'package:zhiying_comm/zhiying_comm.dart'; + +class MineHeaderCreater extends WidgetCreater { + @override + List createWidgets(Map model) { + return [ + MineHeader(), + ]; + } +} diff --git a/lib/widgets/mine/mine_header/mine_header_sk.dart b/lib/widgets/mine/mine_header/mine_header_sk.dart new file mode 100644 index 0000000..45bf917 --- /dev/null +++ b/lib/widgets/mine/mine_header/mine_header_sk.dart @@ -0,0 +1,45 @@ +import 'package:flutter/material.dart'; +import 'package:shimmer/shimmer.dart'; + +class MineHeaderSkeleton extends StatelessWidget { + @override + Widget build(BuildContext context) { + return Shimmer.fromColors( + baseColor: Colors.grey[300], + highlightColor: Colors.grey[100], + child: Container( + child: Row( + children: [ + Container( + margin: EdgeInsets.only(left: 20, top: 20, bottom: 20, right: 12), + width: 56, + height: 56, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(28), + ), + ), + Expanded( + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + width: 120, + height: 20, + color: Colors.white, + ), + Container( + margin: EdgeInsets.only(top: 8), + width: 80, + height: 12, + color: Colors.white, + ), + ], + )) + ], + ), + ), + ); + } +} diff --git a/lib/widgets/mine_header/mine_header.dart b/lib/widgets/mine/mine_nav/mine_nav.dart similarity index 86% rename from lib/widgets/mine_header/mine_header.dart rename to lib/widgets/mine/mine_nav/mine_nav.dart index 39cb919..f1cac58 100644 --- a/lib/widgets/mine_header/mine_header.dart +++ b/lib/widgets/mine/mine_nav/mine_nav.dart @@ -3,10 +3,10 @@ import 'dart:ui'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -class MineHeaderDelegate extends SliverPersistentHeaderDelegate { +class MineNavDelegate extends SliverPersistentHeaderDelegate { double _height; - MineHeaderDelegate() : super() { + MineNavDelegate() : super() { _height = MediaQueryData.fromWindow(window).padding.top + 44; } @@ -16,7 +16,7 @@ class MineHeaderDelegate extends SliverPersistentHeaderDelegate { // print('${shrinkOffset.toString()}'); double percent = shrinkOffset / _height; print('${percent.toString()}'); - return MineHeader(Colors.red.withOpacity(percent)); + return MineNav(Colors.red.withOpacity(percent)); } @override @@ -30,10 +30,10 @@ class MineHeaderDelegate extends SliverPersistentHeaderDelegate { false; // 如果内容需要更新,设置为true } -class MineHeader extends StatelessWidget { +class MineNav extends StatelessWidget { final Color color; - MineHeader(this.color); + MineNav(this.color); @override Widget build(BuildContext context) { diff --git a/lib/widgets/mine_header/mine_header_creater.dart b/lib/widgets/mine/mine_nav/mine_nav_creater.dart similarity index 67% rename from lib/widgets/mine_header/mine_header_creater.dart rename to lib/widgets/mine/mine_nav/mine_nav_creater.dart index 2274daf..1341cbf 100644 --- a/lib/widgets/mine_header/mine_header_creater.dart +++ b/lib/widgets/mine/mine_nav/mine_nav_creater.dart @@ -1,15 +1,15 @@ import 'package:flutter/material.dart'; -import 'package:zhiying_base_widget/widgets/mine_header/mine_header.dart'; +import 'package:zhiying_base_widget/widgets/mine/mine_nav/mine_nav.dart'; import 'package:zhiying_comm/zhiying_comm.dart'; -class MineHeaderCreater extends WidgetCreater { +class MineNavCreater extends WidgetCreater { @override List createWidgets(Map model) { return [ SliverPersistentHeader( pinned: true, floating: false, - delegate: MineHeaderDelegate(), + delegate: MineNavDelegate(), ), ]; } diff --git a/lib/widgets/mine_data/mine_data.dart b/lib/widgets/mine/mine_nav/mine_nav_sk.dart similarity index 100% rename from lib/widgets/mine_data/mine_data.dart rename to lib/widgets/mine/mine_nav/mine_nav_sk.dart diff --git a/lib/widgets/mine_quick_entry/bloc/mine_quick_entry_bloc.dart b/lib/widgets/mine/mine_quick_entry/bloc/mine_quick_entry_bloc.dart similarity index 91% rename from lib/widgets/mine_quick_entry/bloc/mine_quick_entry_bloc.dart rename to lib/widgets/mine/mine_quick_entry/bloc/mine_quick_entry_bloc.dart index 681d4c4..1f33e03 100644 --- a/lib/widgets/mine_quick_entry/bloc/mine_quick_entry_bloc.dart +++ b/lib/widgets/mine/mine_quick_entry/bloc/mine_quick_entry_bloc.dart @@ -1,6 +1,6 @@ import 'dart:async'; -import 'package:zhiying_base_widget/widgets/mine_quick_entry/models/mine_quick_entry_model.dart'; +import 'package:zhiying_base_widget/widgets/mine/mine_quick_entry/models/mine_quick_entry_model.dart'; import 'package:zhiying_comm/util/base_bloc.dart'; import 'package:zhiying_comm/zhiying_comm.dart'; diff --git a/lib/widgets/mine_quick_entry/mine_quick_entry.dart b/lib/widgets/mine/mine_quick_entry/mine_quick_entry.dart similarity index 80% rename from lib/widgets/mine_quick_entry/mine_quick_entry.dart rename to lib/widgets/mine/mine_quick_entry/mine_quick_entry.dart index 41d2df7..1901d55 100644 --- a/lib/widgets/mine_quick_entry/mine_quick_entry.dart +++ b/lib/widgets/mine/mine_quick_entry/mine_quick_entry.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; -import 'package:zhiying_base_widget/widgets/mine_quick_entry/bloc/mine_quick_entry_bloc.dart'; -import 'package:zhiying_base_widget/widgets/mine_quick_entry/mine_quick_entry_sk.dart'; -import 'package:zhiying_base_widget/widgets/mine_quick_entry/models/mine_quick_entry_model.dart'; +import 'package:zhiying_base_widget/widgets/mine/mine_quick_entry/bloc/mine_quick_entry_bloc.dart'; +import 'package:zhiying_base_widget/widgets/mine/mine_quick_entry/mine_quick_entry_sk.dart'; +import 'package:zhiying_base_widget/widgets/mine/mine_quick_entry/models/mine_quick_entry_model.dart'; import 'package:zhiying_comm/util/base_bloc.dart'; class MineQuickEntry extends StatefulWidget { diff --git a/lib/widgets/mine_quick_entry/mine_quick_entry_creater.dart b/lib/widgets/mine/mine_quick_entry/mine_quick_entry_creater.dart similarity index 74% rename from lib/widgets/mine_quick_entry/mine_quick_entry_creater.dart rename to lib/widgets/mine/mine_quick_entry/mine_quick_entry_creater.dart index 9363a2e..3721a2b 100644 --- a/lib/widgets/mine_quick_entry/mine_quick_entry_creater.dart +++ b/lib/widgets/mine/mine_quick_entry/mine_quick_entry_creater.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:zhiying_base_widget/widgets/mine_quick_entry/mine_quick_entry.dart'; +import 'package:zhiying_base_widget/widgets/mine/mine_quick_entry/mine_quick_entry.dart'; import 'package:zhiying_comm/zhiying_comm.dart'; class MineQuickEntryCreater extends WidgetCreater { diff --git a/lib/widgets/mine_quick_entry/mine_quick_entry_sk.dart b/lib/widgets/mine/mine_quick_entry/mine_quick_entry_sk.dart similarity index 93% rename from lib/widgets/mine_quick_entry/mine_quick_entry_sk.dart rename to lib/widgets/mine/mine_quick_entry/mine_quick_entry_sk.dart index 87057d7..00b23ac 100644 --- a/lib/widgets/mine_quick_entry/mine_quick_entry_sk.dart +++ b/lib/widgets/mine/mine_quick_entry/mine_quick_entry_sk.dart @@ -5,6 +5,12 @@ class MineQuickEntrySkeleton extends StatelessWidget { @override Widget build(BuildContext context) { return Container( + margin: EdgeInsets.only( + left: 12.5, + right: 12.5, + top: 6, + bottom: 6, + ), width: double.infinity, decoration: BoxDecoration( borderRadius: BorderRadius.circular(7.5), color: Colors.white), diff --git a/lib/widgets/mine_quick_entry/models/mine_quick_entry_model.dart b/lib/widgets/mine/mine_quick_entry/models/mine_quick_entry_model.dart similarity index 100% rename from lib/widgets/mine_quick_entry/models/mine_quick_entry_model.dart rename to lib/widgets/mine/mine_quick_entry/models/mine_quick_entry_model.dart diff --git a/lib/widgets/mine_data/mine_data_creater.dart b/lib/widgets/mine_data/mine_data_creater.dart deleted file mode 100644 index e69de29..0000000 diff --git a/lib/widgets/mine_data/mine_data_sk.dart b/lib/widgets/mine_data/mine_data_sk.dart deleted file mode 100644 index e69de29..0000000 diff --git a/lib/widgets/mine_header/mine_header_sk.dart b/lib/widgets/mine_header/mine_header_sk.dart deleted file mode 100644 index e69de29..0000000 diff --git a/lib/widgets/others/mine_header_bg_widget.dart b/lib/widgets/others/mine_header_bg_widget.dart index d91c602..aae595f 100644 --- a/lib/widgets/others/mine_header_bg_widget.dart +++ b/lib/widgets/others/mine_header_bg_widget.dart @@ -54,7 +54,7 @@ class _MineHeaderBgWidgetState extends State { @override Widget build(BuildContext context) { - print('mmine_hider_bg_widget build'); + print('mine_header_bg_widget build ${_offsetY.toString()}'); return Transform.translate( offset: Offset(0, _offsetY), child: _content, diff --git a/lib/widgets/others/normal_nav/normal_nav.dart b/lib/widgets/others/normal_nav/normal_nav.dart new file mode 100644 index 0000000..ffc8cf6 --- /dev/null +++ b/lib/widgets/others/normal_nav/normal_nav.dart @@ -0,0 +1,104 @@ +import 'dart:ui'; + +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:zhiying_base_widget/pages/mine_page/mine_page.dart'; + +class NormalNavDelegate extends SliverPersistentHeaderDelegate { + double _height; + + NormalNavDelegate() : super() { + _height = MediaQueryData.fromWindow(window).padding.top + 44; + } + + @override + Widget build( + BuildContext context, double shrinkOffset, bool overlapsContent) { + print('${shrinkOffset.toString()}'); + double percent = shrinkOffset / _height; + print('${percent.toString()}'); + return NormalNav(Colors.red.withOpacity(percent)); + } + + @override + double get maxExtent => _height; + + @override + double get minExtent => _height; + + @override + bool shouldRebuild(SliverPersistentHeaderDelegate oldDelegate) => + false; // 如果内容需要更新,设置为true +} + +class NormalNav extends StatelessWidget { + final Color color; + + NormalNav(this.color); + + @override + Widget build(BuildContext context) { + return Container( + color: color, + child: Column( + children: [ + Expanded(child: Container()), + Container( + width: double.infinity, + height: 44, + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Navigator.of(context).canPop() + ? GestureDetector( + child: Container( + width: 44, + height: 44, + child: Icon( + Icons.arrow_back_ios, + color: Colors.white, + ), + ), + onTap: () { + if (Navigator.canPop(context)) { + Navigator.pop(context); + } + }, + ) + : Container( + width: 44, + height: 44, + ), + Expanded( + child: Container( + child: Center( + child: Text( + '我的钱包', + style: TextStyle(fontSize: 18, color: Colors.white), + ), + ), + ), + ), + GestureDetector( + child: Container( + width: 44, + height: 44, + child: Icon( + Icons.settings, + color: Colors.white, + ), + ), + onTap: () { + Navigator.push(context, + MaterialPageRoute(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 new file mode 100644 index 0000000..db81c66 --- /dev/null +++ b/lib/widgets/others/normal_nav/normal_nav_creater.dart @@ -0,0 +1,21 @@ +import 'package:flutter/material.dart'; +import 'package:zhiying_base_widget/widgets/others/normal_nav/normal_nav.dart'; +import 'package:zhiying_comm/zhiying_comm.dart'; + +class NormalNavCreater extends WidgetCreater { + @override + List createWidgets(Map model) { + return [ + SliverPersistentHeader( + pinned: true, + floating: true, + delegate: NormalNavDelegate(), + ), + ]; + } + + @override + bool isSliverChild() { + return true; + } +} diff --git a/lib/widgets/wallet/wallet_data/wallet_data.dart b/lib/widgets/wallet/wallet_data/wallet_data.dart new file mode 100644 index 0000000..806ca4c --- /dev/null +++ b/lib/widgets/wallet/wallet_data/wallet_data.dart @@ -0,0 +1,13 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:zhiying_base_widget/widgets/wallet/wallet_data/wallet_data_sk.dart'; + +class WalletData extends StatelessWidget { + @override + Widget build(BuildContext context) { + return Container( + width: double.infinity, + child: WalletDataSkeleton(), + ); + } +} diff --git a/lib/widgets/wallet/wallet_data/wallet_data_creater.dart b/lib/widgets/wallet/wallet_data/wallet_data_creater.dart new file mode 100644 index 0000000..b917d7e --- /dev/null +++ b/lib/widgets/wallet/wallet_data/wallet_data_creater.dart @@ -0,0 +1,12 @@ +import 'package:flutter/material.dart'; +import 'package:zhiying_base_widget/widgets/wallet/wallet_data/wallet_data.dart'; +import 'package:zhiying_comm/zhiying_comm.dart'; + +class WalletDataCreater extends WidgetCreater { + @override + List createWidgets(Map model) { + return [ + WalletData(), + ]; + } +} diff --git a/lib/widgets/wallet/wallet_data/wallet_data_sk.dart b/lib/widgets/wallet/wallet_data/wallet_data_sk.dart new file mode 100644 index 0000000..cb36f51 --- /dev/null +++ b/lib/widgets/wallet/wallet_data/wallet_data_sk.dart @@ -0,0 +1,111 @@ +import 'package:flutter/material.dart'; +import 'package:shimmer/shimmer.dart'; + +class WalletDataSkeleton extends StatelessWidget { + @override + Widget build(BuildContext context) { + return Container( + margin: EdgeInsets.only(left: 12.5, right: 12.5, top: 4, bottom: 4), + decoration: BoxDecoration( + color: Colors.white, borderRadius: BorderRadius.circular(7.5)), + child: Shimmer.fromColors( + baseColor: Colors.grey[300], + highlightColor: Colors.grey[100], + child: Column( + children: [ + Container( + width: double.infinity, + height: 85, + child: Row( + children: [ + Container( + margin: EdgeInsets.only(left: 15), + width: 26, + height: 34, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(4)), + ), + Expanded( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Expanded( + child: _createText1(), + ) + ], + ) + ], + )) + ], + ), + ), + Container( + width: double.infinity, + height: 60, + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Expanded( + child: _createText2(), + ), + Expanded( + child: _createText2(), + ), + Expanded( + child: _createText2(), + ) + ], + ), + ), + ], + ), + ), + ); + } + + Widget _createText1() { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Container( + margin: EdgeInsets.only(left: 15), + height: 15, + width: 120, + color: Colors.white, + ), + Container( + margin: EdgeInsets.only(left: 15, right: 15, top: 4), + height: 15, + color: Colors.white, + ), + ], + ); + } + + Widget _createText2() { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Container( + margin: EdgeInsets.only(left: 15), + height: 15, + width: 44, + color: Colors.white, + ), + Container( + margin: EdgeInsets.only(left: 15, top: 6), + height: 15, + width: 64, + color: Colors.white, + ), + ], + ); + } +} diff --git a/lib/widgets/wallet/wallet_detail/wallet_detail.dart b/lib/widgets/wallet/wallet_detail/wallet_detail.dart new file mode 100644 index 0000000..179c219 --- /dev/null +++ b/lib/widgets/wallet/wallet_detail/wallet_detail.dart @@ -0,0 +1,18 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:zhiying_base_widget/pages/withdraw_page/withdraw_page.dart'; +import 'package:zhiying_base_widget/widgets/wallet/wallet_detail/wallet_detail_sk.dart'; + +class WalletDetail extends StatelessWidget { + @override + Widget build(BuildContext context) { + return GestureDetector( + child: WalletDetailSkeleton(), + onTap: () { + Navigator.push(context, MaterialPageRoute(builder: (context) { + return WithdrawPage(); + })); + }, + ); + } +} diff --git a/lib/widgets/wallet/wallet_detail/wallet_detail_sk.dart b/lib/widgets/wallet/wallet_detail/wallet_detail_sk.dart new file mode 100644 index 0000000..9092382 --- /dev/null +++ b/lib/widgets/wallet/wallet_detail/wallet_detail_sk.dart @@ -0,0 +1,34 @@ +import 'package:flutter/material.dart'; +import 'package:shimmer/shimmer.dart'; + +class WalletDetailSkeleton extends StatelessWidget { + @override + Widget build(BuildContext context) { + return Container( + margin: EdgeInsets.only(left: 12.5, right: 12.5, top: 4, bottom: 4), + padding: EdgeInsets.only(left: 15, right: 15, top: 10, bottom: 10), + decoration: BoxDecoration( + color: Colors.white, borderRadius: BorderRadius.circular(7.5)), + child: Shimmer.fromColors( + baseColor: Colors.grey[300], + highlightColor: Colors.grey[100], + child: Row( + children: [ + Container( + width: 18, + height: 18, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(9), + color: Colors.white), + ), + Container( + margin: EdgeInsets.only(left: 8), + width: 120, + height: 14, + color: Colors.white, + ), + ], + )), + ); + } +} diff --git a/lib/widgets/wallet/wallet_income/wallet_income.dart b/lib/widgets/wallet/wallet_income/wallet_income.dart new file mode 100644 index 0000000..3197d07 --- /dev/null +++ b/lib/widgets/wallet/wallet_income/wallet_income.dart @@ -0,0 +1,9 @@ +import 'package:flutter/material.dart'; +import 'package:zhiying_base_widget/widgets/wallet/wallet_income/wallet_income_sk.dart'; + +class WalletIncome extends StatelessWidget { + @override + Widget build(BuildContext context) { + return WalletIncomeSkeleton(); + } +} diff --git a/lib/widgets/wallet/wallet_income/wallet_income_sk.dart b/lib/widgets/wallet/wallet_income/wallet_income_sk.dart new file mode 100644 index 0000000..0a23e34 --- /dev/null +++ b/lib/widgets/wallet/wallet_income/wallet_income_sk.dart @@ -0,0 +1,104 @@ +import 'package:flutter/material.dart'; +import 'package:shimmer/shimmer.dart'; + +class WalletIncomeSkeleton extends StatelessWidget { + @override + Widget build(BuildContext context) { + return Container( + margin: EdgeInsets.only(left: 12.5, right: 12.5, top: 4, bottom: 4), + padding: EdgeInsets.only(left: 15, right: 15, top: 10, bottom: 10), + decoration: BoxDecoration( + color: Colors.white, borderRadius: BorderRadius.circular(7.5)), + child: Shimmer.fromColors( + baseColor: Colors.grey[300], + highlightColor: Colors.grey[100], + child: Column( + children: [ + Container( + width: double.infinity, + child: _createTab(), + ), + Container( + margin: EdgeInsets.only(top: 6), + width: double.infinity, + child: _createTags(), + ), + Container( + margin: EdgeInsets.only(top: 6), + height: 64, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(7.5), + color: Colors.white), + ), + _createDataRow(), + _createDataRow(), + _createDataRow(), + ], + )), + ); + } + + Widget _createTab() { + return Row( + children: List.generate(5, (index) { + return Expanded( + child: Container( + height: 14, + margin: EdgeInsets.only(left: 10, right: 10, top: 4, bottom: 4), + color: Colors.white, + ), + ); + }), + ); + } + + Widget _createTags() { + return Row( + children: List.generate(5, (index) { + return Expanded( + child: Container( + height: 20, + margin: EdgeInsets.only(left: 10, right: 10, top: 4, bottom: 4), + decoration: BoxDecoration( + color: Colors.white, borderRadius: BorderRadius.circular(10)), + ), + ); + }), + ); + } + + Widget _createDataRow() { + return Column( + children: [ + Container( + margin: EdgeInsets.only(top: 8, bottom: 2), + width: 64, + height: 18, + color: Colors.white, + ), + Row( + children: [ + Expanded( + child: Container( + margin: EdgeInsets.only(top: 6, right: 5), + height: 64, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(7.5), + color: Colors.white), + ), + ), + Expanded( + child: Container( + margin: EdgeInsets.only(top: 6, left: 5), + height: 64, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(7.5), + color: Colors.white), + ), + ) + ], + ) + ], + ); + } +}