Skip to content

Commit

Permalink
SNRGY-3221 fix wrong index length of nav bar when items are disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
zsco committed May 7, 2024
1 parent 64083ef commit bb67783
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
17 changes: 15 additions & 2 deletions lib/widgets/tabs/device_tabs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import 'package:mobile_app/widgets/tabs/shared/search_delegate.dart';
import 'package:sidebarx/sidebarx.dart';

import '../../services/settings.dart';
import '../shared/toast.dart';

class DeviceTabs extends StatefulWidget {
const DeviceTabs({super.key});
Expand Down Expand Up @@ -332,20 +333,32 @@ class DeviceTabsState extends State<DeviceTabs> with RestorationMixin {

navItems.forEach((navItem) {
if (navItem.disabled) {
sidebarItems.add(SidebarXItem(
icon: Icons.disabled_by_default,
label: navItem.name,
selectable: false,
onTap: () {
setState(() {
Navigator.pop(context);
Toast.showToastNoContext("Currently unavailable");
});
})
);
return;
}
sidebarItems.add(SidebarXItem(
icon: navItem.icon,
label: navItem.name,
selectable: false,
selectable: true,
onTap: () {
setState(() {
_sidebarController.selectIndex(navItem.index);
_navigationIndex = navItem.index;
switchScreen(_navigationIndex, true);
Navigator.pop(context);
});
}));
})
);
});

var textColor = MyTheme.textColor;
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 0.0.315+315
version: 0.0.316+316


environment:
Expand Down

0 comments on commit bb67783

Please sign in to comment.