feat: honestly forgot
This commit is contained in:
parent
48bcf0b1f8
commit
da953ba651
19 changed files with 1097 additions and 244 deletions
71
lib/ui/home_page/widgets/create_confirmation_popup.dart
Normal file
71
lib/ui/home_page/widgets/create_confirmation_popup.dart
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:seshat/ui/home_page/view_model/home_view_model.dart';
|
||||
|
||||
class CreateConfirmationPopup extends StatefulWidget {
|
||||
const CreateConfirmationPopup({super.key, required this.viewModel});
|
||||
|
||||
final HomeViewModel viewModel;
|
||||
|
||||
@override
|
||||
State<CreateConfirmationPopup> createState() =>
|
||||
_CreateConfirmationPopupState();
|
||||
}
|
||||
|
||||
class _CreateConfirmationPopupState extends State<CreateConfirmationPopup> {
|
||||
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
||||
String? name;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: Text("Créer une BAL"),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Form(
|
||||
key: _formKey,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
TextFormField(
|
||||
decoration: InputDecoration(
|
||||
labelText: "Nom de la BAL",
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return "Veuillez entrer un nom";
|
||||
}
|
||||
return null;
|
||||
},
|
||||
onSaved: (newValue) {
|
||||
name = newValue;
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: Text("Annuler"),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
if (_formKey.currentState!.validate()) {
|
||||
_formKey.currentState!.save();
|
||||
await widget.viewModel.createBal(name!);
|
||||
}
|
||||
if (context.mounted) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
},
|
||||
child: Text("Valider"),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in a new issue