2024-09-04 18:05:04 +00:00
|
|
|
import 'package:cdb_ui/api.dart';
|
2024-09-19 06:46:48 +00:00
|
|
|
import 'package:cdb_ui/pages/flow.dart';
|
2024-09-20 07:18:06 +00:00
|
|
|
import 'package:cdb_ui/pages/items.dart';
|
|
|
|
import 'package:cdb_ui/pages/locations.dart';
|
2024-09-08 15:45:48 +00:00
|
|
|
import 'package:cdb_ui/pages/setup.dart';
|
2024-09-20 07:18:06 +00:00
|
|
|
import 'package:cdb_ui/pages/stats.dart';
|
2024-09-04 18:05:04 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
2024-09-08 15:45:48 +00:00
|
|
|
Future<void> main() async {
|
|
|
|
await API().init();
|
2024-09-04 18:05:04 +00:00
|
|
|
runApp(const MyApp());
|
|
|
|
}
|
|
|
|
|
|
|
|
class MyApp extends StatelessWidget {
|
|
|
|
const MyApp({super.key});
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return MaterialApp(
|
|
|
|
title: 'CDB',
|
|
|
|
theme: ThemeData(
|
2024-09-07 22:51:18 +00:00
|
|
|
colorScheme: ColorScheme.fromSeed(
|
|
|
|
seedColor: Colors.deepPurple, brightness: Brightness.dark),
|
2024-09-04 18:05:04 +00:00
|
|
|
useMaterial3: true,
|
|
|
|
),
|
2024-09-16 07:42:55 +00:00
|
|
|
home: API().isInit() ? const MyHomePage() : const SetupPage(),
|
2024-09-04 18:05:04 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-09-05 10:03:47 +00:00
|
|
|
class MyHomePage extends StatefulWidget {
|
|
|
|
const MyHomePage({super.key});
|
|
|
|
|
|
|
|
@override
|
|
|
|
State<MyHomePage> createState() => _MyHomePageState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _MyHomePageState extends State<MyHomePage> {
|
|
|
|
int pageIndex = 0;
|
|
|
|
|
2024-09-16 07:42:55 +00:00
|
|
|
List<Widget> pages = [
|
|
|
|
const StatsPage(),
|
|
|
|
const ItemsPage(),
|
|
|
|
const FlowsPage(),
|
|
|
|
const LocationsPage()
|
|
|
|
];
|
2024-09-05 10:03:47 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Scaffold(
|
|
|
|
bottomNavigationBar: BottomNavigationBar(
|
2024-09-15 13:15:46 +00:00
|
|
|
fixedColor: Colors.white,
|
|
|
|
unselectedItemColor: Colors.white70,
|
2024-09-05 10:03:47 +00:00
|
|
|
items: const [
|
|
|
|
BottomNavigationBarItem(icon: Icon(Icons.home), label: "Home"),
|
|
|
|
BottomNavigationBarItem(
|
|
|
|
icon: Icon(Icons.data_object), label: "Items"),
|
2024-09-07 21:56:52 +00:00
|
|
|
BottomNavigationBarItem(icon: Icon(Icons.receipt), label: "Flows"),
|
2024-09-05 10:03:47 +00:00
|
|
|
BottomNavigationBarItem(
|
|
|
|
icon: Icon(Icons.location_city), label: "Locations"),
|
|
|
|
],
|
|
|
|
currentIndex: pageIndex,
|
|
|
|
onTap: (value) {
|
|
|
|
setState(() {
|
|
|
|
pageIndex = value;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
),
|
|
|
|
body: pages[pageIndex],
|
2024-09-04 18:05:04 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|