添加退出确认

hmxc
张萌 3 years ago
parent 16934b5f8e
commit d2bcd5dc36

@ -4,6 +4,8 @@ import 'dart:async';
import 'package:aku_community_manager/provider/message_provider.dart';
import 'package:aku_community_manager/ui/widgets/common/aku_button.dart';
import 'package:aku_community_manager/ui/widgets/common/aku_material_button.dart';
import 'package:aku_community_manager/utils/websocket/web_socket_util.dart';
import 'package:bot_toast/bot_toast.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
@ -64,6 +66,8 @@ class _HomePageState extends State<HomePage> {
bool _onload = true;
EasyRefreshController? _refreshController;
DateTime? _lastPressed;
///bar
Widget _menuButton(String assetPath, String text, Widget page) {
final appProvider = Provider.of<AppProvider>(context);
@ -400,7 +404,21 @@ class _HomePageState extends State<HomePage> {
),
),
//
body: EasyRefresh(
body: WillPopScope(
onWillPop: () async {
if (_lastPressed == null ||
DateTime.now().difference(_lastPressed!) >
Duration(seconds: 1)) {
//1
_lastPressed = DateTime.now();
BotToast.showText(text: '再点击一次返回退出');
return false;
}
//app
WebSocketUtil().closeWebSocket();
return true;
},
child: EasyRefresh(
firstRefresh: true,
header: MaterialHeader(),
controller: _refreshController,
@ -412,7 +430,7 @@ class _HomePageState extends State<HomePage> {
var dataList = await BussinessFunc.getBussinessModelList(1);
_todoModelList =
dataList.map((e) => ToDoModel.fromJson(e)).toList();
_anounceMentList = await _getAnouncement() ;
_anounceMentList = await _getAnouncement();
_onload = false;
setState(() {});
}
@ -475,8 +493,8 @@ class _HomePageState extends State<HomePage> {
child: Stack(children: [
CarouselSlider(
items: _anounceMentList
.map(
(e) => AllAnouncementState.anounceCard(e))
.map((e) =>
AllAnouncementState.anounceCard(e))
.toList(),
options: CarouselOptions(
viewportFraction: 1.0,
@ -502,8 +520,8 @@ class _HomePageState extends State<HomePage> {
return Container(
width: 12.w,
height: 12.w,
margin:
EdgeInsets.symmetric(horizontal: 12.w),
margin: EdgeInsets.symmetric(
horizontal: 12.w),
decoration: BoxDecoration(
shape: BoxShape.circle,
color: _currentIndicator == index
@ -621,12 +639,18 @@ class _HomePageState extends State<HomePage> {
children: [
Row(
children: [
_card(_itemNumModel.unProcessedNum ?? 0,
'未处理事项', Color(0xFFFF4E0D), 0),
_card(
_itemNumModel.unProcessedNum ?? 0,
'未处理事项',
Color(0xFFFF4E0D),
0),
GridientDiveder()
.verticalDivider(166.5.w),
_card(_itemNumModel.processingNum ?? 0,
'处理中事项', Color(0xFFFFC40C), 1),
_card(
_itemNumModel.processingNum ?? 0,
'处理中事项',
Color(0xFFFFC40C),
1),
],
),
Row(children: [
@ -643,8 +667,8 @@ class _HomePageState extends State<HomePage> {
.verticalDivider(
166.5.w,
),
_card(_itemNumModel.allNum ?? 0, '全部事项',
Color(0xFF333333), 3),
_card(_itemNumModel.allNum ?? 0,
'全部事项', Color(0xFF333333), 3),
],
),
],
@ -654,6 +678,7 @@ class _HomePageState extends State<HomePage> {
),
),
),
),
value: SystemUiOverlayStyle.dark,
);
}

Loading…
Cancel
Save