修复我的房屋页数组溢出问题

websocket关闭时修改provider状态
hmxc
张萌 3 years ago
parent 3718ba0130
commit 6bb4c899ea

@ -2,7 +2,6 @@
// Generated file. Do not edit. // Generated file. Do not edit.
// //
// ignore_for_file: directives_ordering
// ignore_for_file: lines_longer_than_80_chars // ignore_for_file: lines_longer_than_80_chars
import 'package:device_info_plus_web/device_info_plus_web.dart'; import 'package:device_info_plus_web/device_info_plus_web.dart';

@ -181,10 +181,8 @@ class _SettingsPageState extends State<SettingsPage> {
CupertinoSwitch( CupertinoSwitch(
value: UserTool.appProveider.fireAlert, value: UserTool.appProveider.fireAlert,
onChanged: (value) { onChanged: (value) {
UserTool.appProveider.setFireAlert(value); if (value) {
if (UserTool.appProveider.fireAlert) {
WebSocketUtil().startWebSocket(); WebSocketUtil().startWebSocket();
WebSocketUtil().setPrintHeart(value);
} else { } else {
WebSocketUtil().closeWebSocket(); WebSocketUtil().closeWebSocket();
} }

@ -0,0 +1,32 @@
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class ContactManagerPainter extends CustomPainter {
@override
void paint(Canvas canvas, Size size) {
Paint paint = Paint()
..strokeWidth = 2.w
..style = PaintingStyle.stroke;
Path path = Path();
Rect rect = Rect.fromCircle(center: Offset(200.w, 200.w), radius: 120.w);
path.addArc(rect, 0, pi * 2);
Gradient gradient = LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [Color(0xFFF9F9F9), Color(0xFF4AFD71)]);
paint.shader = gradient.createShader(rect);
canvas.drawPath(path, paint);
}
@override
bool shouldRepaint(covariant CustomPainter oldDelegate) {
return false;
}
@override
bool shouldRebuildSemantics(covariant CustomPainter oldDelegate) {
return false;
}
}

@ -60,6 +60,7 @@ class UserProvider extends ChangeNotifier {
HiveStore.appBox!.delete('token'); HiveStore.appBox!.delete('token');
HiveStore.appBox!.delete('login'); HiveStore.appBox!.delete('login');
WebSocketUtil().closeWebSocket(); WebSocketUtil().closeWebSocket();
notifyListeners(); notifyListeners();
} }

@ -152,20 +152,21 @@ class HouseCard extends StatelessWidget {
], ],
).expand(), ).expand(),
// //
!isOwner isOwner
? SizedBox() ? SizedBox()
: Column( : Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text( Text(
'到期时间${_isOverDate(DateUtil.getDateTime(model!.effectiveTimeEnd!)!)}', '到期时间${_isOverDate(DateUtil.getDateTime(model!.effectiveTimeEnd ?? ''))}',
style: style:
Theme.of(context).textTheme.subtitle2!.copyWith( Theme.of(context).textTheme.subtitle2!.copyWith(
color: Color(0xFF666666), color: Color(0xFF666666),
), ),
), ),
Text( Text(
DateUtil.formatDateStr(model!.effectiveTimeEnd!, DateUtil.formatDateStr(
model!.effectiveTimeEnd ?? '',
format: 'yyyy-MM-dd'), format: 'yyyy-MM-dd'),
style: Theme.of(context).textTheme.subtitle1, style: Theme.of(context).textTheme.subtitle1,
), ),
@ -185,7 +186,10 @@ class HouseCard extends StatelessWidget {
); );
} }
String _isOverDate(DateTime date) { String _isOverDate(DateTime? date) {
if (date == null) {
return '未知';
}
if (DateTime.now().isAfter(date)) { if (DateTime.now().isAfter(date)) {
return '已过期'; return '已过期';
} else { } else {

@ -2,6 +2,7 @@ import 'package:aku_community/base/base_style.dart';
import 'package:aku_community/ui/profile/house/identify_selection_page.dart'; import 'package:aku_community/ui/profile/house/identify_selection_page.dart';
import 'package:aku_community/ui/profile/house/my_house_list.dart'; import 'package:aku_community/ui/profile/house/my_house_list.dart';
import 'package:aku_community/ui/profile/house/tenant_house_list_page.dart'; import 'package:aku_community/ui/profile/house/tenant_house_list_page.dart';
import 'package:aku_community/ui/profile/house/upload_empty_form_page.dart';
import 'package:aku_community/widget/buttons/bottom_button.dart'; import 'package:aku_community/widget/buttons/bottom_button.dart';
import 'package:aku_community/widget/others/user_tool.dart'; import 'package:aku_community/widget/others/user_tool.dart';
import 'package:bot_toast/bot_toast.dart'; import 'package:bot_toast/bot_toast.dart';
@ -54,7 +55,6 @@ class _HouseOwnersPageState extends State<HouseOwnersPage> {
} }
bool get isOwner { bool get isOwner {
switch (UserTool.userProvider.userDetailModel!.type) { switch (UserTool.userProvider.userDetailModel!.type) {
case 1: case 1:
return true; return true;
@ -91,16 +91,19 @@ class _HouseOwnersPageState extends State<HouseOwnersPage> {
@override @override
void initState() { void initState() {
Function cancel = BotToast.showLoading(); Future.delayed(Duration(milliseconds: 300), () async {
try { Function cancel = BotToast.showLoading();
Future.delayed(Duration(milliseconds: 300), () async { try {
await UserTool.userProvider.updateUserDetail(); await UserTool.userProvider.updateUserDetail();
}); UserTool.appProveider.updateHouses(await HouseFunc.passedHouses);
} catch (e) { } catch (e) {
LoggerData.addData(e); LoggerData.addData(e);
} }
_onload = false; _onload = false;
cancel(); cancel();
setState(() {});
});
super.initState(); super.initState();
} }
@ -128,7 +131,7 @@ class _HouseOwnersPageState extends State<HouseOwnersPage> {
: EasyRefresh( : EasyRefresh(
header: MaterialHeader(), header: MaterialHeader(),
controller: _refreshController, controller: _refreshController,
firstRefresh: true, firstRefresh: false,
onRefresh: () async { onRefresh: () async {
appProvider.updateHouses(await HouseFunc.passedHouses); appProvider.updateHouses(await HouseFunc.passedHouses);
}, },
@ -170,7 +173,7 @@ class _HouseOwnersPageState extends State<HouseOwnersPage> {
child: Text('添加房屋'), child: Text('添加房屋'),
), ),
), ),
if (!isOwner && !_emptyHouse) _contractRelevant(), if (!isOwner && !_emptyHouse) _contractRelevant().expand()
], ],
), ),
), ),
@ -186,7 +189,7 @@ class _HouseOwnersPageState extends State<HouseOwnersPage> {
if (result == true) _refreshController.callRefresh(); if (result == true) _refreshController.callRefresh();
} }
// ///
Widget _contractRelevant() { Widget _contractRelevant() {
return GridView.count( return GridView.count(
crossAxisCount: 2, crossAxisCount: 2,
@ -197,7 +200,9 @@ class _HouseOwnersPageState extends State<HouseOwnersPage> {
_cardBuild(R.ASSETS_ICONS_PAY_PNG, '缴费查询', '查看租金及保证金情况', () {}), _cardBuild(R.ASSETS_ICONS_PAY_PNG, '缴费查询', '查看租金及保证金情况', () {}),
_cardBuild(R.ASSETS_ICONS_CHANGE_PNG, '合同变更', '变更合同信息、重新签约', () {}), _cardBuild(R.ASSETS_ICONS_CHANGE_PNG, '合同变更', '变更合同信息、重新签约', () {}),
_cardBuild(R.ASSETS_ICONS_CONTRACT_PNG, '合同续签', '到期前线上办理续签手续', () {}), _cardBuild(R.ASSETS_ICONS_CONTRACT_PNG, '合同续签', '到期前线上办理续签手续', () {}),
_cardBuild(R.ASSETS_ICONS_FINISH_PNG, '合同终止', '线上申请终止合同', () {}) _cardBuild(R.ASSETS_ICONS_FINISH_PNG, '合同终止', '线上申请终止合同', () {
Get.to(() => UploadEmptyFormPage());
})
], ],
); );
} }

