import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:hydrated_bloc/hydrated_bloc.dart'; import 'package:ot_viewer_app/global_location_store.dart'; import 'package:ot_viewer_app/refresh_cubit.dart'; import 'package:ot_viewer_app/settings_page.dart'; import 'package:path_provider/path_provider.dart'; import 'map_page.dart'; import 'package:get_it/get_it.dart'; import 'owntracks_api.dart'; Future main() async { WidgetsFlutterBinding.ensureInitialized(); HydratedBloc.storage = await HydratedStorage.build( storageDirectory: kIsWeb ? HydratedStorage.webStorageDirectory : await getApplicationDocumentsDirectory(), ); GetIt.I .registerSingleton(GlobalLocationStoreCubit()); GetIt.I.registerSingleton(RefreshCubit()); runApp( MultiBlocProvider( providers: [ BlocProvider( lazy: false, create: (BuildContext context) => SettingsCubit(), ), BlocProvider( create: (BuildContext context) => GetIt.I.get(), ), ], child: MyApp(), ), ); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: 'OwnTracks Data Viewer', theme: ThemeData.dark(), home: Scaffold( appBar: AppBar( title: const Text('OwnTrakcs Data Viewer'), actions: [ IconButton( icon: const Icon(Icons.refresh), onPressed: () async { context.read().triggerRefresh(); }, ), ], ), body: const MainPage(), ), ); } } class MainPage extends StatefulWidget { const MainPage({super.key}); @override createState() => _MainPageState(); } class _MainPageState extends State { int _currentIndex = 0; final List _pages = [ const MapPage(), const SettingsPage(), // Assume this is your settings page widget ]; void _onItemTapped(int index) { setState(() { _currentIndex = index; }); } @override Widget build(BuildContext context) { return Scaffold( body: IndexedStack( index: _currentIndex, children: _pages, ), bottomNavigationBar: BottomNavigationBar( items: const [ BottomNavigationBarItem( icon: Icon(Icons.map), label: 'Map', ), BottomNavigationBarItem( icon: Icon(Icons.settings), label: 'Settings', ), ], currentIndex: _currentIndex, onTap: _onItemTapped, ), ); } }