68 lines
2.4 KiB
Dart
68 lines
2.4 KiB
Dart
import 'package:awesome_dialog/awesome_dialog.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'package:smoke_cess_app/providers/page_provider.dart';
|
|
import 'package:smoke_cess_app/providers/tasks_provider.dart';
|
|
import 'package:smoke_cess_app/services/pages_service.dart';
|
|
import 'package:smoke_cess_app/providers/settings_provider.dart';
|
|
|
|
import '../widgets/todo_icon.dart';
|
|
|
|
class MyHomePage extends StatelessWidget {
|
|
const MyHomePage({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
SettingsProvider settingsProvider = context.watch<SettingsProvider>();
|
|
TasksProvider tasksProvider = context.watch<TasksProvider>();
|
|
PageProvider pageProvider = context.watch<PageProvider>();
|
|
bool isConfigured = settingsProvider.initialized;
|
|
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
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(
|
|
'${pageProvider.currentPageData['title']} ${isConfigured ? "Gruppe ${settingsProvider.settings?.group}" : ""}')
|
|
],
|
|
)),
|
|
body: Stack(alignment: Alignment.center, children: [
|
|
Image.asset(
|
|
'assets/ZI_logo.png',
|
|
opacity: const AlwaysStoppedAnimation(0.05),
|
|
width: MediaQuery.of(context).size.width * 0.8,
|
|
),
|
|
pageProvider.currentPageData['page'],
|
|
]),
|
|
bottomNavigationBar: NavigationBar(
|
|
onDestinationSelected: isConfigured
|
|
? pageProvider.setCurrentPage
|
|
: (value) => AwesomeDialog(
|
|
context: context,
|
|
dialogType: DialogType.info,
|
|
title: 'Fehlende Konfiguration',
|
|
desc: 'Bitte QR Code Scannen!',
|
|
).show(),
|
|
selectedIndex: pageProvider.currentPageIndex,
|
|
destinations: pages.keys.map((key) {
|
|
return NavigationDestination(
|
|
icon: tasksProvider.tasks[key] ?? false
|
|
? MyToDoIcon(pages[key]?['icon'])
|
|
: pages[key]!['icon'],
|
|
label: pages[key]?['title']);
|
|
}).toList()),
|
|
);
|
|
}
|
|
}
|