2023-02-14 14:02:26 +01:00
|
|
|
import 'package:flutter/material.dart';
|
2023-02-27 02:27:42 +01:00
|
|
|
import 'package:provider/provider.dart';
|
2023-02-14 14:02:26 +01:00
|
|
|
import 'package:smoke_cess_app/pages/mood_page.dart';
|
|
|
|
import 'package:smoke_cess_app/pages/relapse_page.dart';
|
2023-02-17 13:47:52 +01:00
|
|
|
import 'package:smoke_cess_app/pages/scanner_page.dart';
|
2023-02-14 14:02:26 +01:00
|
|
|
import 'package:smoke_cess_app/pages/sleep_page.dart';
|
2023-02-20 21:32:28 +01:00
|
|
|
import 'package:smoke_cess_app/pages/interval_page.dart';
|
2023-02-27 02:27:42 +01:00
|
|
|
import 'package:smoke_cess_app/providers/settings_provider.dart';
|
2023-02-26 14:10:06 +01:00
|
|
|
import 'package:smoke_cess_app/services/settings_service.dart';
|
2023-02-17 13:47:52 +01:00
|
|
|
import 'package:smoke_cess_app/widgets/missing_config_popup.dart';
|
2023-02-14 14:02:26 +01:00
|
|
|
|
|
|
|
class MyHomePage extends StatefulWidget {
|
|
|
|
const MyHomePage({super.key});
|
|
|
|
|
|
|
|
@override
|
2023-02-14 14:13:32 +01:00
|
|
|
MyHomePageState createState() => MyHomePageState();
|
2023-02-14 14:02:26 +01:00
|
|
|
}
|
|
|
|
|
2023-02-14 14:13:32 +01:00
|
|
|
class MyHomePageState extends State<MyHomePage> {
|
2023-02-26 17:07:38 +01:00
|
|
|
int _selectedIndex = 4;
|
2023-02-27 11:57:55 +01:00
|
|
|
bool _isConfigured = false;
|
2023-02-17 13:47:52 +01:00
|
|
|
|
2023-02-15 14:30:25 +01:00
|
|
|
final List<String> _titles = [
|
|
|
|
'Stimmung',
|
|
|
|
'Schlaf',
|
|
|
|
'Timer',
|
|
|
|
'Rückfall',
|
2023-02-17 13:47:52 +01:00
|
|
|
'Scanner'
|
2023-02-15 14:30:25 +01:00
|
|
|
];
|
2023-02-14 14:13:32 +01:00
|
|
|
static const List<Widget> _widgetOptions = <Widget>[
|
|
|
|
MoodPage(),
|
|
|
|
SleepPage(),
|
2023-02-19 15:44:41 +01:00
|
|
|
IntervalTimerPage(),
|
2023-02-14 14:13:32 +01:00
|
|
|
RelapsePage(),
|
2023-02-19 17:54:30 +01:00
|
|
|
ScannerPage(),
|
2023-02-14 14:02:26 +01:00
|
|
|
];
|
|
|
|
|
2023-02-27 11:57:55 +01:00
|
|
|
void _onItemTapped(int index) {
|
2023-02-19 14:24:39 +01:00
|
|
|
setState(() {
|
2023-02-27 11:57:55 +01:00
|
|
|
_isConfigured
|
2023-02-17 13:47:52 +01:00
|
|
|
? _selectedIndex = index
|
|
|
|
: showDialog(
|
|
|
|
context: context,
|
|
|
|
builder: (BuildContext context) {
|
2023-02-20 19:32:23 +01:00
|
|
|
return const MissingConfigPopup(
|
|
|
|
title: 'Fehlende Konfiguration',
|
|
|
|
text: 'Bitte QR Code Scannen!',
|
|
|
|
);
|
2023-02-17 13:47:52 +01:00
|
|
|
});
|
|
|
|
});
|
2023-02-14 14:02:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2023-02-27 11:57:55 +01:00
|
|
|
var settingsModel = context.watch<SettingsProvider>();
|
|
|
|
var group = settingsModel.settings?.group;
|
|
|
|
_isConfigured = settingsModel.initialized;
|
2023-02-14 14:02:26 +01:00
|
|
|
return Scaffold(
|
2023-02-20 19:50:09 +01:00
|
|
|
appBar: AppBar(
|
|
|
|
title: Text(
|
2023-02-27 11:57:55 +01:00
|
|
|
'${_titles[_selectedIndex]} ${_isConfigured ? "Gruppe $group" : ""}')),
|
2023-02-14 14:02:26 +01:00
|
|
|
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(
|
2023-02-17 13:47:52 +01:00
|
|
|
icon: Icon(Icons.camera_alt_outlined, color: Colors.black),
|
2023-02-14 14:02:26 +01:00
|
|
|
label: 'Settings'),
|
|
|
|
],
|
|
|
|
|
|
|
|
//onTap: _onItemTapped,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|