cdb_ui/lib/main.dart
2024-09-24 18:00:13 +02:00

72 lines
1.9 KiB
Dart

import 'package:cdb_ui/api.dart';
import 'package:cdb_ui/pages/flow/flows_page.dart';
import 'package:cdb_ui/pages/items.dart';
import 'package:cdb_ui/pages/locations.dart';
import 'package:cdb_ui/pages/setup.dart';
import 'package:cdb_ui/pages/stats.dart';
import 'package:flutter/material.dart';
Future<void> main() async {
await API().init();
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'CDB',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(
seedColor: Colors.deepPurple, brightness: Brightness.dark),
useMaterial3: true,
),
home: API().isInit() ? const MyHomePage() : const SetupPage(),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key});
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int pageIndex = 0;
List<Widget> pages = [
const StatsPage(),
const ItemsPage(),
const FlowsPage(),
const LocationsPage()
];
@override
Widget build(BuildContext context) {
return Scaffold(
bottomNavigationBar: BottomNavigationBar(
fixedColor: Colors.white,
unselectedItemColor: Colors.white70,
items: const [
BottomNavigationBarItem(icon: Icon(Icons.home), label: "Home"),
BottomNavigationBarItem(
icon: Icon(Icons.data_object), label: "Items"),
BottomNavigationBarItem(icon: Icon(Icons.receipt), label: "Flows"),
BottomNavigationBarItem(
icon: Icon(Icons.location_city), label: "Locations"),
],
currentIndex: pageIndex,
onTap: (value) {
setState(() {
pageIndex = value;
});
},
),
body: pages[pageIndex],
);
}
}