Skip to content

Commit

Permalink
Listen to broadcast providers to a lower level in the widget tree and
Browse files Browse the repository at this point in the history
disable action buttons until loading is complete
  • Loading branch information
julien4215 committed Dec 28, 2024
1 parent 4efc7d0 commit ae38426
Show file tree
Hide file tree
Showing 2 changed files with 218 additions and 195 deletions.
40 changes: 25 additions & 15 deletions lib/src/view/analysis/analysis_layout.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ enum AnalysisTab {

/// Indicator for the analysis tab, typically shown in the app bar.
class AppBarAnalysisTabIndicator extends StatefulWidget {
const AppBarAnalysisTabIndicator({required this.tabs, required this.controller, super.key});
const AppBarAnalysisTabIndicator({
required this.tabs,
required this.controller,
this.enable = true,
super.key,
});

final TabController controller;

Expand All @@ -49,6 +54,8 @@ class AppBarAnalysisTabIndicator extends StatefulWidget {
/// and the length of the [AnalysisLayout.children] list.
final List<AnalysisTab> tabs;

final bool enable;

@override
State<AppBarAnalysisTabIndicator> createState() => _AppBarAnalysisTabIndicatorState();
}
Expand Down Expand Up @@ -87,21 +94,24 @@ class _AppBarAnalysisTabIndicatorState extends State<AppBarAnalysisTabIndicator>
return AppBarIconButton(
icon: Icon(widget.tabs[widget.controller.index].icon),
semanticsLabel: widget.tabs[widget.controller.index].l10n(context.l10n),
onPressed: () {
showAdaptiveActionSheet<void>(
context: context,
actions:
widget.tabs.map((tab) {
return BottomSheetAction(
leading: Icon(tab.icon),
makeLabel: (context) => Text(tab.l10n(context.l10n)),
onPressed: (_) {
widget.controller.animateTo(widget.tabs.indexOf(tab));
},
onPressed:
(widget.enable)
? () {
showAdaptiveActionSheet<void>(
context: context,
actions:
widget.tabs.map((tab) {
return BottomSheetAction(
leading: Icon(tab.icon),
makeLabel: (context) => Text(tab.l10n(context.l10n)),
onPressed: (_) {
widget.controller.animateTo(widget.tabs.indexOf(tab));
},
);
}).toList(),
);
}).toList(),
);
},
}
: null,
);
}
}
Expand Down
Loading

0 comments on commit ae38426

Please sign in to comment.