BASE: Update Icons & Name Of The App.
This commit is contained in:
@@ -3,7 +3,7 @@ import 'package:customer/models/user_model.dart';
|
||||
import 'package:customer/screen_ui/location_enable_screens/location_permission_screen.dart';
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:get/get.dart' hide Trans;
|
||||
import 'package:firebase_auth/firebase_auth.dart' as auth;
|
||||
import '../constant/constant.dart';
|
||||
import '../models/referral_model.dart';
|
||||
@@ -17,9 +17,11 @@ class SignUpController extends GetxController {
|
||||
Rx<TextEditingController> lastNameController = TextEditingController().obs;
|
||||
Rx<TextEditingController> emailController = TextEditingController().obs;
|
||||
Rx<TextEditingController> mobileController = TextEditingController().obs;
|
||||
Rx<TextEditingController> countryCodeController = TextEditingController(text: Constant.defaultCountryCode).obs;
|
||||
Rx<TextEditingController> countryCodeController =
|
||||
TextEditingController(text: Constant.defaultCountryCode).obs;
|
||||
Rx<TextEditingController> passwordController = TextEditingController().obs;
|
||||
Rx<TextEditingController> confirmPasswordController = TextEditingController().obs;
|
||||
Rx<TextEditingController> confirmPasswordController =
|
||||
TextEditingController().obs;
|
||||
Rx<TextEditingController> referralController = TextEditingController().obs;
|
||||
|
||||
final FocusNode emailFocusNode = FocusNode();
|
||||
@@ -90,7 +92,8 @@ class SignUpController extends GetxController {
|
||||
} else if (lastNameController.value.text.isEmpty) {
|
||||
ShowToastDialog.showToast("Please enter last name".tr());
|
||||
return false;
|
||||
} else if (emailController.value.text.isEmpty || !emailController.value.text.isEmail) {
|
||||
} else if (emailController.value.text.isEmpty ||
|
||||
!emailController.value.text.isEmail) {
|
||||
ShowToastDialog.showToast("Please enter a valid email address".tr());
|
||||
return false;
|
||||
} else if (mobileController.value.text.isEmpty) {
|
||||
@@ -99,8 +102,11 @@ class SignUpController extends GetxController {
|
||||
} else if (passwordController.value.text.length < 6) {
|
||||
ShowToastDialog.showToast("Password must be at least 6 characters".tr());
|
||||
return false;
|
||||
} else if (passwordController.value.text != confirmPasswordController.value.text) {
|
||||
ShowToastDialog.showToast("Password and Confirm password do not match".tr());
|
||||
} else if (passwordController.value.text !=
|
||||
confirmPasswordController.value.text) {
|
||||
ShowToastDialog.showToast(
|
||||
"Password and Confirm password do not match".tr(),
|
||||
);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -109,7 +115,10 @@ class SignUpController extends GetxController {
|
||||
/// Email Sign-up Flow
|
||||
Future<void> _signUpWithEmail() async {
|
||||
try {
|
||||
final credential = await _firebaseAuth.createUserWithEmailAndPassword(email: emailController.value.text.trim(), password: passwordController.value.text.trim());
|
||||
final credential = await _firebaseAuth.createUserWithEmailAndPassword(
|
||||
email: emailController.value.text.trim(),
|
||||
password: passwordController.value.text.trim(),
|
||||
);
|
||||
|
||||
if (credential.user != null) {
|
||||
final newUser = await _buildUserModel(credential.user?.uid ?? '');
|
||||
@@ -119,7 +128,9 @@ class SignUpController extends GetxController {
|
||||
_navigateBasedOnAddress(newUser);
|
||||
}
|
||||
} on auth.FirebaseAuthException catch (e) {
|
||||
debugPrint("FirebaseAuthException caught: code=${e.code}, message=${e.message}");
|
||||
debugPrint(
|
||||
"FirebaseAuthException caught: code=${e.code}, message=${e.message}",
|
||||
);
|
||||
if (e.code == 'email-already-in-use') {
|
||||
ShowToastDialog.showToast("Email already in use".tr());
|
||||
} else if (e.code == 'weak-password') {
|
||||
@@ -131,7 +142,9 @@ class SignUpController extends GetxController {
|
||||
}
|
||||
} catch (e) {
|
||||
debugPrint("Something went wrong: ${e.toString()}");
|
||||
ShowToastDialog.showToast("${'something_went_wrong'.tr()}: ${e.toString()}");
|
||||
ShowToastDialog.showToast(
|
||||
"${'something_went_wrong'.tr()}: ${e.toString()}",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,9 +186,17 @@ class SignUpController extends GetxController {
|
||||
/// Handle Referral Logic
|
||||
Future<void> _handleReferral(String userId) async {
|
||||
final referralCode = referralController.value.text.trim();
|
||||
final referralBy = referralCode.isNotEmpty ? (await FireStoreUtils.getReferralUserByCode(referralCode))?.id ?? '' : '';
|
||||
final referralBy =
|
||||
referralCode.isNotEmpty
|
||||
? (await FireStoreUtils.getReferralUserByCode(referralCode))?.id ??
|
||||
''
|
||||
: '';
|
||||
|
||||
final referral = ReferralModel(id: userId, referralBy: referralBy, referralCode: Constant.getReferralCode());
|
||||
final referral = ReferralModel(
|
||||
id: userId,
|
||||
referralBy: referralBy,
|
||||
referralCode: Constant.getReferralCode(),
|
||||
);
|
||||
|
||||
await FireStoreUtils.referralAdd(referral);
|
||||
}
|
||||
@@ -183,7 +204,10 @@ class SignUpController extends GetxController {
|
||||
/// Navigate Based on Shipping Address
|
||||
void _navigateBasedOnAddress(UserModel user) {
|
||||
if (user.shippingAddress?.isNotEmpty == true) {
|
||||
final defaultAddress = user.shippingAddress!.firstWhere((e) => e.isDefault == true, orElse: () => user.shippingAddress!.first);
|
||||
final defaultAddress = user.shippingAddress!.firstWhere(
|
||||
(e) => e.isDefault == true,
|
||||
orElse: () => user.shippingAddress!.first,
|
||||
);
|
||||
|
||||
/// Save the default address to global constant
|
||||
Constant.selectedLocation = defaultAddress;
|
||||
|
||||
Reference in New Issue
Block a user