92 lines
2.8 KiB
Dart
92 lines
2.8 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'package:smoke_cess_app/pages/mood_page.dart';
|
|
import 'package:smoke_cess_app/pages/relapse_page.dart';
|
|
import 'package:smoke_cess_app/pages/scanner_page.dart';
|
|
import 'package:smoke_cess_app/pages/sleep_page.dart';
|
|
import 'package:smoke_cess_app/pages/interval_page.dart';
|
|
import 'package:smoke_cess_app/providers/settings_provider.dart';
|
|
import 'package:smoke_cess_app/services/settings_service.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<MyHomePage> {
|
|
int _selectedIndex = 4;
|
|
bool _isConfigured = false;
|
|
|
|
final List<String> _titles = [
|
|
'Stimmung',
|
|
'Schlaf',
|
|
'Timer',
|
|
'Rückfall',
|
|
'Scanner'
|
|
];
|
|
static const List<Widget> _widgetOptions = <Widget>[
|
|
MoodPage(),
|
|
SleepPage(),
|
|
IntervalTimerPage(),
|
|
RelapsePage(),
|
|
ScannerPage(),
|
|
];
|
|
|
|
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<SettingsProvider>();
|
|
var group = settingsModel.settings?.group;
|
|
_isConfigured = settingsModel.initialized;
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: Text(
|
|
'${_titles[_selectedIndex]} ${_isConfigured ? "Gruppe $group" : ""}')),
|
|
body: _widgetOptions.elementAt(_selectedIndex),
|
|
bottomNavigationBar: NavigationBar(
|
|
onDestinationSelected: _onItemTapped,
|
|
selectedIndex: _selectedIndex,
|
|
destinations: const <Widget>[
|
|
NavigationDestination(
|
|
icon: Icon(Icons.mood_outlined, color: Colors.black),
|
|
label: 'Stimmung'),
|
|
NavigationDestination(
|
|
icon: Icon(Icons.bedtime_outlined, color: Colors.black),
|
|
label: 'Schlaf'),
|
|
NavigationDestination(
|
|
icon: Icon(
|
|
Icons.timer_outlined,
|
|
color: Colors.black,
|
|
),
|
|
label: 'Timer'),
|
|
NavigationDestination(
|
|
icon: Icon(Icons.smoke_free_outlined, color: Colors.black),
|
|
label: 'Rückfall'),
|
|
NavigationDestination(
|
|
icon: Icon(Icons.camera_alt_outlined, color: Colors.black),
|
|
label: 'Settings'),
|
|
],
|
|
|
|
//onTap: _onItemTapped,
|
|
),
|
|
);
|
|
}
|
|
}
|