init
This commit is contained in:
83
lib/app/navigation/home_shell.dart
Normal file
83
lib/app/navigation/home_shell.dart
Normal file
@@ -0,0 +1,83 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../features/peers/pages/peers_page.dart';
|
||||
import '../features/settings/pages/settings_page.dart';
|
||||
import '../features/transfer/pages/transfer_page.dart';
|
||||
|
||||
enum AppTab { peers, transfer, settings }
|
||||
|
||||
class HomeShell extends StatefulWidget {
|
||||
const HomeShell({super.key});
|
||||
|
||||
@override
|
||||
State<HomeShell> createState() => _HomeShellState();
|
||||
}
|
||||
|
||||
class _HomeShellState extends State<HomeShell> {
|
||||
AppTab _current = AppTab.peers;
|
||||
|
||||
void _onSelect(int index) {
|
||||
setState(() {
|
||||
_current = AppTab.values[index];
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final isWide = MediaQuery.sizeOf(context).width >= 920;
|
||||
final pages = const [PeersPage(), TransferPage(), SettingsPage()];
|
||||
|
||||
if (isWide) {
|
||||
return Scaffold(
|
||||
body: Row(
|
||||
children: [
|
||||
NavigationRail(
|
||||
selectedIndex: _current.index,
|
||||
onDestinationSelected: _onSelect,
|
||||
labelType: NavigationRailLabelType.all,
|
||||
minWidth: 84,
|
||||
destinations: const [
|
||||
NavigationRailDestination(
|
||||
icon: Icon(Icons.radar_rounded),
|
||||
label: Text('Peers'),
|
||||
),
|
||||
NavigationRailDestination(
|
||||
icon: Icon(Icons.sync_alt_rounded),
|
||||
label: Text('Transfer'),
|
||||
),
|
||||
NavigationRailDestination(
|
||||
icon: Icon(Icons.tune_rounded),
|
||||
label: Text('Settings'),
|
||||
),
|
||||
],
|
||||
),
|
||||
const VerticalDivider(width: 1),
|
||||
Expanded(child: pages[_current.index]),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
body: pages[_current.index],
|
||||
bottomNavigationBar: NavigationBar(
|
||||
selectedIndex: _current.index,
|
||||
onDestinationSelected: _onSelect,
|
||||
destinations: const [
|
||||
NavigationDestination(
|
||||
icon: Icon(Icons.radar_rounded),
|
||||
label: 'Peers',
|
||||
),
|
||||
NavigationDestination(
|
||||
icon: Icon(Icons.sync_alt_rounded),
|
||||
label: 'Transfer',
|
||||
),
|
||||
NavigationDestination(
|
||||
icon: Icon(Icons.tune_rounded),
|
||||
label: 'Settings',
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user