Skip to content

Commit c36bb0f

Browse files
committed
chore: refactor bnb labels hiding
- when showing only selected, the width is the same so the overflow also occurs...
1 parent 06c3eef commit c36bb0f

2 files changed

Lines changed: 9 additions & 14 deletions

File tree

lib/helpers/bottom_navigation_bar.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ class _MainBottomNavigationBarState extends State<MainBottomNavigationBar> {
100100
if (_selectedIndex == 0) {
101101
actions = UIProvider().getNewsAppBarActions(context);
102102
}
103+
bool disableBottomNavigationBarLabels = Hive.box('settings')
104+
.get('disableBottomNavigationBarLabels', defaultValue: false) as bool;
103105

104106
return Scaffold(
105107
appBar: AppBar(
@@ -120,6 +122,9 @@ class _MainBottomNavigationBarState extends State<MainBottomNavigationBar> {
120122
elevation: 10.0,
121123
destinations: UIProvider().getBottomNavigationBarButtons(context),
122124
onDestinationSelected: _onItemTapped,
125+
labelBehavior: disableBottomNavigationBarLabels
126+
? NavigationDestinationLabelBehavior.alwaysHide
127+
: NavigationDestinationLabelBehavior.alwaysShow,
123128
),
124129
body: screens.elementAt(_selectedIndex),
125130
);

lib/providers/general/ui.dart

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,6 @@ class UIProvider {
212212
) {
213213
String championship = Hive.box('settings')
214214
.get('championship', defaultValue: 'Formula 1') as String;
215-
bool disableBottomNavigationBarLabels = Hive.box('settings')
216-
.get('disableBottomNavigationBarLabels', defaultValue: false) as bool;
217215
if (championship == 'Formula 1' || championship == 'Formula E') {
218216
return [
219217
NavigationDestination(
@@ -223,9 +221,7 @@ class UIProvider {
223221
selectedIcon: const Icon(
224222
Icons.feed,
225223
),
226-
label: !disableBottomNavigationBarLabels
227-
? AppLocalizations.of(context)!.news
228-
: "",
224+
label: AppLocalizations.of(context)!.news,
229225
),
230226
NavigationDestination(
231227
icon: const Icon(
@@ -234,9 +230,7 @@ class UIProvider {
234230
selectedIcon: const Icon(
235231
Icons.play_circle,
236232
),
237-
label: !disableBottomNavigationBarLabels
238-
? AppLocalizations.of(context)!.videos
239-
: "",
233+
label: AppLocalizations.of(context)!.videos,
240234
),
241235
NavigationDestination(
242236
icon: const Icon(
@@ -245,9 +239,7 @@ class UIProvider {
245239
selectedIcon: const Icon(
246240
Icons.emoji_events,
247241
),
248-
label: !disableBottomNavigationBarLabels
249-
? AppLocalizations.of(context)!.standings
250-
: "",
242+
label: AppLocalizations.of(context)!.standings,
251243
),
252244
NavigationDestination(
253245
icon: const Icon(
@@ -256,9 +248,7 @@ class UIProvider {
256248
selectedIcon: const Icon(
257249
Icons.calendar_today,
258250
),
259-
label: !disableBottomNavigationBarLabels
260-
? AppLocalizations.of(context)!.schedule
261-
: "",
251+
label: AppLocalizations.of(context)!.schedule,
262252
),
263253
];
264254
} else if (championship == 'Formula 2' ||

0 commit comments

Comments
 (0)