diff --git a/lib/screens/home/home.dart b/lib/screens/home/home.dart index 71c9ab3f..6dac8f92 100644 --- a/lib/screens/home/home.dart +++ b/lib/screens/home/home.dart @@ -32,67 +32,70 @@ class Home extends StatelessWidget { Widget build(BuildContext context) { final authStore = context.read(); - return Scaffold( - appBar: AppBar( - centerTitle: false, - title: Observer( - builder: (_) { - final titles = [ - if (authStore.isLoggedIn) 'Followed Streams', - 'Top', - 'Search', - ]; + return GestureDetector( + onTap: () => FocusManager.instance.primaryFocus?.unfocus(), + child: Scaffold( + appBar: AppBar( + centerTitle: false, + title: Observer( + builder: (_) { + final titles = [ + if (authStore.isLoggedIn) 'Followed Streams', + 'Top', + 'Search', + ]; - return Text(titles[homeStore.selectedIndex]); - }, + return Text(titles[homeStore.selectedIndex]); + }, + ), + actions: [ + IconButton( + tooltip: 'Settings', + icon: const Icon(Icons.settings), + onPressed: () => Navigator.push( + context, + MaterialPageRoute( + builder: (context) => Settings(settingsStore: context.read()), + ), + ), + ) + ], ), - actions: [ - IconButton( - tooltip: 'Settings', - icon: const Icon(Icons.settings), - onPressed: () => Navigator.push( - context, - MaterialPageRoute( - builder: (context) => Settings(settingsStore: context.read()), - ), + body: SafeArea( + child: Observer( + builder: (_) => IndexedStack( + index: homeStore.selectedIndex, + children: [ + if (authStore.isLoggedIn) StreamsList(store: followedStreamsStore!), + TopSection( + topSectionStore: topSectionStore, + categoriesSectionStore: categoriesSectionStore, + ), + Search(searchStore: searchStore), + ], ), - ) - ], - ), - body: SafeArea( - child: Observer( - builder: (_) => IndexedStack( - index: homeStore.selectedIndex, - children: [ - if (authStore.isLoggedIn) StreamsList(store: followedStreamsStore!), - TopSection( - topSectionStore: topSectionStore, - categoriesSectionStore: categoriesSectionStore, - ), - Search(searchStore: searchStore), - ], ), ), - ), - bottomNavigationBar: Observer( - builder: (_) => BottomNavigationBar( - items: [ - if (authStore.isLoggedIn) + bottomNavigationBar: Observer( + builder: (_) => BottomNavigationBar( + items: [ + if (authStore.isLoggedIn) + const BottomNavigationBarItem( + icon: Icon(Icons.favorite), + label: 'Followed', + ), const BottomNavigationBarItem( - icon: Icon(Icons.favorite), - label: 'Followed', + icon: Icon(Icons.arrow_upward), + label: 'Top', ), - const BottomNavigationBarItem( - icon: Icon(Icons.arrow_upward), - label: 'Top', - ), - const BottomNavigationBarItem( - icon: Icon(Icons.search), - label: 'Search', - ), - ], - currentIndex: homeStore.selectedIndex, - onTap: homeStore.handleTap, + const BottomNavigationBarItem( + icon: Icon(Icons.search), + label: 'Search', + ), + ], + currentIndex: homeStore.selectedIndex, + onTap: homeStore.handleTap, + ), ), ), ); diff --git a/lib/screens/home/search/search.dart b/lib/screens/home/search/search.dart index 077e0061..e4fbed28 100644 --- a/lib/screens/home/search/search.dart +++ b/lib/screens/home/search/search.dart @@ -52,73 +52,70 @@ class _SearchState extends State { ), ), Expanded( - child: GestureDetector( - onTap: FocusManager.instance.primaryFocus?.unfocus, - child: Observer( - builder: (context) { - if (textEditingController.text.isEmpty || searchStore.channelFuture == null || searchStore.categoryFuture == null) { - return Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - if (searchStore.searchHistory.isNotEmpty) - const Padding( - padding: EdgeInsets.all(15.0), - child: Text( - 'HISTORY', - style: TextStyle(fontWeight: FontWeight.bold), - ), + child: Observer( + builder: (context) { + if (textEditingController.text.isEmpty || searchStore.channelFuture == null || searchStore.categoryFuture == null) { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + if (searchStore.searchHistory.isNotEmpty) + const Padding( + padding: EdgeInsets.all(15.0), + child: Text( + 'HISTORY', + style: TextStyle(fontWeight: FontWeight.bold), ), - Expanded( - child: ListView( - children: searchStore.searchHistory - .mapIndexed( - (index, searchTerm) => ListTile( - leading: const Icon(Icons.history), - title: Text(searchTerm), - trailing: IconButton( - tooltip: 'Remove', - icon: const Icon(Icons.cancel), - onPressed: () => setState(() { - searchStore.searchHistory.removeAt(index); - }), - ), - onTap: () { - setState(() { - textEditingController.text = searchTerm; - searchStore.handleQuery(searchTerm); - }); - }, + ), + Expanded( + child: ListView( + children: searchStore.searchHistory + .mapIndexed( + (index, searchTerm) => ListTile( + leading: const Icon(Icons.history), + title: Text(searchTerm), + trailing: IconButton( + tooltip: 'Remove', + icon: const Icon(Icons.cancel), + onPressed: () => setState(() { + searchStore.searchHistory.removeAt(index); + }), ), - ) - .toList(), - ), - ), - ], - ); - } - return CustomScrollView( - slivers: [ - const SliverToBoxAdapter( - child: SectionHeader( - 'Channels', - padding: headerPadding, + onTap: () { + setState(() { + textEditingController.text = searchTerm; + searchStore.handleQuery(searchTerm); + }); + }, + ), + ) + .toList(), ), ), - SearchResultsChannels( - searchStore: searchStore, - query: textEditingController.text, - ), - const SliverToBoxAdapter( - child: SectionHeader( - 'Categories', - padding: headerPadding, - ), - ), - SearchResultsCategories(searchStore: searchStore), ], ); - }, - ), + } + return CustomScrollView( + slivers: [ + const SliverToBoxAdapter( + child: SectionHeader( + 'Channels', + padding: headerPadding, + ), + ), + SearchResultsChannels( + searchStore: searchStore, + query: textEditingController.text, + ), + const SliverToBoxAdapter( + child: SectionHeader( + 'Categories', + padding: headerPadding, + ), + ), + SearchResultsCategories(searchStore: searchStore), + ], + ); + }, ), ), ],