44 lines
1.0 KiB
Dart
44 lines
1.0 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'devices_screen.dart';
|
|
import 'timbang_screen.dart';
|
|
|
|
/// Root scaffold with bottom nav: Devices and Timbang (scale display).
|
|
class MainShell extends StatefulWidget {
|
|
const MainShell({super.key});
|
|
|
|
@override
|
|
State<MainShell> createState() => _MainShellState();
|
|
}
|
|
|
|
class _MainShellState extends State<MainShell> {
|
|
int _index = 0;
|
|
|
|
static const _tabs = [
|
|
(label: 'Devices', icon: Icons.list_alt),
|
|
(label: 'Timbang', icon: Icons.monitor_weight),
|
|
];
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
body: IndexedStack(
|
|
index: _index,
|
|
children: const [
|
|
DevicesScreen(),
|
|
TimbangScreen(),
|
|
],
|
|
),
|
|
bottomNavigationBar: BottomNavigationBar(
|
|
currentIndex: _index,
|
|
onTap: (i) => setState(() => _index = i),
|
|
items: _tabs
|
|
.map((t) => BottomNavigationBarItem(
|
|
icon: Icon(t.icon),
|
|
label: t.label,
|
|
))
|
|
.toList(),
|
|
),
|
|
);
|
|
}
|
|
}
|