From 29350221f68673317e6c3394a3c2ff50688e88e3 Mon Sep 17 00:00:00 2001 From: zhangmeng <494089941@qq.com> Date: Wed, 22 Sep 2021 14:35:07 +0800 Subject: [PATCH] fix some issues --- lib/ui/home/messages/message.dart | 23 +++++++++--------- lib/ui/login/login_sms_page.dart | 24 +++++++++---------- .../facilities/facilities_card.dart | 19 ++++++++------- .../facilities/facilities_map.dart | 6 ++--- lib/ui/settings/settings_page.dart | 2 +- lib/utils/network/net_util.dart | 17 +++++++------ 6 files changed, 46 insertions(+), 45 deletions(-) diff --git a/lib/ui/home/messages/message.dart b/lib/ui/home/messages/message.dart index 5fd3f0f..248bd15 100644 --- a/lib/ui/home/messages/message.dart +++ b/lib/ui/home/messages/message.dart @@ -1,26 +1,24 @@ // Flutter imports: import 'package:aku_community_manager/const/api.dart'; +// Project imports: +import 'package:aku_community_manager/const/resource.dart'; import 'package:aku_community_manager/provider/message_provider.dart'; +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/system_message.dart'; import 'package:aku_community_manager/ui/widgets/common/aku_button.dart'; +import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart'; import 'package:aku_community_manager/utils/network/base_model.dart'; import 'package:aku_community_manager/utils/network/net_util.dart'; -import 'package:flutter/material.dart'; - // Package imports: import 'package:dio/dio.dart'; +import 'package:flutter/material.dart'; import 'package:flutter_easyrefresh/easy_refresh.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart' hide Response; import 'package:get/instance_manager.dart'; import 'package:provider/provider.dart'; -// Project imports: -import 'package:aku_community_manager/const/resource.dart'; -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/system_message.dart'; -import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart'; - class Message extends StatefulWidget { Message({Key? key}) : super(key: key); @@ -30,6 +28,7 @@ class Message extends StatefulWidget { class _MessageState extends State { EasyRefreshController _refreshController = EasyRefreshController(); + Widget _messageTypeImage(String type) { late String path; Color? ca; @@ -156,7 +155,9 @@ class _MessageState extends State { messageProvider.sysDate, _messageTypeImage('系统消息'), '系统消息', - '你有一条新的${messageProvider.sysMesTypeString}待处理', + messageProvider.sysMessage == 0 + ? '暂无新的系统消息' + : '你有一条新的${messageProvider.sysMesTypeString}待处理', messageProvider.sysMessage, onpressed: () async { BaseModel baseModel = @@ -174,7 +175,7 @@ class _MessageState extends State { messageProvider.commentDate, _messageTypeImage('评论消息'), '评论消息', - '你有一条新的评论回复', + messageProvider.commentMessage == 0 ? '暂无新的评论消息' : '你有一条新的评论回复', messageProvider.commentMessage, onpressed: () async { BaseModel baseModel = diff --git a/lib/ui/login/login_sms_page.dart b/lib/ui/login/login_sms_page.dart index fecb84b..1aebc06 100644 --- a/lib/ui/login/login_sms_page.dart +++ b/lib/ui/login/login_sms_page.dart @@ -1,18 +1,6 @@ // Dart imports: import 'dart:async'; -// Flutter imports: -import 'package:aku_community_manager/ui/login/login_page.dart'; -import 'package:aku_community_manager/ui/widgets/common/aku_material_button.dart'; -import 'package:flutter/material.dart'; - -import 'package:bot_toast/bot_toast.dart'; -import 'package:dio/dio.dart'; -import 'package:get/get.dart' hide Response; -import 'package:pin_input_text_field/pin_input_text_field.dart'; -import 'package:power_logger/power_logger.dart'; -import 'package:provider/provider.dart'; - // Project imports: import 'package:aku_community_manager/const/api.dart'; import 'package:aku_community_manager/provider/user_provider.dart'; @@ -20,9 +8,19 @@ import 'package:aku_community_manager/style/app_style.dart'; import 'package:aku_community_manager/tools/screen_tool.dart'; import 'package:aku_community_manager/tools/widget_tool.dart'; import 'package:aku_community_manager/ui/home/home_page.dart'; +// Flutter imports: +import 'package:aku_community_manager/ui/login/login_page.dart'; import 'package:aku_community_manager/ui/widgets/common/aku_back_button.dart'; +import 'package:aku_community_manager/ui/widgets/common/aku_material_button.dart'; import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart'; import 'package:aku_community_manager/utils/network/net_util.dart'; +import 'package:bot_toast/bot_toast.dart'; +import 'package:dio/dio.dart'; +import 'package:flutter/material.dart'; +import 'package:get/get.dart' hide Response; +import 'package:pin_input_text_field/pin_input_text_field.dart'; +import 'package:power_logger/power_logger.dart'; +import 'package:provider/provider.dart'; class LoginSMSPage extends StatefulWidget { final String phone; @@ -129,7 +127,7 @@ class _LoginSMSPageState extends State { if (response.data['status'] == true) { await userProvider.setLogin(response.data['token']); cancel(); - Get.offAll(HomePage()); + Get.offAll(() => HomePage()); } else { _textEditingController.clear(); cancel(); diff --git a/lib/ui/manage_pages/facilities/facilities_card.dart b/lib/ui/manage_pages/facilities/facilities_card.dart index fcff50a..7d16f82 100644 --- a/lib/ui/manage_pages/facilities/facilities_card.dart +++ b/lib/ui/manage_pages/facilities/facilities_card.dart @@ -1,27 +1,29 @@ // Flutter imports: import 'package:aku_community_manager/models/manager/facilities/facilities_check_list_model.dart'; +// Project imports: +import 'package:aku_community_manager/style/app_style.dart'; +import 'package:aku_community_manager/tools/aku_divider.dart'; import 'package:aku_community_manager/ui/manage_pages/facilities/facilities_inspect_report_page.dart'; import 'package:aku_community_manager/ui/manage_pages/facilities/facilities_map.dart'; import 'package:aku_community_manager/ui/widgets/common/aku_material_button.dart'; import 'package:common_utils/common_utils.dart'; import 'package:flutter/material.dart'; - // Package imports: import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:velocity_x/velocity_x.dart'; -// Project imports: -import 'package:aku_community_manager/style/app_style.dart'; -import 'package:aku_community_manager/tools/aku_divider.dart'; - class FacilitiesCard extends StatefulWidget { final int index; final int facilitiesType; final FacilitiesCheckListModel model; final VoidCallback? callRefresh; FacilitiesCard( - {Key? key, required this.index, required this.model, required this.facilitiesType, this.callRefresh}) + {Key? key, + required this.index, + required this.model, + required this.facilitiesType, + this.callRefresh}) : super(key: key); @override @@ -123,13 +125,14 @@ class _FacilitiesCardState extends State { _buildTile( R.ASSETS_MANAGE_CLOCK_PNG, '检查提交时间', - DateUtil.formatDateStr(widget.model.checkDate!, + DateUtil.formatDateStr(widget.model.checkDate ?? '', format: 'yyyy-MM-dd HH:mm')), ]; case 2: return [ 15.w.heightBox, - _buildTile(R.ASSETS_MANAGE_CLOCK_PNG, '未完成原因', widget.model.detail!, + _buildTile( + R.ASSETS_MANAGE_CLOCK_PNG, '未完成原因', widget.model.detail ?? '', color: Colors.red), 15.w.heightBox, _buildTile(R.ASSETS_MANAGE_CLOCK_PNG, '规定任务时间', diff --git a/lib/ui/manage_pages/facilities/facilities_map.dart b/lib/ui/manage_pages/facilities/facilities_map.dart index 3b939ae..87b6cd2 100644 --- a/lib/ui/manage_pages/facilities/facilities_map.dart +++ b/lib/ui/manage_pages/facilities/facilities_map.dart @@ -4,12 +4,12 @@ import 'package:flutter/material.dart'; ///设施检查相关map class FacilitiesMap { ///设施检查状态 - static Map inspectStatus = {1: '待检查', 2: '未完成', 3: '已检查'}; + static Map inspectStatus = {1: '待检查', 3: '未完成', 2: '已完成'}; ///设施检查状态的文字颜色 static Map insepectColor = { 1: Color(0xFFF49F02), - 2: Color(0xFF666666), - 3: Color(0xFF999999) + 2: Color(0xFF999999), + 3: Color(0xFF666666) }; } diff --git a/lib/ui/settings/settings_page.dart b/lib/ui/settings/settings_page.dart index 9159f57..8b242a2 100644 --- a/lib/ui/settings/settings_page.dart +++ b/lib/ui/settings/settings_page.dart @@ -91,7 +91,7 @@ class _SettingsPageState extends State { color: AppStyle.primaryColor, onPressed: () { userProvider.logout(); - Get.offAll(HomePage()); + Get.offAll(() => HomePage()); }, child: Text( '退出登录', diff --git a/lib/utils/network/net_util.dart b/lib/utils/network/net_util.dart index 9c92bb6..ac82f88 100644 --- a/lib/utils/network/net_util.dart +++ b/lib/utils/network/net_util.dart @@ -1,13 +1,6 @@ // Dart imports: import 'dart:io'; -// Package imports: -import 'package:bot_toast/bot_toast.dart'; -import 'package:dio/dio.dart'; -import 'package:get/get.dart' hide Response, FormData, MultipartFile; -import 'package:power_logger/power_logger.dart'; -import 'package:provider/provider.dart'; - // Project imports: import 'package:aku_community_manager/const/api.dart'; import 'package:aku_community_manager/provider/user_provider.dart'; @@ -15,6 +8,12 @@ import 'package:aku_community_manager/ui/login/login_page.dart'; import 'package:aku_community_manager/utils/network/base_file_model.dart'; import 'package:aku_community_manager/utils/network/base_list_model.dart'; import 'package:aku_community_manager/utils/network/base_model.dart'; +// Package imports: +import 'package:bot_toast/bot_toast.dart'; +import 'package:dio/dio.dart'; +import 'package:get/get.dart' hide Response, FormData, MultipartFile; +import 'package:power_logger/power_logger.dart'; +import 'package:provider/provider.dart'; class NetUtil { Dio? _dio; @@ -142,7 +141,7 @@ class NetUtil { } else { for (var item in files) { BaseFileModel model = await NetUtil().upload(api, item); - urls.add(model.url??''); + urls.add(model.url ?? ''); } } @@ -176,7 +175,7 @@ class NetUtil { final userProvider = Provider.of(Get.context!, listen: false); if (!model.status! && model.message == '登录失效,请登录' && userProvider.isLogin) { userProvider.logout(); - Get.offAll(LoginPage()); + Get.offAll(() => LoginPage()); } if (!model.status! || showMessage) { BotToast.showText(text: model.message!);