@ -8,6 +8,7 @@ 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/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/ui/dialogs/general_dialog.dart ' ;
import ' package:tangheem/widgets/common_textfield_widget.dart ' ;
import ' package:tangheem/widgets/common_textfield_widget.dart ' ;
class RegistrationScreen extends StatefulWidget {
class RegistrationScreen extends StatefulWidget {
@ -58,14 +59,18 @@ 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 {
GeneralResponseModel model = await UserApiClient ( ) . registerUser ( _firstName , _lastName , _email , _password , _countryCode , _phone ) ;
GeneralResponseModel model = await UserApiClient ( ) . registerUser ( _firstName , _lastName , _email , _password , _countryCode , _phone ) ;
if ( model . message = = " UserRegistration Already Exists " ) {
if ( model . message = = " UserRegistration Already Exists " ) {
Utils . showToast ( " البريد الإلكتروني مستخدم سابقا " ) ;
Utils . showToast ( " البريد الإلكتروني مستخدم سابقا " ) ;
Utils . hideLoading ( context ) ;
Utils . hideLoading ( context ) ;
return ;
return ;
}
}
Utils . showToast ( " تم إنشاء الحساب بنجاح " ) ;
Utils . hideLoading ( context ) ;
Utils . hideLoading ( context ) ;
await showDialog (
context: context ,
barrierColor: ColorConsts . secondaryWhite . withOpacity ( 0.8 ) ,
builder: ( BuildContext context ) = > GeneralDialog ( message: " تم إنشاء الحساب بنجاح , الرجاء توثيق الحساب من خلال الرابط المرسل إلى بريدك الإلكتروني " ) ,
) ;
Navigator . pop ( context ) ;
Navigator . pop ( context ) ;
} catch ( ex ) {
} catch ( ex ) {
if ( mounted ) Utils . handleException ( ex , null ) ;
if ( mounted ) Utils . handleException ( ex , null ) ;
@ -162,7 +167,7 @@ class _RegistrationScreenState extends State<RegistrationScreen> {
SizedBox ( width: 8 ) ,
SizedBox ( width: 8 ) ,
Expanded (
Expanded (
child: Text (
child: Text (
" أقر بأن ي إطلعت على شروط الاستخدام و سياسية الخصوصية و أوافق عليها " ,
" أقر بأن جميع البيانات المدخلة أعلاه صحيحة " ,
style: TextStyle ( color: Colors . white , fontSize: 13 ) ,
style: TextStyle ( color: Colors . white , fontSize: 13 ) ,
) ,
) ,
) ,
) ,
@ -174,6 +179,10 @@ class _RegistrationScreenState extends State<RegistrationScreen> {
height: 50 ,
height: 50 ,
child: TextButton (
child: TextButton (
onPressed: ( ) {
onPressed: ( ) {
if ( _emailController . text . length < 1 ) {
Utils . showToast ( " يرجى إدخال البريد الإلكتروني " ) ;
return ;
}
if ( _firstNameController . text . length < 1 ) {
if ( _firstNameController . text . length < 1 ) {
Utils . showToast ( " يرجى إدخال الاسم الأول " ) ;
Utils . showToast ( " يرجى إدخال الاسم الأول " ) ;
return ;
return ;
@ -182,10 +191,6 @@ class _RegistrationScreenState extends State<RegistrationScreen> {
Utils . showToast ( " يرجى إدخال الاسم الأخير " ) ;
Utils . showToast ( " يرجى إدخال الاسم الأخير " ) ;
return ;
return ;
}
}
if ( _emailController . text . length < 1 ) {
Utils . showToast ( " يرجى إدخال البريد الإلكتروني " ) ;
return ;
}
if ( _selectedCountry ? . countryCode = = null ) {
if ( _selectedCountry ? . countryCode = = null ) {
Utils . showToast ( " يرجى اختيار الدولة " ) ;
Utils . showToast ( " يرجى اختيار الدولة " ) ;
return ;
return ;
@ -193,6 +198,9 @@ class _RegistrationScreenState extends State<RegistrationScreen> {
if ( _mobileNumberController . text . length < 1 ) {
if ( _mobileNumberController . text . length < 1 ) {
Utils . showToast ( " يرجى إدخال رقم الجوال " ) ;
Utils . showToast ( " يرجى إدخال رقم الجوال " ) ;
return ;
return ;
} else if ( _mobileNumberController . text . length < 8 | | _mobileNumberController . text . length > 12 ) {
Utils . showToast ( " رقم الهاتف غير صحيح " ) ;
return ;
}
}
if ( _passwordController . text . length < 1 ) {
if ( _passwordController . text . length < 1 ) {
Utils . showToast ( " يرجى إدخال كلمة المرور " ) ;
Utils . showToast ( " يرجى إدخال كلمة المرور " ) ;
@ -221,8 +229,8 @@ class _RegistrationScreenState extends State<RegistrationScreen> {
_firstNameController . text , _lastNameController . text , _emailController . text , _passwordController . text , _selectedCountry ? . countryCode , _mobileNumberController . text ) ;
_firstNameController . text , _lastNameController . text , _emailController . text , _passwordController . text , _selectedCountry ? . countryCode , _mobileNumberController . text ) ;
} ,
} ,
style: TextButton . styleFrom (
style: TextButton . styleFrom (
primary: Colors . white ,
backgroundColor: ColorConsts . secondaryPink ,
backgroundColor: ColorConsts . secondaryPink ,
foregroundColor: Colors . white ,
textStyle: TextStyle ( fontSize: 16 , fontFamily: " DroidKufi " ) ,
textStyle: TextStyle ( fontSize: 16 , fontFamily: " DroidKufi " ) ,
shape: RoundedRectangleBorder (
shape: RoundedRectangleBorder (
borderRadius: BorderRadius . circular ( 6.0 ) ,
borderRadius: BorderRadius . circular ( 6.0 ) ,