|
|
|
@ -6,6 +6,7 @@ import 'package:tangheem/classes/colors.dart';
|
|
|
|
import 'package:tangheem/classes/utils.dart';
|
|
|
|
import 'package:tangheem/classes/utils.dart';
|
|
|
|
import 'package:tangheem/extensions/string_extensions.dart';
|
|
|
|
import 'package:tangheem/extensions/string_extensions.dart';
|
|
|
|
import 'package:tangheem/models/country_model.dart';
|
|
|
|
import 'package:tangheem/models/country_model.dart';
|
|
|
|
|
|
|
|
import 'package:tangheem/models/general_response_model.dart';
|
|
|
|
import 'package:tangheem/ui/bottom_sheets/country_selection_bottom_sheet.dart';
|
|
|
|
import 'package:tangheem/ui/bottom_sheets/country_selection_bottom_sheet.dart';
|
|
|
|
import 'package:tangheem/widgets/common_textfield_widget.dart';
|
|
|
|
import 'package:tangheem/widgets/common_textfield_widget.dart';
|
|
|
|
|
|
|
|
|
|
|
|
@ -57,8 +58,13 @@ class _RegistrationScreenState extends State<RegistrationScreen> {
|
|
|
|
void registerUser(String _firstName, String _lastName, String _email, String _password, String _countryCode, String _phone) async {
|
|
|
|
void registerUser(String _firstName, String _lastName, String _email, String _password, String _countryCode, String _phone) async {
|
|
|
|
Utils.showLoading(context);
|
|
|
|
Utils.showLoading(context);
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
await UserApiClient().registerUser(_firstName, _lastName, _email, _password, _countryCode, _phone);
|
|
|
|
GeneralResponseModel model = await UserApiClient().registerUser(_firstName, _lastName, _email, _password, _countryCode, _phone);
|
|
|
|
Utils.showToast("تسجيل بنجاح");
|
|
|
|
if(model.message == "UserRegistration Already Exists") {
|
|
|
|
|
|
|
|
Utils.showToast("البريد الإلكتروني مستخدم سابقا");
|
|
|
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Utils.showToast("تم إنشاء الحساب بنجاح");
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
Navigator.pop(context);
|
|
|
|
Navigator.pop(context);
|
|
|
|
} catch (ex) {
|
|
|
|
} catch (ex) {
|
|
|
|
@ -116,14 +122,14 @@ class _RegistrationScreenState extends State<RegistrationScreen> {
|
|
|
|
child: Column(
|
|
|
|
child: Column(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
CommonTextFieldWidget(hint: "الاسم الاول", controller: _firstNameController),
|
|
|
|
CommonTextFieldWidget(hint: "البريد الإلكتروني", controller: _emailController),
|
|
|
|
SizedBox(height: 8),
|
|
|
|
SizedBox(height: 8),
|
|
|
|
CommonTextFieldWidget(hint: "اسم النهاية", controller: _lastNameController),
|
|
|
|
CommonTextFieldWidget(hint: "الاسم الأول", controller: _firstNameController),
|
|
|
|
SizedBox(height: 8),
|
|
|
|
SizedBox(height: 8),
|
|
|
|
CommonTextFieldWidget(hint: "الايميل", controller: _emailController),
|
|
|
|
CommonTextFieldWidget(hint: "الاسم الأخير", controller: _lastNameController),
|
|
|
|
SizedBox(height: 8),
|
|
|
|
SizedBox(height: 8),
|
|
|
|
CommonTextFieldWidget(
|
|
|
|
CommonTextFieldWidget(
|
|
|
|
hint: _selectedCountry?.countryNameAr ?? "البلد",
|
|
|
|
hint: _selectedCountry?.countryNameAr ?? "الدولة",
|
|
|
|
controller: null,
|
|
|
|
controller: null,
|
|
|
|
suffixWidget: Icon(Icons.keyboard_arrow_down, size: 18, color: ColorConsts.secondaryOrange),
|
|
|
|
suffixWidget: Icon(Icons.keyboard_arrow_down, size: 18, color: ColorConsts.secondaryOrange),
|
|
|
|
onTap: () {
|
|
|
|
onTap: () {
|
|
|
|
@ -169,46 +175,46 @@ class _RegistrationScreenState extends State<RegistrationScreen> {
|
|
|
|
child: TextButton(
|
|
|
|
child: TextButton(
|
|
|
|
onPressed: () {
|
|
|
|
onPressed: () {
|
|
|
|
if (_firstNameController.text.length < 1) {
|
|
|
|
if (_firstNameController.text.length < 1) {
|
|
|
|
Utils.showToast("اسم المستخدم فارغ");
|
|
|
|
Utils.showToast("يرجى إدخال الاسم الأول");
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (_lastNameController.text.length < 1) {
|
|
|
|
if (_lastNameController.text.length < 1) {
|
|
|
|
Utils.showToast("الاسم فارغ");
|
|
|
|
Utils.showToast("يرجى إدخال الاسم الأخير");
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (_emailController.text.length < 1) {
|
|
|
|
if (_emailController.text.length < 1) {
|
|
|
|
Utils.showToast("البريد الإلكتروني فارغ");
|
|
|
|
Utils.showToast("يرجى إدخال البريد الإلكتروني");
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (_selectedCountry?.countryCode == null) {
|
|
|
|
if (_selectedCountry?.countryCode == null) {
|
|
|
|
Utils.showToast("يجب عليك اختيار الدولة");
|
|
|
|
Utils.showToast("يرجى اختيار الدولة");
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (_mobileNumberController.text.length < 1) {
|
|
|
|
if (_mobileNumberController.text.length < 1) {
|
|
|
|
Utils.showToast("رقم الهاتف فارغ");
|
|
|
|
Utils.showToast("يرجى إدخال رقم الجوال");
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (_passwordController.text.length < 1) {
|
|
|
|
if (_passwordController.text.length < 1) {
|
|
|
|
Utils.showToast("كلمة المرور فارغة");
|
|
|
|
Utils.showToast("يرجى إدخال كلمة المرور");
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (_confirmPasswordController.text.length < 1) {
|
|
|
|
if (_confirmPasswordController.text.length < 1) {
|
|
|
|
Utils.showToast("أدخل كلمة المرور نفسها للتأكيد");
|
|
|
|
Utils.showToast("يرجى تأكيد كلمة المرور");
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!_emailController.text.isValidEmail()) {
|
|
|
|
if (!_emailController.text.isValidEmail()) {
|
|
|
|
Utils.showToast("بريد إلكتروني خاطئ");
|
|
|
|
Utils.showToast("صيغة البريد الإلكتروني خاطئة");
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (_passwordController.text != _confirmPasswordController.text) {
|
|
|
|
if (_passwordController.text != _confirmPasswordController.text) {
|
|
|
|
Utils.showToast("كلمات السر الخاصة بك غير صحيحة");
|
|
|
|
Utils.showToast("كلمة المرور غير متطابقة");
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!_isAccept) {
|
|
|
|
if (!_isAccept) {
|
|
|
|
Utils.showToast("يجب عليك قبول البيان للمتابعة");
|
|
|
|
Utils.showToast("الرجاء الموافقة على سياسة الخصوصية");
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
registerUser(
|
|
|
|
registerUser(
|
|
|
|
|