Compare commits

..

4 Commits

5 changed files with 171 additions and 27 deletions

View File

@ -72,7 +72,7 @@ class _TheLoginState extends ConsumerState<TheLogin> with CommonMixin {
@override
void initState() {
Future.delayed(Duration(seconds: 3), () => sysProtocol(context));
Future.delayed(Duration(seconds: 2), () => sysProtocol(context));
Future(() {
// Provider
ref.read(userTokenProvider.notifier).clean(); //

View File

@ -27,7 +27,6 @@ import 'package:marking_app/pages/marking/index.dart';
import 'package:marking_app/provider/user_provider.dart';
import 'package:marking_app/utils/index.dart';
import 'package:marking_app/utils/request/rest_client.dart';
import 'package:marking_app/utils/sys_protocol.dart';
import 'package:package_info/package_info.dart';
import 'homework_correction/job_home.dart';
@ -70,7 +69,6 @@ class TheMainPageState extends ConsumerState<TheMainPage> with CommonMixin {
void initState() {
_pageController = PageController(initialPage: tabIndex);
_otherFocusNode = FocusNode();
Future.delayed(Duration(seconds: 1), () => sysProtocol(context));
// APP升级校验在登录后
_userListener = ref.read(userProvider.notifier).addListener((state) {
if (state.id != '0' && state.id != '') {

File diff suppressed because one or more lines are too long

View File

@ -41,6 +41,7 @@ class FastData {
static const String _INPUT_KEYBOARD_GUIDE_PAGE_WORK = "APP:MARKING:GUIDE_PAGE:WORK";
//
static const String _SYS_PROTOCOL = "APP:SYS:PROTOCOL";
static const String _SYS_PROTOCOL_SHOW = "APP:SYS:PROTOCOL_SHOW";
static SharedPreferences? _prefs;
@ -286,4 +287,19 @@ class FastData {
SharedPreferences thePrefs = await getSharedInstance();
thePrefs.remove(_SYS_PROTOCOL);
}
Future<bool> setSysProtocolShow(bool val) async {
SharedPreferences thePrefs = await getSharedInstance();
return await thePrefs.setBool(_SYS_PROTOCOL_SHOW, val);
}
Future<bool?> getSysProtocolShow([SharedPreferences? thePrefs]) async {
if (thePrefs == null) thePrefs = await getSharedInstance();
return thePrefs.getBool(_SYS_PROTOCOL_SHOW);
}
void cleanSysProtocolShow() async {
SharedPreferences thePrefs = await getSharedInstance();
thePrefs.remove(_SYS_PROTOCOL_SHOW);
}
}

View File

@ -74,6 +74,7 @@ class Protocol extends Dialog {
],
),
),
SizedBox(height: 10.h),
Row(
children: [
Expanded(
@ -122,17 +123,25 @@ class Protocol extends Dialog {
}
///
void sysProtocol(BuildContext context) async {
Future<void> sysProtocol(BuildContext context) async {
bool? _sysProtocol = await FastData.getInstance().getSysProtocol();
if (_sysProtocol == null || !_sysProtocol) {
print('进来这里....');
showDialog(
context: context,
barrierDismissible: false,
builder: (ctx) {
return Protocol(ctx);
},
);
bool? _sysProtocolShow = await FastData.getInstance().getSysProtocolShow();
if (_sysProtocolShow != true) {
try {
await FastData.getInstance().setSysProtocolShow(true);
return showDialog(
context: context,
barrierDismissible: false,
// useRootNavigator: false,
builder: (ctx) => Protocol(ctx),
);
} catch (e) {
FastData.getInstance().cleanSysProtocol();
} finally {
FastData.getInstance().cleanSysProtocolShow();
}
}
}
}