-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: handle email and phone text inpiuts on auth page
- Loading branch information
1 parent
4fb5c8f
commit 307ae74
Showing
4 changed files
with
74 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
lib/app/features/auth/views/pages/auth_page/controllers/email_controller.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import 'package:flutter/cupertino.dart'; | ||
|
||
const String pattern = | ||
r'^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$'; | ||
|
||
class EmailController { | ||
final GlobalKey<FormState> formKey = GlobalKey<FormState>(); | ||
final RegExp regex = RegExp(pattern); | ||
final TextEditingController controller = TextEditingController(); | ||
|
||
String errorMessage = ''; | ||
|
||
String? onVerify() { | ||
final String trimmedEmail = controller.text.trim(); | ||
|
||
if (!regex.hasMatch(trimmedEmail)) { | ||
errorMessage = 'Enter a valid email address'; | ||
} | ||
|
||
return errorMessage.isEmpty ? null : errorMessage; | ||
} | ||
|
||
void dispose() { | ||
controller.dispose(); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
lib/app/features/auth/views/pages/auth_page/controllers/phone_number_controller.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import 'package:flutter/cupertino.dart'; | ||
|
||
class PhoneNumberController { | ||
final GlobalKey<FormState> formKey = GlobalKey<FormState>(); | ||
|
||
final TextEditingController controller = TextEditingController(); | ||
|
||
String errorMessage = ''; | ||
|
||
String? onVerify() { | ||
//TODO: validate phone number locally here | ||
return null; | ||
} | ||
|
||
void dispose() { | ||
controller.dispose(); | ||
} | ||
} |
Empty file.