From 5ede9cc5f7d969951b2944ac7c0fa858d15dbb18 Mon Sep 17 00:00:00 2001 From: zhangmeng <494089941@qq.com> Date: Wed, 19 May 2021 10:23:24 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=20=E5=BA=94=E7=94=A8?= =?UTF-8?q?=E8=A2=AB=E5=90=8E=E5=8F=B0=E6=9D=80=E6=8E=89=20=E5=86=8D?= =?UTF-8?q?=E6=AC=A1=E5=90=AF=E5=8A=A8=E4=BC=9A=E5=8D=A1=E5=9C=A8=E5=90=AF?= =?UTF-8?q?=E5=8A=A8=E9=A1=B5=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/home/home_page.dart | 10 ++++- lib/pages/splash/splash_page.dart | 6 ++- lib/pages/tab_navigator.dart | 63 +++++-------------------------- lib/provider/user_provider.dart | 4 +- 4 files changed, 25 insertions(+), 58 deletions(-) diff --git a/lib/pages/home/home_page.dart b/lib/pages/home/home_page.dart index 13d1839c..693db6bb 100644 --- a/lib/pages/home/home_page.dart +++ b/lib/pages/home/home_page.dart @@ -50,7 +50,7 @@ class _HomePageState extends State List? data; - EasyRefreshController _refreshController = EasyRefreshController(); + late EasyRefreshController _refreshController; int page = 1; @@ -61,6 +61,14 @@ class _HomePageState extends State void initState() { super.initState(); _scrollController = ScrollController(); + _refreshController = EasyRefreshController(); + } + + @override + void dispose() { + _refreshController.dispose(); + _scrollController?.dispose(); + super.dispose(); } @override diff --git a/lib/pages/splash/splash_page.dart b/lib/pages/splash/splash_page.dart index c389817f..11a222f7 100644 --- a/lib/pages/splash/splash_page.dart +++ b/lib/pages/splash/splash_page.dart @@ -58,7 +58,11 @@ class _SplashPageState extends State { context, debug: DeveloperUtil.dev, ); - _initOp().then((value) => Get.offAll(() => TabNavigator())); + Future.delayed(Duration(milliseconds: 1000), () async { + await _initOp(); + Get.offAll(() => TabNavigator()); + }); + // _initOp().then((value) => Get.offAll(() => TabNavigator())); } @override diff --git a/lib/pages/tab_navigator.dart b/lib/pages/tab_navigator.dart index 0f3e26ce..cbc4c0a4 100644 --- a/lib/pages/tab_navigator.dart +++ b/lib/pages/tab_navigator.dart @@ -1,14 +1,13 @@ -import 'package:aku_community/base/base_style.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:bot_toast/bot_toast.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:aku_community/const/resource.dart'; import 'package:aku_community/ui/community/community_views/community_page.dart'; import 'package:aku_community/ui/market/market_page.dart'; import 'package:aku_community/widget/bee_scaffold.dart'; -import 'package:get/get.dart'; import 'home/home_page.dart'; import 'personal/personal_page.dart'; import 'property/property_index.dart'; @@ -99,59 +98,15 @@ class _TabNavigatorState extends State return BeeScaffold( body: WillPopScope( onWillPop: () async { - // if (_lastPressed == null || - // DateTime.now().difference(_lastPressed!) > Duration(seconds: 1)) { - // //两次点击间隔超过1秒重新计算 - // _lastPressed = DateTime.now(); - // BotToast.showText(text: '再点击一次返回退出'); - // return false; - // } + if (_lastPressed == null || + DateTime.now().difference(_lastPressed!) > Duration(seconds: 1)) { + //两次点击间隔超过1秒重新计算 + _lastPressed = DateTime.now(); + BotToast.showText(text: '再点击一次返回退出'); + return false; + } //否则关闭app - bool _reslut = true; - showCupertinoDialog( - context: context, - builder: (context) { - return CupertinoAlertDialog( - title: Text( - '确认退出?', - style: TextStyle( - color: Colors.black, - fontSize: 40.sp, - fontWeight: FontWeight.bold, - ), - ), - actions: [ - CupertinoActionSheetAction( - onPressed: () { - Get.back(); - }, - child: Text( - '确认', - style: TextStyle( - color: Colors.black, - fontSize: 32.sp, - fontWeight: FontWeight.bold, - ), - ), - ), - CupertinoActionSheetAction( - onPressed: () { - Get.back(); - _reslut = false; - }, - child: Text( - '取消', - style: TextStyle( - color: kPrimaryColor, - fontSize: 32.sp, - fontWeight: FontWeight.bold, - ), - ), - ) - ], - ); - }); - return _reslut; + return true; }, child: TabBarView( children: _pages, diff --git a/lib/provider/user_provider.dart b/lib/provider/user_provider.dart index 620745f2..936f5887 100644 --- a/lib/provider/user_provider.dart +++ b/lib/provider/user_provider.dart @@ -22,7 +22,7 @@ class UserProvider extends ChangeNotifier { bool _isLogin = false; bool get isLogin => _isLogin; bool get isNotLogin => !_isLogin; - Future setLogin(int? token) async { + Future setLogin(int token) async { final appProvider = Provider.of(Get.context!, listen: false); _isLogin = true; NetUtil().dio!.options.headers.putIfAbsent('App-Admin-Token', () => token); @@ -52,7 +52,7 @@ class UserProvider extends ChangeNotifier { Future updateProfile() async { _userInfoModel = await SignFunc.getUserInfo(); if (_userInfoModel != null && !kIsWeb && !Platform.isMacOS) { - await JPush().setAlias(_userInfoModel!.id.toString()); + await JPush().setAlias(_userInfoModel?.id.toString()??''); } notifyListeners(); }