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/assets/icons/alarm.png b/assets/icons/alarm.png new file mode 100644 index 00000000..f9400ca1 Binary files /dev/null and b/assets/icons/alarm.png differ diff --git a/lib/const/resource.dart b/lib/const/resource.dart index 89cd90e4..9773b63e 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'; @@ -105,6 +205,9 @@ class R { /// ![preview](file:///Users/akufe/Documents/akuCommunity/assets/icons/add.png) static const String ASSETS_ICONS_ADD_PNG = 'assets/icons/add.png'; + /// ![preview](file:///Users/akufe/Documents/akuCommunity/assets/icons/alarm.png) + static const String ASSETS_ICONS_ALARM_PNG = 'assets/icons/alarm.png'; + /// ![preview](file:///Users/akufe/Documents/akuCommunity/assets/icons/app_add.png) static const String ASSETS_ICONS_APP_ADD_PNG = 'assets/icons/app_add.png'; diff --git a/lib/constants/api.dart b/lib/constants/api.dart index 0da0fa35..49184be1 100644 --- a/lib/constants/api.dart +++ b/lib/constants/api.dart @@ -159,6 +159,9 @@ class _Community { ///社区公告:根据社区公告主键id查询社区公告信息 String get boardDetail => '/user/announcement/findById'; + + ///社区话题:查询最新的所有主题信息 + String get topicList => '/user/gambit/list'; } class _Upload { diff --git a/lib/constants/application_objects.dart b/lib/constants/application_objects.dart new file mode 100644 index 00000000..f6c9d9bd --- /dev/null +++ b/lib/constants/application_objects.dart @@ -0,0 +1,107 @@ +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/one_alarm/widget/alarm_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) => + 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('一键报警', R.ASSETS_APPLICATIONS_POLICE_PNG, AlarmPage()), +]; + +///全部应用按钮 +AO allApp = AO('全部应用', R.ASSETS_APPLICATIONS_ALL_APP_PNG, AllApplicationPage()); + +///为您推荐 original value +List _recommendApp = [ + '一键开门', + '访客邀请', + '报事报修', + '建议咨询', + '一键报警', +]; + +///为您推荐 +List get recommendApp => _recommendApp.map((e) => AO.fromRaw(e)).toList(); + +///智慧管家 original value +List _smartManagerApp = [ + '一键开门', + '开门码', + '访客邀请', + '报事报修', + '生活缴费', + '业委会', + '建议咨询', + '便民电话', + '活动投票', + '物品出门', + '投诉表扬', + '问卷调查', + '装修管理', + '借还管理', + '一键报警', +]; + +///智慧管家 +List get smartManagerApp => + _smartManagerApp.map((e) => AO.fromRaw(e)).toList(); 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/model/community/community_topic_model.dart b/lib/model/community/community_topic_model.dart new file mode 100644 index 00000000..6508ff3c --- /dev/null +++ b/lib/model/community/community_topic_model.dart @@ -0,0 +1,146 @@ +import 'package:akuCommunity/model/common/img_model.dart'; + +class CommunityTopicModel { + int id; + int createId; + int isComment; + int isLike; + String createName; + String content; + String gambitTitle; + String createDate; + List likeNames; + List imgUrls; + List headSculptureImgUrl; + List gambitThemeCommentVoList; + + CommunityTopicModel( + {this.id, + this.createId, + this.isComment, + this.isLike, + this.createName, + this.content, + this.gambitTitle, + this.createDate, + this.likeNames, + this.imgUrls, + this.headSculptureImgUrl, + this.gambitThemeCommentVoList}); + + CommunityTopicModel.fromJson(Map json) { + id = json['id']; + createId = json['createId']; + isComment = json['isComment']; + isLike = json['isLike']; + createName = json['createName']; + content = json['content']; + gambitTitle = json['gambitTitle']; + createDate = json['createDate']; + if (json['likeNames'] != null) { + likeNames = new List(); + json['likeNames'].forEach((v) { + likeNames.add(new LikeNames.fromJson(v)); + }); + } + if (json['imgUrls'] != null) { + imgUrls = new List(); + json['imgUrls'].forEach((v) { + imgUrls.add(new ImgModel.fromJson(v)); + }); + } else + imgUrls = []; + if (json['headSculptureImgUrl'] != null) { + headSculptureImgUrl = new List(); + json['headSculptureImgUrl'].forEach((v) { + headSculptureImgUrl.add(new ImgModel.fromJson(v)); + }); + } else + headSculptureImgUrl = []; + if (json['gambitThemeCommentVoList'] != null) { + gambitThemeCommentVoList = new List(); + json['gambitThemeCommentVoList'].forEach((v) { + gambitThemeCommentVoList.add(new GambitThemeCommentVoList.fromJson(v)); + }); + } + } + + Map toJson() { + final Map data = new Map(); + data['id'] = this.id; + data['createId'] = this.createId; + data['isComment'] = this.isComment; + data['isLike'] = this.isLike; + data['createName'] = this.createName; + data['content'] = this.content; + data['gambitTitle'] = this.gambitTitle; + data['createDate'] = this.createDate; + if (this.likeNames != null) { + data['likeNames'] = this.likeNames.map((v) => v.toJson()).toList(); + } + if (this.imgUrls != null) { + data['imgUrls'] = this.imgUrls.map((v) => v.toJson()).toList(); + } + if (this.headSculptureImgUrl != null) { + data['headSculptureImgUrl'] = + this.headSculptureImgUrl.map((v) => v.toJson()).toList(); + } + if (this.gambitThemeCommentVoList != null) { + data['gambitThemeCommentVoList'] = + this.gambitThemeCommentVoList.map((v) => v.toJson()).toList(); + } + return data; + } +} + +class LikeNames { + int id; + String name; + + LikeNames({this.id, this.name}); + + LikeNames.fromJson(Map json) { + id = json['id']; + name = json['name']; + } + + Map toJson() { + final Map data = new Map(); + data['id'] = this.id; + data['name'] = this.name; + return data; + } +} + +class GambitThemeCommentVoList { + int id; + String parentName; + String content; + String createName; + String createDate; + + GambitThemeCommentVoList( + {this.id, + this.parentName, + this.content, + this.createName, + this.createDate}); + + GambitThemeCommentVoList.fromJson(Map json) { + id = json['id']; + parentName = json['parentName']; + content = json['content']; + createName = json['createName']; + createDate = json['createDate']; + } + + Map toJson() { + final Map data = new Map(); + data['id'] = this.id; + data['parentName'] = this.parentName; + data['content'] = this.content; + data['createName'] = this.createName; + data['createDate'] = this.createDate; + return data; + } +} diff --git a/lib/pages/activities_page/activities_page.dart b/lib/pages/activities_page/activities_page.dart index 2d32e722..9d7944ef 100644 --- a/lib/pages/activities_page/activities_page.dart +++ b/lib/pages/activities_page/activities_page.dart @@ -10,6 +10,8 @@ import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:akuCommunity/widget/activity_card.dart'; import 'package:akuCommunity/widget/bee_scaffold.dart'; +//TODO CLEAN BOTTOM CODES. +@Deprecated("sh*t activities_page need to be cleaned.") class ActivitiesPage extends StatefulWidget { ActivitiesPage({Key key}) : super(key: key); diff --git a/lib/pages/community/community_index.dart b/lib/pages/community/community_index.dart index b507052a..e6473843 100644 --- a/lib/pages/community/community_index.dart +++ b/lib/pages/community/community_index.dart @@ -12,6 +12,8 @@ import 'package:akuCommunity/utils/headers.dart'; import 'package:akuCommunity/widget/bee_scaffold.dart'; import 'widget/tab_list.dart'; +//TODO CLEAN BOTTOM CODES. +@Deprecated("sh*t community_index need to be cleaned.") class CommunityIndex extends StatefulWidget { CommunityIndex({Key key}) : super(key: key); @@ -103,7 +105,6 @@ class _CommunityIndexState extends State child: Icon( Icons.add, color: Colors.white, - size: 40.sp, ), onPressed: noteCreateRouter, ); @@ -115,61 +116,53 @@ class _CommunityIndexState extends State return BeeScaffold( title: '社区', actions: _listActions(), - body: Stack( + body: Column( children: [ - Column( - children: [ - Material( - color: kForeGroundColor, - child: PreferredSize( - preferredSize: Size.fromHeight(kToolbarHeight), - child: Align( - alignment: Alignment.centerLeft, - child: TabBar( - indicatorPadding: EdgeInsets.zero, - controller: _tabController, - isScrollable: true, - indicatorColor: Color(0xffFFd000), - indicatorWeight: 2.w, - indicatorSize: TabBarIndicatorSize.label, - unselectedLabelStyle: TextStyle( - color: Color(0xFF333333), - fontSize: 28.sp, - ), - labelStyle: TextStyle( - fontSize: 28.sp, - color: Color(0xff333333), - fontWeight: FontWeight.bold, - ), - tabs: List.generate( - tabs.length, - (index) => Tab( - text: tabs[index]['name'], - ), - ), - ), - ), - ), - ), - Expanded( - child: TabBarView( + Material( + color: kForeGroundColor, + child: PreferredSize( + preferredSize: Size.fromHeight(kToolbarHeight), + child: Align( + alignment: Alignment.centerLeft, + child: TabBar( + indicatorPadding: EdgeInsets.zero, controller: _tabController, - children: List.generate( + isScrollable: true, + indicatorColor: Color(0xffFFd000), + indicatorWeight: 2.w, + indicatorSize: TabBarIndicatorSize.label, + unselectedLabelStyle: TextStyle( + color: Color(0xFF333333), + fontSize: 28.sp, + ), + labelStyle: TextStyle( + fontSize: 28.sp, + color: Color(0xff333333), + fontWeight: FontWeight.bold, + ), + tabs: List.generate( tabs.length, - (index) => TabList(index: index), + (index) => Tab( + text: tabs[index]['name'], + ), ), ), ), - // _floatingActionButton(), - ], + ), + ), + Expanded( + child: TabBarView( + controller: _tabController, + children: List.generate( + tabs.length, + (index) => TabList(index: index), + ), + ), ), - Positioned( - right: 30.w, - bottom: 50.w, - child: _floatingActionButton(), - ) + // _floatingActionButton(), ], ), + fab: _floatingActionButton(), ); } } diff --git a/lib/pages/home/home_page.dart b/lib/pages/home/home_page.dart index 4784a24d..99c4b40a 100644 --- a/lib/pages/home/home_page.dart +++ b/lib/pages/home/home_page.dart @@ -4,6 +4,9 @@ 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/buttons/column_action_button.dart'; +import 'package:akuCommunity/widget/views/application_view.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -74,8 +77,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 @@ -104,23 +106,6 @@ class _HomePageState extends State }); } - _buildColButton({IconData icon, String title, VoidCallback onTap}) { - return MaterialButton( - onPressed: onTap, - minWidth: 0, - padding: EdgeInsets.symmetric(horizontal: 16.w), - materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Icon(icon, size: 48.w, color: Colors.black), - 4.hb, - title.text.size(20.sp).black.make(), - ], - ), - ); - } - @override Widget build(BuildContext context) { super.build(context); @@ -131,12 +116,11 @@ class _HomePageState extends State appBar: AnimateAppBar( scrollController: _scrollController, actions: [ - _buildColButton( - icon: AntDesign.bells, + ColumnActionButton( + onPressed: MessageCenterPage().to, title: '消息', - onTap: MessageCenterPage().to, + path: R.ASSETS_ICONS_ALARM_PNG, ), - 16.wb, ], ), body: EasyRefresh( @@ -160,10 +144,7 @@ class _HomePageState extends State SizedBox(height: 100.w), ContainerComment( radius: 8, - customWidget: GridButtons( - gridList: _gridList, - crossCount: 4, - ), + customWidget: ApplicationView(), ), // SingleAdSpace( // imagePath: R.ASSETS_EXAMPLE_GUANGGAO2_PNG, diff --git a/lib/pages/market/market_page.dart b/lib/pages/market/market_page.dart index c1ca7ada..3ad2273b 100644 --- a/lib/pages/market/market_page.dart +++ b/lib/pages/market/market_page.dart @@ -133,13 +133,6 @@ class _MarketPageState extends State imagePath: 'assets/example/guanggao5.png', radius: 36, ), - ContainerComment( - radius: 8, - customWidget: GridButtons( - gridList: [], - crossCount: 4, - ), - ), ], ), ), diff --git a/lib/pages/one_alarm/widget/alarm_page.dart b/lib/pages/one_alarm/widget/alarm_page.dart index 8eec80ea..5d93b905 100644 --- a/lib/pages/one_alarm/widget/alarm_page.dart +++ b/lib/pages/one_alarm/widget/alarm_page.dart @@ -126,7 +126,6 @@ class _AlarmPageState extends State { Container( margin: EdgeInsets.only(top: 32.w), width: 686.w, - height: 148.w, decoration: BoxDecoration( color: Colors.white.withOpacity(0.9), borderRadius: BorderRadius.circular(16), @@ -138,7 +137,6 @@ class _AlarmPageState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - SizedBox(height: 24.w), Container( margin: EdgeInsets.only(top: 24.w, left: 32.w), child: Text( @@ -174,6 +172,7 @@ class _AlarmPageState extends State { ], ), ), + 24.hb, ], )), Spacer(), diff --git a/lib/pages/property/property_index.dart b/lib/pages/property/property_index.dart index e8d2dc29..2bfb96c8 100644 --- a/lib/pages/property/property_index.dart +++ b/lib/pages/property/property_index.dart @@ -1,5 +1,7 @@ // Flutter imports: +import 'package:akuCommunity/constants/application_objects.dart'; import 'package:akuCommunity/ui/community/notice/notice_page.dart'; +import 'package:akuCommunity/widget/views/application_view.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -202,10 +204,7 @@ class _PropertyIndexState extends State SliverToBoxAdapter( child: ContainerComment( radius: 8, - customWidget: GridButtons( - gridList: _gridList, - crossCount: 4, - ), + customWidget: ApplicationView.custom(items: smartManagerApp), ), ), SliverToBoxAdapter( diff --git a/lib/pages/splash/splash_page.dart b/lib/pages/splash/splash_page.dart index b2d7e837..4a470e0b 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: @@ -39,6 +40,8 @@ class _SplashPageState extends State { //ensure call _originOp first. await _originOp(); final userProvider = Provider.of(context, listen: false); + final appProvider = Provider.of(context, listen: false); + appProvider.initApplications(); //app init delay 2 second await Future.delayed(Duration(seconds: 2)); if (HiveStore.appBox.get('login') ?? false) { diff --git a/lib/pages/tab_navigator.dart b/lib/pages/tab_navigator.dart index ac10db5f..0269f741 100644 --- a/lib/pages/tab_navigator.dart +++ b/lib/pages/tab_navigator.dart @@ -1,4 +1,5 @@ // Flutter imports: +import 'package:akuCommunity/ui/community/community_views/community_page.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -37,7 +38,8 @@ class _TabNavigatorState extends State { HomePage(), // MarketPage(), PropertyIndex(), - CommunityIndex(), + // CommunityIndex(), + CommunityPage(), PersonalIndex() ]; } diff --git a/lib/provider/app_provider.dart b/lib/provider/app_provider.dart new file mode 100644 index 00000000..b228e555 --- /dev/null +++ b/lib/provider/app_provider.dart @@ -0,0 +1,57 @@ +import 'package:akuCommunity/constants/application_objects.dart'; +import 'package:akuCommunity/utils/hive_store.dart'; +import 'package:flutter/material.dart'; + +class AppProvider extends ChangeNotifier { + ///初始值为 + /// + ///``` + ///'一键开门', + /// '访客邀请', + /// '报事报修', + /// '生活缴费', + /// '业委会', + /// '建议投诉', + /// '便民电话', + ///``` + List _myApplications = [ + '一键开门', + '访客邀请', + '报事报修', + '生活缴费', + '业委会', + '建议咨询', + '便民电话', + ].map((e) => AO.fromRaw(e)).toList(); + + ///我的应用 + List get myApplications { + return _myApplications; + } + + ///初始化我的应用 + initApplications() { + if (HiveStore.appBox.containsKey('app')) + _myApplications = (HiveStore.appBox.get('app') as List) + .map((e) => AO.fromRaw(e)) + .toList(); + notifyListeners(); + } + + ///添加我的应用 + insertApplication(AO app) { + if (!_myApplications.contains(app) && _myApplications.length < 7) + _myApplications.insert(0, app); + if (!_myApplications.contains(app) && _myApplications.length >= 7) { + _myApplications.insert(0, app); + _myApplications.removeLast(); + } + HiveStore.appBox.put('app', _myApplications.map((e) => e.title).toList()); + notifyListeners(); + } + + ///移除我的应用 + removeApplication(AO obj) { + if (_myApplications.remove(obj)) notifyListeners(); + } +} diff --git a/lib/ui/community/community_views/community_page.dart b/lib/ui/community/community_views/community_page.dart new file mode 100644 index 00000000..4d58a2d9 --- /dev/null +++ b/lib/ui/community/community_views/community_page.dart @@ -0,0 +1,67 @@ +import 'package:akuCommunity/ui/community/community_views/my_community_view.dart'; +import 'package:akuCommunity/ui/community/community_views/new_community_view.dart'; +import 'package:akuCommunity/ui/community/community_views/topic/topic_community_view.dart'; +import 'package:akuCommunity/utils/headers.dart'; +import 'package:akuCommunity/widget/bee_scaffold.dart'; +import 'package:akuCommunity/widget/buttons/column_action_button.dart'; +import 'package:akuCommunity/widget/tab_bar/bee_tab_bar.dart'; +import 'package:flutter/material.dart'; + +class CommunityPage extends StatefulWidget { + CommunityPage({Key key}) : super(key: key); + + @override + _CommunityPageState createState() => _CommunityPageState(); +} + +class _CommunityPageState extends State + with TickerProviderStateMixin, AutomaticKeepAliveClientMixin { + TabController _tabController; + List _tabs = ['最新', '话题', '我的']; + @override + void initState() { + super.initState(); + _tabController = TabController( + vsync: this, + length: _tabs.length, + ); + } + + @override + Widget build(BuildContext context) { + super.build(context); + return BeeScaffold( + title: '社区', + actions: [ + ColumnActionButton( + onPressed: () {}, + title: '消息', + path: R.ASSETS_ICONS_ALARM_PNG, + ), + ], + appBarBottom: PreferredSize( + preferredSize: Size.fromHeight(48), + child: Align( + alignment: Alignment.centerLeft, + child: BeeTabBar( + controller: _tabController, + tabs: _tabs, + scrollable: true, + ), + ), + ), + body: TabBarView( + children: [ + NewCommunityView(), + TopicCommunityView(), + MyCommunityView(), + ], + controller: _tabController, + ), + bodyColor: Colors.white, + ); + } + + @override + bool get wantKeepAlive => true; +} diff --git a/lib/ui/community/community_views/my_community_view.dart b/lib/ui/community/community_views/my_community_view.dart new file mode 100644 index 00000000..3a101b32 --- /dev/null +++ b/lib/ui/community/community_views/my_community_view.dart @@ -0,0 +1,20 @@ +import 'package:flutter/material.dart'; + +class MyCommunityView extends StatefulWidget { + MyCommunityView({Key key}) : super(key: key); + + @override + _MyCommunityViewState createState() => _MyCommunityViewState(); +} + +class _MyCommunityViewState extends State + with AutomaticKeepAliveClientMixin { + @override + Widget build(BuildContext context) { + super.build(context); + return Container(); + } + + @override + bool get wantKeepAlive => true; +} diff --git a/lib/ui/community/community_views/new_community_view.dart b/lib/ui/community/community_views/new_community_view.dart new file mode 100644 index 00000000..626bfbf8 --- /dev/null +++ b/lib/ui/community/community_views/new_community_view.dart @@ -0,0 +1,20 @@ +import 'package:flutter/material.dart'; + +class NewCommunityView extends StatefulWidget { + NewCommunityView({Key key}) : super(key: key); + + @override + _NewCommunityViewState createState() => _NewCommunityViewState(); +} + +class _NewCommunityViewState extends State + with AutomaticKeepAliveClientMixin { + @override + Widget build(BuildContext context) { + super.build(context); + return Container(); + } + + @override + bool get wantKeepAlive => true; +} diff --git a/lib/ui/community/community_views/topic/topic_community_view.dart b/lib/ui/community/community_views/topic/topic_community_view.dart new file mode 100644 index 00000000..a1e4190c --- /dev/null +++ b/lib/ui/community/community_views/topic/topic_community_view.dart @@ -0,0 +1,125 @@ +import 'dart:ui'; + +import 'package:akuCommunity/ui/community/community_views/topic/topic_detail_page.dart'; +import 'package:akuCommunity/utils/headers.dart'; +import 'package:akuCommunity/constants/api.dart'; +import 'package:akuCommunity/model/community/community_topic_model.dart'; +import 'package:akuCommunity/pages/things_page/widget/bee_list_view.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_easyrefresh/easy_refresh.dart'; +import 'package:get/get.dart'; + +class TopicCommunityView extends StatefulWidget { + TopicCommunityView({Key key}) : super(key: key); + + @override + _TopicCommunityViewState createState() => _TopicCommunityViewState(); +} + +class _TopicCommunityViewState extends State + with AutomaticKeepAliveClientMixin { + EasyRefreshController _refreshController = EasyRefreshController(); + + _buildItem(CommunityTopicModel model) { + var firstImg = ''; + if (model?.imgUrls?.isNotEmpty ?? false) { + firstImg = model?.imgUrls?.first?.url ?? ''; + } + return MaterialButton( + padding: EdgeInsets.symmetric(horizontal: 53.w, vertical: 20.w), + onPressed: () { + Get.to(TopicDetailPage(id: model.id)); + }, + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + clipBehavior: Clip.antiAlias, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(8.w), + color: Colors.black12, + ), + child: Stack( + children: [ + FadeInImage.assetNetwork( + placeholder: R.ASSETS_IMAGES_LOGO_PNG, + image: API.image(firstImg), + height: 160.w, + width: 250.w, + ), + Positioned( + bottom: 0, + left: 0, + right: 0, + child: ClipRRect( + borderRadius: BorderRadius.vertical( + bottom: Radius.circular(8.w), + ), + child: BackdropFilter( + filter: ImageFilter.blur(sigmaX: 5, sigmaY: 5), + //TODO 等待后端接口补充话题摘要 + // model.summary + child: ('#${''}') + .text + .center + .size(28.sp) + .white + .make() + .material(color: Colors.black26), + ), + ), + ), + ], + ), + ), + 12.wb, + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + (model?.gambitTitle ?? '') + .text + .maxLines(2) + .size(28.sp) + .bold + .overflow(TextOverflow.ellipsis) + .make(), + (model?.content ?? '') + .text + .maxLines(1) + .size(22.sp) + .overflow(TextOverflow.ellipsis) + .make(), + 12.hb, + ], + ).expand(), + ], + ), + ); + } + + @override + Widget build(BuildContext context) { + super.build(context); + return BeeListView( + path: API.community.topicList, + controller: _refreshController, + convert: (model) { + return model.tableList + .map((e) => CommunityTopicModel.fromJson(e)) + .toList(); + }, + builder: (items) { + return ListView.separated( + itemBuilder: (context, index) { + return _buildItem(items[index]); + }, + separatorBuilder: (_, __) => 20.hb, + itemCount: items.length, + ); + }, + ); + } + + @override + bool get wantKeepAlive => true; +} diff --git a/lib/ui/community/community_views/topic/topic_detail_page.dart b/lib/ui/community/community_views/topic/topic_detail_page.dart new file mode 100644 index 00000000..0f0efcd1 --- /dev/null +++ b/lib/ui/community/community_views/topic/topic_detail_page.dart @@ -0,0 +1,38 @@ +import 'package:akuCommunity/ui/community/community_views/topic/topic_scrollable_text.dart'; +import 'package:akuCommunity/utils/headers.dart'; +import 'package:flutter/material.dart'; + +class TopicDetailPage extends StatefulWidget { + final int id; + TopicDetailPage({Key key, @required this.id}) : super(key: key); + + @override + _TopicDetailPageState createState() => _TopicDetailPageState(); +} + +class _TopicDetailPageState extends State { + @override + Widget build(BuildContext context) { + return Scaffold( + body: CustomScrollView( + slivers: [ + SliverAppBar( + expandedHeight: 500.w, + backgroundColor: Colors.transparent, + elevation: 0, + pinned: true, + flexibleSpace: FlexibleSpaceBar( + title: TopicScrollableText(title: '#TEST'), + titlePadding: EdgeInsets.zero, + collapseMode: CollapseMode.pin, + background: Container(color: Colors.red), + ), + ), + SliverToBoxAdapter( + child: 40000.hb, + ), + ], + ), + ); + } +} diff --git a/lib/ui/community/community_views/topic/topic_scrollable_text.dart b/lib/ui/community/community_views/topic/topic_scrollable_text.dart new file mode 100644 index 00000000..bb23f6e0 --- /dev/null +++ b/lib/ui/community/community_views/topic/topic_scrollable_text.dart @@ -0,0 +1,47 @@ +import 'package:akuCommunity/utils/headers.dart'; +import 'package:flutter/material.dart'; + +class TopicScrollableText extends StatefulWidget { + final String title; + TopicScrollableText({Key key, @required this.title}) : super(key: key); + + @override + _TopicScrollableTextState createState() => _TopicScrollableTextState(); +} + +class _TopicScrollableTextState extends State { + ScrollPosition _scrollPosition; + + _positionListener() { + setState(() {}); + } + + @override + void dispose() { + _scrollPosition?.removeListener(_positionListener); + super.dispose(); + } + + @override + void didChangeDependencies() { + super.didChangeDependencies(); + _scrollPosition = Scrollable.of(context)?.position; + _scrollPosition?.addListener(_positionListener); + } + + double get offset { + if (_scrollPosition.pixels >= 500.w) return 1; + if (_scrollPosition.pixels < 500.w && _scrollPosition.pixels >= 0) { + return _scrollPosition.pixels / 500.w; + } else + return 0; + } + + @override + Widget build(BuildContext context) { + return Padding( + padding: EdgeInsets.only(bottom: 202.w - offset * 160.w), + child: Text(widget.title), + ); + } +} diff --git a/lib/ui/home/application/all_application.dart b/lib/ui/home/application/all_application.dart new file mode 100644 index 00000000..3226e80f --- /dev/null +++ b/lib/ui/home/application/all_application.dart @@ -0,0 +1,266 @@ +import 'package:akuCommunity/base/base_style.dart'; +import 'package:akuCommunity/constants/application_objects.dart'; +import 'package:akuCommunity/provider/app_provider.dart'; +import 'package:akuCommunity/utils/headers.dart'; +import 'package:akuCommunity/widget/bee_back_button.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:provider/provider.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 { + bool _editMode = false; + + int _index = 0; + + PageController _pageController = PageController(); + + _buildTile(AO object, {bool editMode = false}) { + return MaterialButton( + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8.w)), + padding: EdgeInsets.zero, + onPressed: editMode ? null : () => 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(), + ], + ), + ); + } + + _buildEditTile() { + return Row( + children: [ + 74.hb, + '我的应用'.text.make(), + Spacer(), + MaterialButton( + padding: EdgeInsets.zero, + elevation: 0, + height: 52.w, + minWidth: 90.w, + onPressed: () { + _editMode = !_editMode; + setState(() {}); + }, + color: kPrimaryColor, + child: (_editMode ? '完成' : '编辑').text.bold.size(28.sp).make(), + ), + ], + ).pSymmetric(h: 32.w).material(color: Colors.white); + } + + _buildMyApp() { + final appProvider = Provider.of(context); + return GridView.builder( + padding: EdgeInsets.symmetric(horizontal: 32.w), + shrinkWrap: true, + physics: NeverScrollableScrollPhysics(), + gridDelegate: + SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 4), + itemBuilder: (context, index) { + return Stack( + children: [ + _buildTile( + appProvider.myApplications[index], + editMode: _editMode, + ), + Positioned( + right: 0, + top: 0, + child: AnimatedOpacity( + duration: Duration(milliseconds: 300), + curve: Curves.easeInOutCubic, + opacity: _editMode ? 1 : 0, + child: CupertinoButton( + minSize: 60.w, + padding: EdgeInsets.zero, + onPressed: _editMode + ? () { + appProvider.removeApplication( + appProvider.myApplications[index], + ); + } + : null, + child: Image.asset( + R.ASSETS_ICONS_APP_REDUCE_PNG, + height: 24.w, + width: 24.w, + ), + ), + ), + ), + ], + ); + }, + itemCount: appProvider.myApplications.length, + ).material(color: Colors.white); + } + + _buildListTile(String title, int index) { + bool sameIndex = _index == index; + return Stack( + fit: StackFit.passthrough, + children: [ + MaterialButton( + materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, + padding: EdgeInsets.zero, + color: sameIndex ? Colors.white : Color(0xFFEFEFEF), + elevation: 0, + height: 88.w, + onPressed: () { + setState(() { + _index = index; + }); + _pageController.animateToPage( + index, + duration: Duration(milliseconds: 300), + curve: Curves.easeInOutCubic, + ); + }, + child: title.text.size(28.sp).make(), + ), + Positioned( + left: 0, + top: 24.w, + bottom: 24.w, + child: AnimatedContainer( + duration: Duration(milliseconds: 300), + curve: Curves.easeInOutCubic, + width: sameIndex ? 3.w : 10.w, + color: sameIndex ? kPrimaryColor : kPrimaryColor.withOpacity(0), + ), + ), + ], + ); + } + + Widget _buildView(List objects) { + final appProvider = Provider.of(context); + return GridView.builder( + gridDelegate: + SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3), + itemBuilder: (context, index) { + return Stack( + children: [ + _buildTile(objects[index], editMode: _editMode), + Positioned( + right: 0, + top: 0, + child: AnimatedOpacity( + duration: Duration(milliseconds: 300), + curve: Curves.easeInOutCubic, + opacity: _editMode ? 1 : 0, + child: CupertinoButton( + minSize: 60.w, + padding: EdgeInsets.zero, + onPressed: _editMode + ? () => appProvider.insertApplication(objects[index]) + : null, + child: Image.asset( + R.ASSETS_ICONS_APP_ADD_PNG, + height: 24.w, + width: 24.w, + ), + ), + ), + ), + ], + ); + }, + itemCount: objects.length, + ); + } + + Widget _buildAppList() { + return Row( + children: [ + SizedBox( + width: 172.w, + child: ListView( + padding: EdgeInsets.zero, + children: [ + _buildListTile('为您推荐', 0), + _buildListTile('智慧管家', 1), + // _buildListTile('商城购物', 2), + ], + ), + ).material(color: Color(0xFFEFEFEF)), + PageView( + physics: NeverScrollableScrollPhysics(), + scrollDirection: Axis.vertical, + controller: _pageController, + children: [ + _buildView(recommendApp), + _buildView(smartManagerApp), + ], + ).expand(), + ], + ).material(color: Colors.white); + } + + @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: Column( + children: [ + _buildEditTile(), + Divider( + indent: 32.w, + endIndent: 32.w, + height: 1.w, + ).material(color: Colors.white), + _buildMyApp(), + 32.hb, + _buildAppList().expand(), + ], + ), + ); + } +} 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/utils/network/net_util.dart b/lib/utils/network/net_util.dart index c4eb7669..666cf01b 100644 --- a/lib/utils/network/net_util.dart +++ b/lib/utils/network/net_util.dart @@ -178,7 +178,7 @@ class NetUtil { _parseRequestError(BaseModel model, {bool showMessage = false}) { final userProvider = Provider.of(Get.context, listen: false); - if (!model.status && model.message == '登录失效,请登录') { + if (!model.status && model.message == '登录失效,请登录' && userProvider.isLogin) { userProvider.logout(); Get.offAll(SignInPage()); } diff --git a/lib/widget/bee_scaffold.dart b/lib/widget/bee_scaffold.dart index df31eb0a..686c5f82 100644 --- a/lib/widget/bee_scaffold.dart +++ b/lib/widget/bee_scaffold.dart @@ -22,28 +22,31 @@ class BeeScaffold extends StatefulWidget { final Widget leading; final Widget bottomNavi; final PreferredSizeWidget appBarBottom; - BeeScaffold( - {Key key, - @required this.title, - this.body, - this.actions, - this.leading, - this.bgColor = Colors.white, - this.bodyColor = const Color(0xFFF9F9F9), - this.bottomNavi, - this.appBarBottom}) - : super(key: key); + final FloatingActionButton fab; + BeeScaffold({ + Key key, + @required this.title, + this.body, + this.actions, + this.leading, + this.bgColor = Colors.white, + this.bodyColor = const Color(0xFFF9F9F9), + this.bottomNavi, + this.appBarBottom, + this.fab, + }) : super(key: key); - BeeScaffold.white( - {Key key, - @required this.title, - this.body, - this.actions, - this.leading, - this.bgColor = Colors.white, - this.bottomNavi, - this.appBarBottom}) - : this.bodyColor = Colors.white, + BeeScaffold.white({ + Key key, + @required this.title, + this.body, + this.actions, + this.leading, + this.bgColor = Colors.white, + this.bottomNavi, + this.appBarBottom, + this.fab, + }) : this.bodyColor = Colors.white, super(key: key); @override @@ -67,6 +70,7 @@ class _BeeScaffoldState extends State { ), body: widget.body, bottomNavigationBar: widget.bottomNavi, + floatingActionButton: widget.fab, ); } } diff --git a/lib/widget/buttons/column_action_button.dart b/lib/widget/buttons/column_action_button.dart new file mode 100644 index 00000000..84793698 --- /dev/null +++ b/lib/widget/buttons/column_action_button.dart @@ -0,0 +1,29 @@ +import 'package:akuCommunity/utils/headers.dart'; +import 'package:flutter/material.dart'; +import 'package:velocity_x/velocity_x.dart'; + +class ColumnActionButton extends StatelessWidget { + final VoidCallback onPressed; + final String title; + final String path; + const ColumnActionButton({Key key, this.onPressed, this.title, this.path}) + : super(key: key); + + @override + Widget build(BuildContext context) { + return MaterialButton( + minWidth: 72.w, + padding: EdgeInsets.zero, + onPressed: onPressed, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + mainAxisSize: MainAxisSize.max, + children: [ + Image.asset(path, height: 48.w, width: 48.w), + 4.hb, + title.text.size(20.sp).black.make(), + ], + ), + ); + } +} 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/tab_bar/bee_tab_bar.dart b/lib/widget/tab_bar/bee_tab_bar.dart index 19c09a29..837c5d94 100644 --- a/lib/widget/tab_bar/bee_tab_bar.dart +++ b/lib/widget/tab_bar/bee_tab_bar.dart @@ -11,9 +11,14 @@ class BeeTabBar extends StatefulWidget with PreferredSizeWidget { final TabController controller; final List tabs; final Function(int index) onTap; - BeeTabBar( - {Key key, @required this.controller, @required this.tabs, this.onTap}) - : super(key: key); + final bool scrollable; + BeeTabBar({ + Key key, + @required this.controller, + @required this.tabs, + this.onTap, + this.scrollable = false, + }) : super(key: key); @override _BeeTabBarState createState() => _BeeTabBarState(); @@ -54,6 +59,7 @@ class _BeeTabBarState extends State { indicatorSize: TabBarIndicatorSize.label, tabs: widget.tabs.map((e) => Tab(text: e)).toList(), onTap: widget.onTap, + isScrollable: widget.scrollable, ); } } diff --git a/lib/widget/views/application_view.dart b/lib/widget/views/application_view.dart new file mode 100644 index 00000000..16394485 --- /dev/null +++ b/lib/widget/views/application_view.dart @@ -0,0 +1,65 @@ +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 { + final List items; + ApplicationView({Key key}) + : items = null, + super(key: key); + + ApplicationView.custom({Key key, @required this.items}) + : assert(items != null), + 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(), + ], + ), + ); + } + + bool get _isCustom => widget.items != null; + List get _items { + final appProvider = Provider.of(context); + + return _isCustom ? widget.items : appProvider.myApplications; + } + + @override + Widget build(BuildContext context) { + return GridView.builder( + padding: EdgeInsets.zero, + gridDelegate: + SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 4), + itemBuilder: (context, index) { + if (index == _items.length) return _buildTile(allApp); + return _buildTile(_items[index]); + }, + itemCount: _items.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/