2023-02-27 20:02:15 +01:00
|
|
|
import 'package:awesome_dialog/awesome_dialog.dart';
|
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-03-03 12:48:19 +01:00
|
|
|
import 'package:smoke_cess_app/providers/page_provider.dart';
|
2023-03-02 19:31:47 +01:00
|
|
|
import 'package:smoke_cess_app/providers/tasks_provider.dart';
|
2023-02-27 17:27:01 +01:00
|
|
|
import 'package:smoke_cess_app/services/pages_service.dart';
|
2023-02-27 02:27:42 +01:00
|
|
|
import 'package:smoke_cess_app/providers/settings_provider.dart';
|
2023-02-14 14:02:26 +01:00
|
|
|
|
2023-03-02 20:20:17 +01:00
|
|
|
import '../widgets/todo_icon.dart';
|
|
|
|
|
2023-03-05 21:37:27 +01:00
|
|
|
class MyHomePage extends StatelessWidget {
|
2023-02-14 14:02:26 +01:00
|
|
|
const MyHomePage({super.key});
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2023-03-05 21:37:27 +01:00
|
|
|
SettingsProvider settingsProvider = context.watch<SettingsProvider>();
|
|
|
|
TasksProvider tasksProvider = context.watch<TasksProvider>();
|
2023-03-04 17:58:04 +01:00
|
|
|
PageProvider pageProvider = context.watch<PageProvider>();
|
2023-03-05 21:37:27 +01:00
|
|
|
bool isConfigured = settingsProvider.initialized;
|
2023-03-04 17:58:04 +01:00
|
|
|
|
2023-02-14 14:02:26 +01:00
|
|
|
return Scaffold(
|
2023-02-20 19:50:09 +01:00
|
|
|
appBar: AppBar(
|
2023-03-04 17:58:04 +01:00
|
|
|
title: Row(
|
|
|
|
children: [
|
|
|
|
Stack(
|
|
|
|
children: [
|
|
|
|
const SizedBox(
|
|
|
|
width: 70,
|
|
|
|
),
|
|
|
|
if (pageProvider.showForm)
|
|
|
|
IconButton(
|
|
|
|
icon: const Icon(Icons.arrow_back, color: Colors.white),
|
|
|
|
onPressed: pageProvider.swap),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
Text(
|
2023-03-05 21:37:27 +01:00
|
|
|
'${pageProvider.currentPageData['title']} ${isConfigured ? "Gruppe ${settingsProvider.settings?.group}" : ""}')
|
2023-03-04 17:58:04 +01:00
|
|
|
],
|
|
|
|
)),
|
2023-03-05 21:37:27 +01:00
|
|
|
body: pageProvider.currentPageData['page'],
|
2023-02-14 14:02:26 +01:00
|
|
|
bottomNavigationBar: NavigationBar(
|
2023-03-05 21:37:27 +01:00
|
|
|
onDestinationSelected: isConfigured
|
2023-03-05 21:44:51 +01:00
|
|
|
? pageProvider.setCurrentPage
|
2023-03-05 21:37:27 +01:00
|
|
|
: (value) => AwesomeDialog(
|
|
|
|
context: context,
|
|
|
|
dialogType: DialogType.info,
|
|
|
|
title: 'Fehlende Konfiguration',
|
|
|
|
desc: 'Bitte QR Code Scannen!',
|
|
|
|
).show(),
|
|
|
|
selectedIndex: pageProvider.currentPageIndex,
|
2023-02-27 14:57:56 +01:00
|
|
|
destinations: pages.keys.map((key) {
|
|
|
|
return NavigationDestination(
|
2023-03-04 17:58:04 +01:00
|
|
|
icon: tasksProvider.tasks[key] ?? false
|
2023-03-02 19:31:47 +01:00
|
|
|
? MyToDoIcon(pages[key]?['icon'])
|
|
|
|
: pages[key]!['icon'],
|
2023-03-02 18:35:03 +01:00
|
|
|
label: pages[key]?['title']);
|
2023-02-27 14:57:56 +01:00
|
|
|
}).toList()),
|
2023-02-14 14:02:26 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|