import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:smoke_cess_app/pages/pages_service.dart'; import 'package:smoke_cess_app/providers/settings_provider.dart'; import 'package:smoke_cess_app/widgets/missing_config_popup.dart'; class MyHomePage extends StatefulWidget { const MyHomePage({super.key}); @override MyHomePageState createState() => MyHomePageState(); } class MyHomePageState extends State { int _selectedIndex = 4; bool _isConfigured = false; void _onItemTapped(int index) { setState(() { _isConfigured ? _selectedIndex = index : showDialog( context: context, builder: (BuildContext context) { return const MissingConfigPopup( title: 'Fehlende Konfiguration', text: 'Bitte QR Code Scannen!', ); }); }); } @override Widget build(BuildContext context) { var settingsModel = context.watch(); var group = settingsModel.settings?.group; _isConfigured = settingsModel.initialized; return Scaffold( appBar: AppBar( title: Text( '${pages.keys.elementAt(_selectedIndex)} ${_isConfigured ? "Gruppe $group" : ""}')), body: Center( child: SingleChildScrollView( child: pages.values.elementAt(_selectedIndex)['page'])), bottomNavigationBar: NavigationBar( onDestinationSelected: _onItemTapped, selectedIndex: _selectedIndex, destinations: pages.keys.map((key) { return NavigationDestination( icon: pages[key]!['icon'] ?? const Icon(Icons.disabled_by_default), label: key); }).toList()), ); } }