feat(nav): move mobile settings to home menu
This commit is contained in:
@@ -66,6 +66,7 @@ import '../services/system_shelf_service.dart';
|
||||
import 'auth_screen.dart';
|
||||
import 'libraries/content_state_builder.dart';
|
||||
import 'main_screen.dart';
|
||||
import 'settings/settings_screen.dart';
|
||||
import '../watch_together/watch_together.dart';
|
||||
import '../providers/companion_remote_provider.dart';
|
||||
import '../widgets/companion_remote/remote_session_dialog.dart';
|
||||
@@ -1101,6 +1102,16 @@ class _DiscoverScreenState extends State<DiscoverScreen>
|
||||
Navigator.push(context, MaterialPageRoute(builder: (context) => const ProfileSwitchScreen()));
|
||||
}
|
||||
|
||||
void _handleOpenSettings(BuildContext context) {
|
||||
final mainScope = MainScreenFocusScope.of(context, listen: false);
|
||||
if (mainScope != null) {
|
||||
mainScope.openSettings?.call();
|
||||
return;
|
||||
}
|
||||
|
||||
Navigator.push(context, MaterialPageRoute(builder: (_) => const SettingsScreen()));
|
||||
}
|
||||
|
||||
/// Build the [FocusableAction] wrapping the user menu.
|
||||
/// Pulls live state from [ActiveProfileProvider]; the menu reuses
|
||||
/// [_userMenuItems] for the menu contents so d-pad and tap paths
|
||||
@@ -1146,6 +1157,7 @@ class _DiscoverScreenState extends State<DiscoverScreen>
|
||||
),
|
||||
if (switchable.isNotEmpty) const AppMenuDivider(),
|
||||
AppMenuItem<String>(value: 'manage_profiles', icon: Symbols.group_rounded, label: t.profiles.sectionTitle),
|
||||
AppMenuItem<String>(value: 'settings', icon: Symbols.settings_rounded, label: t.common.settings),
|
||||
AppMenuItem<String>(value: 'logout', icon: Symbols.logout_rounded, label: t.common.logout),
|
||||
];
|
||||
}
|
||||
@@ -1160,6 +1172,10 @@ class _DiscoverScreenState extends State<DiscoverScreen>
|
||||
_handleSwitchProfile(context);
|
||||
return;
|
||||
}
|
||||
if (value == 'settings') {
|
||||
_handleOpenSettings(context);
|
||||
return;
|
||||
}
|
||||
if (value.startsWith('profile:')) {
|
||||
final id = value.substring('profile:'.length);
|
||||
final active = context.read<ActiveProfileProvider>();
|
||||
|
||||
@@ -69,6 +69,7 @@ class MainScreenFocusScope extends InheritedWidget {
|
||||
final double? foregroundWidth;
|
||||
final double? viewportWidth;
|
||||
final void Function(String libraryGlobalKey)? selectLibrary;
|
||||
final VoidCallback? openSettings;
|
||||
|
||||
const MainScreenFocusScope({
|
||||
super.key,
|
||||
@@ -81,6 +82,7 @@ class MainScreenFocusScope extends InheritedWidget {
|
||||
this.foregroundWidth,
|
||||
this.viewportWidth,
|
||||
this.selectLibrary,
|
||||
this.openSettings,
|
||||
required super.child,
|
||||
});
|
||||
|
||||
@@ -1405,6 +1407,16 @@ class _MainScreenState extends State<MainScreen>
|
||||
}
|
||||
}
|
||||
|
||||
void _openSettings() {
|
||||
if (PlatformDetector.shouldUseSideNavigation(context)) {
|
||||
_selectTab(NavigationTabId.settings);
|
||||
_focusContent(restorePreviousFocus: false);
|
||||
return;
|
||||
}
|
||||
|
||||
Navigator.push(context, MaterialPageRoute(builder: (_) => const SettingsScreen()));
|
||||
}
|
||||
|
||||
void _handleLibrariesScreenSelected(String libraryGlobalKey) {
|
||||
if (_selectedLibraryGlobalKey == libraryGlobalKey) return;
|
||||
setState(() => _selectedLibraryGlobalKey = libraryGlobalKey);
|
||||
@@ -1472,6 +1484,12 @@ class _MainScreenState extends State<MainScreen>
|
||||
return NavigationTab.getVisibleTabs(isOffline: isOffline, hasLiveTv: _hasLiveTv);
|
||||
}
|
||||
|
||||
List<NavigationTab> _getBottomNavigationTabs(BuildContext context) {
|
||||
final tabs = _getVisibleTabs(_isOffline);
|
||||
if (!PlatformDetector.isMobile(context)) return tabs;
|
||||
return tabs.where((tab) => tab.id != NavigationTabId.settings).toList();
|
||||
}
|
||||
|
||||
/// Get the GlobalKey for a given tab.
|
||||
GlobalKey? _screenKeyFor(NavigationTabId tab) {
|
||||
return switch (tab) {
|
||||
@@ -1485,9 +1503,10 @@ class _MainScreenState extends State<MainScreen>
|
||||
}
|
||||
|
||||
Widget _buildBottomNavigationBar(BuildContext context, {required bool hideLabels}) {
|
||||
final tabs = _getVisibleTabs(_isOffline);
|
||||
final tabs = _getBottomNavigationTabs(context);
|
||||
final selectedIndex = tabs.indexWhere((tab) => tab.id == _currentTab);
|
||||
final navigationBar = NavigationBar(
|
||||
selectedIndex: _currentIndex,
|
||||
selectedIndex: selectedIndex >= 0 ? selectedIndex : 0,
|
||||
onDestinationSelected: (i) {
|
||||
if (i >= 0 && i < tabs.length) _selectTab(tabs[i].id);
|
||||
},
|
||||
@@ -1592,6 +1611,7 @@ class _MainScreenState extends State<MainScreen>
|
||||
foregroundWidth: contentLayout.width,
|
||||
viewportWidth: viewportWidth,
|
||||
selectLibrary: _selectLibrary,
|
||||
openSettings: _openSettings,
|
||||
child: SideNavigationScope(
|
||||
child: Stack(
|
||||
clipBehavior: Clip.hardEdge,
|
||||
|
||||
Reference in New Issue
Block a user