GardenPlanner/lib/widgets/header.dart

68 lines
2.1 KiB
Dart
Raw Normal View History

2023-06-25 10:13:39 +02:00
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: [
2023-06-25 10:15:30 +02:00
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();
},
),
],
);
},
2023-06-25 10:13:39 +02:00
);
},
2023-06-25 10:15:30 +02:00
icon: const Icon(Icons.save),
label: const Text('Speichern'),
style: ElevatedButton.styleFrom(
foregroundColor: Colors.black,
backgroundColor: Colors.white,
),
))
2023-06-25 10:13:39 +02:00
],
);
}
}