diff --git a/android/app/build.gradle b/android/app/build.gradle index 1209ecb..2294797 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -78,9 +78,19 @@ android { signingConfig signingConfigs.release } debug { + minifyEnabled true + useProguard true + multiDexEnabled true + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + signingConfig signingConfigs.release } profile{ + minifyEnabled true + useProguard true + multiDexEnabled true + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + signingConfig signingConfigs.release } } diff --git a/lib/main.dart b/lib/main.dart index ee91a01..69bcc55 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -35,6 +35,8 @@ void main() async { print("flutter onReceiveNotification: $message"); LoggerData.addData(message); await JpushMessageParse(message).shot(); + final appProvider = Provider.of(Get.context, listen: false); + appProvider.updateMessage(); }, // 点击通知回调方法。 onOpenNotification: (Map message) async { @@ -87,6 +89,7 @@ class MyApp extends StatelessWidget { designSize: Size(750, 1334), builder: () { return GetMaterialApp( + debugShowCheckedModeBanner: false, title: '小蜜蜂管家', theme: AppTheme.themeData, home: SplashPage(), diff --git a/lib/provider/app_provider.dart b/lib/provider/app_provider.dart index 5fc923e..b2dbc0e 100644 --- a/lib/provider/app_provider.dart +++ b/lib/provider/app_provider.dart @@ -1,10 +1,13 @@ // Flutter imports: +import 'package:aku_community_manager/const/api.dart'; +import 'package:aku_community_manager/utils/network/net_util.dart'; import 'package:amap_flutter_location/amap_flutter_location.dart'; import 'package:amap_flutter_location/amap_location_option.dart'; import 'package:flutter/material.dart'; // Project imports: import 'package:aku_community_manager/ui/home/application/applications_page.dart'; +import 'package:dio/dio.dart'; class AppProvider extends ChangeNotifier { List _recentUsedApp = []; @@ -50,4 +53,18 @@ class AppProvider extends ChangeNotifier { _flutterLocation.stopLocation(); _flutterLocation.destroy(); } + + int _sysMessage = 0; + int _commentMessage = 0; + bool get hasMessage => _sysMessage != 0 || _commentMessage != 0; + int get sysMessage => _sysMessage; + int get commentMessage => _commentMessage; + + updateMessage() async { + Response response = await NetUtil().dio.get(API.message.messageCenter); + if (response == null || response.data == null) return; + _sysMessage = response.data['sysCount'] ?? 0; + _commentMessage = response.data['commentCount'] ?? 0; + notifyListeners(); + } } diff --git a/lib/provider/user_provider.dart b/lib/provider/user_provider.dart index 3b7399a..20d8268 100644 --- a/lib/provider/user_provider.dart +++ b/lib/provider/user_provider.dart @@ -2,6 +2,7 @@ import 'dart:io'; // Flutter imports: +import 'package:aku_community_manager/provider/app_provider.dart'; import 'package:aku_community_manager/utils/network/base_file_model.dart'; import 'package:bot_toast/bot_toast.dart'; import 'package:flutter/material.dart'; @@ -16,6 +17,9 @@ import 'package:aku_community_manager/utils/network/net_util.dart'; import 'package:aku_community_manager/models/user/user_info_model.dart' as USER_INFO; +import 'package:get/get.dart'; +import 'package:jpush_flutter/jpush_flutter.dart'; +import 'package:provider/provider.dart'; //登录状态管理 class UserProvider extends ChangeNotifier { @@ -44,6 +48,8 @@ class UserProvider extends ChangeNotifier { ///更新用户profile Future updateProfile() async { + final appProvider = Provider.of(Get.context, listen: false); + appProvider.updateMessage(); BaseModel model = await NetUtil().get(API.user.profile); if (model == null) return null; @@ -53,10 +59,14 @@ class UserProvider extends ChangeNotifier { Future updateUserInfo() async { BaseModel model = await NetUtil().get(API.user.info); + if (model == null) return null; - else - return USER_INFO.UserInfoModel.fromJson(model.data); + else { + var userModel = USER_INFO.UserInfoModel.fromJson(model.data); + JPush().setAlias(userModel.id.toString()); + return userModel; + } } ///注销登录 diff --git a/lib/ui/agreements/agreement_page.dart b/lib/ui/agreements/agreement_page.dart index f554c71..66d6710 100644 --- a/lib/ui/agreements/agreement_page.dart +++ b/lib/ui/agreements/agreement_page.dart @@ -216,9 +216,7 @@ class AgreementPage extends StatelessWidget { 2020年10月21日 ''', - style: TextStyle( - fontSize: 30.w, - ), + style: Theme.of(context).textTheme.subtitle1, ), ), ); diff --git a/lib/ui/agreements/privacy_page.dart b/lib/ui/agreements/privacy_page.dart index 8820e0f..1d00520 100644 --- a/lib/ui/agreements/privacy_page.dart +++ b/lib/ui/agreements/privacy_page.dart @@ -18,10 +18,6 @@ class PrivacyPage extends StatelessWidget { padding: EdgeInsets.all(16.sp), child: Column( children: [ - Text( - '小蜜蜂智慧社区管家端隐私政策', - style: TextStyle(fontWeight: FontWeight.w600, fontSize: 35.w), - ), Text( ''' 小蜜蜂智慧社区管家端APP是由深圳市凯达来科技有限公司提供的一款智慧社区APP,为用户提供更好、更优、更个性化的服务是我们坚持不懈的追求,也希望通过我们提供的服务可以更方便您的生活。依据法律的规定,我们将在特定情形下收集、使用、保存和披露您的个人信息。以下条款描述了我们如何收集、使用、保存和披露您的个人信息。 @@ -124,9 +120,7 @@ class PrivacyPage extends StatelessWidget { 深圳市凯达来科技有限公司 2020年10月20日 ''', - style: TextStyle( - fontSize: 30.w, - ), + style: Theme.of(context).textTheme.subtitle1, ), ], ), diff --git a/lib/ui/home/home_page.dart b/lib/ui/home/home_page.dart index a3c0f2c..7582f07 100644 --- a/lib/ui/home/home_page.dart +++ b/lib/ui/home/home_page.dart @@ -5,10 +5,12 @@ import 'package:aku_community_manager/models/manager/bussiness_and_fix/bussiness import 'package:aku_community_manager/models/manager/item_num_model.dart'; import 'package:aku_community_manager/models/todo_bussiness/todo_model.dart'; import 'package:aku_community_manager/models/todo_bussiness/todo_outdoor_model.dart'; +import 'package:aku_community_manager/tools/user_tool.dart'; import 'package:aku_community_manager/ui/home/business/bussiness_func.dart'; import 'package:aku_community_manager/ui/home/business/todo_outdoor_card.dart'; import 'package:aku_community_manager/utils/network/base_list_model.dart'; import 'package:aku_community_manager/utils/network/net_util.dart'; +import 'package:badges/badges.dart'; import 'package:dio/dio.dart'; import 'package:firebase_crashlytics/firebase_crashlytics.dart'; import 'package:flutter/material.dart'; @@ -151,12 +153,15 @@ class _HomePageState extends State { statusBarColor: Colors.transparent, )); Future.delayed(Duration(milliseconds: 300), () async { - _itemNumModel = await _getItemNum(); - var dataList = await BussinessFunc.getBussinessModelList(1); - _todoModelList = dataList.map((e) => ToDoModel.fromJson(e)).toList(); - _anounceMentList = await _getAnouncement(); - _onload = false; - setState(() {}); + final userProvider = Provider.of(context, listen: false); + if (userProvider.isLogin) { + _itemNumModel = await _getItemNum(); + var dataList = await BussinessFunc.getBussinessModelList(1); + _todoModelList = dataList.map((e) => ToDoModel.fromJson(e)).toList(); + _anounceMentList = await _getAnouncement(); + _onload = false; + setState(() {}); + } }); } @@ -182,6 +187,10 @@ class _HomePageState extends State { @override Widget build(BuildContext context) { final userProvider = Provider.of(context); + final appProvider = Provider.of(context); + var loadingWidget = Center( + child: CircularProgressIndicator(), + ); return AnnotatedRegion( child: Scaffold( drawer: PersonalDraw(), @@ -261,7 +270,7 @@ class _HomePageState extends State { ), SizedBox(width: 19.w), Text( - '搜索工单订单号、手机', + '搜索应用', style: TextStyle( color: AppStyle.minorTextColor, fontSize: 28.sp, @@ -300,32 +309,40 @@ class _HomePageState extends State { // ]), // ), // ), - Container( - margin: EdgeInsets.only(top: 5.w, bottom: 5.w), - child: AkuMaterialButton( - minWidth: 78.w, - //消息按钮 - height: double.infinity, - onPressed: () { - if (userProvider.isLogin) - Get.to(() => Message()); - else - Get.to(() => LoginPage()); - }, - child: Column(children: [ - Image.asset( - R.ASSETS_HOME_IC_NEWS_PNG, - height: 48.w, - width: 48.w, - ), - Text( - '消息', - style: TextStyle( - color: AppStyle.primaryTextColor, - fontSize: 20.sp, + Badge( + elevation: 0, + position: BadgePosition.topEnd( + top: 4, + end: 4, + ), + showBadge: appProvider.hasMessage, + child: Container( + margin: EdgeInsets.only(top: 5.w, bottom: 5.w), + child: AkuMaterialButton( + minWidth: 78.w, + //消息按钮 + height: double.infinity, + onPressed: () { + if (userProvider.isLogin) + Get.to(() => Message()); + else + Get.to(() => LoginPage()); + }, + child: Column(children: [ + Image.asset( + R.ASSETS_HOME_IC_NEWS_PNG, + height: 48.w, + width: 48.w, ), - ), - ]), + Text( + '消息', + style: TextStyle( + color: AppStyle.primaryTextColor, + fontSize: 20.sp, + ), + ), + ]), + ), ), ), SizedBox(width: 17.w), @@ -389,114 +406,23 @@ class _HomePageState extends State { ), ), ), - body: _onload - ? Center( - child: Shimmer.fromColors( - child: 'LOADING······'.text.black.size(50.sp).make(), - baseColor: Colors.white, - highlightColor: kPrimaryColor), - ) - : ListView( - padding: EdgeInsets.all(32.w), - children: [ - Container( - //公告标题行 - width: double.infinity, - height: 45.w, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - '今日公告', - style: TextStyle( - color: Color(0xFF4A4B51), - fontSize: 32.sp, - fontWeight: FontWeight.bold, - ), - ), - Spacer(), - AkuButton( - //全部公告按钮 - onPressed: () { - Get.to(() => AllAnouncement()); - }, - child: Row( - children: [ - Text( - '全部公告', - style: TextStyle( - color: AppStyle.minorTextColor, - fontSize: 24.sp, - fontWeight: FontWeight.bold, - ), - ), - Icon( - Icons.arrow_forward_ios, - size: 22.w, - color: AppStyle.minorTextColor, - ) - ], - ), - ), - ], - ), - ), - SizedBox(height: 16.w), - //公告栏 - Container( - color: Color(0xFFFFFFFF), - width: double.infinity, - height: 172.w, - child: Stack(children: [ - CarouselSlider( - items: _anounceMentList - .map((e) => AllAnouncementState.anounceCard(e)) - .toList(), - options: CarouselOptions( - viewportFraction: 1.0, - aspectRatio: 686 / 172, - autoPlay: true, - onPageChanged: (index, _) { - setState(() { - _currentIndicator = index; - }); - }, - ), - ), - Positioned( - top: 144.w, - left: 0, - bottom: 16.w, - right: 0, + //需要重构 + body: (!UserTool.userProvider.isLogin) + ? SizedBox() + : _onload + ? loadingWidget + : ListView( + padding: EdgeInsets.all(32.w), + children: [ + Container( + //公告标题行 + width: double.infinity, + height: 45.w, child: Row( - mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.center, - children: _anounceMentList.map((e) { - int index = _anounceMentList.indexOf(e); - return Container( - width: 12.w, - height: 12.w, - margin: EdgeInsets.symmetric(horizontal: 12.w), - decoration: BoxDecoration( - shape: BoxShape.circle, - color: _currentIndicator == index - ? Color(0xFFFFC40C) - : Color(0xFFE8E8E8), - ), - ); - }).toList(), - ), - ), - ]), - ), - SizedBox(height: 16.w), - //待办事项标题行 - !userProvider.isLogin - ? SizedBox() - : Row( children: [ Text( - '待办事项', + '今日公告', style: TextStyle( color: Color(0xFF4A4B51), fontSize: 32.sp, @@ -505,112 +431,203 @@ class _HomePageState extends State { ), Spacer(), AkuButton( - padding: EdgeInsets.symmetric(vertical: 16.w), + //全部公告按钮 onPressed: () { - Get.to(BusinessPage(initIndex: 3)); + Get.to(() => AllAnouncement()); }, child: Row( children: [ Text( - '全部事项', + '全部公告', style: TextStyle( - color: AppStyle.minorTextColor, - fontSize: 24.sp, - fontWeight: FontWeight.bold), + color: AppStyle.minorTextColor, + fontSize: 24.sp, + fontWeight: FontWeight.bold, + ), ), Icon( Icons.arrow_forward_ios, size: 22.w, color: AppStyle.minorTextColor, - ), + ) ], ), ), ], ), - SizedBox(height: 16.w), - //待办事项栏 - !userProvider.isLogin - ? SizedBox() - : Container( - height: 480.w, - child: ListView.separated( - separatorBuilder: (context, index) { - return AkuBox.w(16); - }, - scrollDirection: Axis.horizontal, - itemBuilder: (context, index) { - return Container( - width: 526.w, - child: Builder( - builder: (context) { - if (_todoModelList[index] - .dynamicModel - .runtimeType == - BussinessAndFixModel) { - return BusinessFixCard( - model: _todoModelList[index] - .dynamicModel); - } else if (_todoModelList[index] - .dynamicModel - .runtimeType == - ToDoOutDoorModel) { - return ToDoOutDoorCard( - model: - _todoModelList[index].dynamicModel, - ); - } else - return SizedBox(); - }, - ), - ); - }, - itemCount: _todoModelList.length, + ), + SizedBox(height: 16.w), + //公告栏 + Container( + color: Color(0xFFFFFFFF), + width: double.infinity, + height: 172.w, + child: Stack(children: [ + CarouselSlider( + items: _anounceMentList + .map((e) => AllAnouncementState.anounceCard(e)) + .toList(), + options: CarouselOptions( + viewportFraction: 1.0, + aspectRatio: 686 / 172, + autoPlay: true, + onPageChanged: (index, _) { + setState(() { + _currentIndicator = index; + }); + }, + ), ), - ), - SizedBox(height: 24.w), - //底部信息栏 - !userProvider.isLogin - ? SizedBox() - : Container( - width: double.infinity, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(8.w), - color: Colors.white, + Positioned( + top: 144.w, + left: 0, + bottom: 16.w, + right: 0, + child: Row( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: MainAxisAlignment.center, + children: _anounceMentList.map((e) { + int index = _anounceMentList.indexOf(e); + return Container( + width: 12.w, + height: 12.w, + margin: + EdgeInsets.symmetric(horizontal: 12.w), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: _currentIndicator == index + ? Color(0xFFFFC40C) + : Color(0xFFE8E8E8), + ), + ); + }).toList(), + ), ), - child: Column( - children: [ - Row( - children: [ - _card(_itemNumModel.unProcessedNum ?? 0, - '未处理事项', Color(0xFFFF4E0D), 0), - GridientDiveder().verticalDivider(166.5.w), - _card(_itemNumModel.processingNum ?? 0, - '处理中事项', Color(0xFFFFC40C), 1), - ], + ]), + ), + SizedBox(height: 16.w), + //待办事项标题行 + !userProvider.isLogin + ? SizedBox() + : Row( + children: [ + Text( + '待办事项', + style: TextStyle( + color: Color(0xFF4A4B51), + fontSize: 32.sp, + fontWeight: FontWeight.bold, + ), + ), + Spacer(), + AkuButton( + padding: EdgeInsets.symmetric(vertical: 16.w), + onPressed: () { + Get.to(BusinessPage(initIndex: 3)); + }, + child: Row( + children: [ + Text( + '全部事项', + style: TextStyle( + color: AppStyle.minorTextColor, + fontSize: 24.sp, + fontWeight: FontWeight.bold), + ), + Icon( + Icons.arrow_forward_ios, + size: 22.w, + color: AppStyle.minorTextColor, + ), + ], + ), + ), + ], + ), + SizedBox(height: 16.w), + //待办事项栏 + !userProvider.isLogin + ? SizedBox() + : Container( + height: 480.w, + child: ListView.separated( + separatorBuilder: (context, index) { + return AkuBox.w(16); + }, + scrollDirection: Axis.horizontal, + itemBuilder: (context, index) { + return Container( + width: 526.w, + child: Builder( + builder: (context) { + if (_todoModelList[index] + .dynamicModel + .runtimeType == + BussinessAndFixModel) { + return BusinessFixCard( + model: _todoModelList[index] + .dynamicModel); + } else if (_todoModelList[index] + .dynamicModel + .runtimeType == + ToDoOutDoorModel) { + return ToDoOutDoorCard( + model: _todoModelList[index] + .dynamicModel, + ); + } else + return SizedBox(); + }, + ), + ); + }, + itemCount: _todoModelList.length, + ), + ), + SizedBox(height: 24.w), + //底部信息栏 + !userProvider.isLogin + ? SizedBox() + : Container( + width: double.infinity, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(8.w), + color: Colors.white, ), - Row(children: [ - GridientDiveder().horizontalDivider(343.w), - GridientDiveder(isReverse: true) - .horizontalDivider(343.w) - ]), - Row( + child: Column( children: [ - _card(_itemNumModel.processedNum ?? 0, - '已处理事项', Color(0xFF3F8FFE), 2), - GridientDiveder(isReverse: true) - .verticalDivider( - 166.5.w, + Row( + children: [ + _card(_itemNumModel.unProcessedNum ?? 0, + '未处理事项', Color(0xFFFF4E0D), 0), + GridientDiveder() + .verticalDivider(166.5.w), + _card(_itemNumModel.processingNum ?? 0, + '处理中事项', Color(0xFFFFC40C), 1), + ], + ), + Row(children: [ + GridientDiveder().horizontalDivider(343.w), + GridientDiveder(isReverse: true) + .horizontalDivider(343.w) + ]), + Row( + children: [ + _card(_itemNumModel.processedNum ?? 0, + '已处理事项', Color(0xFF3F8FFE), 2), + GridientDiveder(isReverse: true) + .verticalDivider( + 166.5.w, + ), + _card(_itemNumModel.allNum ?? 0, '全部事项', + Color(0xFF333333), 3), + ], ), - _card(_itemNumModel.allNum ?? 0, '全部事项', - Color(0xFF333333), 3), ], ), - ], - ), - ), - ], - ), + ), + ], + ), ), value: SystemUiOverlayStyle.dark, ); diff --git a/lib/ui/home/messages/message.dart b/lib/ui/home/messages/message.dart index ec18e9f..f6527c2 100644 --- a/lib/ui/home/messages/message.dart +++ b/lib/ui/home/messages/message.dart @@ -1,6 +1,5 @@ // Flutter imports: -import 'package:aku_community_manager/const/api.dart'; -import 'package:aku_community_manager/utils/network/net_util.dart'; +import 'package:aku_community_manager/provider/app_provider.dart'; import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; @@ -17,6 +16,7 @@ import 'package:aku_community_manager/style/app_style.dart'; import 'package:aku_community_manager/ui/home/messages/comment_message.dart'; import 'package:aku_community_manager/ui/home/messages/system_message.dart'; import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart'; +import 'package:provider/provider.dart'; class Message extends StatefulWidget { Message({Key key}) : super(key: key); @@ -26,8 +26,6 @@ class Message extends StatefulWidget { } class _MessageState extends State { - int _messageCount = 0; - int _commentCount = 0; EasyRefreshController _refreshController = EasyRefreshController(); Widget _messageTypeImage(String type) { String path; @@ -132,15 +130,9 @@ class _MessageState extends State { ); } - Future _updateMessageCenter() async { - Response response = await NetUtil().dio.get(API.message.messageCenter); - if (response == null || response.data == null) return; - _messageCount = response.data['sysCount'] ?? 0; - _commentCount = response.data['commentCount'] ?? 0; - } - @override Widget build(BuildContext context) { + final appProvider = Provider.of(context); return AkuScaffold( title: '消息', titleStyle: AppStyle().barTitleStyle, @@ -148,8 +140,7 @@ class _MessageState extends State { controller: _refreshController, firstRefresh: true, onRefresh: () async { - await _updateMessageCenter(); - setState(() {}); + await appProvider.updateMessage(); }, header: MaterialHeader(), child: ListView( @@ -160,7 +151,7 @@ class _MessageState extends State { _messageTypeImage('系统消息'), '系统消息', '你有一条新的报事报修待处理', - _messageCount, + appProvider.sysMessage, onpressed: () { Get.to(() => SystemMessage()); }, @@ -173,7 +164,7 @@ class _MessageState extends State { _messageTypeImage('评论消息'), '评论消息', '你有一条新的评论回复', - _commentCount, + appProvider.commentMessage, onpressed: () { Get.to(() => CommentMessage()); }, diff --git a/lib/ui/home/search_workorder_page.dart b/lib/ui/home/search_workorder_page.dart index f092141..a3f3657 100644 --- a/lib/ui/home/search_workorder_page.dart +++ b/lib/ui/home/search_workorder_page.dart @@ -91,7 +91,7 @@ class _SearchWorkOrderpageState extends State { child: TextField( controller: _textController, decoration: InputDecoration( - hintText: '搜索工单、手机号', + hintText: '搜索应用', hintStyle: TextStyle( color: AppStyle.minorTextColor, fontSize: 28.sp, diff --git a/pubspec.lock b/pubspec.lock index 92dc238..c405806 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -82,6 +82,13 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "3.0.0" + badges: + dependency: "direct main" + description: + name: badges + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.2.0" boolean_selector: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 9164e8d..01e92e0 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -72,6 +72,7 @@ dependencies: url: http://159.75.73.143:8080/third_packages/jpush_flutter shimmer: ^2.0.0-nullsafety.0 + badges: ^1.2.0 dev_dependencies: flutter_test: