From 509d1d2a2e79c6afbf729496312d6fa77db36d58 Mon Sep 17 00:00:00 2001 From: Armand <4831c0@proton.me> Date: Tue, 26 Aug 2025 22:40:20 +0200 Subject: [PATCH] make reauth reminder a toast --- firka/lib/l10n | 2 +- firka/lib/ui/phone/pages/extras/extras.dart | 22 +------- .../ui/phone/screens/home/home_screen.dart | 52 ++++++++++++++++--- .../lib/ui/phone/widgets/bottom_nav_icon.dart | 6 +-- 4 files changed, 49 insertions(+), 33 deletions(-) diff --git a/firka/lib/l10n b/firka/lib/l10n index e62275a..868bd39 160000 --- a/firka/lib/l10n +++ b/firka/lib/l10n @@ -1 +1 @@ -Subproject commit e62275ae5d5de8e68e39aa8c5e3d1424155fdafd +Subproject commit 868bd39590f2358c0a4cd776dc99641c3e1f47b1 diff --git a/firka/lib/ui/phone/pages/extras/extras.dart b/firka/lib/ui/phone/pages/extras/extras.dart index de0a5a1..23fc1a5 100644 --- a/firka/lib/ui/phone/pages/extras/extras.dart +++ b/firka/lib/ui/phone/pages/extras/extras.dart @@ -6,10 +6,8 @@ import 'package:flutter/material.dart'; import '../../../../helpers/firka_bundle.dart'; import '../../screens/debug/debug_screen.dart'; -import '../../screens/login/login_screen.dart'; -void showExtrasBottomSheet( - BuildContext context, bool loggedOut, AppInitialization data) { +void showExtrasBottomSheet(BuildContext context, AppInitialization data) { showModalBottomSheet( context: context, elevation: 100, @@ -41,24 +39,6 @@ void showExtrasBottomSheet( padding: const EdgeInsets.all(16.0), child: Column( children: [ - !loggedOut - ? SizedBox() - : GestureDetector( - onTap: () { - Navigator.pop(context); - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => DefaultAssetBundle( - bundle: FirkaBundle(), - child: LoginScreen(data)))); - }, - child: FirkaCard( - left: [Text(data.l10n.reauth_screen)], - right: [], - color: appStyle.colors.accent, - ), - ), GestureDetector( onTap: () => { Navigator.pop(context), diff --git a/firka/lib/ui/phone/screens/home/home_screen.dart b/firka/lib/ui/phone/screens/home/home_screen.dart index 9373a98..63e3707 100644 --- a/firka/lib/ui/phone/screens/home/home_screen.dart +++ b/firka/lib/ui/phone/screens/home/home_screen.dart @@ -17,11 +17,13 @@ import 'package:majesticons_flutter/majesticons_flutter.dart'; import '../../../../helpers/db/widget.dart'; import '../../../../helpers/debug_helper.dart'; +import '../../../../helpers/firka_bundle.dart'; import '../../../widget/firka_icon.dart'; import '../../pages/extras/extras.dart'; import '../../pages/extras/main_error.dart'; import '../../pages/home/home_grades_subject.dart'; import '../../pages/home/home_timetable.dart'; +import '../login/login_screen.dart'; class HomeScreen extends StatefulWidget { final AppInitialization data; @@ -34,7 +36,7 @@ class HomeScreen extends StatefulWidget { enum HomePages { home, grades, timetable, timetableMo } -enum ActiveToastType { fetching, error, none } +enum ActiveToastType { fetching, error, reauth, none } class ActiveHomePage { final HomePages page; @@ -62,7 +64,6 @@ class _HomeScreenState extends State { List previousPages = List.empty(growable: true); Widget? toast; - bool userLoggedOut = false; ActiveToastType activeToast = ActiveToastType.none; @@ -86,7 +87,47 @@ class _HomeScreenState extends State { if (res.statusCode >= 400 || res.err == TokenExpiredException().toString()) { setState(() { - userLoggedOut = true; + activeToast = ActiveToastType.reauth; + toast = Positioned( + top: MediaQuery.of(context).size.height / 1.6, + left: 0.0, + right: 0.0, + bottom: 0, + child: Center( + child: GestureDetector( + child: Card( + color: appStyle.colors.warningCard, + shadowColor: Colors.transparent, + child: Padding( + padding: EdgeInsets.all(8), + child: Row( + mainAxisSize: MainAxisSize.min, + // Use min to prevent filling the width + children: [ + FirkaIconWidget(FirkaIconType.majesticons, + Majesticon.alertCircleSolid, + color: appStyle.colors.warningAccent, size: 24), + SizedBox(width: 4), + Text( + widget.data.l10n.reauth, + style: appStyle.fonts.B_14SB + .copyWith(color: appStyle.colors.warningText), + ) + ], + ), + ), + ), + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => DefaultAssetBundle( + bundle: FirkaBundle(), + child: LoginScreen(widget.data)))); + }, + ), + ), + ); }); return; } @@ -191,7 +232,6 @@ class _HomeScreenState extends State { _updateSystemUI(); }); - userLoggedOut = false; prefetch(); } @@ -353,15 +393,13 @@ class _HomeScreenState extends State { BottomNavIconWidget( () { HapticFeedback.lightImpact(); - showExtrasBottomSheet( - context, userLoggedOut, widget.data); + showExtrasBottomSheet(context, widget.data); }, false, Majesticon.globeEarthLine, widget.data.l10n.other, appStyle.colors.secondary, appStyle.colors.textPrimary, - warn: userLoggedOut, ), ], ), diff --git a/firka/lib/ui/phone/widgets/bottom_nav_icon.dart b/firka/lib/ui/phone/widgets/bottom_nav_icon.dart index ac0895b..9f6cc8c 100644 --- a/firka/lib/ui/phone/widgets/bottom_nav_icon.dart +++ b/firka/lib/ui/phone/widgets/bottom_nav_icon.dart @@ -12,11 +12,10 @@ class BottomNavIconWidget extends StatelessWidget { final String text; final Color iconColor; final Color textColor; - final bool warn; const BottomNavIconWidget(this.onTap, this.active, this.icon, this.text, this.iconColor, this.textColor, - {this.warn = false, super.key}); + {super.key}); @override Widget build(BuildContext context) { @@ -32,8 +31,7 @@ class BottomNavIconWidget extends StatelessWidget { mainAxisSize: MainAxisSize.min, children: [ FirkaIconWidget(FirkaIconType.majesticons, icon, - color: warn ? appStyle.colors.errorAccent : iconColor, - size: 24) + color: iconColor, size: 24) .build(context), const SizedBox(height: 4), Text(