diff --git a/lib/constants/api.dart b/lib/constants/api.dart index f6d25e02..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'; @@ -308,4 +313,8 @@ class _Facility { ///设施预约:结束使用 String get stop => '/user/facilitiesAppointment/useStop'; + + ///设施预约:根据设施分类主键id查询设施信息 + String get detailType => + '/user/facilitiesAppointment/findFacilitiesByCategoryId'; } 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/models/facility/facility_type_detail_model.dart b/lib/models/facility/facility_type_detail_model.dart new file mode 100644 index 00000000..8e306b64 --- /dev/null +++ b/lib/models/facility/facility_type_detail_model.dart @@ -0,0 +1,20 @@ +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/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/pages/express_packages/express_package_card.dart b/lib/pages/express_packages/express_package_card.dart index 55a530e0..51c18784 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; @@ -94,7 +96,27 @@ class _ExpressPackageCardState extends State { ) ], ), - ] + ], + 40.w.heightBox, + Row( + children: [ + Spacer(), + MaterialButton( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(74.w)), + padding: EdgeInsets.symmetric(vertical: 8.w, horizontal: 24.w), + height: 50.w, + color: kPrimaryColor, + elevation: 0, + focusElevation: 0, + hoverElevation: 0, + disabledElevation: 0, + highlightElevation: 0, + onPressed: () {}, + child: '确认领取'.text.size(24.sp).bold.color(ktextPrimary).make(), + ) + ], + ), ], ), ); 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/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/home/home_page.dart b/lib/pages/home/home_page.dart index 6036afd7..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/community/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/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/community/facility/facility_appointment_page.dart b/lib/ui/community/facility/facility_appointment_page.dart index bd39a379..b1e38297 100644 --- a/lib/ui/community/facility/facility_appointment_page.dart +++ b/lib/ui/community/facility/facility_appointment_page.dart @@ -4,7 +4,7 @@ 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/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'; @@ -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..6c5b1ace 100644 --- a/lib/ui/community/facility/facility_preview_page.dart +++ b/lib/ui/community/facility/facility_preorder_page.dart @@ -9,9 +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_model.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/pick_facility_page.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'; @@ -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..314bd79a 100644 --- a/lib/ui/community/facility/facility_type_card.dart +++ b/lib/ui/community/facility/facility_type_card.dart @@ -6,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 { @@ -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..bec2036e --- /dev/null +++ b/lib/ui/community/facility/facility_type_detail_page.dart @@ -0,0 +1,70 @@ +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'; + +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/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..1e469e79 --- /dev/null +++ b/lib/ui/home/public_infomation/public_infomation_card.dart @@ -0,0 +1,54 @@ +import 'package:flutter/material.dart'; + +import 'package:aku_community/base/base_style.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..e1e8faed 100644 --- a/lib/ui/community/public_infomation_page.dart +++ b/lib/ui/home/public_infomation/public_infomation_page.dart @@ -1,5 +1,6 @@ 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'; @@ -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..f62ee2d9 --- /dev/null +++ b/lib/ui/home/public_infomation/public_infomation_view.dart @@ -0,0 +1,25 @@ +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 { + 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, + ); + } +} 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/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 cf3dd0e9..ad96c6d9 100644 --- a/lib/ui/market/category/category_page.dart +++ b/lib/ui/market/category/category_page.dart @@ -1,18 +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) { @@ -21,7 +40,9 @@ class _CategoryPageState extends State { actions: [ IconButton( icon: Icon(CupertinoIcons.search), - onPressed: () {}, + onPressed: () { + Get.to(() => SearchGoodsPage()); + }, ), ], bgColor: Colors.white, @@ -34,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( @@ -43,18 +66,32 @@ class _CategoryPageState extends State { minWidth: double.infinity, onPressed: () { _index = index; - + _tabController.animateTo(index); setState(() {}); }, child: Text( - 'TEST', - style: TextStyle(), + item.name, + style: TextStyle( + color: sameIndex ? kPrimaryColor : ktextPrimary, + ), + ), + ), + AnimatedPositioned( + left: sameIndex ? 0 : -8.w, + top: sameIndex ? 20.w : 30.w, + bottom: sameIndex ? 20.w : 30.w, + duration: Duration(milliseconds: 300), + curve: Curves.easeInOutCubic, + child: Container( + color: kPrimaryColor, + width: 8.w, + height: 40.w, ), ), ], ); }, - itemCount: 10, + itemCount: widget.models.length, ), ), VerticalDivider( @@ -62,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/goods/goods_card.dart b/lib/ui/market/goods/goods_card.dart index c04fb3bb..2d874a2f 100644 --- a/lib/ui/market/goods/goods_card.dart +++ b/lib/ui/market/goods/goods_card.dart @@ -1,6 +1,9 @@ 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'; class GoodsCard extends StatelessWidget { @@ -12,7 +15,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..d742f19e --- /dev/null +++ b/lib/ui/market/goods/goods_detail_page.dart @@ -0,0 +1,17 @@ +import 'package:flutter/material.dart'; + +import 'package:aku_community/widget/bee_scaffold.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(); + } +} diff --git a/lib/ui/market/market_page.dart b/lib/ui/market/market_page.dart index 4f158f9f..957d6f3c 100644 --- a/lib/ui/market/market_page.dart +++ b/lib/ui/market/market_page.dart @@ -1,3 +1,8 @@ +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'; import 'package:flutter_screenutil/flutter_screenutil.dart'; @@ -5,6 +10,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'; @@ -19,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 @@ -30,12 +41,24 @@ 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( 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, @@ -80,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/ui/market/search/search_goods_page.dart b/lib/ui/market/search/search_goods_page.dart new file mode 100644 index 00000000..0d3b0e83 --- /dev/null +++ b/lib/ui/market/search/search_goods_page.dart @@ -0,0 +1,148 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.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, + 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/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/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) { 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 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(); 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'], + ); +}