Skip to content

Commit

Permalink
fix(flutter_deck): update slide number on route change
Browse files Browse the repository at this point in the history
  • Loading branch information
mkobuolys committed Apr 8, 2024
1 parent 54a92bc commit c2683e6
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions packages/flutter_deck/lib/src/controls/flutter_deck_controls.dart
Original file line number Diff line number Diff line change
Expand Up @@ -170,31 +170,35 @@ class _SlideNumberButton extends StatelessWidget {

final flutterDeck = context.flutterDeck;
final controlsNotifier = flutterDeck.controlsNotifier;
final router = flutterDeck.router;
final shortcuts = flutterDeck.globalConfiguration.controls.shortcuts;
final shortcut = LocalizedShortcutLabeler.instance.getShortcutLabel(
shortcuts.toggleNavigationDrawer,
MaterialLocalizations.of(context),
);

return ListenableBuilder(
listenable: controlsNotifier,
builder: (context, child) {
final enabled =
!controlsNotifier.intentDisabled(const ToggleDrawerIntent());

return IconButton(
icon: Text(
'${flutterDeck.slideNumber}',
style: TextStyle(
color: enabled ? theme.iconTheme.color : theme.disabledColor,
fontWeight: FontWeight.bold,
listenable: router,
builder: (context, child) => ListenableBuilder(
listenable: controlsNotifier,
builder: (context, child) {
final enabled =
!controlsNotifier.intentDisabled(const ToggleDrawerIntent());

return IconButton(
icon: Text(
'${flutterDeck.slideNumber}',
style: TextStyle(
color: enabled ? theme.iconTheme.color : theme.disabledColor,
fontWeight: FontWeight.bold,
),
),
),
tooltip: 'Open navigation drawer'
'${shortcuts.enabled ? ' ($shortcut)' : ''}',
onPressed: enabled ? controlsNotifier.toggleDrawer : null,
);
},
tooltip: 'Open navigation drawer'
'${shortcuts.enabled ? ' ($shortcut)' : ''}',
onPressed: enabled ? controlsNotifier.toggleDrawer : null,
);
},
),
);
}
}
Expand Down

0 comments on commit c2683e6

Please sign in to comment.