diff --git a/lib/pages/home_view/home_view.dart b/lib/pages/home_view/home_view.dart index 9b6f6eddb..7619a5d34 100644 --- a/lib/pages/home_view/home_view.dart +++ b/lib/pages/home_view/home_view.dart @@ -17,6 +17,7 @@ import 'package:flutter_svg/svg.dart'; import '../../app_config.dart'; import '../../providers/global/notifications_provider.dart'; +import '../../providers/global/prefs_provider.dart'; import '../../providers/ui/home_view_index_provider.dart'; import '../../providers/ui/unread_notifications_provider.dart'; import '../../services/event_bus/events/global/tor_connection_status_changed_event.dart'; @@ -172,6 +173,20 @@ class _HomeViewState extends ConsumerState { @override Widget build(BuildContext context) { debugPrint("BUILD: $runtimeType"); + + // dirty hack + ref.listen( + prefsChangeNotifierProvider.select((value) => value.enableExchange), + (prev, next) { + if (next == false && + mounted && + ref.read(homeViewPageIndexStateProvider) != 0) { + WidgetsBinding.instance.addPostFrameCallback( + (_) => ref.read(homeViewPageIndexStateProvider.state).state = 0, + ); + } + }); + return WillPopScope( onWillPop: _onWillPop, child: Background( @@ -345,7 +360,8 @@ class _HomeViewState extends ConsumerState { ), body: Column( children: [ - if (_children.length > 1) + if (_children.length > 1 && + ref.watch(prefsChangeNotifierProvider).enableExchange) Container( decoration: BoxDecoration( color: Theme.of(context) diff --git a/lib/pages/home_view/sub_widgets/home_view_button_bar.dart b/lib/pages/home_view/sub_widgets/home_view_button_bar.dart index 4fab857eb..9741603ac 100644 --- a/lib/pages/home_view/sub_widgets/home_view_button_bar.dart +++ b/lib/pages/home_view/sub_widgets/home_view_button_bar.dart @@ -44,10 +44,6 @@ class _HomeViewButtonBarState extends ConsumerState { @override Widget build(BuildContext context) { - final prefs = ref.watch(prefsChangeNotifierProvider); - - final showExchange = prefs.enableExchange; - final selectedIndex = ref.watch(homeViewPageIndexStateProvider.state).state; return Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, @@ -90,11 +86,11 @@ class _HomeViewButtonBarState extends ConsumerState { ), ), ), - if (AppConfig.hasFeature(AppFeature.swap) && showExchange) + if (AppConfig.hasFeature(AppFeature.swap)) const SizedBox( width: 8, ), - if (AppConfig.hasFeature(AppFeature.swap) && showExchange) + if (AppConfig.hasFeature(AppFeature.swap)) Expanded( child: TextButton( style: selectedIndex == 1 @@ -141,11 +137,11 @@ class _HomeViewButtonBarState extends ConsumerState { ), ), ), - if (AppConfig.hasFeature(AppFeature.buy) && showExchange) + if (AppConfig.hasFeature(AppFeature.buy)) const SizedBox( width: 8, ), - if (AppConfig.hasFeature(AppFeature.buy) && showExchange) + if (AppConfig.hasFeature(AppFeature.buy)) Expanded( child: TextButton( style: selectedIndex == 2