添加退出确认

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/provider/message_provider.dart';
import 'package:aku_community_manager/ui/widgets/common/aku_button.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/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/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
@ -64,6 +66,8 @@ class _HomePageState extends State<HomePage> {
bool _onload = true; bool _onload = true;
EasyRefreshController? _refreshController; EasyRefreshController? _refreshController;
DateTime? _lastPressed;
///bar ///bar
Widget _menuButton(String assetPath, String text, Widget page) { Widget _menuButton(String assetPath, String text, Widget page) {
final appProvider = Provider.of<AppProvider>(context); 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, firstRefresh: true,
header: MaterialHeader(), header: MaterialHeader(),
controller: _refreshController, controller: _refreshController,
@ -412,7 +430,7 @@ class _HomePageState extends State<HomePage> {
var dataList = await BussinessFunc.getBussinessModelList(1); var dataList = await BussinessFunc.getBussinessModelList(1);
_todoModelList = _todoModelList =
dataList.map((e) => ToDoModel.fromJson(e)).toList(); dataList.map((e) => ToDoModel.fromJson(e)).toList();
_anounceMentList = await _getAnouncement() ; _anounceMentList = await _getAnouncement();
_onload = false; _onload = false;
setState(() {}); setState(() {});
} }
@ -475,8 +493,8 @@ class _HomePageState extends State<HomePage> {
child: Stack(children: [ child: Stack(children: [
CarouselSlider( CarouselSlider(
items: _anounceMentList items: _anounceMentList
.map( .map((e) =>
(e) => AllAnouncementState.anounceCard(e)) AllAnouncementState.anounceCard(e))
.toList(), .toList(),
options: CarouselOptions( options: CarouselOptions(
viewportFraction: 1.0, viewportFraction: 1.0,
@ -502,8 +520,8 @@ class _HomePageState extends State<HomePage> {
return Container( return Container(
width: 12.w, width: 12.w,
height: 12.w, height: 12.w,
margin: margin: EdgeInsets.symmetric(
EdgeInsets.symmetric(horizontal: 12.w), horizontal: 12.w),
decoration: BoxDecoration( decoration: BoxDecoration(
shape: BoxShape.circle, shape: BoxShape.circle,
color: _currentIndicator == index color: _currentIndicator == index
@ -621,12 +639,18 @@ class _HomePageState extends State<HomePage> {
children: [ children: [
Row( Row(
children: [ children: [
_card(_itemNumModel.unProcessedNum ?? 0, _card(
'未处理事项', Color(0xFFFF4E0D), 0), _itemNumModel.unProcessedNum ?? 0,
'未处理事项',
Color(0xFFFF4E0D),
0),
GridientDiveder() GridientDiveder()
.verticalDivider(166.5.w), .verticalDivider(166.5.w),
_card(_itemNumModel.processingNum ?? 0, _card(
'处理中事项', Color(0xFFFFC40C), 1), _itemNumModel.processingNum ?? 0,
'处理中事项',
Color(0xFFFFC40C),
1),
], ],
), ),
Row(children: [ Row(children: [
@ -643,8 +667,8 @@ class _HomePageState extends State<HomePage> {
.verticalDivider( .verticalDivider(
166.5.w, 166.5.w,
), ),
_card(_itemNumModel.allNum ?? 0, '全部事项', _card(_itemNumModel.allNum ?? 0,
Color(0xFF333333), 3), '全部事项', Color(0xFF333333), 3),
], ],
), ),
], ],
@ -654,6 +678,7 @@ class _HomePageState extends State<HomePage> {
), ),
), ),
), ),
),
value: SystemUiOverlayStyle.dark, value: SystemUiOverlayStyle.dark,
); );
} }

Loading…
Cancel
Save