From fb423a7e61cdec85a71b7fe53542dd5be0fa2197 Mon Sep 17 00:00:00 2001 From: laiiihz Date: Sat, 8 May 2021 09:05:50 +0800 Subject: [PATCH 1/8] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=85=AC=E5=85=B1?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/generated_plugin_registrant.dart | 3 +- lib/pages/home/home_page.dart | 2 +- .../public_infomation_card.dart | 53 +++++++++++++++++++ .../public_infomation_page.dart | 2 + .../public_infomation_view.dart | 24 +++++++++ 5 files changed, 82 insertions(+), 2 deletions(-) create mode 100644 lib/ui/home/public_infomation/public_infomation_card.dart rename lib/ui/{community => home/public_infomation}/public_infomation_page.dart (88%) create mode 100644 lib/ui/home/public_infomation/public_infomation_view.dart diff --git a/lib/generated_plugin_registrant.dart b/lib/generated_plugin_registrant.dart index 8e0b1cb0..222a4e7a 100644 --- a/lib/generated_plugin_registrant.dart +++ b/lib/generated_plugin_registrant.dart @@ -6,12 +6,13 @@ import 'package:device_info_plus_web/device_info_plus_web.dart'; import 'package:firebase_core_web/firebase_core_web.dart'; -import 'package:flutter_web_plugins/flutter_web_plugins.dart'; import 'package:image_picker_for_web/image_picker_for_web.dart'; import 'package:package_info_plus_web/package_info_plus_web.dart'; import 'package:shared_preferences_web/shared_preferences_web.dart'; import 'package:url_launcher_web/url_launcher_web.dart'; +import 'package:flutter_web_plugins/flutter_web_plugins.dart'; + // ignore: public_member_api_docs void registerPlugins(Registrar registrar) { DeviceInfoPlusPlugin.registerWith(registrar); diff --git a/lib/pages/home/home_page.dart b/lib/pages/home/home_page.dart index 6036afd7..1420116b 100644 --- a/lib/pages/home/home_page.dart +++ b/lib/pages/home/home_page.dart @@ -19,7 +19,7 @@ import 'package:aku_community/provider/app_provider.dart'; import 'package:aku_community/ui/community/activity/activity_card.dart'; import 'package:aku_community/ui/community/activity/activity_list_page.dart'; import 'package:aku_community/ui/community/community_func.dart'; -import 'package:aku_community/ui/community/public_infomation_page.dart'; +import 'package:aku_community/ui/home/public_infomation/public_infomation_page.dart'; import 'package:aku_community/ui/home/home_notification.dart'; import 'package:aku_community/ui/home/home_title.dart'; import 'package:aku_community/utils/headers.dart'; diff --git a/lib/ui/home/public_infomation/public_infomation_card.dart b/lib/ui/home/public_infomation/public_infomation_card.dart new file mode 100644 index 00000000..9fb24f99 --- /dev/null +++ b/lib/ui/home/public_infomation/public_infomation_card.dart @@ -0,0 +1,53 @@ +import 'package:aku_community/base/base_style.dart'; +import 'package:flutter/material.dart'; +import 'package:aku_community/utils/headers.dart'; + +class PublicInfomationCard extends StatelessWidget { + const PublicInfomationCard({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return MaterialButton( + color: Colors.white, + elevation: 0, + materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, + onPressed: () {}, + padding: EdgeInsets.zero, + child: Container( + height: 248.w, + padding: EdgeInsets.symmetric(horizontal: 32.w, vertical: 24.w), + child: Row( + children: [ + Expanded( + child: Column( + children: [ + Text('今日快讯|日本决定将核污水拍入海中,中方对此强势喊话日本考虑需谨慎'), + Spacer(), + DefaultTextStyle( + style: TextStyle( + color: ktextSubColor, + fontSize: 20.sp, + ), + child: Row( + children: [ + Text('测试'), + Spacer(), + Text('发布于 4-11 10:11'), + ], + ), + ), + ], + ), + ), + 32.wb, + SizedBox( + width: 240.w, + height: 200.w, + child: Placeholder(), + ), + ], + ), + ), + ); + } +} diff --git a/lib/ui/community/public_infomation_page.dart b/lib/ui/home/public_infomation/public_infomation_page.dart similarity index 88% rename from lib/ui/community/public_infomation_page.dart rename to lib/ui/home/public_infomation/public_infomation_page.dart index 19e00d96..06556657 100644 --- a/lib/ui/community/public_infomation_page.dart +++ b/lib/ui/home/public_infomation/public_infomation_page.dart @@ -1,3 +1,4 @@ +import 'package:aku_community/ui/home/public_infomation/public_infomation_view.dart'; import 'package:flutter/material.dart'; import 'package:aku_community/widget/bee_scaffold.dart'; @@ -25,6 +26,7 @@ class _PublicInfomationPageState extends State return BeeScaffold( title: '公共资讯', appBarBottom: BeeTabBar(controller: _tabController, tabs: pubTabs), + body: PublicInfomationView(), ); } } diff --git a/lib/ui/home/public_infomation/public_infomation_view.dart b/lib/ui/home/public_infomation/public_infomation_view.dart new file mode 100644 index 00000000..fba43b6d --- /dev/null +++ b/lib/ui/home/public_infomation/public_infomation_view.dart @@ -0,0 +1,24 @@ +import 'package:aku_community/ui/home/public_infomation/public_infomation_card.dart'; +import 'package:flutter/material.dart'; +import 'package:aku_community/utils/headers.dart'; + +class PublicInfomationView extends StatefulWidget { + PublicInfomationView({Key? key}) : super(key: key); + + @override + _PublicInfomationViewState createState() => _PublicInfomationViewState(); +} + +class _PublicInfomationViewState extends State { + @override + Widget build(BuildContext context) { + return ListView.separated( + padding: EdgeInsets.symmetric(vertical: 24.w), + itemBuilder: (context, index) { + return PublicInfomationCard(); + }, + separatorBuilder: (_, __) => 24.hb, + itemCount: 100, + ); + } +} From c23e186969988d860d3043759f2f6d01de9b8eef Mon Sep 17 00:00:00 2001 From: laiiihz Date: Sat, 8 May 2021 10:25:05 +0800 Subject: [PATCH 2/8] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=95=86=E5=93=81?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/ui/market/market_page.dart | 8 ++ lib/ui/market/search/search_goods_page.dart | 146 ++++++++++++++++++++ lib/widget/bee_scaffold.dart | 2 +- 3 files changed, 155 insertions(+), 1 deletion(-) create mode 100644 lib/ui/market/search/search_goods_page.dart diff --git a/lib/ui/market/market_page.dart b/lib/ui/market/market_page.dart index 4f158f9f..ca21b32f 100644 --- a/lib/ui/market/market_page.dart +++ b/lib/ui/market/market_page.dart @@ -1,3 +1,5 @@ +import 'package:aku_community/ui/market/search/search_goods_page.dart'; +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; @@ -30,6 +32,12 @@ class _MarketPageState extends State super.build(context); final mediaWidth = MediaQuery.of(context).size.width; return BeeScaffold( + leading: IconButton( + icon: Icon(CupertinoIcons.search), + onPressed: () { + Get.to(() => SearchGoodsPage()); + }, + ), title: '商城', actions: [ MaterialButton( diff --git a/lib/ui/market/search/search_goods_page.dart b/lib/ui/market/search/search_goods_page.dart new file mode 100644 index 00000000..03c321d5 --- /dev/null +++ b/lib/ui/market/search/search_goods_page.dart @@ -0,0 +1,146 @@ +import 'package:aku_community/base/base_style.dart'; +import 'package:aku_community/ui/market/goods/goods_card.dart'; +import 'package:aku_community/widget/bee_scaffold.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:aku_community/utils/headers.dart'; +import 'package:waterfall_flow/waterfall_flow.dart'; + +enum OrderType { + NORMAL, + SALES, + PRICE_HIGH, + PRICE_LOW, +} + +class SearchGoodsPage extends StatefulWidget { + SearchGoodsPage({Key? key}) : super(key: key); + + @override + SearchGoodsPageState createState() => SearchGoodsPageState(); +} + +class SearchGoodsPageState extends State { + TextEditingController _editingController = TextEditingController(); + OrderType _orderType = OrderType.NORMAL; + IconData priceIcon = CupertinoIcons.chevron_up_chevron_down; + @override + Widget build(BuildContext context) { + final normalTypeButton = MaterialButton( + onPressed: () { + _orderType = OrderType.NORMAL; + priceIcon = CupertinoIcons.chevron_up_chevron_down; + setState(() {}); + }, + child: Text( + '综合', + style: TextStyle( + color: + _orderType == OrderType.NORMAL ? kDarkPrimaryColor : ktextPrimary, + ), + ), + height: 80.w, + materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, + ); + final salesTypeButton = MaterialButton( + onPressed: () { + _orderType = OrderType.SALES; + priceIcon = CupertinoIcons.chevron_up_chevron_down; + setState(() {}); + }, + child: Text( + '销量', + style: TextStyle( + color: + _orderType == OrderType.SALES ? kDarkPrimaryColor : ktextPrimary, + ), + ), + height: 80.w, + materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, + ); + + final priceButton = MaterialButton( + onPressed: () { + switch (_orderType) { + case OrderType.NORMAL: + case OrderType.SALES: + _orderType = OrderType.PRICE_HIGH; + priceIcon = CupertinoIcons.chevron_up; + break; + case OrderType.PRICE_HIGH: + _orderType = OrderType.PRICE_LOW; + priceIcon = CupertinoIcons.chevron_down; + break; + case OrderType.PRICE_LOW: + _orderType = OrderType.PRICE_HIGH; + priceIcon = CupertinoIcons.chevron_up; + break; + } + setState(() {}); + }, + child: Row( + children: [ + Text( + '价格', + style: TextStyle( + color: _orderType == OrderType.PRICE_HIGH || + _orderType == OrderType.PRICE_LOW + ? kDarkPrimaryColor + : ktextPrimary, + ), + ), + Icon( + priceIcon, + size: 32.w, + color: _orderType == OrderType.PRICE_HIGH || + _orderType == OrderType.PRICE_LOW + ? kDarkPrimaryColor + : ktextPrimary, + ), + ], + ), + height: 80.w, + materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, + ); + return BeeScaffold( + title: Padding( + padding: EdgeInsets.symmetric(vertical: 12.w), + child: TextField( + controller: _editingController, + decoration: InputDecoration( + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(40), + ), + filled: true, + fillColor: Color(0xFFF3F3F3), + isDense: true, + prefixIcon: Icon(CupertinoIcons.search), + ), + ), + ), + //TODO 列表排序 + // appBarBottom: PreferredSize( + // child: Row( + // children: [ + // normalTypeButton, + // salesTypeButton, + // priceButton, + // ], + // ), + // preferredSize: Size.fromHeight(80.w), + // ), + body: WaterfallFlow.builder( + padding: EdgeInsets.all(32.w), + gridDelegate: SliverWaterfallFlowDelegateWithFixedCrossAxisCount( + crossAxisCount: 2, + mainAxisSpacing: 20.w, + crossAxisSpacing: 20.w, + ), + itemBuilder: (context, index) { + return GoodsCard(); + }, + itemCount: 10, + ), + ); + } +} diff --git a/lib/widget/bee_scaffold.dart b/lib/widget/bee_scaffold.dart index 1df5daba..b4ce21be 100644 --- a/lib/widget/bee_scaffold.dart +++ b/lib/widget/bee_scaffold.dart @@ -5,7 +5,7 @@ import 'package:aku_community/constants/app_theme.dart'; import 'package:aku_community/widget/bee_back_button.dart'; class BeeScaffold extends StatelessWidget { - final String? title; + final dynamic? title; final Widget? body; /// appbar background color From 537dec7130aca904364a0b88576bb8c1fa81d3fa Mon Sep 17 00:00:00 2001 From: laiiihz Date: Sat, 8 May 2021 10:26:28 +0800 Subject: [PATCH 3/8] [auto task] sort & format --- lib/constants/application_objects.dart | 2 +- lib/generated_plugin_registrant.dart | 3 +-- lib/pages/express_packages/express_package_card.dart | 11 +++++++---- lib/pages/express_packages/express_package_page.dart | 10 +++++----- lib/pages/express_packages/express_package_view.dart | 6 ++++-- lib/pages/home/home_page.dart | 2 +- .../public_infomation/public_infomation_card.dart | 3 ++- .../public_infomation/public_infomation_page.dart | 2 +- .../public_infomation/public_infomation_view.dart | 3 ++- lib/ui/market/market_page.dart | 2 +- lib/ui/market/search/search_goods_page.dart | 10 ++++++---- 11 files changed, 31 insertions(+), 23 deletions(-) diff --git a/lib/constants/application_objects.dart b/lib/constants/application_objects.dart index eab4910d..276587e0 100644 --- a/lib/constants/application_objects.dart +++ b/lib/constants/application_objects.dart @@ -1,11 +1,11 @@ // import 'package:aku_community/widget/bee_scaffold.dart'; -import 'package:aku_community/pages/express_packages/express_package_page.dart'; import 'package:flutter/material.dart'; import 'package:aku_community/const/resource.dart'; import 'package:aku_community/pages/convenient_phone/convenient_phone_page.dart'; import 'package:aku_community/pages/event_activity/event_voting_page.dart'; +import 'package:aku_community/pages/express_packages/express_package_page.dart'; import 'package:aku_community/pages/goods_deto_page/goods_deto_page.dart'; import 'package:aku_community/pages/goods_manage_page/select_borrow_return_page.dart'; import 'package:aku_community/pages/industry_committee/industry_committee_page.dart'; diff --git a/lib/generated_plugin_registrant.dart b/lib/generated_plugin_registrant.dart index 222a4e7a..8e0b1cb0 100644 --- a/lib/generated_plugin_registrant.dart +++ b/lib/generated_plugin_registrant.dart @@ -6,13 +6,12 @@ import 'package:device_info_plus_web/device_info_plus_web.dart'; import 'package:firebase_core_web/firebase_core_web.dart'; +import 'package:flutter_web_plugins/flutter_web_plugins.dart'; import 'package:image_picker_for_web/image_picker_for_web.dart'; import 'package:package_info_plus_web/package_info_plus_web.dart'; import 'package:shared_preferences_web/shared_preferences_web.dart'; import 'package:url_launcher_web/url_launcher_web.dart'; -import 'package:flutter_web_plugins/flutter_web_plugins.dart'; - // ignore: public_member_api_docs void registerPlugins(Registrar registrar) { DeviceInfoPlusPlugin.registerWith(registrar); diff --git a/lib/pages/express_packages/express_package_card.dart b/lib/pages/express_packages/express_package_card.dart index e5912f2a..9f88136c 100644 --- a/lib/pages/express_packages/express_package_card.dart +++ b/lib/pages/express_packages/express_package_card.dart @@ -1,10 +1,12 @@ -import 'package:aku_community/base/base_style.dart'; -import 'package:aku_community/widget/bee_divider.dart'; import 'package:flutter/material.dart'; + import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:velocity_x/velocity_x.dart'; -import 'package:aku_community/extensions/widget_list_ext.dart'; + +import 'package:aku_community/base/base_style.dart'; import 'package:aku_community/const/resource.dart'; +import 'package:aku_community/extensions/widget_list_ext.dart'; +import 'package:aku_community/widget/bee_divider.dart'; class ExpressPackageCard extends StatefulWidget { final int index; @@ -70,7 +72,8 @@ class _ExpressPackageCardState extends State { children: [ Spacer(), MaterialButton( - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(74.w)), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(74.w)), padding: EdgeInsets.symmetric(vertical: 8.w, horizontal: 24.w), height: 50.w, color: kPrimaryColor, diff --git a/lib/pages/express_packages/express_package_page.dart b/lib/pages/express_packages/express_package_page.dart index 6ed5475f..64a2ae17 100644 --- a/lib/pages/express_packages/express_package_page.dart +++ b/lib/pages/express_packages/express_package_page.dart @@ -1,7 +1,8 @@ +import 'package:flutter/material.dart'; + import 'package:aku_community/pages/express_packages/express_package_view.dart'; import 'package:aku_community/widget/bee_scaffold.dart'; import 'package:aku_community/widget/tab_bar/bee_tab_bar.dart'; -import 'package:flutter/material.dart'; class ExpressPackagePage extends StatefulWidget { ExpressPackagePage({Key? key}) : super(key: key); @@ -26,10 +27,9 @@ class _ExpressPackagePageState extends State title: '快递包裹', appBarBottom: BeeTabBar(controller: _tabController, tabs: _tabs), body: TabBarView( - controller: _tabController, - children:List.generate(_tabs.length, (index) => ExpressPackageView(index:index)) ), + controller: _tabController, + children: List.generate( + _tabs.length, (index) => ExpressPackageView(index: index))), ); } - - } diff --git a/lib/pages/express_packages/express_package_view.dart b/lib/pages/express_packages/express_package_view.dart index 1f83fe19..5fe827ca 100644 --- a/lib/pages/express_packages/express_package_view.dart +++ b/lib/pages/express_packages/express_package_view.dart @@ -1,7 +1,9 @@ -import 'package:aku_community/pages/express_packages/express_package_card.dart'; import 'package:flutter/material.dart'; + import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:aku_community/pages/express_packages/express_package_card.dart'; + class ExpressPackageView extends StatefulWidget { final int index; ExpressPackageView({Key? key, required this.index}) : super(key: key); @@ -14,7 +16,7 @@ class _ExpressPackageViewState extends State { @override Widget build(BuildContext context) { return ListView( - padding: EdgeInsets.symmetric(vertical: 16.w,horizontal: 32.w), + padding: EdgeInsets.symmetric(vertical: 16.w, horizontal: 32.w), children: [ExpressPackageCard(index: widget.index)], ); } diff --git a/lib/pages/home/home_page.dart b/lib/pages/home/home_page.dart index 1420116b..c626658a 100644 --- a/lib/pages/home/home_page.dart +++ b/lib/pages/home/home_page.dart @@ -19,9 +19,9 @@ import 'package:aku_community/provider/app_provider.dart'; import 'package:aku_community/ui/community/activity/activity_card.dart'; import 'package:aku_community/ui/community/activity/activity_list_page.dart'; import 'package:aku_community/ui/community/community_func.dart'; -import 'package:aku_community/ui/home/public_infomation/public_infomation_page.dart'; import 'package:aku_community/ui/home/home_notification.dart'; import 'package:aku_community/ui/home/home_title.dart'; +import 'package:aku_community/ui/home/public_infomation/public_infomation_page.dart'; import 'package:aku_community/utils/headers.dart'; import 'package:aku_community/utils/login_util.dart'; import 'package:aku_community/widget/buttons/column_action_button.dart'; diff --git a/lib/ui/home/public_infomation/public_infomation_card.dart b/lib/ui/home/public_infomation/public_infomation_card.dart index 9fb24f99..1e469e79 100644 --- a/lib/ui/home/public_infomation/public_infomation_card.dart +++ b/lib/ui/home/public_infomation/public_infomation_card.dart @@ -1,5 +1,6 @@ -import 'package:aku_community/base/base_style.dart'; import 'package:flutter/material.dart'; + +import 'package:aku_community/base/base_style.dart'; import 'package:aku_community/utils/headers.dart'; class PublicInfomationCard extends StatelessWidget { diff --git a/lib/ui/home/public_infomation/public_infomation_page.dart b/lib/ui/home/public_infomation/public_infomation_page.dart index 06556657..e1e8faed 100644 --- a/lib/ui/home/public_infomation/public_infomation_page.dart +++ b/lib/ui/home/public_infomation/public_infomation_page.dart @@ -1,6 +1,6 @@ -import 'package:aku_community/ui/home/public_infomation/public_infomation_view.dart'; import 'package:flutter/material.dart'; +import 'package:aku_community/ui/home/public_infomation/public_infomation_view.dart'; import 'package:aku_community/widget/bee_scaffold.dart'; import 'package:aku_community/widget/tab_bar/bee_tab_bar.dart'; diff --git a/lib/ui/home/public_infomation/public_infomation_view.dart b/lib/ui/home/public_infomation/public_infomation_view.dart index fba43b6d..f62ee2d9 100644 --- a/lib/ui/home/public_infomation/public_infomation_view.dart +++ b/lib/ui/home/public_infomation/public_infomation_view.dart @@ -1,5 +1,6 @@ -import 'package:aku_community/ui/home/public_infomation/public_infomation_card.dart'; import 'package:flutter/material.dart'; + +import 'package:aku_community/ui/home/public_infomation/public_infomation_card.dart'; import 'package:aku_community/utils/headers.dart'; class PublicInfomationView extends StatefulWidget { diff --git a/lib/ui/market/market_page.dart b/lib/ui/market/market_page.dart index ca21b32f..5ca3f99b 100644 --- a/lib/ui/market/market_page.dart +++ b/lib/ui/market/market_page.dart @@ -1,4 +1,3 @@ -import 'package:aku_community/ui/market/search/search_goods_page.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -7,6 +6,7 @@ import 'package:get/get.dart'; import 'package:aku_community/ui/market/_market_data.dart'; import 'package:aku_community/ui/market/category/category_page.dart'; +import 'package:aku_community/ui/market/search/search_goods_page.dart'; import 'package:aku_community/utils/headers.dart'; import 'package:aku_community/widget/bee_scaffold.dart'; import 'package:aku_community/widget/tab_bar/bee_tab_bar.dart'; diff --git a/lib/ui/market/search/search_goods_page.dart b/lib/ui/market/search/search_goods_page.dart index 03c321d5..0d3b0e83 100644 --- a/lib/ui/market/search/search_goods_page.dart +++ b/lib/ui/market/search/search_goods_page.dart @@ -1,11 +1,13 @@ -import 'package:aku_community/base/base_style.dart'; -import 'package:aku_community/ui/market/goods/goods_card.dart'; -import 'package:aku_community/widget/bee_scaffold.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:aku_community/utils/headers.dart'; + import 'package:waterfall_flow/waterfall_flow.dart'; +import 'package:aku_community/base/base_style.dart'; +import 'package:aku_community/ui/market/goods/goods_card.dart'; +import 'package:aku_community/utils/headers.dart'; +import 'package:aku_community/widget/bee_scaffold.dart'; + enum OrderType { NORMAL, SALES, From 391a4713b0cfa227c99c61c3852483791e2c8c6d Mon Sep 17 00:00:00 2001 From: laiiihz Date: Sat, 8 May 2021 11:15:03 +0800 Subject: [PATCH 4/8] update static lint issue --- .../deto_create_page/deto_create_page.dart | 2 -- .../sign/sign_up/sign_up_verify_page.dart | 5 ---- lib/ui/community/activity/activity_card.dart | 28 +++++++++---------- .../topic/topic_detail_page.dart | 2 +- lib/ui/manager/advice/new_advice_page.dart | 6 ---- lib/utils/bee_parse.dart | 1 - lib/widget/views/application_view.dart | 3 +- 7 files changed, 15 insertions(+), 32 deletions(-) diff --git a/lib/pages/goods_deto_page/deto_create_page/deto_create_page.dart b/lib/pages/goods_deto_page/deto_create_page/deto_create_page.dart index 52fc5603..7bfd1981 100644 --- a/lib/pages/goods_deto_page/deto_create_page/deto_create_page.dart +++ b/lib/pages/goods_deto_page/deto_create_page/deto_create_page.dart @@ -389,8 +389,6 @@ class _DetoCreatePageState extends State { bool _canSubmit(int? weight, int approach, DateTime? dateTime, String? item) { if (weight == null) { return false; - } else if (approach == null) { - return false; } else if (dateTime == null) { return false; } else if (item.isEmptyOrNull) { diff --git a/lib/pages/sign/sign_up/sign_up_verify_page.dart b/lib/pages/sign/sign_up/sign_up_verify_page.dart index 0b057dc1..473409a7 100644 --- a/lib/pages/sign/sign_up/sign_up_verify_page.dart +++ b/lib/pages/sign/sign_up/sign_up_verify_page.dart @@ -2,14 +2,12 @@ import 'package:flutter/material.dart'; import 'package:flustars/flustars.dart'; import 'package:get/get.dart'; -import 'package:provider/provider.dart'; import 'package:velocity_x/velocity_x.dart'; import 'package:aku_community/base/base_style.dart'; import 'package:aku_community/pages/sign/sign_func.dart'; import 'package:aku_community/pages/sign/sign_up/sign_up_common_widget.dart'; import 'package:aku_community/pages/tab_navigator.dart'; -import 'package:aku_community/provider/sign_up_provider.dart'; import 'package:aku_community/utils/headers.dart'; class SignUpVerifyPage extends StatefulWidget { @@ -79,9 +77,6 @@ class _SignUpVerifyPageState extends State { disabledColor: kPrimaryColor.withOpacity(0.3), child: '登录'.text.bold.make(), onPressed: () async { - final signUpProvider = - Provider.of(context, listen: false); - if (_formKey.currentState!.validate()) { bool result = await SignFunc.signUp(); if (result) Get.offAll(() => TabNavigator()); diff --git a/lib/ui/community/activity/activity_card.dart b/lib/ui/community/activity/activity_card.dart index c5817bf0..cfa38d06 100644 --- a/lib/ui/community/activity/activity_card.dart +++ b/lib/ui/community/activity/activity_card.dart @@ -37,21 +37,19 @@ class ActivityCard extends StatelessWidget { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - ImgModel.first(model!.imgUrls) == null - ? SizedBox() - : Hero( - tag: ImgModel.first(model!.imgUrls), - child: Material( - color: Colors.grey, - child: FadeInImage.assetNetwork( - placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, - image: API.image(ImgModel.first(model!.imgUrls)), - height: 210.w, - width: double.infinity, - fit: BoxFit.cover, - ), - ), - ), + Hero( + tag: ImgModel.first(model!.imgUrls), + child: Material( + color: Colors.grey, + child: FadeInImage.assetNetwork( + placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, + image: API.image(ImgModel.first(model!.imgUrls)), + height: 210.w, + width: double.infinity, + fit: BoxFit.cover, + ), + ), + ), model!.title!.text .size(28.sp) .black diff --git a/lib/ui/community/community_views/topic/topic_detail_page.dart b/lib/ui/community/community_views/topic/topic_detail_page.dart index 408bea08..dd1d86e3 100644 --- a/lib/ui/community/community_views/topic/topic_detail_page.dart +++ b/lib/ui/community/community_views/topic/topic_detail_page.dart @@ -41,7 +41,7 @@ class _TopicDetailPageState extends State { heroTag: 'event_add', onPressed: () async { if (LoginUtil.isNotLogin) return; - bool? result = await Get.to(() => AddNewEventPage.topic( + await Get.to(() => AddNewEventPage.topic( topicName: widget.model!.summary, initTopic: widget.model!.id, )); diff --git a/lib/ui/manager/advice/new_advice_page.dart b/lib/ui/manager/advice/new_advice_page.dart index b670b90b..8c7253e5 100644 --- a/lib/ui/manager/advice/new_advice_page.dart +++ b/lib/ui/manager/advice/new_advice_page.dart @@ -41,24 +41,18 @@ class _NewAdvicePageState extends State { switch (widget.type) { case AdviceType.SUGGESTION: return '建议咨询'; - break; case AdviceType.COMPLAIN: return '投诉表扬'; - break; } - return ''; } List get tabs { switch (widget.type) { case AdviceType.SUGGESTION: return ['您的建议', '您的咨询']; - break; case AdviceType.COMPLAIN: return ['您的投诉', '您的表扬']; - break; } - return []; } _buildType(int index, String asset, String title) { diff --git a/lib/utils/bee_parse.dart b/lib/utils/bee_parse.dart index d0f11592..d547fb49 100644 --- a/lib/utils/bee_parse.dart +++ b/lib/utils/bee_parse.dart @@ -22,7 +22,6 @@ class BeeParse { switch (dif) { case -1: return '去年'; - break; case 0: return '今年'; case 1: diff --git a/lib/widget/views/application_view.dart b/lib/widget/views/application_view.dart index 3a2d3164..c0503726 100644 --- a/lib/widget/views/application_view.dart +++ b/lib/widget/views/application_view.dart @@ -18,8 +18,7 @@ class ApplicationView extends StatefulWidget { ApplicationView.custom( {Key? key, required List this.items, this.needAllApp = true}) - : assert(items != null), - super(key: key); + : super(key: key); @override _ApplicationViewState createState() => _ApplicationViewState(); From 9474139828703fbec5e60603cdbd7e464cd2fd89 Mon Sep 17 00:00:00 2001 From: laiiihz Date: Sat, 8 May 2021 11:25:29 +0800 Subject: [PATCH 5/8] ad goods detail page --- lib/ui/market/category/category_page.dart | 18 ++++++++++++++++-- lib/ui/market/goods/goods_card.dart | 4 +++- lib/ui/market/goods/goods_detail_page.dart | 16 ++++++++++++++++ 3 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 lib/ui/market/goods/goods_detail_page.dart diff --git a/lib/ui/market/category/category_page.dart b/lib/ui/market/category/category_page.dart index cf3dd0e9..964f3799 100644 --- a/lib/ui/market/category/category_page.dart +++ b/lib/ui/market/category/category_page.dart @@ -1,3 +1,4 @@ +import 'package:aku_community/base/base_style.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -43,12 +44,25 @@ class _CategoryPageState extends State { minWidth: double.infinity, onPressed: () { _index = index; - setState(() {}); }, child: Text( 'TEST', - style: TextStyle(), + style: TextStyle( + color: sameIndex ? kPrimaryColor : ktextPrimary, + ), + ), + ), + AnimatedPositioned( + left: sameIndex ? 0 : -8.w, + top: sameIndex ? 20.w : 10.w, + bottom: sameIndex ? 20.w : 10.w, + duration: Duration(milliseconds: 300), + curve: Curves.easeInOutCubic, + child: Container( + color: kPrimaryColor, + width: 8.w, + height: 40.w, ), ), ], diff --git a/lib/ui/market/goods/goods_card.dart b/lib/ui/market/goods/goods_card.dart index c04fb3bb..44495bb5 100644 --- a/lib/ui/market/goods/goods_card.dart +++ b/lib/ui/market/goods/goods_card.dart @@ -1,7 +1,9 @@ +import 'package:aku_community/ui/market/goods/goods_detail_page.dart'; import 'package:flutter/material.dart'; import 'package:aku_community/base/base_style.dart'; import 'package:aku_community/utils/headers.dart'; +import 'package:get/get.dart'; class GoodsCard extends StatelessWidget { const GoodsCard({Key? key}) : super(key: key); @@ -12,7 +14,7 @@ class GoodsCard extends StatelessWidget { color: Colors.white, elevation: 0, padding: EdgeInsets.zero, - onPressed: () {}, + onPressed: () => Get.to(() => GoodsDetailPage()), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ diff --git a/lib/ui/market/goods/goods_detail_page.dart b/lib/ui/market/goods/goods_detail_page.dart new file mode 100644 index 00000000..e1437f3b --- /dev/null +++ b/lib/ui/market/goods/goods_detail_page.dart @@ -0,0 +1,16 @@ +import 'package:aku_community/widget/bee_scaffold.dart'; +import 'package:flutter/material.dart'; + +class GoodsDetailPage extends StatefulWidget { + GoodsDetailPage({Key? key}) : super(key: key); + + @override + _GoodsDetailPageState createState() => _GoodsDetailPageState(); +} + +class _GoodsDetailPageState extends State { + @override + Widget build(BuildContext context) { + return BeeScaffold(); + } +} From c6939e6a709a20560cf13cce9d3eaf62d1325a83 Mon Sep 17 00:00:00 2001 From: laiiihz Date: Sat, 8 May 2021 13:33:08 +0800 Subject: [PATCH 6/8] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=AE=BE=E6=96=BD?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/constants/api.dart | 4 ++ lib/generated_plugin_registrant.dart | 3 +- .../facility/facility_type_detail_model.dart | 19 ++++++ .../facility_type_detail_model.g.dart | 15 ++++ .../facility/facility_appointment_page.dart | 4 +- ..._page.dart => facility_preorder_page.dart} | 12 ++-- .../facility/facility_type_card.dart | 5 +- .../facility/facility_type_detail_page.dart | 68 +++++++++++++++++++ pubspec.lock | 7 ++ pubspec.yaml | 1 + tool/_project_manage.dart | 8 +++ 11 files changed, 137 insertions(+), 9 deletions(-) create mode 100644 lib/models/facility/facility_type_detail_model.dart create mode 100644 lib/models/facility/facility_type_detail_model.g.dart rename lib/ui/community/facility/{facility_preview_page.dart => facility_preorder_page.dart} (93%) create mode 100644 lib/ui/community/facility/facility_type_detail_page.dart diff --git a/lib/constants/api.dart b/lib/constants/api.dart index f6d25e02..9b66826e 100644 --- a/lib/constants/api.dart +++ b/lib/constants/api.dart @@ -308,4 +308,8 @@ class _Facility { ///设施预约:结束使用 String get stop => '/user/facilitiesAppointment/useStop'; + + ///设施预约:根据设施分类主键id查询设施信息 + String get detailType => + '/user/facilitiesAppointment/findFacilitiesByCategoryId'; } diff --git a/lib/generated_plugin_registrant.dart b/lib/generated_plugin_registrant.dart index 8e0b1cb0..222a4e7a 100644 --- a/lib/generated_plugin_registrant.dart +++ b/lib/generated_plugin_registrant.dart @@ -6,12 +6,13 @@ import 'package:device_info_plus_web/device_info_plus_web.dart'; import 'package:firebase_core_web/firebase_core_web.dart'; -import 'package:flutter_web_plugins/flutter_web_plugins.dart'; import 'package:image_picker_for_web/image_picker_for_web.dart'; import 'package:package_info_plus_web/package_info_plus_web.dart'; import 'package:shared_preferences_web/shared_preferences_web.dart'; import 'package:url_launcher_web/url_launcher_web.dart'; +import 'package:flutter_web_plugins/flutter_web_plugins.dart'; + // ignore: public_member_api_docs void registerPlugins(Registrar registrar) { DeviceInfoPlusPlugin.registerWith(registrar); diff --git a/lib/models/facility/facility_type_detail_model.dart b/lib/models/facility/facility_type_detail_model.dart new file mode 100644 index 00000000..fd246302 --- /dev/null +++ b/lib/models/facility/facility_type_detail_model.dart @@ -0,0 +1,19 @@ +import 'package:equatable/equatable.dart'; +import 'package:json_annotation/json_annotation.dart'; +part 'facility_type_detail_model.g.dart'; + +@JsonSerializable() +class FacilityTypeDetailModel extends Equatable { + final int id; + final String name; + FacilityTypeDetailModel({ + required this.id, + required this.name, + }); + + factory FacilityTypeDetailModel.fromJson(Map json) => + _$FacilityTypeDetailModelFromJson(json); + + @override + List get props => [id]; +} diff --git a/lib/models/facility/facility_type_detail_model.g.dart b/lib/models/facility/facility_type_detail_model.g.dart new file mode 100644 index 00000000..0b36cc15 --- /dev/null +++ b/lib/models/facility/facility_type_detail_model.g.dart @@ -0,0 +1,15 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'facility_type_detail_model.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +FacilityTypeDetailModel _$FacilityTypeDetailModelFromJson( + Map json) { + return FacilityTypeDetailModel( + id: json['id'] as int, + name: json['name'] as String, + ); +} diff --git a/lib/ui/community/facility/facility_appointment_page.dart b/lib/ui/community/facility/facility_appointment_page.dart index bd39a379..df4f79e0 100644 --- a/lib/ui/community/facility/facility_appointment_page.dart +++ b/lib/ui/community/facility/facility_appointment_page.dart @@ -1,10 +1,10 @@ +import 'package:aku_community/ui/community/facility/pick_facility_page.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:aku_community/ui/community/facility/facility_appointment_view.dart'; -import 'package:aku_community/ui/community/facility/facility_preview_page.dart'; import 'package:aku_community/widget/bee_scaffold.dart'; import 'package:aku_community/widget/tab_bar/bee_tab_bar.dart'; @@ -38,7 +38,7 @@ class _FacilityAppointmentPageState extends State actions: [ IconButton( icon: Icon(CupertinoIcons.add_circled), - onPressed: () => Get.to(() => FacilityPreorderPage()), + onPressed: () => Get.to(() => PickFacilityPage()), ), ], appBarBottom: BeeTabBar( diff --git a/lib/ui/community/facility/facility_preview_page.dart b/lib/ui/community/facility/facility_preorder_page.dart similarity index 93% rename from lib/ui/community/facility/facility_preview_page.dart rename to lib/ui/community/facility/facility_preorder_page.dart index 04dd1056..ee977764 100644 --- a/lib/ui/community/facility/facility_preview_page.dart +++ b/lib/ui/community/facility/facility_preorder_page.dart @@ -1,3 +1,5 @@ +import 'package:aku_community/models/facility/facility_type_detail_model.dart'; +import 'package:aku_community/ui/community/facility/facility_type_detail_page.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -9,9 +11,7 @@ import 'package:provider/provider.dart'; import 'package:aku_community/base/base_style.dart'; import 'package:aku_community/constants/api.dart'; import 'package:aku_community/constants/app_theme.dart'; -import 'package:aku_community/models/facility/facility_type_model.dart'; import 'package:aku_community/provider/app_provider.dart'; -import 'package:aku_community/ui/community/facility/pick_facility_page.dart'; import 'package:aku_community/ui/profile/house/pick_my_house_page.dart'; import 'package:aku_community/utils/headers.dart'; import 'package:aku_community/utils/network/net_util.dart'; @@ -21,14 +21,15 @@ import 'package:aku_community/widget/buttons/bottom_button.dart'; import 'package:aku_community/widget/picker/bee_date_picker.dart'; class FacilityPreorderPage extends StatefulWidget { - FacilityPreorderPage({Key? key}) : super(key: key); + final int id; + FacilityPreorderPage({Key? key, required this.id}) : super(key: key); @override _FacilityPreorderPageState createState() => _FacilityPreorderPageState(); } class _FacilityPreorderPageState extends State { - FacilityTypeModel? typeModel; + FacilityTypeDetailModel? typeModel; DateTime? startDate; DateTime? endDate; @@ -68,7 +69,8 @@ class _FacilityPreorderPageState extends State { width: 60.w, ), onTap: () async { - FacilityTypeModel? model = await Get.to(() => PickFacilityPage()); + FacilityTypeDetailModel? model = + await Get.to(() => FacilityTypeDetailPage(model: typeModel, id: widget.id)); if (model != null) typeModel = model; setState(() {}); }, diff --git a/lib/ui/community/facility/facility_type_card.dart b/lib/ui/community/facility/facility_type_card.dart index e95f5476..99f3c309 100644 --- a/lib/ui/community/facility/facility_type_card.dart +++ b/lib/ui/community/facility/facility_type_card.dart @@ -1,3 +1,4 @@ +import 'package:aku_community/ui/community/facility/facility_preorder_page.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; @@ -74,7 +75,9 @@ class FacilityTypeCard extends StatelessWidget { 24.hb, ], ), - onPressed: () => Get.back(result: model), + onPressed: () { + Get.off(() => FacilityPreorderPage(id: model.id)); + }, ); } } diff --git a/lib/ui/community/facility/facility_type_detail_page.dart b/lib/ui/community/facility/facility_type_detail_page.dart new file mode 100644 index 00000000..f6f0a463 --- /dev/null +++ b/lib/ui/community/facility/facility_type_detail_page.dart @@ -0,0 +1,68 @@ +import 'package:aku_community/constants/api.dart'; +import 'package:aku_community/models/facility/facility_type_detail_model.dart'; +import 'package:aku_community/utils/network/base_model.dart'; +import 'package:aku_community/utils/network/net_util.dart'; +import 'package:aku_community/widget/bee_divider.dart'; +import 'package:aku_community/widget/bee_scaffold.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_easyrefresh/easy_refresh.dart'; +import 'package:get/get.dart'; + +class FacilityTypeDetailPage extends StatefulWidget { + final int id; + final FacilityTypeDetailModel? model; + FacilityTypeDetailPage({ + Key? key, + required this.model, + required this.id, + }) : super(key: key); + + @override + _FacilityTypeDetailPageState createState() => _FacilityTypeDetailPageState(); +} + +class _FacilityTypeDetailPageState extends State { + List _models = []; + @override + Widget build(BuildContext context) { + return BeeScaffold( + title: '选择设施', + body: EasyRefresh( + firstRefresh: true, + header: MaterialHeader(), + onRefresh: () async { + BaseModel model = await NetUtil().get( + API.manager.facility.detailType, + params: {'categoryId': widget.id}, + ); + _models = (model.data as List) + .map((e) => FacilityTypeDetailModel.fromJson(e)) + .toList(); + setState(() {}); + }, + child: ListView.separated( + itemBuilder: (context, index) { + final item = _models[index]; + return ListTile( + onTap: () => selectModel(item), + leading: Radio( + value: item, + groupValue: widget.model, + onChanged: (_) { + selectModel(item); + }, + ), + title: Text(item.name), + ); + }, + separatorBuilder: (_, __) => BeeDivider.horizontal(), + itemCount: _models.length, + ), + ), + ); + } + + void selectModel(FacilityTypeDetailModel model) { + Get.back(result: model); + } +} diff --git a/pubspec.lock b/pubspec.lock index 006f4b97..1b02dbad 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -302,6 +302,13 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "4.0.0" + equatable: + dependency: "direct main" + description: + name: equatable + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.0.0" extended_list_library: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 1b1742fd..c3fcdbc7 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -68,6 +68,7 @@ dependencies: json_annotation: ^4.0.1 waterfall_flow: ^3.0.1 qr_code_scanner: ^0.4.0 + equatable: ^2.0.0 dev_dependencies: flutter_test: diff --git a/tool/_project_manage.dart b/tool/_project_manage.dart index bc04b0ed..19bf399d 100644 --- a/tool/_project_manage.dart +++ b/tool/_project_manage.dart @@ -33,3 +33,11 @@ void gitPush() { arguments: ['push'], ); } + +@Task('build runner') +void gen() async { + await Pub.runAsync( + 'build_runner', + arguments: ['build'], + ); +} From 1977601ec81c2812a36a99fa8000d7ae3246b02f Mon Sep 17 00:00:00 2001 From: laiiihz Date: Sat, 8 May 2021 13:33:24 +0800 Subject: [PATCH 7/8] [auto task] sort & format --- lib/generated_plugin_registrant.dart | 3 +-- lib/models/facility/facility_type_detail_model.dart | 1 + lib/ui/community/facility/facility_appointment_page.dart | 2 +- lib/ui/community/facility/facility_preorder_page.dart | 8 ++++---- lib/ui/community/facility/facility_type_card.dart | 2 +- lib/ui/community/facility/facility_type_detail_page.dart | 8 +++++--- lib/ui/market/category/category_page.dart | 2 +- lib/ui/market/goods/goods_card.dart | 5 +++-- lib/ui/market/goods/goods_detail_page.dart | 3 ++- 9 files changed, 19 insertions(+), 15 deletions(-) diff --git a/lib/generated_plugin_registrant.dart b/lib/generated_plugin_registrant.dart index 222a4e7a..8e0b1cb0 100644 --- a/lib/generated_plugin_registrant.dart +++ b/lib/generated_plugin_registrant.dart @@ -6,13 +6,12 @@ import 'package:device_info_plus_web/device_info_plus_web.dart'; import 'package:firebase_core_web/firebase_core_web.dart'; +import 'package:flutter_web_plugins/flutter_web_plugins.dart'; import 'package:image_picker_for_web/image_picker_for_web.dart'; import 'package:package_info_plus_web/package_info_plus_web.dart'; import 'package:shared_preferences_web/shared_preferences_web.dart'; import 'package:url_launcher_web/url_launcher_web.dart'; -import 'package:flutter_web_plugins/flutter_web_plugins.dart'; - // ignore: public_member_api_docs void registerPlugins(Registrar registrar) { DeviceInfoPlusPlugin.registerWith(registrar); diff --git a/lib/models/facility/facility_type_detail_model.dart b/lib/models/facility/facility_type_detail_model.dart index fd246302..8e306b64 100644 --- a/lib/models/facility/facility_type_detail_model.dart +++ b/lib/models/facility/facility_type_detail_model.dart @@ -1,5 +1,6 @@ import 'package:equatable/equatable.dart'; import 'package:json_annotation/json_annotation.dart'; + part 'facility_type_detail_model.g.dart'; @JsonSerializable() diff --git a/lib/ui/community/facility/facility_appointment_page.dart b/lib/ui/community/facility/facility_appointment_page.dart index df4f79e0..b1e38297 100644 --- a/lib/ui/community/facility/facility_appointment_page.dart +++ b/lib/ui/community/facility/facility_appointment_page.dart @@ -1,10 +1,10 @@ -import 'package:aku_community/ui/community/facility/pick_facility_page.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:aku_community/ui/community/facility/facility_appointment_view.dart'; +import 'package:aku_community/ui/community/facility/pick_facility_page.dart'; import 'package:aku_community/widget/bee_scaffold.dart'; import 'package:aku_community/widget/tab_bar/bee_tab_bar.dart'; diff --git a/lib/ui/community/facility/facility_preorder_page.dart b/lib/ui/community/facility/facility_preorder_page.dart index ee977764..6c5b1ace 100644 --- a/lib/ui/community/facility/facility_preorder_page.dart +++ b/lib/ui/community/facility/facility_preorder_page.dart @@ -1,5 +1,3 @@ -import 'package:aku_community/models/facility/facility_type_detail_model.dart'; -import 'package:aku_community/ui/community/facility/facility_type_detail_page.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -11,7 +9,9 @@ import 'package:provider/provider.dart'; import 'package:aku_community/base/base_style.dart'; import 'package:aku_community/constants/api.dart'; import 'package:aku_community/constants/app_theme.dart'; +import 'package:aku_community/models/facility/facility_type_detail_model.dart'; import 'package:aku_community/provider/app_provider.dart'; +import 'package:aku_community/ui/community/facility/facility_type_detail_page.dart'; import 'package:aku_community/ui/profile/house/pick_my_house_page.dart'; import 'package:aku_community/utils/headers.dart'; import 'package:aku_community/utils/network/net_util.dart'; @@ -69,8 +69,8 @@ class _FacilityPreorderPageState extends State { width: 60.w, ), onTap: () async { - FacilityTypeDetailModel? model = - await Get.to(() => FacilityTypeDetailPage(model: typeModel, id: widget.id)); + FacilityTypeDetailModel? model = await Get.to(() => + FacilityTypeDetailPage(model: typeModel, id: widget.id)); if (model != null) typeModel = model; setState(() {}); }, diff --git a/lib/ui/community/facility/facility_type_card.dart b/lib/ui/community/facility/facility_type_card.dart index 99f3c309..314bd79a 100644 --- a/lib/ui/community/facility/facility_type_card.dart +++ b/lib/ui/community/facility/facility_type_card.dart @@ -1,4 +1,3 @@ -import 'package:aku_community/ui/community/facility/facility_preorder_page.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; @@ -7,6 +6,7 @@ import 'package:aku_community/base/base_style.dart'; import 'package:aku_community/constants/api.dart'; import 'package:aku_community/model/common/img_model.dart'; import 'package:aku_community/models/facility/facility_type_model.dart'; +import 'package:aku_community/ui/community/facility/facility_preorder_page.dart'; import 'package:aku_community/utils/headers.dart'; class FacilityTypeCard extends StatelessWidget { diff --git a/lib/ui/community/facility/facility_type_detail_page.dart b/lib/ui/community/facility/facility_type_detail_page.dart index f6f0a463..bec2036e 100644 --- a/lib/ui/community/facility/facility_type_detail_page.dart +++ b/lib/ui/community/facility/facility_type_detail_page.dart @@ -1,12 +1,14 @@ +import 'package:flutter/material.dart'; + +import 'package:flutter_easyrefresh/easy_refresh.dart'; +import 'package:get/get.dart'; + import 'package:aku_community/constants/api.dart'; import 'package:aku_community/models/facility/facility_type_detail_model.dart'; import 'package:aku_community/utils/network/base_model.dart'; import 'package:aku_community/utils/network/net_util.dart'; import 'package:aku_community/widget/bee_divider.dart'; import 'package:aku_community/widget/bee_scaffold.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_easyrefresh/easy_refresh.dart'; -import 'package:get/get.dart'; class FacilityTypeDetailPage extends StatefulWidget { final int id; diff --git a/lib/ui/market/category/category_page.dart b/lib/ui/market/category/category_page.dart index 964f3799..82e7c172 100644 --- a/lib/ui/market/category/category_page.dart +++ b/lib/ui/market/category/category_page.dart @@ -1,7 +1,7 @@ -import 'package:aku_community/base/base_style.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:aku_community/base/base_style.dart'; import 'package:aku_community/utils/headers.dart'; import 'package:aku_community/widget/bee_scaffold.dart'; diff --git a/lib/ui/market/goods/goods_card.dart b/lib/ui/market/goods/goods_card.dart index 44495bb5..2d874a2f 100644 --- a/lib/ui/market/goods/goods_card.dart +++ b/lib/ui/market/goods/goods_card.dart @@ -1,9 +1,10 @@ -import 'package:aku_community/ui/market/goods/goods_detail_page.dart'; import 'package:flutter/material.dart'; +import 'package:get/get.dart'; + import 'package:aku_community/base/base_style.dart'; +import 'package:aku_community/ui/market/goods/goods_detail_page.dart'; import 'package:aku_community/utils/headers.dart'; -import 'package:get/get.dart'; class GoodsCard extends StatelessWidget { const GoodsCard({Key? key}) : super(key: key); diff --git a/lib/ui/market/goods/goods_detail_page.dart b/lib/ui/market/goods/goods_detail_page.dart index e1437f3b..d742f19e 100644 --- a/lib/ui/market/goods/goods_detail_page.dart +++ b/lib/ui/market/goods/goods_detail_page.dart @@ -1,6 +1,7 @@ -import 'package:aku_community/widget/bee_scaffold.dart'; import 'package:flutter/material.dart'; +import 'package:aku_community/widget/bee_scaffold.dart'; + class GoodsDetailPage extends StatefulWidget { GoodsDetailPage({Key? key}) : super(key: key); From 9bf3a7dd8a3eb5d8a359c0db79468fb0363dd533 Mon Sep 17 00:00:00 2001 From: laiiihz Date: Sat, 8 May 2021 15:10:28 +0800 Subject: [PATCH 8/8] update category --- lib/constants/api.dart | 5 +++ lib/generated_plugin_registrant.dart | 3 +- lib/models/market/display_category_model.dart | 33 ++++++++++++++ lib/models/market/market_category_model.dart | 23 ++++++++++ .../market/market_category_model.g.dart | 17 ++++++++ lib/ui/market/category/category_card.dart | 43 +++++++++++++++++++ lib/ui/market/category/category_page.dart | 43 ++++++++++++++++--- lib/ui/market/category/category_sub_card.dart | 43 +++++++++++++++++++ lib/ui/market/category/category_sub_view.dart | 38 ++++++++++++++++ lib/ui/market/market_page.dart | 21 +++++++-- lib/utils/network/net_util.dart | 6 ++- 11 files changed, 263 insertions(+), 12 deletions(-) create mode 100644 lib/models/market/display_category_model.dart create mode 100644 lib/models/market/market_category_model.dart create mode 100644 lib/models/market/market_category_model.g.dart create mode 100644 lib/ui/market/category/category_card.dart create mode 100644 lib/ui/market/category/category_sub_card.dart create mode 100644 lib/ui/market/category/category_sub_view.dart diff --git a/lib/constants/api.dart b/lib/constants/api.dart index 9b66826e..695e092b 100644 --- a/lib/constants/api.dart +++ b/lib/constants/api.dart @@ -18,6 +18,7 @@ class API { static _Upload upload = _Upload(); static _Community community = _Community(); static _Message message = _Message(); + static _Market market = _Market(); } class _Login { @@ -255,6 +256,10 @@ class _Community { String get signUpActivity => '/user/activity/signUp'; } +class _Market { + String get category => '/user/shop/findAllCategory'; +} + class _Upload { ///上传咨询建议照片 String get uploadAdvice => '/user/upload/uploadAdvice'; diff --git a/lib/generated_plugin_registrant.dart b/lib/generated_plugin_registrant.dart index 8e0b1cb0..222a4e7a 100644 --- a/lib/generated_plugin_registrant.dart +++ b/lib/generated_plugin_registrant.dart @@ -6,12 +6,13 @@ import 'package:device_info_plus_web/device_info_plus_web.dart'; import 'package:firebase_core_web/firebase_core_web.dart'; -import 'package:flutter_web_plugins/flutter_web_plugins.dart'; import 'package:image_picker_for_web/image_picker_for_web.dart'; import 'package:package_info_plus_web/package_info_plus_web.dart'; import 'package:shared_preferences_web/shared_preferences_web.dart'; import 'package:url_launcher_web/url_launcher_web.dart'; +import 'package:flutter_web_plugins/flutter_web_plugins.dart'; + // ignore: public_member_api_docs void registerPlugins(Registrar registrar) { DeviceInfoPlusPlugin.registerWith(registrar); diff --git a/lib/models/market/display_category_model.dart b/lib/models/market/display_category_model.dart new file mode 100644 index 00000000..ccc75b3c --- /dev/null +++ b/lib/models/market/display_category_model.dart @@ -0,0 +1,33 @@ +import 'package:aku_community/constants/api.dart'; +import 'package:aku_community/models/market/market_category_model.dart'; +import 'package:aku_community/utils/network/base_model.dart'; +import 'package:aku_community/utils/network/net_util.dart'; + +class DisplayCategoryModel { + final MarketCategoryModel model; + final List children; + DisplayCategoryModel({ + required this.model, + required this.children, + }); + + static Future> get top8 async { + List models = await fetchCategory(0); + if (models.length >= 8) + return models.getRange(0, 8).toList(); + else + return models; + } + + ///获取分类列表 + static Future> fetchCategory(int parentId) async { + BaseModel model = await NetUtil().get( + API.market.category, + params: {'parentId': parentId}, + ); + if (model.data == null) return []; + return (model.data as List) + .map((e) => MarketCategoryModel.fromJson(e)) + .toList(); + } +} diff --git a/lib/models/market/market_category_model.dart b/lib/models/market/market_category_model.dart new file mode 100644 index 00000000..9be19759 --- /dev/null +++ b/lib/models/market/market_category_model.dart @@ -0,0 +1,23 @@ +import 'package:equatable/equatable.dart'; + +import 'package:aku_community/model/common/img_model.dart'; +import 'package:json_annotation/json_annotation.dart'; + +part 'market_category_model.g.dart'; + +@JsonSerializable() +class MarketCategoryModel extends Equatable { + final int id; + final String name; + final List imgList; + MarketCategoryModel({ + required this.id, + required this.name, + required this.imgList, + }); + @override + List get props => [id]; + + factory MarketCategoryModel.fromJson(Map json) => + _$MarketCategoryModelFromJson(json); +} diff --git a/lib/models/market/market_category_model.g.dart b/lib/models/market/market_category_model.g.dart new file mode 100644 index 00000000..a56d8934 --- /dev/null +++ b/lib/models/market/market_category_model.g.dart @@ -0,0 +1,17 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'market_category_model.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +MarketCategoryModel _$MarketCategoryModelFromJson(Map json) { + return MarketCategoryModel( + id: json['id'] as int, + name: json['name'] as String, + imgList: (json['imgList'] as List) + .map((e) => ImgModel.fromJson(e as Map)) + .toList(), + ); +} diff --git a/lib/ui/market/category/category_card.dart b/lib/ui/market/category/category_card.dart new file mode 100644 index 00000000..14d976c2 --- /dev/null +++ b/lib/ui/market/category/category_card.dart @@ -0,0 +1,43 @@ +import 'package:aku_community/constants/api.dart'; +import 'package:aku_community/model/common/img_model.dart'; +import 'package:aku_community/models/market/market_category_model.dart'; +import 'package:aku_community/ui/market/goods/goods_list_view.dart'; +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:aku_community/utils/headers.dart'; + +class CategoryCard extends StatelessWidget { + final MarketCategoryModel model; + const CategoryCard({Key? key, required this.model}) : super(key: key); + + @override + Widget build(BuildContext context) { + return MaterialButton( + child: Column( + children: [ + Spacer(), + FadeInImage.assetNetwork( + image: API.image(ImgModel.first(model.imgList)), + placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, + height: 75.w, + width: 75.w, + ), + 12.hb, + Text( + model.name, + style: TextStyle( + fontSize: 24.sp, + color: Color(0xFF4A4B51), + ), + ), + Spacer(), + ], + ), + onPressed: () { + Get.to( + () => GoodsListView(), + ); + }, + ); + } +} diff --git a/lib/ui/market/category/category_page.dart b/lib/ui/market/category/category_page.dart index 82e7c172..ad96c6d9 100644 --- a/lib/ui/market/category/category_page.dart +++ b/lib/ui/market/category/category_page.dart @@ -1,19 +1,37 @@ +import 'package:aku_community/models/market/market_category_model.dart'; +import 'package:aku_community/ui/market/category/category_sub_view.dart'; +import 'package:aku_community/ui/market/search/search_goods_page.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:aku_community/base/base_style.dart'; import 'package:aku_community/utils/headers.dart'; import 'package:aku_community/widget/bee_scaffold.dart'; +import 'package:get/get.dart'; class CategoryPage extends StatefulWidget { - CategoryPage({Key? key}) : super(key: key); + final List models; + CategoryPage({Key? key, required this.models}) : super(key: key); @override _CategoryPageState createState() => _CategoryPageState(); } -class _CategoryPageState extends State { +class _CategoryPageState extends State + with TickerProviderStateMixin { int _index = 0; + late TabController _tabController; + @override + void initState() { + super.initState(); + _tabController = TabController(length: widget.models.length, vsync: this); + } + + @override + void dispose() { + _tabController.dispose(); + super.dispose(); + } @override Widget build(BuildContext context) { @@ -22,7 +40,9 @@ class _CategoryPageState extends State { actions: [ IconButton( icon: Icon(CupertinoIcons.search), - onPressed: () {}, + onPressed: () { + Get.to(() => SearchGoodsPage()); + }, ), ], bgColor: Colors.white, @@ -35,8 +55,10 @@ class _CategoryPageState extends State { SizedBox( width: 203.w, child: ListView.builder( + physics: ClampingScrollPhysics(), itemBuilder: (context, index) { bool sameIndex = index == _index; + final item = widget.models[index]; return Stack( children: [ MaterialButton( @@ -44,10 +66,11 @@ class _CategoryPageState extends State { minWidth: double.infinity, onPressed: () { _index = index; + _tabController.animateTo(index); setState(() {}); }, child: Text( - 'TEST', + item.name, style: TextStyle( color: sameIndex ? kPrimaryColor : ktextPrimary, ), @@ -55,8 +78,8 @@ class _CategoryPageState extends State { ), AnimatedPositioned( left: sameIndex ? 0 : -8.w, - top: sameIndex ? 20.w : 10.w, - bottom: sameIndex ? 20.w : 10.w, + top: sameIndex ? 20.w : 30.w, + bottom: sameIndex ? 20.w : 30.w, duration: Duration(milliseconds: 300), curve: Curves.easeInOutCubic, child: Container( @@ -68,7 +91,7 @@ class _CategoryPageState extends State { ], ); }, - itemCount: 10, + itemCount: widget.models.length, ), ), VerticalDivider( @@ -76,6 +99,12 @@ class _CategoryPageState extends State { width: 1, thickness: 1, ), + TabBarView( + controller: _tabController, + physics: NeverScrollableScrollPhysics(), + children: + widget.models.map((e) => CategorySubView(id: e.id)).toList(), + ).expand(), ], ), ); diff --git a/lib/ui/market/category/category_sub_card.dart b/lib/ui/market/category/category_sub_card.dart new file mode 100644 index 00000000..0140173b --- /dev/null +++ b/lib/ui/market/category/category_sub_card.dart @@ -0,0 +1,43 @@ +import 'package:aku_community/constants/api.dart'; +import 'package:aku_community/model/common/img_model.dart'; +import 'package:aku_community/models/market/market_category_model.dart'; +import 'package:aku_community/ui/market/goods/goods_list_view.dart'; +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:aku_community/utils/headers.dart'; + +class CategorySubCard extends StatelessWidget { + final MarketCategoryModel model; + const CategorySubCard({Key? key, required this.model}) : super(key: key); + + @override + Widget build(BuildContext context) { + return MaterialButton( + child: Column( + children: [ + Spacer(), + FadeInImage.assetNetwork( + image: API.image(ImgModel.first(model.imgList)), + placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, + height: 75.w, + width: 75.w, + ), + 12.hb, + Text( + model.name, + style: TextStyle( + fontSize: 24.sp, + color: Color(0xFF4A4B51), + ), + ), + Spacer(), + ], + ), + onPressed: () { + Get.to( + () => GoodsListView(), + ); + }, + ); + } +} diff --git a/lib/ui/market/category/category_sub_view.dart b/lib/ui/market/category/category_sub_view.dart new file mode 100644 index 00000000..20b24f7b --- /dev/null +++ b/lib/ui/market/category/category_sub_view.dart @@ -0,0 +1,38 @@ +import 'package:aku_community/models/market/display_category_model.dart'; +import 'package:aku_community/models/market/market_category_model.dart'; +import 'package:aku_community/ui/market/category/category_sub_card.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_easyrefresh/easy_refresh.dart'; + +class CategorySubView extends StatefulWidget { + final int id; + CategorySubView({Key? key, required this.id}) : super(key: key); + + @override + _CategorySubViewState createState() => _CategorySubViewState(); +} + +class _CategorySubViewState extends State { + List _models = []; + @override + Widget build(BuildContext context) { + return EasyRefresh( + header: MaterialHeader(), + firstRefresh: true, + onRefresh: () async { + _models = await DisplayCategoryModel.fetchCategory(widget.id); + setState(() {}); + }, + child: GridView.builder( + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 3, + ), + itemBuilder: (context, index) { + final model = _models[index]; + return CategorySubCard(model: model); + }, + itemCount: _models.length, + ), + ); + } +} diff --git a/lib/ui/market/market_page.dart b/lib/ui/market/market_page.dart index 5ca3f99b..957d6f3c 100644 --- a/lib/ui/market/market_page.dart +++ b/lib/ui/market/market_page.dart @@ -1,3 +1,7 @@ +import 'package:aku_community/models/market/display_category_model.dart'; +import 'package:aku_community/models/market/market_category_model.dart'; +import 'package:aku_community/ui/market/category/category_card.dart'; +import 'package:bot_toast/bot_toast.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -21,10 +25,15 @@ class MarketPage extends StatefulWidget { class _MarketPageState extends State with AutomaticKeepAliveClientMixin, TickerProviderStateMixin { late TabController _tabController; + List _marketModels = []; @override void initState() { super.initState(); _tabController = TabController(length: 2, vsync: this); + DisplayCategoryModel.top8.then((value) { + _marketModels = value; + setState(() {}); + }); } @override @@ -43,7 +52,13 @@ class _MarketPageState extends State MaterialButton( minWidth: 108.w, padding: EdgeInsets.zero, - onPressed: () => Get.to(() => CategoryPage()), + onPressed: () async { + final cancel = BotToast.showLoading(); + List models = + await DisplayCategoryModel.fetchCategory(0); + cancel(); + Get.to(() => CategoryPage(models: models)); + }, child: Column( mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.max, @@ -88,8 +103,8 @@ class _MarketPageState extends State childAspectRatio: 1, ), shrinkWrap: true, - children: mockableMarketData - .map((e) => MockableMarketWidget(data: e)) + children: _marketModels + .map((e) => CategoryCard(model: e)) .toList(), ), ), diff --git a/lib/utils/network/net_util.dart b/lib/utils/network/net_util.dart index ca82b336..29b92c6e 100644 --- a/lib/utils/network/net_util.dart +++ b/lib/utils/network/net_util.dart @@ -1,5 +1,6 @@ import 'dart:io'; +import 'package:aku_community/utils/developer_util.dart'; import 'package:bot_toast/bot_toast.dart'; import 'package:dio/dio.dart'; import 'package:flustars/flustars.dart'; @@ -139,7 +140,10 @@ class NetUtil { _parseErr(DioError err) { LoggerData.addData(err); _makeToast(String message) { - BotToast.showText(text: '$message\_${err.response?.statusCode ?? ''}'); + if (DeveloperUtil.dev) + BotToast.showText(text: '$message\_${err.response?.statusCode ?? ''}'); + else + BotToast.showText(text: '网络出现问题'); } switch (err.type) {