back button to appbar, added round add button to add entries
parent
3038efcd27
commit
8143a91020
|
@ -38,22 +38,37 @@ class MyHomePageState extends State<MyHomePage> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var settingsModel = context.watch<SettingsProvider>();
|
||||
var tasksModel = context.watch<TasksProvider>();
|
||||
_isConfigured = settingsModel.initialized;
|
||||
var settingsProvider = context.watch<SettingsProvider>();
|
||||
var tasksProvider = context.watch<TasksProvider>();
|
||||
PageProvider pageProvider = context.watch<PageProvider>();
|
||||
|
||||
_isConfigured = settingsProvider.initialized;
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(
|
||||
'${pages.values.elementAt(_selectedIndex)['title']} ${_isConfigured ? "Gruppe ${settingsModel.settings?.group}" : ""}')),
|
||||
body: SingleChildScrollView(
|
||||
child: pages.values.elementAt(_selectedIndex)['page'],
|
||||
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(
|
||||
'${pages.values.elementAt(_selectedIndex)['title']} ${_isConfigured ? "Gruppe ${settingsProvider.settings?.group}" : ""}')
|
||||
],
|
||||
)),
|
||||
body: pages.values.elementAt(_selectedIndex)['page'],
|
||||
bottomNavigationBar: NavigationBar(
|
||||
onDestinationSelected: _onItemTapped,
|
||||
selectedIndex: _selectedIndex,
|
||||
destinations: pages.keys.map((key) {
|
||||
return NavigationDestination(
|
||||
icon: tasksModel.tasks[key] ?? false
|
||||
icon: tasksProvider.tasks[key] ?? false
|
||||
? MyToDoIcon(pages[key]?['icon'])
|
||||
: pages[key]!['icon'],
|
||||
label: pages[key]?['title']);
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
class RoundAddButton extends StatelessWidget {
|
||||
final VoidCallback onPressed;
|
||||
|
||||
const RoundAddButton({super.key, required this.onPressed});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ElevatedButton(
|
||||
onPressed: onPressed,
|
||||
style: ElevatedButton.styleFrom(
|
||||
shape: const CircleBorder(),
|
||||
padding: const EdgeInsets.all(20),
|
||||
backgroundColor: Colors.green, // <-- Button color
|
||||
foregroundColor: Colors.blue, // <-- Splash color
|
||||
),
|
||||
child: const Icon(Icons.add_outlined, color: Colors.white),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:smoke_cess_app/services/pages_service.dart';
|
||||
import 'package:smoke_cess_app/widgets/round_button_widget.dart';
|
||||
import '../providers/input_provider.dart';
|
||||
import '../providers/page_provider.dart';
|
||||
import '../providers/tasks_provider.dart';
|
||||
|
@ -17,25 +18,20 @@ class ViewFormPage extends StatelessWidget {
|
|||
Widget build(BuildContext context) {
|
||||
PageProvider pageProvider = context.watch<PageProvider>();
|
||||
TasksProvider tasksProvider = context.watch<TasksProvider>();
|
||||
return Wrap(children: [
|
||||
Align(
|
||||
alignment: Alignment.topLeft,
|
||||
child: IconButton(
|
||||
icon: pageProvider.showForm
|
||||
? const Icon(Icons.arrow_back, color: Colors.black)
|
||||
: const Icon(Icons.add_outlined, color: Colors.black),
|
||||
onPressed: tasksProvider.tasks[page] ?? true
|
||||
? pageProvider.swap
|
||||
: () => showTaskDonePopup(context, page),
|
||||
),
|
||||
),
|
||||
return Column(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
|
||||
pageProvider.showForm
|
||||
? Center(
|
||||
child: ChangeNotifierProvider(
|
||||
create: (context) => InputProvider(),
|
||||
child: form,
|
||||
))
|
||||
: Center(child: view)
|
||||
: Center(child: view),
|
||||
if (!pageProvider.showForm)
|
||||
RoundAddButton(
|
||||
onPressed: tasksProvider.tasks[page] == true
|
||||
? () => pageProvider.swap()
|
||||
: () => showTaskDonePopup(context, page),
|
||||
)
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue