diff --git a/.dart_tool/package_config.json b/.dart_tool/package_config.json index aea820a..92d5aef 100644 --- a/.dart_tool/package_config.json +++ b/.dart_tool/package_config.json @@ -770,7 +770,7 @@ "languageVersion": "2.1" } ], - "generated": "2020-09-21T02:27:30.928433Z", + "generated": "2020-09-21T03:19:08.272955Z", "generator": "pub", "generatorVersion": "2.7.2" } diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml deleted file mode 100644 index a55e7a1..0000000 --- a/.idea/codeStyles/codeStyleConfig.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/saveactions_settings.xml b/.idea/saveactions_settings.xml new file mode 100644 index 0000000..6025467 --- /dev/null +++ b/.idea/saveactions_settings.xml @@ -0,0 +1,13 @@ + + + + + + \ No newline at end of file diff --git a/lib/pages/main_page/main_page.dart b/lib/pages/main_page/main_page.dart index 04aecb5..392de7a 100644 --- a/lib/pages/main_page/main_page.dart +++ b/lib/pages/main_page/main_page.dart @@ -8,6 +8,7 @@ import 'package:zhiying_base_widget/pages/main_page/notifier/main_page_notifier. import 'package:zhiying_base_widget/widgets/others/mine_header_bg_widget.dart'; import 'package:zhiying_comm/util/base_bloc.dart'; import 'package:zhiying_comm/zhiying_comm.dart'; +import 'package:zhiying_base_widget/widgets/home/home_auth/home_auth.dart'; class MainPage extends StatefulWidget { final Map data; @@ -24,9 +25,7 @@ class MainPage extends StatefulWidget { class _MainPageState extends State { @override Widget build(BuildContext context) { - return Scaffold( - backgroundColor: Color(0xfff9f9f9), - body: MultiProvider( + return MultiProvider( providers: [ ChangeNotifierProvider.value(value: MainPageNotifier()), ChangeNotifierProvider.value(value: MainPageBgNotifier()), @@ -35,7 +34,7 @@ class _MainPageState extends State { bloc: MainPageBloc(), child: _MainPageContainer(widget.data), ), - ), + ); } } @@ -56,6 +55,8 @@ class _MainPageContainerState extends State<_MainPageContainer> { RefreshController _refreshController = RefreshController(initialRefresh: false); + Widget _floatWidget; + void _onLoading() async { // await Future.delayed(Duration(milliseconds: 1000)); // if (mounted) setState(() {}); @@ -93,35 +94,41 @@ class _MainPageContainerState extends State<_MainPageContainer> { @override Widget build(BuildContext context) { - return MediaQuery.removePadding( - removeTop: true, - context: context, - child: SmartRefresher( - enablePullDown: true, - enablePullUp: false, - header: WaterDropHeader(), - controller: _refreshController, - onLoading: _onLoading, - child: Container( - width: double.infinity, - child: StreamBuilder>>( - stream: _bloc.outData, - builder: (BuildContext context, AsyncSnapshot snapshot) { - return Stack( - fit: StackFit.passthrough, - children: [ - MineHeaderBgWidget( - controller: _controller, - ), - CustomScrollView( - controller: _controller, - slivers: _createContent(context, snapshot.data ?? []), - ) - ], - ); - }, - ), - )), + return Scaffold( + + backgroundColor: Color(0xfff9f9f9), + floatingActionButton: _floatWidget, + floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, + body: MediaQuery.removePadding( + removeTop: true, + context: context, + child: SmartRefresher( + enablePullDown: true, + enablePullUp: false, + header: WaterDropHeader(), + controller: _refreshController, + onLoading: _onLoading, + child: Container( + width: double.infinity, + child: StreamBuilder>>( + stream: _bloc.outData, + builder: (BuildContext context, AsyncSnapshot snapshot) { + return Stack( + fit: StackFit.passthrough, + children: [ + MineHeaderBgWidget( + controller: _controller, + ), + CustomScrollView( + controller: _controller, + slivers: _createContent(context, snapshot.data ?? []), + ) + ], + ); + }, + ), + )), + ), ); } @@ -133,6 +140,10 @@ class _MainPageContainerState extends State<_MainPageContainer> { WidgetModel.fromJson(Map.from(datas[i])); print('item.modName ${item.modName}'); + if (item.modName == 'index_taobao_auth_tip') { + _floatWidget = HomeAuth(datas[i]); + continue; + } list.addAll(WidgetFactory.create( item.modName, isSliver: true, diff --git a/lib/pages/mine_page/mine_page.dart b/lib/pages/mine_page/mine_page.dart index d03e364..173da02 100644 --- a/lib/pages/mine_page/mine_page.dart +++ b/lib/pages/mine_page/mine_page.dart @@ -73,6 +73,7 @@ class _MinePageState extends State with TickerProviderStateMixin { body: SafeArea( child: NestedScrollView( headerSliverBuilder: _silverBuilder, + body: TabBarView( controller: _tabController, children: [ diff --git a/lib/register.dart b/lib/register.dart index 55a1501..5ac1e87 100644 --- a/lib/register.dart +++ b/lib/register.dart @@ -6,7 +6,6 @@ import 'package:zhiying_base_widget/pages/mine_detail_page/mine_detail_page.dart import 'package:zhiying_base_widget/pages/orders_page/orders_page.dart'; import 'package:zhiying_base_widget/pages/setting_page/setting_page.dart'; import 'package:zhiying_base_widget/pages/wallet_page/wallet_page.dart'; -import 'package:zhiying_base_widget/widgets/home/home_auth/home_auth_creater.dart'; import 'package:zhiying_base_widget/widgets/goods_details/footer/goods_details_footer_widget.dart'; import 'package:zhiying_base_widget/widgets/goods_details/price/goods_details_price_widget.dart'; import 'package:zhiying_base_widget/widgets/goods_details/slide_banner/goods_details_slide_banner_widget.dart'; @@ -56,11 +55,11 @@ class BaseWidgetRegister { // PageFactory.regist('login_account', (model) => LoginAccountPage(model)); // PageFactory.regist('login_invite', (model) => LoginInvitePage()); - PageFactory.regist('pub.flutter.profile_settings', (model) => MineDetailPage()); + PageFactory.regist( + 'pub.flutter.profile_settings', (model) => MineDetailPage()); PageFactory.regist('pub.flutter.settings', (model) => SettingPage(model)); PageFactory.regist('pub.flutter.my_orders', (model) => OrdersPage(model)); - } // 注册控件 @@ -72,64 +71,82 @@ class BaseWidgetRegister { // ==================== 首页 // WidgetFactory.regist('index_title', NormalNavCreater()); /// 首页搜索栏 - // WidgetFactory.regist('index_search', HomeSreachCreater()); - // WidgetFactory.regist('index_search', DefaultWidgetCreater((model) => HomeSreachWidget(model))); +// WidgetFactory.regist('index_search', HomeSreachCreater()); + WidgetFactory.regist('index_search', + DefaultWidgetCreater((model) => HomeSreachWidget(model))); + /// 可滚动banner WidgetFactory.regist('index_carousel', HomeSlideBannerCreater()); WidgetFactory.regist('index_recommend_list', GoodsListCreater()); /// 首页快速入口 - WidgetFactory.regist('multi_nav', DefaultWidgetCreater((model) => HomeQuickEntry(model))); + WidgetFactory.regist( + 'multi_nav', DefaultWidgetCreater((model) => HomeQuickEntry(model))); /// 滚动公告 - WidgetFactory.regist('index_placard', DefaultWidgetCreater((model) => HomeNoticeWidget(model))); + WidgetFactory.regist('index_placard', + DefaultWidgetCreater((model) => HomeNoticeWidget(model))); /// 不可以滚动banner WidgetFactory.regist('index_banner_one', HomeBannerCreater()); WidgetFactory.regist('index_banner_two', HomeBannerCreater()); - WidgetFactory.regist('index_taobao_auth_tip', HomeAuthCreater()); /// ==================== 商品详情 ==================== /// // 商品详情轮播图 - WidgetFactory.regist('product_detail_carousel', DefaultWidgetCreater((model) => GoodsDetailsSlideBannerWidget(model))); + WidgetFactory.regist('product_detail_carousel', + DefaultWidgetCreater((model) => GoodsDetailsSlideBannerWidget(model))); // 商品详情下载APP提示 - WidgetFactory.regist('product_detail_download_tips', DefaultWidgetCreater((model) => UpgradeTipWidget(model))); + WidgetFactory.regist('product_detail_download_tips', + DefaultWidgetCreater((model) => UpgradeTipWidget(model))); // 商品详情价格显示 - WidgetFactory.regist('product_detail_price', DefaultWidgetCreater((model) => GoodsDetailsPriceWidget(model))); + WidgetFactory.regist('product_detail_price', + DefaultWidgetCreater((model) => GoodsDetailsPriceWidget(model))); // 商品详情标题 - WidgetFactory.regist('product_detail_title', DefaultWidgetCreater((model) => GoodsDetailsTitleWidget(model))); + WidgetFactory.regist('product_detail_title', + DefaultWidgetCreater((model) => GoodsDetailsTitleWidget(model))); // 商品详情优惠劵 - WidgetFactory.regist('product_detail_coupon', DefaultWidgetCreater((model) => CounponWidget(model))); + WidgetFactory.regist('product_detail_coupon', + DefaultWidgetCreater((model) => CounponWidget(model))); // 商品详情店铺 - WidgetFactory.regist('product_detail_shop', DefaultWidgetCreater((model) => StoreWidget(model))); + WidgetFactory.regist('product_detail_shop', + DefaultWidgetCreater((model) => StoreWidget(model))); // 商品详情宝贝评价 - WidgetFactory.regist('product_detail_comment', DefaultWidgetCreater((model) => GoodsDetailsEvaluateWidget(model))); + WidgetFactory.regist('product_detail_comment', + DefaultWidgetCreater((model) => GoodsDetailsEvaluateWidget(model))); // 商品详情图片 // WidgetFactory.regist('product_detail_img_list', MineNavCreater()); // 商品详情底部推荐列表 // WidgetFactory.regist('product_detail_bottom_rec', DefaultWidgetCreater((model) => GoodsDetailsEvaluateWidget(model))); // 商品详情底部 - WidgetFactory.regist('product_detail_bottom', DefaultWidgetCreater((model) => GoodsDetailsFooterWidget(model))); - + WidgetFactory.regist('product_detail_bottom', + DefaultWidgetCreater((model) => GoodsDetailsFooterWidget(model))); // ==================== 个人中心 WidgetFactory.regist('profile_appbar', MineNavCreater()); - WidgetFactory.regist('profile_background', DefaultWidgetCreater((model) => MineNavBg(model))); - WidgetFactory.regist('profile_header', DefaultWidgetCreater((model) => MineHeader(model))); - WidgetFactory.regist('profile_earning', DefaultWidgetCreater((model) => MineData(model))); - WidgetFactory.regist('profile_functions', DefaultWidgetCreater((model) => MineQuickEntry(model))); - WidgetFactory.regist('profile_my_functions', DefaultWidgetCreater((model) => MineQuickEntry(model))); - WidgetFactory.regist('profile_carousel', DefaultWidgetCreater((model) => HomeBannerWidget(model))); + WidgetFactory.regist('profile_background', + DefaultWidgetCreater((model) => MineNavBg(model))); + WidgetFactory.regist( + 'profile_header', DefaultWidgetCreater((model) => MineHeader(model))); + WidgetFactory.regist( + 'profile_earning', DefaultWidgetCreater((model) => MineData(model))); + WidgetFactory.regist('profile_functions', + DefaultWidgetCreater((model) => MineQuickEntry(model))); + WidgetFactory.regist('profile_my_functions', + DefaultWidgetCreater((model) => MineQuickEntry(model))); + WidgetFactory.regist('profile_carousel', + DefaultWidgetCreater((model) => HomeBannerWidget(model))); // ==================== 钱包 WidgetFactory.regist( 'wallet_data', DefaultWidgetCreater((model) => WalletData())); -// WidgetFactory.regist( -// 'wallet_detail', DefaultWidgetCreater((model) => WalletDetail())); - WidgetFactory.regist('wallet_detail', HomeAuthCreater()); - WidgetFactory.regist('wallet_data', DefaultWidgetCreater((model) => WalletData())); - WidgetFactory.regist('wallet_detail', DefaultWidgetCreater((model) => WalletDetail())); + WidgetFactory.regist( + 'wallet_detail', DefaultWidgetCreater((model) => WalletDetail())); + WidgetFactory.regist( + 'wallet_data', DefaultWidgetCreater((model) => WalletData())); + WidgetFactory.regist( + 'wallet_detail', DefaultWidgetCreater((model) => WalletDetail())); - WidgetFactory.regist('wallet_income', DefaultWidgetCreater((model) => WalletIncome())); + WidgetFactory.regist( + 'wallet_income', DefaultWidgetCreater((model) => WalletIncome())); } } diff --git a/lib/widgets/home/home_auth/home_auth.dart b/lib/widgets/home/home_auth/home_auth.dart index 9702767..cd5d250 100644 --- a/lib/widgets/home/home_auth/home_auth.dart +++ b/lib/widgets/home/home_auth/home_auth.dart @@ -1,10 +1,20 @@ +import 'dart:convert' as convert; + +import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; +import 'package:zhiying_base_widget/widgets/home/home_auth/models/home_auth_model.dart'; import 'package:zhiying_comm/zhiying_comm.dart'; class HomeAuth extends StatelessWidget { final Map data; + Map _json; + HomeAuthModel _style; - const HomeAuth(this.data, {Key key}) : super(key: key); + HomeAuth(this.data, {Key key}) : super(key: key) { + String d = data['data']; + _json = convert.jsonDecode(d); + _style = HomeAuthModel.fromJson(Map.from(_json)); + } @override Widget build(BuildContext context) { @@ -13,12 +23,13 @@ class HomeAuth extends StatelessWidget { width: double.infinity, margin: EdgeInsets.only(left: 12, right: 12, top: 4, bottom: 4), decoration: BoxDecoration( - color: Colors.white, + color: HexColor.fromHex(_style?.bgColor ?? 'ffffff'), borderRadius: BorderRadius.circular(17), boxShadow: [ BoxShadow( offset: Offset(2, 1), //x,y轴 - color: Color(0x4d767676), //投影颜色 + color: HexColor.fromHex(_style?.shadowColor ?? '767676') + .withAlpha(70), //投影颜色 blurRadius: 5 //投影距离 ) ]), @@ -28,13 +39,20 @@ class HomeAuth extends StatelessWidget { margin: EdgeInsets.only(left: 10, right: 8), width: 20, height: 20, - color: Colors.redAccent, + child: CachedNetworkImage( + imageUrl: _style.icon, + fit: BoxFit.contain, + ), ), Expanded( child: Text( - '一键授权淘宝权限,让购物更轻松', + _style?.text ?? '', maxLines: 1, - style: TextStyle(fontSize: 12, fontWeight: FontWeight.bold), + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.bold, + color: HexColor.fromHex(_style?.textColor ?? '333333'), + ), ), ), GestureDetector( @@ -42,11 +60,14 @@ class HomeAuth extends StatelessWidget { padding: EdgeInsets.only(left: 12, right: 12, top: 3, bottom: 3), margin: EdgeInsets.only(left: 8, right: 8), decoration: BoxDecoration( - color: Colors.redAccent, + color: HexColor.fromHex(_style?.tipBtnBgColor ?? 'FF4242'), borderRadius: BorderRadius.circular(20)), child: Text( - '点击授权', - style: TextStyle(fontSize: 12, color: Colors.white), + _style?.tipBtnText ?? '', + style: TextStyle( + fontSize: 12, + color: HexColor.fromHex(_style?.tipBtnTextColor ?? 'ffffff'), + ), ), ), onTap: () async { diff --git a/lib/widgets/home/home_auth/home_auth_creater.dart b/lib/widgets/home/home_auth/home_auth_creater.dart deleted file mode 100644 index e2e72b4..0000000 --- a/lib/widgets/home/home_auth/home_auth_creater.dart +++ /dev/null @@ -1,21 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:zhiying_base_widget/widgets/home/home_auth/home_auth_delegate.dart'; -import 'package:zhiying_comm/zhiying_comm.dart'; - -class HomeAuthCreater extends WidgetCreater { - @override - List createWidgets(Map model) { - return [ - SliverPersistentHeader( - pinned: true, - floating: false, - delegate: HomeAuthDelegate(model), - ), - ]; - } - - @override - bool isSliverChild() { - return true; - } -} diff --git a/lib/widgets/home/home_auth/home_auth_delegate.dart b/lib/widgets/home/home_auth/home_auth_delegate.dart deleted file mode 100644 index db33761..0000000 --- a/lib/widgets/home/home_auth/home_auth_delegate.dart +++ /dev/null @@ -1,26 +0,0 @@ -import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; -import 'package:zhiying_base_widget/widgets/home/home_auth/home_auth.dart'; - -class HomeAuthDelegate extends SliverPersistentHeaderDelegate { - final Map data; - - HomeAuthDelegate(this.data); - - @override - Widget build( - BuildContext context, double shrinkOffset, bool overlapsContent) { - print('${shrinkOffset.toString()} ${overlapsContent.toString()}'); - return HomeAuth(data); - } - - @override - double get maxExtent => 40; - - @override - double get minExtent => 40; - - @override - bool shouldRebuild(SliverPersistentHeaderDelegate oldDelegate) => - false; // 如果内容需要更新,设置为true -} diff --git a/lib/widgets/home/home_auth/models/home_auth_model.dart b/lib/widgets/home/home_auth/models/home_auth_model.dart new file mode 100644 index 0000000..3b9a562 --- /dev/null +++ b/lib/widgets/home/home_auth/models/home_auth_model.dart @@ -0,0 +1,40 @@ +import 'package:json_annotation/json_annotation.dart'; + +part 'home_auth_model.g.dart'; + +@JsonSerializable() +class HomeAuthModel extends Object { + + @JsonKey(name: 'taobao_auth_icon') + String icon; + + @JsonKey(name: 'taoabo_tip_bg_color') + String bgColor; + + @JsonKey(name: 'taoabo_tip_shadow_color') + String shadowColor; + + @JsonKey(name: 'taoabo_tip_text_color') + String textColor; + + @JsonKey(name: 'taoabo_tip_text') + String text; + + @JsonKey(name: 'taoabo_tip_btn_text_color') + String tipBtnTextColor; + + @JsonKey(name: 'taoabo_tip_btn_bg_color') + String tipBtnBgColor; + + @JsonKey(name: 'taoabo_tip_btn_text') + String tipBtnText; + + HomeAuthModel(this.icon,this.bgColor,this.shadowColor,this.textColor,this.text,this.tipBtnTextColor,this.tipBtnBgColor,this.tipBtnText,); + + factory HomeAuthModel.fromJson(Map srcJson) => _$HomeAuthModelFromJson(srcJson); + + Map toJson() => _$HomeAuthModelToJson(this); + +} + + diff --git a/lib/widgets/home/home_auth/models/home_auth_model.g.dart b/lib/widgets/home/home_auth/models/home_auth_model.g.dart new file mode 100644 index 0000000..dde266f --- /dev/null +++ b/lib/widgets/home/home_auth/models/home_auth_model.g.dart @@ -0,0 +1,32 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'home_auth_model.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +HomeAuthModel _$HomeAuthModelFromJson(Map json) { + return HomeAuthModel( + json['taobao_auth_icon'] as String, + json['taoabo_tip_bg_color'] as String, + json['taoabo_tip_shadow_color'] as String, + json['taoabo_tip_text_color'] as String, + json['taoabo_tip_text'] as String, + json['taoabo_tip_btn_text_color'] as String, + json['taoabo_tip_btn_bg_color'] as String, + json['taoabo_tip_btn_text'] as String, + ); +} + +Map _$HomeAuthModelToJson(HomeAuthModel instance) => + { + 'taobao_auth_icon': instance.icon, + 'taoabo_tip_bg_color': instance.bgColor, + 'taoabo_tip_shadow_color': instance.shadowColor, + 'taoabo_tip_text_color': instance.textColor, + 'taoabo_tip_text': instance.text, + 'taoabo_tip_btn_text_color': instance.tipBtnTextColor, + 'taoabo_tip_btn_bg_color': instance.tipBtnBgColor, + 'taoabo_tip_btn_text': instance.tipBtnText, + }; diff --git a/lib/widgets/others/overlay/taobao_auth_overlay.dart b/lib/widgets/others/overlay/taobao_auth_overlay.dart deleted file mode 100644 index a694302..0000000 --- a/lib/widgets/others/overlay/taobao_auth_overlay.dart +++ /dev/null @@ -1,8 +0,0 @@ -import 'package:flutter/material.dart'; - -class TaobaoAuthOverlay extends StatelessWidget { - @override - Widget build(BuildContext context) { - return Container(); - } -}