@ -1,4 +1,5 @@
import 'dart:async'; import 'dart:async';
import 'package:aku_community/widget/others/user_tool.dart';
import 'package:bot_toast/bot_toast.dart'; import 'package:bot_toast/bot_toast.dart';
import 'package:power_logger/power_logger.dart'; import 'package:power_logger/power_logger.dart';
import 'package:web_socket_channel/io.dart'; import 'package:web_socket_channel/io.dart';
@ -102,6 +103,8 @@ class WebSocketUtil {
onError?.call(e); onError?.call(e);
LoggerData.addData(e); LoggerData.addData(e);
} }
WebSocketUtil().setPrintHeart(true);
} }
// //
@ -176,6 +179,7 @@ class WebSocketUtil {
} }
endReconnect(); endReconnect();
destoryHeart(); destoryHeart();
UserTool.appProveider.setFireAlert(false);
_socketStatus = SOCKETSTATUS.CLOSED; _socketStatus = SOCKETSTATUS.CLOSED;
} }

@ -77,7 +77,7 @@ packages:
name: async name: async
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.7.0" version: "2.5.0"
auto_size_text: auto_size_text:
dependency: transitive dependency: transitive
description: description:
@ -182,7 +182,7 @@ packages:
name: charcode name: charcode
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.3.1" version: "1.2.0"
checked_yaml: checked_yaml:
dependency: transitive dependency: transitive
description: description:
@ -682,7 +682,7 @@ packages:
name: meta name: meta
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.4.0" version: "1.3.0"
mime: mime:
dependency: transitive dependency: transitive
description: description:
@ -1046,7 +1046,7 @@ packages:
name: source_span name: source_span
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.8.1" version: "1.8.0"
sp_util: sp_util:
dependency: transitive dependency: transitive
description: description:
@ -1123,7 +1123,7 @@ packages:
name: test_api name: test_api
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.4.1" version: "0.2.19"
timing: timing:
dependency: transitive dependency: transitive
description: description:

Loading…
Cancel
Save