BASE: Update Icons & Name Of The App.

This commit is contained in:
2025-12-04 10:23:59 +05:00
parent b04050384d
commit e602782edd
228 changed files with 34364 additions and 7905 deletions

View File

@@ -3,7 +3,7 @@ import 'package:customer/screen_ui/location_enable_screens/location_permission_s
import 'package:easy_localization/easy_localization.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:get/get.dart' hide Trans;
import 'package:google_sign_in/google_sign_in.dart';
import 'package:sign_in_with_apple/sign_in_with_apple.dart';
import '../constant/constant.dart';
@@ -46,16 +46,22 @@ class LoginController extends GetxController {
isLoading.value = true;
ShowToastDialog.showLoader("Logging in...".tr());
final credential = await FirebaseAuth.instance.signInWithEmailAndPassword(email: email, password: password);
final credential = await FirebaseAuth.instance.signInWithEmailAndPassword(
email: email,
password: password,
);
final userModel = await FireStoreUtils.getUserProfile(credential.user!.uid);
final userModel = await FireStoreUtils.getUserProfile(
credential.user!.uid,
);
if (userModel != null && userModel.role == Constant.userRoleCustomer) {
if (userModel.active == true) {
userModel.fcmToken = await NotificationService.getToken();
await FireStoreUtils.updateUser(userModel);
if (userModel.shippingAddress != null && userModel.shippingAddress!.isNotEmpty) {
if (userModel.shippingAddress != null &&
userModel.shippingAddress!.isNotEmpty) {
final defaultAddress = userModel.shippingAddress!.firstWhere(
(e) => e.isDefault == true,
orElse: () => userModel.shippingAddress!.first,
@@ -69,12 +75,16 @@ class LoginController extends GetxController {
}
} else {
await FirebaseAuth.instance.signOut();
ShowToastDialog.showToast("This user is disabled. Please contact admin.".tr());
ShowToastDialog.showToast(
"This user is disabled. Please contact admin.".tr(),
);
Get.offAll(() => const LoginScreen());
}
} else {
await FirebaseAuth.instance.signOut();
ShowToastDialog.showToast("This user does not exist in the customer app.".tr());
ShowToastDialog.showToast(
"This user does not exist in the customer app.".tr(),
);
Get.offAll(() => const LoginScreen());
}
} on FirebaseAuthException catch (e) {
@@ -85,7 +95,9 @@ class LoginController extends GetxController {
} else if (e.code == 'invalid-email') {
ShowToastDialog.showToast("Invalid email.".tr());
} else {
ShowToastDialog.showToast(e.message?.tr() ?? "Login failed. Please try again.".tr());
ShowToastDialog.showToast(
e.message?.tr() ?? "Login failed. Please try again.".tr(),
);
}
} finally {
isLoading.value = false;
@@ -107,22 +119,32 @@ class LoginController extends GetxController {
userModel.provider = 'google';
ShowToastDialog.closeLoader();
Get.off(const SignUpScreen(), arguments: {"userModel": userModel, "type": "google"});
Get.off(
const SignUpScreen(),
arguments: {"userModel": userModel, "type": "google"},
);
} else {
await FireStoreUtils.userExistOrNot(value.user!.uid).then((userExit) async {
await FireStoreUtils.userExistOrNot(value.user!.uid).then((
userExit,
) async {
ShowToastDialog.closeLoader();
if (userExit == true) {
UserModel? userModel = await FireStoreUtils.getUserProfile(value.user!.uid);
if (userModel != null && userModel.role == Constant.userRoleCustomer) {
UserModel? userModel = await FireStoreUtils.getUserProfile(
value.user!.uid,
);
if (userModel != null &&
userModel.role == Constant.userRoleCustomer) {
if (userModel.active == true) {
userModel.fcmToken = await NotificationService.getToken();
await FireStoreUtils.updateUser(userModel);
if (userModel.shippingAddress != null && userModel.shippingAddress!.isNotEmpty) {
final defaultAddress = userModel.shippingAddress!.firstWhere(
(e) => e.isDefault == true,
orElse: () => userModel.shippingAddress!.first,
);
if (userModel.shippingAddress != null &&
userModel.shippingAddress!.isNotEmpty) {
final defaultAddress = userModel.shippingAddress!
.firstWhere(
(e) => e.isDefault == true,
orElse: () => userModel.shippingAddress!.first,
);
Constant.selectedLocation = defaultAddress;
@@ -132,12 +154,16 @@ class LoginController extends GetxController {
}
} else {
await FirebaseAuth.instance.signOut();
ShowToastDialog.showToast("This user is disabled. Please contact admin.".tr());
ShowToastDialog.showToast(
"This user is disabled. Please contact admin.".tr(),
);
Get.offAll(() => const LoginScreen());
}
} else {
await FirebaseAuth.instance.signOut();
ShowToastDialog.showToast("This user does not exist in the customer app.".tr());
ShowToastDialog.showToast(
"This user does not exist in the customer app.".tr(),
);
Get.offAll(() => const LoginScreen());
}
} else {
@@ -148,7 +174,10 @@ class LoginController extends GetxController {
userModel.lastName = value.user!.displayName?.split(' ').last;
userModel.provider = 'google';
Get.off(const SignUpScreen(), arguments: {"userModel": userModel, "type": "google"});
Get.off(
const SignUpScreen(),
arguments: {"userModel": userModel, "type": "google"},
);
}
});
}
@@ -174,22 +203,32 @@ class LoginController extends GetxController {
userModel.lastName = appleCredential.familyName;
userModel.provider = 'apple';
Get.off(const SignUpScreen(), arguments: {"userModel": userModel, "type": "apple"});
Get.off(
const SignUpScreen(),
arguments: {"userModel": userModel, "type": "apple"},
);
} else {
// Existing user
await FireStoreUtils.userExistOrNot(userCredential.user!.uid).then((userExit) async {
await FireStoreUtils.userExistOrNot(userCredential.user!.uid).then((
userExit,
) async {
if (userExit == true) {
UserModel? userModel = await FireStoreUtils.getUserProfile(userCredential.user!.uid);
if (userModel != null && userModel.role == Constant.userRoleCustomer) {
UserModel? userModel = await FireStoreUtils.getUserProfile(
userCredential.user!.uid,
);
if (userModel != null &&
userModel.role == Constant.userRoleCustomer) {
if (userModel.active == true) {
userModel.fcmToken = await NotificationService.getToken();
await FireStoreUtils.updateUser(userModel);
if (userModel.shippingAddress != null && userModel.shippingAddress!.isNotEmpty) {
final defaultAddress = userModel.shippingAddress!.firstWhere(
(e) => e.isDefault == true,
orElse: () => userModel.shippingAddress!.first,
);
if (userModel.shippingAddress != null &&
userModel.shippingAddress!.isNotEmpty) {
final defaultAddress = userModel.shippingAddress!
.firstWhere(
(e) => e.isDefault == true,
orElse: () => userModel.shippingAddress!.first,
);
Constant.selectedLocation = defaultAddress;
Get.offAll(() => const ServiceListScreen());
@@ -198,12 +237,16 @@ class LoginController extends GetxController {
}
} else {
await FirebaseAuth.instance.signOut();
ShowToastDialog.showToast("This user is disabled. Please contact admin.".tr());
ShowToastDialog.showToast(
"This user is disabled. Please contact admin.".tr(),
);
Get.offAll(() => const LoginScreen());
}
} else {
await FirebaseAuth.instance.signOut();
ShowToastDialog.showToast("This user does not exist in the customer app.".tr());
ShowToastDialog.showToast(
"This user does not exist in the customer app.".tr(),
);
Get.offAll(() => const LoginScreen());
}
} else {
@@ -215,7 +258,10 @@ class LoginController extends GetxController {
userModel.lastName = appleCredential.familyName;
userModel.provider = 'apple';
Get.off(const SignUpScreen(), arguments: {"userModel": userModel, "type": "apple"});
Get.off(
const SignUpScreen(),
arguments: {"userModel": userModel, "type": "apple"},
);
}
});
}
@@ -234,8 +280,12 @@ class LoginController extends GetxController {
final GoogleSignInAuthentication googleAuth = googleUser.authentication;
final credential = GoogleAuthProvider.credential(idToken: googleAuth.idToken);
final userCredential = await FirebaseAuth.instance.signInWithCredential(credential);
final credential = GoogleAuthProvider.credential(
idToken: googleAuth.idToken,
);
final userCredential = await FirebaseAuth.instance.signInWithCredential(
credential,
);
return userCredential;
} catch (e) {
@@ -255,17 +305,27 @@ class LoginController extends GetxController {
final rawNonce = generateNonce();
final nonce = sha256ofString(rawNonce);
AuthorizationCredentialAppleID appleCredential = await SignInWithApple.getAppleIDCredential(
scopes: [AppleIDAuthorizationScopes.email, AppleIDAuthorizationScopes.fullName],
nonce: nonce,
AuthorizationCredentialAppleID appleCredential =
await SignInWithApple.getAppleIDCredential(
scopes: [
AppleIDAuthorizationScopes.email,
AppleIDAuthorizationScopes.fullName,
],
nonce: nonce,
);
final oauthCredential = OAuthProvider("apple.com").credential(
idToken: appleCredential.identityToken,
rawNonce: rawNonce,
accessToken: appleCredential.authorizationCode,
);
final oauthCredential = OAuthProvider(
"apple.com",
).credential(idToken: appleCredential.identityToken, rawNonce: rawNonce, accessToken: appleCredential.authorizationCode);
UserCredential userCredential = await FirebaseAuth.instance.signInWithCredential(oauthCredential);
return {"appleCredential": appleCredential, "userCredential": userCredential};
UserCredential userCredential = await FirebaseAuth.instance
.signInWithCredential(oauthCredential);
return {
"appleCredential": appleCredential,
"userCredential": userCredential,
};
} catch (e) {
debugPrint(e.toString());
}