From f5eaf482c3c879bcd20fefbd0314a95681d2faef Mon Sep 17 00:00:00 2001
From: Matthew Patrick <Matthew.535200018@stu.untar.ac.id>
Date: Mon, 25 Apr 2022 20:45:24 +0700
Subject: [PATCH] register_form - Added some logic to check if there are any
 fields empty in form

---
 lib/components/register_form.dart | 49 ++++++++++++++++++++++++++++++-
 1 file changed, 48 insertions(+), 1 deletion(-)

diff --git a/lib/components/register_form.dart b/lib/components/register_form.dart
index eed90f3..6d90d8c 100644
--- a/lib/components/register_form.dart
+++ b/lib/components/register_form.dart
@@ -66,7 +66,22 @@ class _Register_FormState extends State<Register_Form> {
                           child: MaterialButton(
                             minWidth: double.infinity,
                             height: 35,
-                            onPressed: () {},
+                            onPressed: () async {
+                              if (_formKey.currentState!.fields["First Name"]!
+                                          .value ==
+                                      '' ||
+                                  _formKey.currentState!.fields["Last Name"]!
+                                          .value ==
+                                      '' ||
+                                  _formKey.currentState!
+                                          .fields["Email Address"]!.value ==
+                                      '' ||
+                                  _formKey.currentState!.fields["Password"]!
+                                          .value ==
+                                      '') {
+                                showAlertDialog(context);
+                              } else {}
+                            },
                             color: const Color(0xff8B0000),
                             shape: RoundedRectangleBorder(
                                 borderRadius: BorderRadius.circular(40)),
@@ -148,3 +163,35 @@ Widget makeInput({label, obscureText = false}) {
     ],
   );
 }
+
+showAlertDialog(BuildContext context) {
+  Widget okButton = TextButton(
+    child: const Text("OK", style: TextStyle(color: Colors.red)),
+    onPressed: () {
+      Navigator.of(context, rootNavigator: true).pop();
+    },
+  );
+  AlertDialog alert = AlertDialog(
+    backgroundColor: const Color(0xff1b1c1e),
+    shape: RoundedRectangleBorder(
+      borderRadius: BorderRadius.circular(10),
+    ),
+    title: const Text(
+      "Error",
+      style: TextStyle(color: Colors.white),
+    ),
+    content: const Text(
+      "Make sure to fill all text fields",
+      style: const TextStyle(color: Colors.white70),
+    ),
+    actions: [
+      okButton,
+    ],
+  );
+  showDialog(
+    context: context,
+    builder: (BuildContext context) {
+      return alert;
+    },
+  );
+}