Skip to content

Commit

Permalink
Disable Watch tab when offline
Browse files Browse the repository at this point in the history
  • Loading branch information
jas14 committed Sep 15, 2024
1 parent 3326e08 commit ecfb126
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/src/navigation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ enum BottomTab {
return Icons.settings;
}
}

bool enabled({required bool isOnline}) {
return this == BottomTab.watch && isOnline;
}
}

final currentBottomTabProvider =
Expand Down Expand Up @@ -151,6 +155,7 @@ class BottomNavScaffold extends ConsumerWidget {
NavigationDestination(
icon: Icon(tab == currentTab ? tab.activeIcon : tab.icon),
label: tab.label(context.l10n),
enabled: tab.enabled(isOnline: isOnline),
),
],
onDestinationSelected: (i) =>
Expand All @@ -161,8 +166,8 @@ class BottomNavScaffold extends ConsumerWidget {
);
case TargetPlatform.iOS:
final isOnline =
ref.watch(connectivityChangesProvider).valueOrNull?.isOnline ??
true;
ref.watch(connectivityChangesProvider).valueOrNull?.isOnline ??
true;
return CupertinoTabScaffold(
tabBuilder: _iOSTabBuilder,
controller: _cupertinoTabController,
Expand Down

0 comments on commit ecfb126

Please sign in to comment.