101 lines
3.4 KiB
Dart
101 lines
3.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_adaptive_scaffold/flutter_adaptive_scaffold.dart';
|
|
import 'package:go_router/go_router.dart';
|
|
|
|
import '../routing/routes.dart';
|
|
import 'scaffold_with_statusbar.dart';
|
|
|
|
/// The Scaffold that is used for the home screen.
|
|
class HomeScaffold extends StatelessWidget {
|
|
const HomeScaffold({
|
|
required this.selectedTab,
|
|
required this.child,
|
|
this.appBar,
|
|
super.key,
|
|
});
|
|
|
|
/// Which tab of the scaffold to display.
|
|
final RoutesHome selectedTab;
|
|
|
|
/// The scaffold body.
|
|
final Widget child;
|
|
|
|
/// The scaffold AppBar.
|
|
final AppBar? appBar;
|
|
|
|
@override
|
|
Widget build(BuildContext context) => ScaffoldWithStatusbar(
|
|
body: AdaptiveScaffold(
|
|
appBar: appBar,
|
|
smallBreakpoint: const WidthPlatformBreakpoint(end: 700),
|
|
mediumBreakpoint:
|
|
const WidthPlatformBreakpoint(begin: 700, end: 1400),
|
|
largeBreakpoint: const WidthPlatformBreakpoint(begin: 1400),
|
|
body: (_) => child,
|
|
selectedIndex: selectedTab.index,
|
|
destinations: const <NavigationDestination>[
|
|
NavigationDestination(
|
|
label: 'Home',
|
|
icon: Icon(Icons.home_outlined),
|
|
selectedIcon: Icon(Icons.home),
|
|
),
|
|
NavigationDestination(
|
|
label: 'Material Demo',
|
|
icon: Icon(Icons.widgets_outlined),
|
|
selectedIcon: Icon(Icons.widgets),
|
|
),
|
|
NavigationDestination(
|
|
label: 'Benchmark',
|
|
icon: Icon(Icons.fireplace_outlined),
|
|
selectedIcon: Icon(Icons.fireplace),
|
|
),
|
|
NavigationDestination(
|
|
label: 'News',
|
|
icon: Icon(Icons.newspaper_outlined),
|
|
selectedIcon: Icon(Icons.newspaper),
|
|
),
|
|
NavigationDestination(
|
|
label: 'Led',
|
|
icon: Icon(Icons.fluorescent_outlined),
|
|
selectedIcon: Icon(Icons.fluorescent),
|
|
),
|
|
NavigationDestination(
|
|
label: 'Matrix',
|
|
icon: Icon(Icons.grid_off),
|
|
selectedIcon: Icon(Icons.grid_on),
|
|
),
|
|
NavigationDestination(
|
|
label: 'System',
|
|
icon: Icon(Icons.insert_chart_outlined_outlined),
|
|
selectedIcon: Icon(Icons.insert_chart),
|
|
),
|
|
NavigationDestination(
|
|
label: 'Settings',
|
|
icon: Icon(Icons.settings_outlined),
|
|
selectedIcon: Icon(Icons.settings),
|
|
),
|
|
],
|
|
onSelectedIndexChange: (int idx) {
|
|
switch (RoutesHome.values[idx]) {
|
|
case RoutesHome.home:
|
|
context.goNamed(RoutesHome.home.name);
|
|
case RoutesHome.materialDemo:
|
|
context.goNamed(RoutesHome.materialDemo.name);
|
|
case RoutesHome.news:
|
|
context.goNamed(RoutesHome.news.name);
|
|
case RoutesHome.benchmark:
|
|
context.goNamed(RoutesHome.benchmark.name);
|
|
case RoutesHome.led:
|
|
context.goNamed(RoutesHome.led.name);
|
|
case RoutesHome.matrix:
|
|
context.goNamed(RoutesHome.matrix.name);
|
|
case RoutesHome.system:
|
|
context.goNamed(RoutesHome.system.name);
|
|
case RoutesHome.settings:
|
|
context.goNamed(RoutesHome.settings.name);
|
|
}
|
|
},
|
|
),
|
|
);
|
|
}
|