diff --git a/lib/globals.dart b/lib/globals.dart index ce07adb..8f89eb7 100644 --- a/lib/globals.dart +++ b/lib/globals.dart @@ -334,6 +334,8 @@ void clearAllStates(BuildContext context) { void checkAuth(BuildContext context) { if (!auth.isAuthed && !auth.checked && !auth.isChecking) { + final state = GoRouterState.of(context); + final router = GoRouter.of(context); auth.checkAuth().then((re) { if (!re) { if (auth.status!.noUser && @@ -341,9 +343,8 @@ void checkAuth(BuildContext context) { return; } final loc = auth.status!.noUser ? "/create_root_user" : "/login"; - final path = GoRouterState.of(context).path; - if (path != loc) { - context.push(loc); + if (state.path != loc) { + router.push(loc); } } }).catchError((err) { diff --git a/lib/main.dart b/lib/main.dart index 06a7da8..90dc422 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -46,7 +46,7 @@ final _router = GoRouter( ), GoRoute( path: LoginPage.routeName, - builder: (context, state) => const LoginPage(), + builder: (context, state) => LoginPage(key: state.pageKey), ), GoRoute( path: CreateRootUserPage.routeName, diff --git a/lib/pages/login.dart b/lib/pages/login.dart index e210614..db9575e 100644 --- a/lib/pages/login.dart +++ b/lib/pages/login.dart @@ -36,7 +36,8 @@ Future login(String username, String password) async { throw re.unwrapErr(); } -class _LoginPageState extends State with ThemeModeWidget { +class _LoginPageState extends State + with ThemeModeWidget, IsTopWidget2 { final _formKey = GlobalKey(); String _username = ""; String _password = ""; @@ -45,6 +46,10 @@ class _LoginPageState extends State with ThemeModeWidget { bool _isLogin = false; bool _checkAuth = false; + void _onStateChanged(dynamic _) { + setState(() {}); + } + @override void initState() { super.initState(); @@ -53,6 +58,13 @@ class _LoginPageState extends State with ThemeModeWidget { _passwordVisible = false; _isValid = false; _isLogin = false; + listener.on("user_logined", _onStateChanged); + } + + @override + void dispose() { + listener.removeEventListener("user_logined", _onStateChanged); + super.dispose(); } static bool _checkIsValid(String username, String password) { @@ -82,6 +94,7 @@ class _LoginPageState extends State with ThemeModeWidget { } void _checkStatus(BuildContext build) { + if (!isTop(context)) return; if (auth.isAuthed) { SchedulerBinding.instance.addPostFrameCallback((_) { build.go("/"); @@ -107,18 +120,18 @@ class _LoginPageState extends State with ThemeModeWidget { Widget build(BuildContext context) { tryInitApi(context); _checkStatus(context); + if (isTop(context) && auth.user != null) { + SchedulerBinding.instance.addPostFrameCallback((_) { + context.canPop() ? context.pop() : context.go("/"); + }); + } return Scaffold( appBar: AppBar( - leading: auth.user == null - ? Container() - : IconButton( - icon: const Icon(Icons.arrow_back), - onPressed: () { - context.canPop() ? context.pop() : context.go("/"); - }), + leading: Container(), title: Text(AppLocalizations.of(context)!.login), actions: [ buildThemeModeIcon(context), + buildMoreVertSettingsButon(context), ], ), body: PopScope( diff --git a/lib/pages/settings/display.dart b/lib/pages/settings/display.dart index 7b5f2d1..a8e0697 100644 --- a/lib/pages/settings/display.dart +++ b/lib/pages/settings/display.dart @@ -237,6 +237,7 @@ class _DisplaySettingsPage extends State : e.langName)) .toList(), leadingIcon: const Icon(Icons.language), + width: 250, )), Container( padding: diff --git a/lib/pages/users.dart b/lib/pages/users.dart index cc909ce..a3093d3 100644 --- a/lib/pages/users.dart +++ b/lib/pages/users.dart @@ -142,7 +142,7 @@ class _UsersPage extends State with ThemeModeWidget, IsTopWidget2 { Widget _buildSliverGrid(BuildContext context) { return SliverGrid( gridDelegate: const SliverGridDelegateWithMaxCrossAxisExtent( - maxCrossAxisExtent: 360.0, + maxCrossAxisExtent: 370.0, mainAxisSpacing: 10.0, crossAxisSpacing: 10.0, mainAxisExtent: 80.0, diff --git a/lib/task.dart b/lib/task.dart index 1164e97..0e545c0 100644 --- a/lib/task.dart +++ b/lib/task.dart @@ -32,6 +32,7 @@ class TaskManager { tasksList.clear(); _channel?.sink.add("{\"type\":\"close\"}"); _channel?.sink.close(); + _channel = null; _closed = true; } diff --git a/pubspec.lock b/pubspec.lock index e75d757..d2e5366 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -362,10 +362,10 @@ packages: dependency: "direct main" description: name: go_router - sha256: "6ad5662b014c06c20fa46ab78715c96b2222a7fe4f87bf77e0289592c2539e86" + sha256: abec47eb8c8c36ebf41d0a4c64dbbe7f956e39a012b3aafc530e951bdc12fe3f url: "https://pub.dev" source: hosted - version: "14.1.3" + version: "14.1.4" graphs: dependency: transitive description: @@ -618,10 +618,10 @@ packages: dependency: transitive description: name: path_provider_android - sha256: a248d8146ee5983446bf03ed5ea8f6533129a12b11f12057ad1b4a67a2b3b41d + sha256: "9c96da072b421e98183f9ea7464898428e764bc0ce5567f27ec8693442e72514" url: "https://pub.dev" source: hosted - version: "2.2.4" + version: "2.2.5" path_provider_foundation: dependency: transitive description: @@ -730,10 +730,10 @@ packages: dependency: transitive description: name: pubspec_parse - sha256: c63b2876e58e194e4b0828fcb080ad0e06d051cb607a6be51a9e084f47cb9367 + sha256: c799b721d79eb6ee6fa56f00c04b472dcd44a30d258fac2174a6ec57302678f8 url: "https://pub.dev" source: hosted - version: "1.2.3" + version: "1.3.0" retrofit: dependency: "direct main" description: @@ -770,10 +770,10 @@ packages: dependency: transitive description: name: shared_preferences_android - sha256: "1ee8bf911094a1b592de7ab29add6f826a7331fb854273d55918693d5364a1f2" + sha256: "93d0ec9dd902d85f326068e6a899487d1f65ffcd5798721a95330b26c8131577" url: "https://pub.dev" source: hosted - version: "2.2.2" + version: "2.2.3" shared_preferences_foundation: dependency: transitive description: @@ -943,26 +943,26 @@ packages: dependency: "direct main" description: name: super_clipboard - sha256: f81058a9b3cadaaf60f37c2a37dd2647c6e5eda4533e335f1512605e3b9fb860 + sha256: "17978c3dc7b6ebf588a8007448f668ad6aa64733b60ed2ae18152113cca39fa2" url: "https://pub.dev" source: hosted - version: "0.8.15" + version: "0.8.16" super_context_menu: dependency: "direct main" description: name: super_context_menu - sha256: "8a5fef2ca0dcb207fef7168c4c00079e649bfc24223a8f72e3cfcf6b7083e89e" + sha256: "33f189fd508716d03daa277d890a8b079f691e3e3577d99d81c1e23b2a9968c7" url: "https://pub.dev" source: hosted - version: "0.8.15" + version: "0.8.16" super_native_extensions: dependency: transitive description: name: super_native_extensions - sha256: bb6499c83484c1dbe293e68907a9b6d51e30b699502c5e11940e834c310df261 + sha256: d2d1259c7e43966173c394ef64475e612bd5822095f6cd1008eb978175ce2f0d url: "https://pub.dev" source: hosted - version: "0.8.15" + version: "0.8.16" synchronized: dependency: transitive description: @@ -1079,10 +1079,10 @@ packages: dependency: transitive description: name: web_socket - sha256: "217f49b5213796cb508d6a942a5dc604ce1cb6a0a6b3d8cb3f0c314f0ecea712" + sha256: "24301d8c293ce6fe327ffe6f59d8fd8834735f0ec36e4fd383ec7ff8a64aa078" url: "https://pub.dev" source: hosted - version: "0.1.4" + version: "0.1.5" web_socket_channel: dependency: "direct main" description: @@ -1141,4 +1141,4 @@ packages: version: "3.1.2" sdks: dart: ">=3.4.0 <4.0.0" - flutter: ">=3.19.0" + flutter: ">=3.22.0"