From bb126718c1bf828bb08dcdd885f4754bfa823b08 Mon Sep 17 00:00:00 2001 From: Lukas <35173609+PHPLukaas@users.noreply.github.com> Date: Wed, 13 Mar 2024 10:57:43 +0100 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F:=20refactor=20of=20datetime?= =?UTF-8?q?=20input?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lib/login/widgets/form/button_submit.dart | 6 +++++- .../lib/login/widgets/form/form_login.dart | 11 ++++++++++- .../login/widgets/form/inputs/input_birthdate.dart | 8 +++++++- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/frontend/app_student/lib/login/widgets/form/button_submit.dart b/frontend/app_student/lib/login/widgets/form/button_submit.dart index e4107a1..c376913 100644 --- a/frontend/app_student/lib/login/widgets/form/button_submit.dart +++ b/frontend/app_student/lib/login/widgets/form/button_submit.dart @@ -7,12 +7,14 @@ class SubmitButton extends StatelessWidget { final TextEditingController ineController; final TextEditingController nameController; final TextEditingController birthDateController; + final DateTime birthDate; const SubmitButton( {super.key, required this.ineController, required this.nameController, - required this.birthDateController}); + required this.birthDateController, + required this.birthDate}); @override Widget build(BuildContext context) { @@ -46,6 +48,8 @@ class SubmitButton extends StatelessWidget { final String name = nameController.text.trim(); final String birthDate = birthDateController.text.trim(); + print(birthDate); + context .read() .saveLoginDetails(ine, name, birthDate); diff --git a/frontend/app_student/lib/login/widgets/form/form_login.dart b/frontend/app_student/lib/login/widgets/form/form_login.dart index 93ff3e9..461f6b0 100644 --- a/frontend/app_student/lib/login/widgets/form/form_login.dart +++ b/frontend/app_student/lib/login/widgets/form/form_login.dart @@ -16,6 +16,7 @@ class FormLoginState extends State { final TextEditingController ineController = TextEditingController(); final TextEditingController nameController = TextEditingController(); final TextEditingController birthDateController = TextEditingController(); + DateTime birthDate = DateTime.now(); @override Widget build(BuildContext context) { @@ -24,12 +25,20 @@ class FormLoginState extends State { child: Column( children: [ INETextField(controller: ineController), - BirthDateField(controller: birthDateController), + BirthDateField( + controller: birthDateController, + onDateChanged: (newDate) { + setState(() { + birthDate = newDate; + }); + }, + ), FirstnameTextField(controller: nameController), SubmitButton( ineController: ineController, nameController: nameController, birthDateController: birthDateController, + birthDate: birthDate, ) ], ), diff --git a/frontend/app_student/lib/login/widgets/form/inputs/input_birthdate.dart b/frontend/app_student/lib/login/widgets/form/inputs/input_birthdate.dart index e159b4b..5be7080 100644 --- a/frontend/app_student/lib/login/widgets/form/inputs/input_birthdate.dart +++ b/frontend/app_student/lib/login/widgets/form/inputs/input_birthdate.dart @@ -2,8 +2,13 @@ import 'package:flutter/material.dart'; class BirthDateField extends StatefulWidget { final TextEditingController controller; + final ValueChanged onDateChanged; - const BirthDateField({super.key, required this.controller}); + const BirthDateField({ + super.key, + required this.controller, + required this.onDateChanged, + }); @override BirthDateFieldState createState() => BirthDateFieldState(); @@ -25,6 +30,7 @@ class BirthDateFieldState extends State { widget.controller.text = _selectedDate.toLocal().toString().split(' ')[0]; }); + widget.onDateChanged(_selectedDate); } }