diff --git a/lib/core/auth/auth_store.dart b/lib/core/auth/auth_store.dart index c3b1ea16..d9595ae3 100644 --- a/lib/core/auth/auth_store.dart +++ b/lib/core/auth/auth_store.dart @@ -139,9 +139,6 @@ abstract class _AuthBase with Store { // Clear the user info. user.dispose(); - // Set the login status to logged out. - _isLoggedIn = false; - // If the default token already exists, set it. _token = await _storage.read(key: 'DEFAULT_TOKEN'); @@ -165,6 +162,8 @@ abstract class _AuthBase with Store { } catch (e) { debugPrint(e.toString()); } + // Set the login status to logged out. + _isLoggedIn = false; debugPrint('Successfully logged out'); } diff --git a/lib/main.dart b/lib/main.dart index fd9c688c..ec898779 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -159,6 +159,13 @@ class MyApp extends StatelessWidget { : ThemeMode.dark, home: Home( homeStore: HomeStore(), + followedStreamsStore: authStore.isLoggedIn + ? ListStore( + authStore: authStore, + twitchApi: twitchApi, + listType: ListType.followed, + ) + : null, topSectionStore: ListStore( authStore: authStore, twitchApi: twitchApi, @@ -168,13 +175,6 @@ class MyApp extends StatelessWidget { authStore: authStore, twitchApi: twitchApi, ), - followedStreamsStore: authStore.isLoggedIn - ? ListStore( - authStore: authStore, - twitchApi: twitchApi, - listType: ListType.followed, - ) - : null, searchStore: SearchStore( authStore: authStore, twitchApi: twitchApi, diff --git a/lib/screens/home/home.dart b/lib/screens/home/home.dart index 1a7ed2d3..71c9ab3f 100644 --- a/lib/screens/home/home.dart +++ b/lib/screens/home/home.dart @@ -14,18 +14,18 @@ import 'package:provider/provider.dart'; class Home extends StatelessWidget { final HomeStore homeStore; + final ListStore? followedStreamsStore; final ListStore topSectionStore; final CategoriesStore categoriesSectionStore; final SearchStore searchStore; - final ListStore? followedStreamsStore; const Home({ Key? key, required this.homeStore, + required this.followedStreamsStore, required this.topSectionStore, required this.categoriesSectionStore, required this.searchStore, - required this.followedStreamsStore, }) : super(key: key); @override @@ -42,9 +42,8 @@ class Home extends StatelessWidget { 'Top', 'Search', ]; - return Text( - titles[homeStore.selectedIndex], - ); + + return Text(titles[homeStore.selectedIndex]); }, ), actions: [ @@ -62,43 +61,39 @@ class Home extends StatelessWidget { ), body: SafeArea( child: Observer( - builder: (_) { - return IndexedStack( - index: homeStore.selectedIndex, - children: [ - if (authStore.isLoggedIn) StreamsList(store: followedStreamsStore!), - TopSection( - topSectionStore: topSectionStore, - categoriesSectionStore: categoriesSectionStore, - ), - Search(searchStore: searchStore), - ], - ); - }, + builder: (_) => IndexedStack( + index: homeStore.selectedIndex, + children: [ + if (authStore.isLoggedIn) StreamsList(store: followedStreamsStore!), + TopSection( + topSectionStore: topSectionStore, + categoriesSectionStore: categoriesSectionStore, + ), + Search(searchStore: searchStore), + ], + ), ), ), bottomNavigationBar: Observer( - builder: (_) { - return BottomNavigationBar( - items: [ - if (authStore.isLoggedIn) - const BottomNavigationBarItem( - icon: Icon(Icons.favorite), - label: 'Followed', - ), + builder: (_) => BottomNavigationBar( + items: [ + if (authStore.isLoggedIn) const BottomNavigationBarItem( - icon: Icon(Icons.arrow_upward), - label: 'Top', + icon: Icon(Icons.favorite), + label: 'Followed', ), - const BottomNavigationBarItem( - icon: Icon(Icons.search), - label: 'Search', - ), - ], - currentIndex: homeStore.selectedIndex, - onTap: homeStore.handleTap, - ); - }, + const BottomNavigationBarItem( + icon: Icon(Icons.arrow_upward), + label: 'Top', + ), + const BottomNavigationBarItem( + icon: Icon(Icons.search), + label: 'Search', + ), + ], + currentIndex: homeStore.selectedIndex, + onTap: homeStore.handleTap, + ), ), ); }