diff --git a/lib/pages/security_page/security_page.dart b/lib/pages/security_page/security_page.dart index 1e4bec1..d920354 100644 --- a/lib/pages/security_page/security_page.dart +++ b/lib/pages/security_page/security_page.dart @@ -1,6 +1,5 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; import 'package:zhiying_base_widget/pages/security_page/models/security_style_model.dart'; import 'package:zhiying_base_widget/pages/security_page/security_page_bloc.dart'; import 'package:zhiying_comm/util/base_bloc.dart'; @@ -60,9 +59,7 @@ class _SecurityContainerState extends State<_SecurityContainer> { return _createItem(item); })?.toList() ?? []); - widgets.add(Provider.of(context).userInfo == null - ? Container() - : _createLogout()); + // widgets.add(_createLogout()); return Scaffold( backgroundColor: Color(0xfff9f9f9), diff --git a/lib/register.dart b/lib/register.dart index 5fa1ebc..a6c9c74 100644 --- a/lib/register.dart +++ b/lib/register.dart @@ -1,4 +1,3 @@ -import 'package:flutter/cupertino.dart'; import 'package:zhiying_base_widget/pages/goods_details_page/goods_details_page.dart'; import 'package:zhiying_base_widget/pages/home_page/home_page.dart'; import 'package:zhiying_base_widget/pages/main_page/main_page.dart'; @@ -18,7 +17,6 @@ import 'package:zhiying_base_widget/widgets/home/home_banner/home_banner_creater import 'package:zhiying_base_widget/widgets/home/home_banner/home_banner_widget.dart'; import 'package:zhiying_base_widget/widgets/home/home_goods/home_goods_creater.dart'; import 'package:zhiying_base_widget/widgets/home/home_notice/home_notice_widget.dart'; -import 'package:zhiying_base_widget/widgets/home/home_notice/model/home_notice_model.dart'; import 'package:zhiying_base_widget/widgets/home/home_slide_banner/home_slide_banner_creater.dart'; import 'package:zhiying_base_widget/widgets/home/home_sreach/home_sreach_creater.dart'; import 'package:zhiying_base_widget/widgets/home/home_sreach/home_sreach_widget.dart'; @@ -54,18 +52,18 @@ class BaseWidgetRegister { PageFactory.regist('profile', (model) => MainPage(model)); PageFactory.regist('category', (model) => WalletPage()); PageFactory.regist('goods_details', (model) => GoodsDetailsPage(model)); - PageFactory.regist('sreach', (model) => SreachPage() ); - PageFactory.regist('sreach_result', (model) => SreachResultPage() ); + PageFactory.regist('sreach', (model) => SreachPage()); + PageFactory.regist('sreach_result', (model) => SreachResultPage()); // PageFactory.regist('login', (model) => LoginPage(model)); // PageFactory.regist('login_quick', (model) => LoginQuickPage(model)); // 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)); - } // 注册控件 @@ -78,16 +76,20 @@ class BaseWidgetRegister { // WidgetFactory.regist('index_title', NormalNavCreater()); /// 首页搜索栏 // WidgetFactory.regist('index_search', HomeSreachCreater()); - WidgetFactory.regist('index_search', DefaultWidgetCreater((model) => HomeSreachWidget(model))); + 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()); @@ -96,35 +98,50 @@ class BaseWidgetRegister { /// ==================== 商品详情 ==================== /// // 商品详情轮播图 - 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', DefaultWidgetCreater((model) => GoodsDetailsImgWidget(model))); + WidgetFactory.regist('product_detail_img_list', + DefaultWidgetCreater((model) => GoodsDetailsImgWidget(model))); // 商品详情底部推荐列表 - WidgetFactory.regist('product_detail_bottom_rec', DefaultWidgetCreater((model) => GoodsListWidget(model))); + WidgetFactory.regist('product_detail_bottom_rec', + DefaultWidgetCreater((model) => GoodsListWidget(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( @@ -132,9 +149,12 @@ class BaseWidgetRegister { // 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_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_banner/home_banner_widget.dart b/lib/widgets/home/home_banner/home_banner_widget.dart index eab1ad3..13b9fe8 100644 --- a/lib/widgets/home/home_banner/home_banner_widget.dart +++ b/lib/widgets/home/home_banner/home_banner_widget.dart @@ -1,9 +1,9 @@ +import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.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:cached_network_image/cached_network_image.dart'; import 'package:zhiying_base_widget/widgets/home/home_banner/model/HomeBannerModel.dart'; import 'package:zhiying_comm/zhiying_comm.dart'; @@ -23,7 +23,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, ), @@ -41,10 +42,9 @@ class HomeBannerContainer extends StatefulWidget { } class _HomeBannerContainerState extends State { - /// 点击事件 - void _itemOnClick(HomeBannerListItemModel model){ - print('${model?.skip_identifier}'); + void _itemOnClick(HomeBannerListItemModel model) { + print('${model?.skipIdentifier}'); RouterUtil.route(model, model.toJson(), context); } @@ -62,14 +62,14 @@ class _HomeBannerContainerState extends State { print(state); if (state is HomeBannerLoadedState) { int lenght = state?.model?.list?.length ?? 0; - if(lenght > 0) + if (lenght > 0) return _getMainWidget(data: state?.model?.list); else return HomeBannerSkeleton(widget?.model); } if (state is HomeBannerCacheState) { int lenght = state?.model?.list?.length ?? 0; - if(lenght > 0) + if (lenght > 0) return _getMainWidget(data: state?.model?.list); else return HomeBannerSkeleton(widget?.model); @@ -80,7 +80,7 @@ class _HomeBannerContainerState extends State { } /// 获取主要视图 - Widget _getMainWidget({List data}){ + Widget _getMainWidget({List data}) { return Container( width: double.infinity, margin: EdgeInsets.only(top: 7.5, left: 2.5, right: 2.5), @@ -90,7 +90,7 @@ class _HomeBannerContainerState extends State { flex: 1, child: GestureDetector( behavior: HitTestBehavior.opaque, - onTap: ()=> _itemOnClick(model), + onTap: () => _itemOnClick(model), child: Container( margin: EdgeInsets.only(left: 5, right: 5), // decoration: BoxDecoration(color: Colors.lightBlue, borderRadius: BorderRadius.circular(7.5)), @@ -102,7 +102,6 @@ class _HomeBannerContainerState extends State { ), ); } - } // // class ItemWidget extends StatelessWidget { diff --git a/lib/widgets/home/home_sreach/home_sreach_widget.dart b/lib/widgets/home/home_sreach/home_sreach_widget.dart index bf736d4..cd3e64b 100644 --- a/lib/widgets/home/home_sreach/home_sreach_widget.dart +++ b/lib/widgets/home/home_sreach/home_sreach_widget.dart @@ -7,17 +7,16 @@ import 'package:zhiying_comm/zhiying_comm.dart'; class HomeSreachDeleagater extends SliverPersistentHeaderDelegate { final Map model; - Map _json; HomeSreachWidget _searchWidget; + Map _json; double _height; HomeSreachDeleagater(this.model) : super() { _height = MediaQueryData.fromWindow(window).padding.top + 44; - String d = model['data']; _json = Map.from(convert.jsonDecode(d)); - _searchWidget = HomeSreachWidget(_json); + _searchWidget = HomeSreachWidget(model); } @override @@ -50,7 +49,23 @@ class HomeSreachDeleagater extends SliverPersistentHeaderDelegate { class HomeSreachWidget extends StatelessWidget { final Map model; - const HomeSreachWidget(this.model); + Map _json; + + HomeSreachWidget(this.model) { + String d = model['data']; + _json = Map.from(convert.jsonDecode(d)); + } + + @override + Widget build(BuildContext context) { + return _HomeSreachContainer(_json); + } +} + +class _HomeSreachContainer extends StatelessWidget { + final Map model; + + const _HomeSreachContainer(this.model); @override Widget build(BuildContext context) { @@ -141,7 +156,7 @@ class HomeSreachWidget extends StatelessWidget { ), ), Text( - model['search_input_hint_text'], + model['search_input_hint_text'] ?? '', style: TextStyle( color: HexColor.fromHex( model['search_input_hint_text_color'] ?? '#ffffff'),