68 lines
2.1 KiB
Dart
68 lines
2.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:garden_planner/constance.dart';
|
|
|
|
class Header extends StatelessWidget implements PreferredSizeWidget {
|
|
final Function() onSidebarToggle;
|
|
final Function() onSave;
|
|
|
|
const Header({Key? key, required this.onSidebarToggle, required this.onSave})
|
|
: super(key: key);
|
|
|
|
@override
|
|
Size get preferredSize => const Size.fromHeight(60);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return AppBar(
|
|
leading: IconButton(
|
|
icon: const Icon(Icons.menu_open),
|
|
onPressed: () {
|
|
onSidebarToggle();
|
|
},
|
|
),
|
|
title: Text(Constance.apptitle),
|
|
actions: [
|
|
Container(
|
|
margin: const EdgeInsets.all(5),
|
|
child: ElevatedButton.icon(
|
|
onPressed: () {
|
|
showDialog(
|
|
context: context,
|
|
builder: (BuildContext context) {
|
|
return AlertDialog(
|
|
title: const Text('Bestätigen'),
|
|
content: const Text('Möchten Sie speichern?'),
|
|
actions: [
|
|
ElevatedButton(
|
|
style: ElevatedButton.styleFrom(
|
|
backgroundColor: Colors.redAccent,
|
|
),
|
|
onPressed: () {
|
|
Navigator.of(context).pop();
|
|
},
|
|
child: const Text('Abbrechen'),
|
|
),
|
|
ElevatedButton(
|
|
child: const Text('Ja'),
|
|
onPressed: () {
|
|
onSave();
|
|
Navigator.of(context).pop();
|
|
},
|
|
),
|
|
],
|
|
);
|
|
},
|
|
);
|
|
},
|
|
icon: const Icon(Icons.save),
|
|
label: const Text('Speichern'),
|
|
style: ElevatedButton.styleFrom(
|
|
foregroundColor: Colors.black,
|
|
backgroundColor: Colors.white,
|
|
),
|
|
))
|
|
],
|
|
);
|
|
}
|
|
}
|