diff --git a/assets/applications/advice.png b/assets/applications/advice.png new file mode 100644 index 00000000..e59df438 Binary files /dev/null and b/assets/applications/advice.png differ diff --git a/assets/applications/all_app.png b/assets/applications/all_app.png new file mode 100644 index 00000000..9fab8df6 Binary files /dev/null and b/assets/applications/all_app.png differ diff --git a/assets/applications/borrow.png b/assets/applications/borrow.png new file mode 100644 index 00000000..849d3de8 Binary files /dev/null and b/assets/applications/borrow.png differ diff --git a/assets/applications/box.png b/assets/applications/box.png new file mode 100644 index 00000000..633f4036 Binary files /dev/null and b/assets/applications/box.png differ diff --git a/assets/applications/committee.png b/assets/applications/committee.png new file mode 100644 index 00000000..478ab9b5 Binary files /dev/null and b/assets/applications/committee.png differ diff --git a/assets/applications/community_phone.png b/assets/applications/community_phone.png new file mode 100644 index 00000000..bdeb8053 Binary files /dev/null and b/assets/applications/community_phone.png differ diff --git a/assets/applications/complaint.png b/assets/applications/complaint.png new file mode 100644 index 00000000..264cc210 Binary files /dev/null and b/assets/applications/complaint.png differ diff --git a/assets/applications/decoration.png b/assets/applications/decoration.png new file mode 100644 index 00000000..7ee94dda Binary files /dev/null and b/assets/applications/decoration.png differ diff --git a/assets/applications/digital.png b/assets/applications/digital.png new file mode 100644 index 00000000..a575f236 Binary files /dev/null and b/assets/applications/digital.png differ diff --git a/assets/applications/door_code.png b/assets/applications/door_code.png new file mode 100644 index 00000000..77d09cdc Binary files /dev/null and b/assets/applications/door_code.png differ diff --git a/assets/applications/fix.png b/assets/applications/fix.png new file mode 100644 index 00000000..c3d77d90 Binary files /dev/null and b/assets/applications/fix.png differ diff --git a/assets/applications/goods_out.png b/assets/applications/goods_out.png new file mode 100644 index 00000000..5b4b0b8a Binary files /dev/null and b/assets/applications/goods_out.png differ diff --git a/assets/applications/home_live.png b/assets/applications/home_live.png new file mode 100644 index 00000000..d8801bea Binary files /dev/null and b/assets/applications/home_live.png differ diff --git a/assets/applications/hospital.png b/assets/applications/hospital.png new file mode 100644 index 00000000..b42386ca Binary files /dev/null and b/assets/applications/hospital.png differ diff --git a/assets/applications/makeup.png b/assets/applications/makeup.png new file mode 100644 index 00000000..34b269b4 Binary files /dev/null and b/assets/applications/makeup.png differ diff --git a/assets/applications/oepn_door.png b/assets/applications/oepn_door.png new file mode 100644 index 00000000..f29f8c1a Binary files /dev/null and b/assets/applications/oepn_door.png differ diff --git a/assets/applications/payment.png b/assets/applications/payment.png new file mode 100644 index 00000000..78fad52d Binary files /dev/null and b/assets/applications/payment.png differ diff --git a/assets/applications/police.png b/assets/applications/police.png new file mode 100644 index 00000000..49ce6dbd Binary files /dev/null and b/assets/applications/police.png differ diff --git a/assets/applications/question.png b/assets/applications/question.png new file mode 100644 index 00000000..1f4146e7 Binary files /dev/null and b/assets/applications/question.png differ diff --git a/assets/applications/snack.png b/assets/applications/snack.png new file mode 100644 index 00000000..5b66db2a Binary files /dev/null and b/assets/applications/snack.png differ diff --git a/assets/applications/tool_bmts.png b/assets/applications/tool_bmts.png new file mode 100644 index 00000000..186fc408 Binary files /dev/null and b/assets/applications/tool_bmts.png differ diff --git a/assets/applications/toy.png b/assets/applications/toy.png new file mode 100644 index 00000000..be514c01 Binary files /dev/null and b/assets/applications/toy.png differ diff --git a/assets/applications/visitor_invite.png b/assets/applications/visitor_invite.png new file mode 100644 index 00000000..8369c182 Binary files /dev/null and b/assets/applications/visitor_invite.png differ diff --git a/assets/applications/vote.png b/assets/applications/vote.png new file mode 100644 index 00000000..064f5bb6 Binary files /dev/null and b/assets/applications/vote.png differ diff --git a/assets/applications/wine.png b/assets/applications/wine.png new file mode 100644 index 00000000..86590f7b Binary files /dev/null and b/assets/applications/wine.png differ diff --git a/lib/const/resource.dart b/lib/const/resource.dart index 89cd90e4..5fd5f746 100644 --- a/lib/const/resource.dart +++ b/lib/const/resource.dart @@ -3,6 +3,106 @@ class R { const R._(); + /// ![preview](file:///Users/akufe/Documents/akuCommunity/assets/applications/advice.png) + static const String ASSETS_APPLICATIONS_ADVICE_PNG = + 'assets/applications/advice.png'; + + /// ![preview](file:///Users/akufe/Documents/akuCommunity/assets/applications/all_app.png) + static const String ASSETS_APPLICATIONS_ALL_APP_PNG = + 'assets/applications/all_app.png'; + + /// ![preview](file:///Users/akufe/Documents/akuCommunity/assets/applications/borrow.png) + static const String ASSETS_APPLICATIONS_BORROW_PNG = + 'assets/applications/borrow.png'; + + /// ![preview](file:///Users/akufe/Documents/akuCommunity/assets/applications/box.png) + static const String ASSETS_APPLICATIONS_BOX_PNG = + 'assets/applications/box.png'; + + /// ![preview](file:///Users/akufe/Documents/akuCommunity/assets/applications/committee.png) + static const String ASSETS_APPLICATIONS_COMMITTEE_PNG = + 'assets/applications/committee.png'; + + /// ![preview](file:///Users/akufe/Documents/akuCommunity/assets/applications/community_phone.png) + static const String ASSETS_APPLICATIONS_COMMUNITY_PHONE_PNG = + 'assets/applications/community_phone.png'; + + /// ![preview](file:///Users/akufe/Documents/akuCommunity/assets/applications/complaint.png) + static const String ASSETS_APPLICATIONS_COMPLAINT_PNG = + 'assets/applications/complaint.png'; + + /// ![preview](file:///Users/akufe/Documents/akuCommunity/assets/applications/decoration.png) + static const String ASSETS_APPLICATIONS_DECORATION_PNG = + 'assets/applications/decoration.png'; + + /// ![preview](file:///Users/akufe/Documents/akuCommunity/assets/applications/digital.png) + static const String ASSETS_APPLICATIONS_DIGITAL_PNG = + 'assets/applications/digital.png'; + + /// ![preview](file:///Users/akufe/Documents/akuCommunity/assets/applications/door_code.png) + static const String ASSETS_APPLICATIONS_DOOR_CODE_PNG = + 'assets/applications/door_code.png'; + + /// ![preview](file:///Users/akufe/Documents/akuCommunity/assets/applications/fix.png) + static const String ASSETS_APPLICATIONS_FIX_PNG = + 'assets/applications/fix.png'; + + /// ![preview](file:///Users/akufe/Documents/akuCommunity/assets/applications/goods_out.png) + static const String ASSETS_APPLICATIONS_GOODS_OUT_PNG = + 'assets/applications/goods_out.png'; + + /// ![preview](file:///Users/akufe/Documents/akuCommunity/assets/applications/home_live.png) + static const String ASSETS_APPLICATIONS_HOME_LIVE_PNG = + 'assets/applications/home_live.png'; + + /// ![preview](file:///Users/akufe/Documents/akuCommunity/assets/applications/hospital.png) + static const String ASSETS_APPLICATIONS_HOSPITAL_PNG = + 'assets/applications/hospital.png'; + + /// ![preview](file:///Users/akufe/Documents/akuCommunity/assets/applications/makeup.png) + static const String ASSETS_APPLICATIONS_MAKEUP_PNG = + 'assets/applications/makeup.png'; + + /// ![preview](file:///Users/akufe/Documents/akuCommunity/assets/applications/oepn_door.png) + static const String ASSETS_APPLICATIONS_OEPN_DOOR_PNG = + 'assets/applications/oepn_door.png'; + + /// ![preview](file:///Users/akufe/Documents/akuCommunity/assets/applications/payment.png) + static const String ASSETS_APPLICATIONS_PAYMENT_PNG = + 'assets/applications/payment.png'; + + /// ![preview](file:///Users/akufe/Documents/akuCommunity/assets/applications/police.png) + static const String ASSETS_APPLICATIONS_POLICE_PNG = + 'assets/applications/police.png'; + + /// ![preview](file:///Users/akufe/Documents/akuCommunity/assets/applications/question.png) + static const String ASSETS_APPLICATIONS_QUESTION_PNG = + 'assets/applications/question.png'; + + /// ![preview](file:///Users/akufe/Documents/akuCommunity/assets/applications/snack.png) + static const String ASSETS_APPLICATIONS_SNACK_PNG = + 'assets/applications/snack.png'; + + /// ![preview](file:///Users/akufe/Documents/akuCommunity/assets/applications/tool_bmts.png) + static const String ASSETS_APPLICATIONS_TOOL_BMTS_PNG = + 'assets/applications/tool_bmts.png'; + + /// ![preview](file:///Users/akufe/Documents/akuCommunity/assets/applications/toy.png) + static const String ASSETS_APPLICATIONS_TOY_PNG = + 'assets/applications/toy.png'; + + /// ![preview](file:///Users/akufe/Documents/akuCommunity/assets/applications/visitor_invite.png) + static const String ASSETS_APPLICATIONS_VISITOR_INVITE_PNG = + 'assets/applications/visitor_invite.png'; + + /// ![preview](file:///Users/akufe/Documents/akuCommunity/assets/applications/vote.png) + static const String ASSETS_APPLICATIONS_VOTE_PNG = + 'assets/applications/vote.png'; + + /// ![preview](file:///Users/akufe/Documents/akuCommunity/assets/applications/wine.png) + static const String ASSETS_APPLICATIONS_WINE_PNG = + 'assets/applications/wine.png'; + /// ![preview](file:///Users/akufe/Documents/akuCommunity/assets/example/QR_code.png) static const String ASSETS_EXAMPLE_QR_CODE_PNG = 'assets/example/QR_code.png'; diff --git a/lib/constants/application_objects.dart b/lib/constants/application_objects.dart new file mode 100644 index 00000000..f2726a40 --- /dev/null +++ b/lib/constants/application_objects.dart @@ -0,0 +1,69 @@ +import 'package:akuCommunity/const/resource.dart'; +import 'package:akuCommunity/pages/convenient_phone/convenient_phone_page.dart'; +import 'package:akuCommunity/pages/fitup_manage/fitup_manage_page.dart'; +import 'package:akuCommunity/pages/goods_deto_page/goods_deto_page.dart'; +import 'package:akuCommunity/pages/goods_manage_page/goods_manage_page.dart'; +import 'package:akuCommunity/pages/industry_committee/industry_committee_page.dart'; +import 'package:akuCommunity/pages/life_pay/life_pay_page.dart'; +import 'package:akuCommunity/pages/open_door_page/open_door_page.dart'; +import 'package:akuCommunity/pages/opening_code_page/opening_code_page.dart'; +import 'package:akuCommunity/pages/questionnaire_page/questionnaire_details_page/questionnaire_details_page.dart'; +import 'package:akuCommunity/pages/things_page/fixed_submit_page.dart'; +import 'package:akuCommunity/pages/visitor_access_page/visitor_access_page.dart'; +import 'package:akuCommunity/ui/home/application/all_application.dart'; +import 'package:akuCommunity/ui/manager/advice/advice_page.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/widgets.dart'; + +///应用对象 +///Application Object +class AO { + String title = ''; + String path = ''; + Widget page = Scaffold(); + + AO( + this.title, + this.path, + this.page, + ); + + AO.fromRaw(String raw) { + appObjects.forEach((element) { + if (element.title == raw) { + this.title = element.title; + this.path = element.path; + this.page = element.page; + } + }); + } + + @override + bool operator ==(Object other) => + identical(this, other) || + other is AO && runtimeType == other.runtimeType && title == other.title; + + @override + int get hashCode => title.hashCode; +} + +List appObjects = [ + AO('一键开门', R.ASSETS_APPLICATIONS_OEPN_DOOR_PNG, OpenDoorPage()), + AO('开门码', R.ASSETS_APPLICATIONS_DOOR_CODE_PNG, OpeningCodePage()), + AO('访客邀请', R.ASSETS_APPLICATIONS_VISITOR_INVITE_PNG, VisitorAccessPage()), + AO('报事报修', R.ASSETS_APPLICATIONS_FIX_PNG, FixedSubmitPage()), + AO('生活缴费', R.ASSETS_APPLICATIONS_PAYMENT_PNG, LifePayPage()), + AO('业委会', R.ASSETS_APPLICATIONS_COMMITTEE_PNG, IndustryCommitteePage()), + AO('建议咨询', R.ASSETS_APPLICATIONS_ADVICE_PNG, + AdvicePage(type: AdviceType.SUGGESTION)), + AO('便民电话', R.ASSETS_APPLICATIONS_COMMUNITY_PHONE_PNG, ConvenientPhonePage()), + AO('活动投票', R.ASSETS_APPLICATIONS_VOTE_PNG, SizedBox()), + AO('物品出门', R.ASSETS_APPLICATIONS_GOODS_OUT_PNG, GoodsDetoPage()), + AO('投诉表扬', R.ASSETS_APPLICATIONS_COMPLAINT_PNG, + AdvicePage(type: AdviceType.COMPLAIN)), + AO('问卷调查', R.ASSETS_APPLICATIONS_QUESTION_PNG, QuestionnaireDetailsPage()), + AO('装修管理', R.ASSETS_APPLICATIONS_DECORATION_PNG, FitupManagePage()), + AO('借还管理', R.ASSETS_APPLICATIONS_BORROW_PNG, GoodsManagePage()), +]; + +AO allApp = AO('全部应用', R.ASSETS_APPLICATIONS_ALL_APP_PNG, AllApplicationPage()); diff --git a/lib/main.dart b/lib/main.dart index a75aa283..97868f42 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,4 +1,5 @@ // Flutter imports: +import 'package:akuCommunity/provider/app_provider.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -44,6 +45,7 @@ class _MyAppState extends State { providers: [ ChangeNotifierProvider(create: (context) => CartProvidde()), ChangeNotifierProvider(create: (context) => UserProvider()), + ChangeNotifierProvider(create: (context) => AppProvider()), ChangeNotifierProvider(create: (context) => SignUpProvider()), ], child: GestureDetector( diff --git a/lib/pages/home/home_page.dart b/lib/pages/home/home_page.dart index 4784a24d..4d338a6d 100644 --- a/lib/pages/home/home_page.dart +++ b/lib/pages/home/home_page.dart @@ -4,6 +4,8 @@ import 'dart:convert'; // Flutter imports: import 'package:akuCommunity/model/community/board_model.dart'; +import 'package:akuCommunity/ui/home/application/all_application.dart'; +import 'package:akuCommunity/widget/views/application_view.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -74,8 +76,7 @@ class _HomePageState extends State GridButton('建议咨询', R.ASSETS_ICONS_TOOL_JYTS_PNG, AdvicePage(type: AdviceType.SUGGESTION).to), GridButton('便民电话', R.ASSETS_ICONS_TOOL_BMDH_PNG, ConvenientPhonePage().to), - GridButton( - '全部应用', R.ASSETS_ICONS_TOOL_QBYY_PNG, TotalApplicationsPage().to), + GridButton('全部应用', R.ASSETS_ICONS_TOOL_QBYY_PNG, AllApplicationPage().to), ]; @override @@ -158,6 +159,10 @@ class _HomePageState extends State HomeSearch(), HomeSwiper(), SizedBox(height: 100.w), + ContainerComment( + radius: 8, + customWidget: ApplicationView(), + ), ContainerComment( radius: 8, customWidget: GridButtons( diff --git a/lib/pages/splash/splash_page.dart b/lib/pages/splash/splash_page.dart index b2d7e837..af62e8f5 100644 --- a/lib/pages/splash/splash_page.dart +++ b/lib/pages/splash/splash_page.dart @@ -1,4 +1,5 @@ // Flutter imports: +import 'package:akuCommunity/provider/app_provider.dart'; import 'package:flutter/material.dart'; // Package imports: diff --git a/lib/provider/app_provider.dart b/lib/provider/app_provider.dart new file mode 100644 index 00000000..9f9d7be8 --- /dev/null +++ b/lib/provider/app_provider.dart @@ -0,0 +1,42 @@ +import 'package:akuCommunity/constants/application_objects.dart'; +import 'package:flutter/material.dart'; + +class AppProvider extends ChangeNotifier { + ///初始值为 + /// + ///``` + ///'一键开门', + /// '访客邀请', + /// '报事报修', + /// '生活缴费', + /// '业委会', + /// '建议投诉', + /// '便民电话', + ///``` + List _myApplications = [ + '一键开门', + '访客邀请', + '报事报修', + '生活缴费', + '业委会', + '建议咨询', + '便民电话', + ].map((e) => AO.fromRaw(e)).toList(); + + ///我的应用 + List get myApplications { + return _myApplications; + } + + ///添加我的应用 + insertApplication(AO app) { + if (!_myApplications.contains(app) && _myApplications.length < 7) + _myApplications.insert(0, app); + notifyListeners(); + } + + ///移除我的应用 + removeApplication(AO obj) { + if (_myApplications.remove(obj)) notifyListeners(); + } +} diff --git a/lib/ui/home/application/all_application.dart b/lib/ui/home/application/all_application.dart new file mode 100644 index 00000000..87b346df --- /dev/null +++ b/lib/ui/home/application/all_application.dart @@ -0,0 +1,52 @@ +import 'package:akuCommunity/base/base_style.dart'; +import 'package:akuCommunity/utils/headers.dart'; +import 'package:akuCommunity/widget/bee_back_button.dart'; +import 'package:flutter/material.dart'; +import 'package:velocity_x/velocity_x.dart'; + +class AllApplicationPage extends StatefulWidget { + AllApplicationPage({Key key}) : super(key: key); + + @override + _AllApplicationPageState createState() => _AllApplicationPageState(); +} + +class _AllApplicationPageState extends State { + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: Color(0xFFF4F4F4), + appBar: AppBar( + backgroundColor: Colors.white, + elevation: 0, + leading: BeeBackButton(), + title: MaterialButton( + materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, + height: 72.w, + shape: StadiumBorder(), + elevation: 0, + minWidth: double.infinity, + color: Color(0xFFF3F3F3), + onPressed: () {}, + child: Row( + children: [ + Icon( + Icons.search, + size: 32.w, + color: Color(0xFF666666), + ), + 10.wb, + '搜索商品、活动、帖子、应用' + .text + .size(28.sp) + .color(ktextSubColor) + .make() + .expand(), + ], + ), + ), + ), + // body: , + ); + } +} diff --git a/lib/utils/headers.dart b/lib/utils/headers.dart index df1f61bd..c2eef697 100644 --- a/lib/utils/headers.dart +++ b/lib/utils/headers.dart @@ -3,6 +3,7 @@ export 'package:akuCommunity/extensions/page_router.dart'; export 'package:akuCommunity/extensions/num_ext.dart'; export 'package:akuCommunity/extensions/widget_list_ext.dart'; export 'package:velocity_x/velocity_x.dart'; +export 'package:akuCommunity/const/resource.dart'; // class Screenutil { // static double length(double lengthNum) => ScreenUtil().setWidth(lengthNum); diff --git a/lib/widget/container_comment.dart b/lib/widget/container_comment.dart index fd4caea0..c6fc52e3 100644 --- a/lib/widget/container_comment.dart +++ b/lib/widget/container_comment.dart @@ -5,6 +5,8 @@ import 'package:flutter/material.dart'; // Package imports: import 'package:flutter_screenutil/flutter_screenutil.dart'; +//TODO CLEAN BOTTOM CODES. +@Deprecated("sh*t container_comment need to be cleaned.") class ContainerComment extends StatelessWidget { final Widget customWidget; final double radius; diff --git a/lib/widget/grid_buttons.dart b/lib/widget/grid_buttons.dart index 673c2992..cc6f547d 100644 --- a/lib/widget/grid_buttons.dart +++ b/lib/widget/grid_buttons.dart @@ -4,6 +4,8 @@ import 'package:flutter/material.dart'; // Package imports: import 'package:flutter_screenutil/flutter_screenutil.dart'; +//TODO CLEAN BOTTOM CODES. +@Deprecated("sh*t grid_buttons need to be cleaned.") class GridButtons extends StatefulWidget { final List gridList; final int crossCount; @@ -21,7 +23,6 @@ class GridButton { } class _GridButtonsState extends State { - @override Widget build(BuildContext context) { return GridView.builder( @@ -55,9 +56,10 @@ class _GridButtonsState extends State { ); }, gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: widget.crossCount, - mainAxisSpacing: 6.0, - childAspectRatio: 1.0), + crossAxisCount: widget.crossCount, + mainAxisSpacing: 6.0, + childAspectRatio: 1.0, + ), ); } } diff --git a/lib/widget/views/application_view.dart b/lib/widget/views/application_view.dart new file mode 100644 index 00000000..af331125 --- /dev/null +++ b/lib/widget/views/application_view.dart @@ -0,0 +1,53 @@ +import 'package:akuCommunity/utils/headers.dart'; +import 'package:akuCommunity/constants/application_objects.dart'; +import 'package:akuCommunity/provider/app_provider.dart'; +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:provider/provider.dart'; +import 'package:velocity_x/velocity_x.dart'; + +class ApplicationView extends StatefulWidget { + ApplicationView({Key key}) : super(key: key); + + @override + _ApplicationViewState createState() => _ApplicationViewState(); +} + +class _ApplicationViewState extends State { + _buildTile(AO object) { + return MaterialButton( + shape: StadiumBorder(), + padding: EdgeInsets.zero, + onPressed: () => Get.to(object.page), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Image.asset( + object.path, + height: 75.w, + width: 75.w, + ), + 8.hb, + object.title.text.size(24.sp).make(), + ], + ), + ); + } + + @override + Widget build(BuildContext context) { + final appProvider = Provider.of(context); + return GridView.builder( + padding: EdgeInsets.zero, + gridDelegate: + SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 4), + itemBuilder: (context, index) { + if (index == appProvider.myApplications.length) + return _buildTile(allApp); + return _buildTile(appProvider.myApplications[index]); + }, + itemCount: appProvider.myApplications.length + 1, + shrinkWrap: true, + ); + } +} diff --git a/pubspec.yaml b/pubspec.yaml index 3c89e8a6..b06b4409 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -115,3 +115,4 @@ flutter: - assets/example/ - assets/tab/ - assets/json/ + - assets/applications/