Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions mobile/lib/pages/common/tab_shell.page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,23 @@ class TabShellPage extends ConsumerStatefulWidget {
}

class _TabShellPageState extends ConsumerState<TabShellPage> {
bool _isMultiSelectEnabled = false;
StreamSubscription? _eventSubscription;

@override
void initState() {
super.initState();
_eventSubscription = EventStream.shared.listen<MultiSelectToggleEvent>(
(event) => setState(() => _isMultiSelectEnabled = event.isEnabled),
);
}

@override
void dispose() {
unawaited(_eventSubscription?.cancel());
super.dispose();
}

@override
Widget build(BuildContext context) {
final isScreenLandscape = context.orientation == Orientation.landscape;
Expand Down Expand Up @@ -84,8 +101,15 @@ class _TabShellPageState extends ConsumerState<TabShellPage> {
builder: (context, child) {
final tabsRouter = AutoTabsRouter.of(context);
return PopScope(
canPop: tabsRouter.activeIndex == 0,
onPopInvokedWithResult: (didPop, _) => !didPop ? tabsRouter.setActiveIndex(0) : null,
canPop: tabsRouter.activeIndex == 0 && !_isMultiSelectEnabled,
onPopInvokedWithResult: (didPop, _) {
// When a multi-select is active, step aside and let the timeline's own PopScope
// reset the selection instead of switching back to the photos tab.
if (didPop || _isMultiSelectEnabled) {
return;
}
tabsRouter.setActiveIndex(0);
},
Comment thread
YarosMallorca marked this conversation as resolved.
Outdated
child: Scaffold(
resizeToAvoidBottomInset: false,
body: isScreenLandscape
Expand Down
Loading