-
-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
31 changed files
with
699 additions
and
319 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import 'package:flutter/cupertino.dart'; | ||
import 'package:get/get.dart'; | ||
import 'package:todo/models/user/user-email.dart'; | ||
|
||
class EditProfileController extends GetxController { | ||
String userName = ""; | ||
String userEmail = ""; | ||
String userAge = ""; | ||
|
||
bool validationEmail = true; | ||
|
||
updateUserName({@required String name}) { | ||
userName = name; | ||
update(); | ||
} | ||
|
||
updateUserEmail({@required String email}) { | ||
userEmail = email; | ||
update(); | ||
} | ||
|
||
updateUserAge({@required String age}) { | ||
userAge = age; | ||
update(); | ||
} | ||
|
||
updateValidations({ | ||
@required bool newValidationEmail, | ||
}) { | ||
validationEmail = newValidationEmail; | ||
print(validationEmail); | ||
|
||
update(); | ||
} | ||
|
||
resetState() { | ||
userName = ""; | ||
userEmail = ""; | ||
userAge = ""; | ||
validationEmail = true; | ||
update(); | ||
} | ||
} | ||
|
||
Future<bool> editProfileChecker({@required String email}) async { | ||
bool response = false; | ||
await EmailValidation(email: email).then((bool value) { | ||
if (email == "") { | ||
response = true; | ||
} else { | ||
response = value; | ||
} | ||
}); | ||
return response; | ||
} |
File renamed without changes.
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
File renamed without changes.
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
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
This file was deleted.
Oops, something went wrong.
Empty file.
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,43 @@ | ||
import 'package:flutter/cupertino.dart'; | ||
import 'package:get/get.dart'; | ||
import 'package:shared_preferences/shared_preferences.dart'; | ||
import 'package:todo/controllers/main-controller.dart'; | ||
|
||
Future<bool> checkUserEmail() async { | ||
SharedPreferences prefs = await SharedPreferences.getInstance(); | ||
bool userNameStatus = prefs.getString('user-email') != null ? true : false; | ||
|
||
return userNameStatus; | ||
} | ||
|
||
Future<bool> setUserEmail({@required String userEmail}) async { | ||
SharedPreferences prefs = await SharedPreferences.getInstance(); | ||
EmailValidation(email: userEmail).then((response) { | ||
if (response) { | ||
prefs.setString('user-email', userEmail); | ||
getUserEmail(); | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
}); | ||
} | ||
|
||
Future<String> getUserEmail() async { | ||
SharedPreferences prefs = await SharedPreferences.getInstance(); | ||
String userEmail = prefs.getString('user-email'); | ||
Get.find<MainController>().updateMainStete(newUserEmail: userEmail); | ||
|
||
return userEmail; | ||
} | ||
|
||
// ignore: non_constant_identifier_names | ||
Future<bool> EmailValidation({@required String email}) async { | ||
Pattern 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,}))$'; | ||
RegExp regex = RegExp(pattern); | ||
if (!regex.hasMatch(email)) | ||
return false; | ||
else | ||
return true; | ||
} |
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,38 @@ | ||
import 'package:flutter/cupertino.dart'; | ||
import 'package:get/get.dart'; | ||
import 'package:shared_preferences/shared_preferences.dart'; | ||
import 'package:todo/controllers/main-controller.dart'; | ||
|
||
Future<bool> checkUserName() async { | ||
SharedPreferences prefs = await SharedPreferences.getInstance(); | ||
bool userNameStatus = prefs.getString('user-name') != null ? true : false; | ||
|
||
// return false; // just for debuging | ||
return userNameStatus; | ||
} | ||
|
||
Future<bool> setUserName({@required String userName}) async { | ||
if (userName == null || | ||
userName == "" || | ||
userName == " " || | ||
userName == " " || | ||
userName == " ") { | ||
return false; | ||
} | ||
try { | ||
SharedPreferences prefs = await SharedPreferences.getInstance(); | ||
prefs.setString('user-name', userName); | ||
getUserName(); | ||
return true; | ||
} catch (e) { | ||
return false; | ||
} | ||
} | ||
|
||
Future<String> getUserName() async { | ||
SharedPreferences prefs = await SharedPreferences.getInstance(); | ||
String userName = prefs.getString('user-name'); | ||
Get.find<MainController>().updateMainStete(newUserName: userName); | ||
|
||
return userName; | ||
} |
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,12 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:todo/models/user/user-email.dart'; | ||
import 'package:todo/models/user/user-name.dart'; | ||
|
||
Future<bool> UpdateUserData({String name, String email, String age}) async { | ||
if (name != null && name != "") { | ||
setUserName(userName: name); | ||
} | ||
if (email != null && email != "") { | ||
setUserEmail(userEmail: email); | ||
} | ||
} |
Oops, something went wrong.