From a761702aa82f508fc10da0de8c27069043e7f073 Mon Sep 17 00:00:00 2001 From: zhang <494089941@qq.com> Date: Wed, 13 Jan 2021 18:22:12 +0800 Subject: [PATCH] update grid buttons --- lib/pages/home/home_page.dart | 52 +++++++++- lib/pages/mine_car_page/mine_car_page.dart | 1 - lib/pages/personal/personal_grid_button.dart | 100 ------------------ lib/pages/personal/personal_page.dart | 81 +++++++++++++-- lib/widget/grid_buttons.dart | 60 +++++++++++ lib/widget/home_gride_button.dart | 104 ------------------- 6 files changed, 178 insertions(+), 220 deletions(-) delete mode 100644 lib/pages/personal/personal_grid_button.dart create mode 100644 lib/widget/grid_buttons.dart delete mode 100644 lib/widget/home_gride_button.dart diff --git a/lib/pages/home/home_page.dart b/lib/pages/home/home_page.dart index f5ad9444..4070677e 100644 --- a/lib/pages/home/home_page.dart +++ b/lib/pages/home/home_page.dart @@ -1,18 +1,26 @@ import 'dart:async'; import 'dart:convert'; import 'package:akuCommunity/base/base_style.dart'; +import 'package:akuCommunity/const/resource.dart'; +import 'package:akuCommunity/pages/convenient_phone/convenient_phone_page.dart'; +import 'package:akuCommunity/pages/industry_committee/industry_committee_page.dart'; +import 'package:akuCommunity/pages/life_pay/life_pay_page.dart'; import 'package:akuCommunity/pages/message_center_page/message_center_page.dart'; +import 'package:akuCommunity/pages/open_door_page/open_door_page.dart'; import 'package:akuCommunity/pages/scan/scan_page.dart'; +import 'package:akuCommunity/pages/things_page/fixed_submit_page.dart'; +import 'package:akuCommunity/pages/things_page/things_page.dart'; +import 'package:akuCommunity/pages/total_application_page/total_applications_page.dart'; +import 'package:akuCommunity/pages/visitor_access_page/visitor_access_page.dart'; import 'package:akuCommunity/widget/bee_scaffold.dart'; import 'package:akuCommunity/extensions/num_ext.dart'; -import 'package:akuCommunity/widget/home_gride_button.dart'; +import 'package:akuCommunity/widget/grid_buttons.dart'; import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter_icons/flutter_icons.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; -import 'package:akuCommunity/base/assets_image.dart'; import 'package:akuCommunity/utils/screenutil.dart'; import 'widget/home_search.dart'; import 'widget/home_swiper.dart'; @@ -20,7 +28,6 @@ import 'widget/home_card.dart'; import 'widget/home_tag_bar.dart'; import 'package:akuCommunity/widget/container_comment.dart'; import 'package:akuCommunity/widget/single_ad_space.dart'; -import 'package:akuCommunity/widget/grid_button.dart'; import 'package:akuCommunity/service/base_model.dart'; import 'package:akuCommunity/model/aku_shop_model.dart'; import 'package:akuCommunity/routers/page_routers.dart'; @@ -47,6 +54,42 @@ class _HomePageState extends State int page = 1; + List _gridList = [ + GridButton('一键开门', R.ASSETS_ICONS_TOOL_YJKM_PNG, () { + Get.to(OpenDoorPage()); + }), + GridButton('访客通行', R.ASSETS_ICONS_TOOL_FKYQ_PNG, () { + Get.to(VisitorAccessPage()); + }), + GridButton('报事报修', R.ASSETS_ICONS_TOOL_BSBX_PNG, () { + Get.to(FixedSubmitPage()); + }), + GridButton('生活缴费', R.ASSETS_ICONS_TOOL_SHJF_PNG, () { + Get.to(LifePayPage()); + }), + GridButton('业委会', R.ASSETS_ICONS_TOOL_YWH_PNG, () { + Get.to(IndustryCommitteePage()); + }), + GridButton('建议咨询', R.ASSETS_ICONS_TOOL_JYTS_PNG, () { + Get.to(ThingsPage( + bundle: Bundle() + ..putMap('things', { + 'title': '建议咨询', + 'treeList': >[ + {'name': '您的建议'}, + {'name': '您的咨询'}, + ] + }), + )); + }), + GridButton('便民电话', R.ASSETS_ICONS_TOOL_BMDH_PNG, () { + Get.to(ConvenientPhonePage()); + }), + GridButton('全部应用', R.ASSETS_ICONS_TOOL_QBYY_PNG, () { + Get.to(TotalApplicationsPage()); + }), + ]; + @override void initState() { super.initState(); @@ -160,7 +203,8 @@ class _HomePageState extends State SizedBox(height: 100.w), ContainerComment( radius: 8, - customWidget: HomeGridButton( + customWidget: GridButtons( + gridList: _gridList, crossCount: 4, ), ), diff --git a/lib/pages/mine_car_page/mine_car_page.dart b/lib/pages/mine_car_page/mine_car_page.dart index d9c39cc7..ed1c5859 100644 --- a/lib/pages/mine_car_page/mine_car_page.dart +++ b/lib/pages/mine_car_page/mine_car_page.dart @@ -3,7 +3,6 @@ import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; import 'package:akuCommunity/utils/screenutil.dart'; import 'package:akuCommunity/base/assets_image.dart'; -import 'package:akuCommunity/widget/common_app_bar.dart'; import 'package:akuCommunity/routers/page_routers.dart'; class MineCarPage extends StatefulWidget { diff --git a/lib/pages/personal/personal_grid_button.dart b/lib/pages/personal/personal_grid_button.dart deleted file mode 100644 index a9c474dc..00000000 --- a/lib/pages/personal/personal_grid_button.dart +++ /dev/null @@ -1,100 +0,0 @@ -import 'package:akuCommunity/pages/activities_page/activities_page.dart'; -import 'package:akuCommunity/pages/address_page/address_page.dart'; -import 'package:akuCommunity/pages/life_pay/life_pay_page.dart'; -import 'package:akuCommunity/pages/mine_car_page/mine_car_page.dart'; -import 'package:akuCommunity/pages/mine_house_page/mine_house_page.dart'; -import 'package:akuCommunity/pages/setting_page/settings_page.dart'; -import 'package:akuCommunity/pages/things_page/fixed_submit_page.dart'; -import 'package:akuCommunity/pages/visitor_access_page/visitor_access_page.dart'; -import 'package:akuCommunity/pages/visitor_access_page/visitor_pass_page.dart'; -import 'package:akuCommunity/routers/page_routers.dart'; -import 'package:akuCommunity/widget/home_gride_button.dart'; -import 'package:flutter/material.dart'; -import 'package:akuCommunity/const/resource.dart'; -import 'package:get/get.dart'; -import 'package:flutter_screenutil/flutter_screenutil.dart'; - -class PersonalGridButton extends StatefulWidget { - final int crossCount; - PersonalGridButton({Key key, this.crossCount}) : super(key: key); - - @override - _PersonalGridButtonState createState() => _PersonalGridButtonState(); -} - -class _PersonalGridButtonState extends State { - List _gridList = [ - GridButton('我的房屋', R.ASSETS_ICONS_USER_ICON_WDFW_PNG, () { - Get.to(MineHousePage()); - }), - GridButton('我的车位', R.ASSETS_ICONS_USER_ICON_WDCW_PNG, () { - Get.to(MineCarPage( - bundle: Bundle()..putMap('carType', {'type': '车位'}), - )); - }), - GridButton('我的车', R.ASSETS_ICONS_USER_ICON_WDC_PNG, () { - Get.to(MineCarPage( - bundle: Bundle()..putMap('carType', {'type': '车'}), - )); - }), - GridButton('社区活动', R.ASSETS_ICONS_USER_ICON_WDSQHD_PNG, () { - Get.to(ActivitiesPage( - bundle: Bundle()..putBool('isVote', false), - )); - }), - GridButton('我的缴费', R.ASSETS_ICONS_USER_ICON_WDJF_PNG, () { - Get.to(LifePayPage()); - }), - GridButton('我的保修', R.ASSETS_ICONS_USER_ICON_WDBX_PNG, () { - Get.to(FixedSubmitPage()); - }), - GridButton('我的地址', R.ASSETS_ICONS_USER_ICON_WDDZ_PNG, () { - Get.to(AddressPage()); - }), - GridButton('我的管家', R.ASSETS_ICONS_USER_ICON_WDGJ_PNG, () {}), - GridButton('我的访客', R.ASSETS_ICONS_USER_ICON_WDFK_PNG, () { - Get.to(VisitorAccessPage()); - }), - GridButton('设置', R.ASSETS_ICONS_USER_ICON_SZ_PNG, () { - Get.to(SettingsPage()); - }), - ]; - @override - Widget build(BuildContext context) { - return GridView.builder( - padding: EdgeInsets.zero, - shrinkWrap: true, - physics: NeverScrollableScrollPhysics(), - itemCount: _gridList.length, - itemBuilder: (BuildContext context, int index) { - return InkWell( - onTap: _gridList[index].onTap, - child: Container( - alignment: Alignment.center, - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Image.asset( - _gridList[index].path, - height: 53.w, - width: 53.w, - fit: BoxFit.cover, - ), - SizedBox(height: 5), - Text( - _gridList[index].title, - style: TextStyle(fontSize: 24.sp), - ) - ], - ), - ), - ); - }, - gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: widget.crossCount, - mainAxisSpacing: 6.0, - childAspectRatio: 1.0), - ); - } -} diff --git a/lib/pages/personal/personal_page.dart b/lib/pages/personal/personal_page.dart index 9b308598..23c406a6 100644 --- a/lib/pages/personal/personal_page.dart +++ b/lib/pages/personal/personal_page.dart @@ -1,7 +1,16 @@ -import 'package:akuCommunity/pages/personal/personal_grid_button.dart'; +import 'package:akuCommunity/const/resource.dart'; +import 'package:akuCommunity/pages/activities_page/activities_page.dart'; +import 'package:akuCommunity/pages/address_page/address_page.dart'; +import 'package:akuCommunity/pages/life_pay/life_pay_page.dart'; +import 'package:akuCommunity/pages/mine_car_page/mine_car_page.dart'; +import 'package:akuCommunity/pages/mine_house_page/mine_house_page.dart'; +import 'package:akuCommunity/pages/setting_page/settings_page.dart'; import 'package:akuCommunity/pages/sign/sign_in_page.dart'; +import 'package:akuCommunity/pages/things_page/fixed_submit_page.dart'; +import 'package:akuCommunity/pages/visitor_access_page/visitor_access_page.dart'; import 'package:akuCommunity/provider/user_provider.dart'; import 'package:akuCommunity/utils/net_util.dart'; +import 'package:akuCommunity/widget/grid_buttons.dart'; import 'package:ani_route/ani_route.dart'; import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; @@ -9,11 +18,11 @@ import 'package:flutter_icons/flutter_icons.dart'; import 'package:akuCommunity/utils/screenutil.dart'; import 'package:akuCommunity/base/assets_image.dart'; import 'package:akuCommunity/base/base_style.dart'; -import 'package:akuCommunity/widget/grid_button.dart'; import 'package:akuCommunity/widget/single_ad_space.dart'; import 'package:akuCommunity/widget/cached_image_wrapper.dart'; import 'package:akuCommunity/routers/page_routers.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:get/get.dart'; import 'package:provider/provider.dart'; class PersonalIndex extends StatefulWidget { @@ -26,6 +35,55 @@ class PersonalIndex extends StatefulWidget { class _PersonalIndexState extends State with SingleTickerProviderStateMixin { + List _manageGridList = [ + GridButton('我的房屋', R.ASSETS_ICONS_USER_ICON_WDFW_PNG, () { + Get.to(MineHousePage()); + }), + GridButton('我的车位', R.ASSETS_ICONS_USER_ICON_WDCW_PNG, () { + Get.to(MineCarPage( + bundle: Bundle()..putMap('carType', {'type': '车位'}), + )); + }), + GridButton('我的车', R.ASSETS_ICONS_USER_ICON_WDC_PNG, () { + Get.to(MineCarPage( + bundle: Bundle()..putMap('carType', {'type': '车'}), + )); + }), + GridButton('社区活动', R.ASSETS_ICONS_USER_ICON_WDSQHD_PNG, () { + Get.to(ActivitiesPage( + bundle: Bundle()..putBool('isVote', false), + )); + }), + GridButton('我的缴费', R.ASSETS_ICONS_USER_ICON_WDJF_PNG, () { + Get.to(LifePayPage()); + }), + GridButton('我的保修', R.ASSETS_ICONS_USER_ICON_WDBX_PNG, () { + Get.to(FixedSubmitPage()); + }), + GridButton('我的地址', R.ASSETS_ICONS_USER_ICON_WDDZ_PNG, () { + Get.to(AddressPage()); + }), + GridButton('我的管家', R.ASSETS_ICONS_USER_ICON_WDGJ_PNG, () {}), + GridButton('我的访客', R.ASSETS_ICONS_USER_ICON_WDFK_PNG, () { + Get.to(VisitorAccessPage()); + }), + GridButton('设置', R.ASSETS_ICONS_USER_ICON_SZ_PNG, () { + Get.to(SettingsPage()); + }), + ]; + + List _orderList = [ + GridButton('待付款', R.ASSETS_ICONS_USER_ICON_DFK_PNG, () {}), + GridButton('待发货', R.ASSETS_ICONS_USER_ICON_DFH_PNG, () {}), + GridButton('待收货', R.ASSETS_ICONS_USER_ICON_DSH_PNG, () {}), + GridButton('待评价', R.ASSETS_ICONS_USER_ICON_DPJ_PNG, () {}), + GridButton('售后', R.ASSETS_ICONS_USER_ICON_SH_PNG, () {}), + ]; + + List _groupOrderList = [ + GridButton('待发货', R.ASSETS_ICONS_USER_ICON_DFH_PNG, () {}), + GridButton('待收货', R.ASSETS_ICONS_USER_ICON_DSH_PNG, () {}), + ]; @override void initState() { super.initState(); @@ -183,9 +241,9 @@ class _PersonalIndexState extends State child: Container( margin: EdgeInsets.only(top: 10.w), color: BaseStyle.colorf9f9f9, - child: GridButton( - gridList: AssetsImage.orderGridList, - count: 5, + child: GridButtons( + gridList: _orderList, + crossCount: 5, ), ), ), @@ -205,9 +263,9 @@ class _PersonalIndexState extends State color: BaseStyle.colorf9f9f9, margin: EdgeInsets.only(top: 10.w), alignment: Alignment.center, - child: GridButton( - gridList: AssetsImage.orderGridList.take(3).skip(1).toList(), - count: 5, + child: GridButtons( + gridList: _groupOrderList, + crossCount: 5, ), ), ), @@ -234,9 +292,10 @@ class _PersonalIndexState extends State mainAxisAlignment: MainAxisAlignment.center, children: [ _containerBar('我的物业'), - PersonalGridButton( - crossCount: 4, - ), + GridButtons( + gridList: _manageGridList, + crossCount: 4, + ), ], ), ), diff --git a/lib/widget/grid_buttons.dart b/lib/widget/grid_buttons.dart new file mode 100644 index 00000000..d1c312dd --- /dev/null +++ b/lib/widget/grid_buttons.dart @@ -0,0 +1,60 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; + +class GridButtons extends StatefulWidget { + final List gridList; + final int crossCount; + GridButtons({Key key, this.crossCount, this.gridList}) : super(key: key); + + @override + _GridButtonsState createState() => _GridButtonsState(); +} + +class GridButton { + String title; + String path; + VoidCallback onTap; + GridButton(this.title, this.path, this.onTap); +} + +class _GridButtonsState extends State { + + @override + Widget build(BuildContext context) { + return GridView.builder( + padding: EdgeInsets.zero, + shrinkWrap: true, + physics: NeverScrollableScrollPhysics(), + itemCount: widget.gridList.length, + itemBuilder: (BuildContext context, int index) { + return InkWell( + onTap: widget.gridList[index].onTap, + child: Container( + alignment: Alignment.center, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Image.asset( + widget.gridList[index].path, + height: 53.w, + width: 53.w, + fit: BoxFit.cover, + ), + SizedBox(height: 5), + Text( + widget.gridList[index].title, + style: TextStyle(fontSize: 24.sp), + ) + ], + ), + ), + ); + }, + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: widget.crossCount, + mainAxisSpacing: 6.0, + childAspectRatio: 1.0), + ); + } +} diff --git a/lib/widget/home_gride_button.dart b/lib/widget/home_gride_button.dart deleted file mode 100644 index fe2e871c..00000000 --- a/lib/widget/home_gride_button.dart +++ /dev/null @@ -1,104 +0,0 @@ -import 'package:akuCommunity/pages/convenient_phone/convenient_phone_page.dart'; -import 'package:akuCommunity/pages/industry_committee/industry_committee_page.dart'; -import 'package:akuCommunity/pages/life_pay/life_pay_page.dart'; -import 'package:akuCommunity/pages/open_door_page/open_door_page.dart'; -import 'package:akuCommunity/pages/things_page/fixed_submit_page.dart'; -import 'package:akuCommunity/pages/things_page/things_page.dart'; -import 'package:akuCommunity/pages/total_application_page/total_applications_page.dart'; -import 'package:akuCommunity/pages/visitor_access_page/visitor_access_page.dart'; -import 'package:akuCommunity/routers/page_routers.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_screenutil/flutter_screenutil.dart'; -import 'package:akuCommunity/const/resource.dart'; -import 'package:get/get.dart'; - -class HomeGridButton extends StatefulWidget { - final int crossCount; - HomeGridButton({Key key, this.crossCount}) : super(key: key); - - @override - _HomeGridButtonState createState() => _HomeGridButtonState(); -} - -class GridButton { - String title; - String path; - VoidCallback onTap; - GridButton(this.title, this.path, this.onTap); -} - -class _HomeGridButtonState extends State { - List _gridList = [ - GridButton('一键开门', R.ASSETS_ICONS_TOOL_YJKM_PNG, () { - Get.to(OpenDoorPage()); - }), - GridButton('访客通行', R.ASSETS_ICONS_TOOL_FKYQ_PNG, () { - Get.to(VisitorAccessPage()); - }), - GridButton('报事报修', R.ASSETS_ICONS_TOOL_BSBX_PNG, () { - Get.to(FixedSubmitPage()); - }), - GridButton('生活缴费', R.ASSETS_ICONS_TOOL_SHJF_PNG, () { - Get.to(LifePayPage()); - }), - GridButton('业委会', R.ASSETS_ICONS_TOOL_YWH_PNG, () { - Get.to(IndustryCommitteePage()); - }), - GridButton('建议咨询', R.ASSETS_ICONS_TOOL_JYTS_PNG, () { - Get.to(ThingsPage( - bundle: Bundle() - ..putMap('things', { - 'title': '建议咨询', - 'treeList': >[ - {'name': '您的建议'}, - {'name': '您的咨询'}, - ] - }), - )); - }), - GridButton('便民电话', R.ASSETS_ICONS_TOOL_BMDH_PNG, () { - Get.to(ConvenientPhonePage()); - }), - GridButton('全部应用', R.ASSETS_ICONS_TOOL_QBYY_PNG, () { - Get.to(TotalApplicationsPage()); - }), - ]; - @override - Widget build(BuildContext context) { - return GridView.builder( - padding: EdgeInsets.zero, - shrinkWrap: true, - physics: NeverScrollableScrollPhysics(), - itemCount: _gridList.length, - itemBuilder: (BuildContext context, int index) { - return InkWell( - onTap: _gridList[index].onTap, - child: Container( - alignment: Alignment.center, - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Image.asset( - _gridList[index].path, - height: 53.w, - width: 53.w, - fit: BoxFit.cover, - ), - SizedBox(height: 5), - Text( - _gridList[index].title, - style: TextStyle(fontSize: 24.sp), - ) - ], - ), - ), - ); - }, - gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: widget.crossCount, - mainAxisSpacing: 6.0, - childAspectRatio: 1.0), - ); - } -}