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