this repo has no description

feat: add session clearing functionality and improve loading indicators in profile and gallery pages

+28 -13
+10
lib/auth.dart
··· 81 81 } 82 82 return session; 83 83 } 84 + 85 + Future<void> clearSession() async { 86 + // Remove session from secure storage 87 + await _storage.delete(key: 'atproto_session'); 88 + // Remove access token from secure storage and memory 89 + await apiService.setToken(null); 90 + // Optionally clear any in-memory session/user data 91 + apiService.currentUser = null; 92 + // If you add a session property to ApiService, clear it here as well 93 + } 84 94 } 85 95 86 96 final auth = Auth();
+13 -6
lib/main.dart
··· 5 5 import 'package:grain/api.dart'; 6 6 import 'package:grain/app_logger.dart'; 7 7 import 'package:grain/app_theme.dart'; 8 + import 'package:grain/auth.dart'; 8 9 import 'package:grain/screens/home_page.dart'; 9 10 import 'package:grain/screens/splash_page.dart'; 10 11 ··· 67 68 await apiService.fetchCurrentUser(); 68 69 } 69 70 70 - void handleSignOut() { 71 + void handleSignOut() async { 72 + await auth.clearSession(); // Clear session data 71 73 setState(() { 72 74 isSignedIn = false; 73 75 }); ··· 75 77 76 78 @override 77 79 Widget build(BuildContext context) { 80 + Widget home; 78 81 if (_loading) { 79 - return const MaterialApp( 80 - home: Scaffold(body: Center(child: CircularProgressIndicator())), 82 + home = Scaffold( 83 + body: Center( 84 + child: CircularProgressIndicator(strokeWidth: 2, color: AppTheme.primaryColor), 85 + ), 81 86 ); 87 + } else { 88 + home = isSignedIn 89 + ? MyHomePage(title: 'Grain', onSignOut: handleSignOut) 90 + : SplashPage(onSignIn: handleSignIn); 82 91 } 83 92 return MaterialApp( 84 93 title: 'Grain', 85 94 theme: AppTheme.lightTheme, 86 95 darkTheme: AppTheme.darkTheme, 87 96 themeMode: ThemeMode.system, 88 - home: isSignedIn 89 - ? MyHomePage(title: 'Grain', onSignOut: handleSignOut) 90 - : SplashPage(onSignIn: handleSignIn), 97 + home: home, 91 98 ); 92 99 } 93 100 }
+1 -3
lib/screens/gallery_page.dart
··· 76 76 if (_loading) { 77 77 return Scaffold( 78 78 backgroundColor: theme.scaffoldBackgroundColor, 79 - body: const Center( 80 - child: CircularProgressIndicator(strokeWidth: 2, color: Color(0xFF0EA5E9)), 81 - ), 79 + body: Center(child: CircularProgressIndicator(strokeWidth: 2, color: theme.primaryColor)), 82 80 ); 83 81 } 84 82 if (_error || gallery == null) {
+4 -4
lib/screens/profile_page.dart
··· 138 138 if (_loading) { 139 139 return Scaffold( 140 140 backgroundColor: Theme.of(context).scaffoldBackgroundColor, 141 - body: const Center( 142 - child: CircularProgressIndicator(strokeWidth: 2, color: AppTheme.primaryColor), 141 + body: Center( 142 + child: CircularProgressIndicator(strokeWidth: 2, color: theme.colorScheme.primary), 143 143 ), 144 144 ); 145 145 } ··· 319 319 children: [ 320 320 // Galleries tab, edge-to-edge grid 321 321 _galleriesLoading 322 - ? const Center( 322 + ? Center( 323 323 child: CircularProgressIndicator( 324 324 strokeWidth: 2, 325 - color: AppTheme.primaryColor, 325 + color: theme.colorScheme.primary, 326 326 ), 327 327 ) 328 328 : _galleries.isEmpty