import 'package:cdb_ui/api.dart'; import 'package:cdb_ui/pages/flow.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 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 createState() => _MyHomePageState(); } class _MyHomePageState extends State { int pageIndex = 0; List 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], ); } }