Fixed Bug when swapping pages
parent
f62cdd2543
commit
ccf34c07e8
|
@ -5,6 +5,7 @@ import 'package:smoke_cess_app/providers/tasks_provider.dart';
|
||||||
import 'package:smoke_cess_app/services/notification_service.dart';
|
import 'package:smoke_cess_app/services/notification_service.dart';
|
||||||
import 'package:timezone/data/latest.dart' as tz;
|
import 'package:timezone/data/latest.dart' as tz;
|
||||||
import 'globals.dart' as globals;
|
import 'globals.dart' as globals;
|
||||||
|
import 'providers/page_provider.dart';
|
||||||
import 'providers/settings_provider.dart';
|
import 'providers/settings_provider.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
|
@ -34,6 +35,9 @@ class MyApp extends StatelessWidget {
|
||||||
update: (context, value, TasksProvider? previous) =>
|
update: (context, value, TasksProvider? previous) =>
|
||||||
TasksProvider(value),
|
TasksProvider(value),
|
||||||
),
|
),
|
||||||
|
ChangeNotifierProvider(
|
||||||
|
create: (context) => PageProvider(),
|
||||||
|
)
|
||||||
],
|
],
|
||||||
child: const MyHomePage(),
|
child: const MyHomePage(),
|
||||||
));
|
));
|
||||||
|
|
|
@ -20,15 +20,19 @@ class MyHomePageState extends State<MyHomePage> {
|
||||||
bool _isConfigured = false;
|
bool _isConfigured = false;
|
||||||
|
|
||||||
void _onItemTapped(int index) {
|
void _onItemTapped(int index) {
|
||||||
|
PageProvider pageProvider = context.watch<PageProvider>();
|
||||||
setState(() {
|
setState(() {
|
||||||
_isConfigured
|
if (_isConfigured) {
|
||||||
? _selectedIndex = index
|
pageProvider.showForm = false;
|
||||||
: AwesomeDialog(
|
_selectedIndex = index;
|
||||||
context: context,
|
return;
|
||||||
dialogType: DialogType.info,
|
}
|
||||||
title: 'Fehlende Konfiguration',
|
AwesomeDialog(
|
||||||
desc: 'Bitte QR Code Scannen!',
|
context: context,
|
||||||
).show();
|
dialogType: DialogType.info,
|
||||||
|
title: 'Fehlende Konfiguration',
|
||||||
|
desc: 'Bitte QR Code Scannen!',
|
||||||
|
).show();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,10 +46,8 @@ class MyHomePageState extends State<MyHomePage> {
|
||||||
title: Text(
|
title: Text(
|
||||||
'${pages.values.elementAt(_selectedIndex)['title']} ${_isConfigured ? "Gruppe ${settingsModel.settings?.group}" : ""}')),
|
'${pages.values.elementAt(_selectedIndex)['title']} ${_isConfigured ? "Gruppe ${settingsModel.settings?.group}" : ""}')),
|
||||||
body: SingleChildScrollView(
|
body: SingleChildScrollView(
|
||||||
child: ChangeNotifierProvider(
|
|
||||||
create: (context) => PageProvider(),
|
|
||||||
child: pages.values.elementAt(_selectedIndex)['page'],
|
child: pages.values.elementAt(_selectedIndex)['page'],
|
||||||
)),
|
),
|
||||||
bottomNavigationBar: NavigationBar(
|
bottomNavigationBar: NavigationBar(
|
||||||
onDestinationSelected: _onItemTapped,
|
onDestinationSelected: _onItemTapped,
|
||||||
selectedIndex: _selectedIndex,
|
selectedIndex: _selectedIndex,
|
||||||
|
|
Loading…
Reference in New Issue