From 6e9f213cdcc4309cfba41192b6243f7213a81749 Mon Sep 17 00:00:00 2001 From: "k.mannweiler" <2012491@stud.hs-mannheim.de> Date: Fri, 3 Mar 2023 12:48:19 +0100 Subject: [PATCH] Added PageProvider --- lib/pages/main_page.dart | 9 ++++++--- lib/providers/page_provider.dart | 10 ++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 lib/providers/page_provider.dart diff --git a/lib/pages/main_page.dart b/lib/pages/main_page.dart index ce6a1ff..338dd75 100644 --- a/lib/pages/main_page.dart +++ b/lib/pages/main_page.dart @@ -1,6 +1,7 @@ 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'; @@ -40,9 +41,11 @@ class MyHomePageState extends State { appBar: AppBar( title: Text( '${pages.values.elementAt(_selectedIndex)['title']} ${_isConfigured ? "Gruppe ${settingsModel.settings?.group}" : ""}')), - body: Center( - child: SingleChildScrollView( - child: pages.values.elementAt(_selectedIndex)['page'])), + body: SingleChildScrollView( + child: ChangeNotifierProvider( + create: (context) => PageProvider(), + child: pages.values.elementAt(_selectedIndex)['page'], + )), bottomNavigationBar: NavigationBar( onDestinationSelected: _onItemTapped, selectedIndex: _selectedIndex, diff --git a/lib/providers/page_provider.dart b/lib/providers/page_provider.dart new file mode 100644 index 0000000..a17ff26 --- /dev/null +++ b/lib/providers/page_provider.dart @@ -0,0 +1,10 @@ +import 'package:flutter/material.dart'; + +class PageProvider extends ChangeNotifier { + bool showForm = false; + + void swap() { + showForm = !showForm; + notifyListeners(); + } +}