BASE: Switch From EasyLocalization To GetX Localization.
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
import 'dart:convert';
|
||||
import 'package:customer/screen_ui/location_enable_screens/location_permission_screen.dart';
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:customer/utils/app_router.dart';
|
||||
|
||||
import 'package:firebase_auth/firebase_auth.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart' hide Trans;
|
||||
import 'package:get/get.dart';
|
||||
import 'package:google_sign_in/google_sign_in.dart';
|
||||
import 'package:sign_in_with_apple/sign_in_with_apple.dart';
|
||||
import '../constant/constant.dart';
|
||||
@@ -33,18 +34,18 @@ class LoginController extends GetxController {
|
||||
final email = emailController.value.text.trim();
|
||||
final password = passwordController.value.text.trim();
|
||||
if (email.isEmpty || !email.contains('@')) {
|
||||
ShowToastDialog.showToast("Please enter a valid email address".tr());
|
||||
ShowToastDialog.showToast("Please enter a valid email address".tr);
|
||||
return;
|
||||
}
|
||||
|
||||
if (password.isEmpty) {
|
||||
ShowToastDialog.showToast("Please enter your password".tr());
|
||||
ShowToastDialog.showToast("Please enter your password".tr);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
isLoading.value = true;
|
||||
ShowToastDialog.showLoader("Logging in...".tr());
|
||||
ShowToastDialog.showLoader("Logging in...".tr);
|
||||
|
||||
final credential = await FirebaseAuth.instance.signInWithEmailAndPassword(
|
||||
email: email,
|
||||
@@ -69,34 +70,34 @@ class LoginController extends GetxController {
|
||||
|
||||
Constant.selectedLocation = defaultAddress;
|
||||
|
||||
Get.offAll(() => const ServiceListScreen());
|
||||
Get.offAll(ServiceListScreen());
|
||||
} else {
|
||||
Get.offAll(() => const LocationPermissionScreen());
|
||||
Get.offAll(LocationPermissionScreen());
|
||||
}
|
||||
} else {
|
||||
await FirebaseAuth.instance.signOut();
|
||||
ShowToastDialog.showToast(
|
||||
"This user is disabled. Please contact admin.".tr(),
|
||||
"This user is disabled. Please contact admin.".tr,
|
||||
);
|
||||
Get.offAll(() => const LoginScreen());
|
||||
Get.offAll(LoginScreen());
|
||||
}
|
||||
} else {
|
||||
await FirebaseAuth.instance.signOut();
|
||||
ShowToastDialog.showToast(
|
||||
"This user does not exist in the customer app.".tr(),
|
||||
"This user does not exist in the customer app.".tr,
|
||||
);
|
||||
Get.offAll(() => const LoginScreen());
|
||||
Get.offAll(LoginScreen());
|
||||
}
|
||||
} on FirebaseAuthException catch (e) {
|
||||
if (e.code == 'user-not-found') {
|
||||
ShowToastDialog.showToast("No user found for that email.".tr());
|
||||
ShowToastDialog.showToast("No user found for that email.".tr);
|
||||
} else if (e.code == 'wrong-password') {
|
||||
ShowToastDialog.showToast("Wrong password provided.".tr());
|
||||
ShowToastDialog.showToast("Wrong password provided.".tr);
|
||||
} else if (e.code == 'invalid-email') {
|
||||
ShowToastDialog.showToast("Invalid email.".tr());
|
||||
ShowToastDialog.showToast("Invalid email.".tr);
|
||||
} else {
|
||||
ShowToastDialog.showToast(
|
||||
e.message?.tr() ?? "Login failed. Please try again.".tr(),
|
||||
e.message?.tr ?? "Login failed. Please try again.".tr,
|
||||
);
|
||||
}
|
||||
} finally {
|
||||
@@ -106,7 +107,7 @@ class LoginController extends GetxController {
|
||||
}
|
||||
|
||||
Future<void> loginWithGoogle() async {
|
||||
ShowToastDialog.showLoader("please wait...".tr());
|
||||
ShowToastDialog.showLoader("please wait...".tr);
|
||||
await signInWithGoogle().then((value) async {
|
||||
ShowToastDialog.closeLoader();
|
||||
if (value != null) {
|
||||
@@ -148,23 +149,23 @@ class LoginController extends GetxController {
|
||||
|
||||
Constant.selectedLocation = defaultAddress;
|
||||
|
||||
Get.offAll(() => const ServiceListScreen());
|
||||
Get.offAll(ServiceListScreen());
|
||||
} else {
|
||||
Get.offAll(() => const LocationPermissionScreen());
|
||||
Get.offAll(LocationPermissionScreen());
|
||||
}
|
||||
} else {
|
||||
await FirebaseAuth.instance.signOut();
|
||||
ShowToastDialog.showToast(
|
||||
"This user is disabled. Please contact admin.".tr(),
|
||||
"This user is disabled. Please contact admin.".tr,
|
||||
);
|
||||
Get.offAll(() => const LoginScreen());
|
||||
Get.offAll(LoginScreen());
|
||||
}
|
||||
} else {
|
||||
await FirebaseAuth.instance.signOut();
|
||||
ShowToastDialog.showToast(
|
||||
"This user does not exist in the customer app.".tr(),
|
||||
"This user does not exist in the customer app.".tr,
|
||||
);
|
||||
Get.offAll(() => const LoginScreen());
|
||||
Get.offAll(LoginScreen());
|
||||
}
|
||||
} else {
|
||||
UserModel userModel = UserModel();
|
||||
@@ -186,7 +187,7 @@ class LoginController extends GetxController {
|
||||
}
|
||||
|
||||
Future<void> loginWithApple() async {
|
||||
ShowToastDialog.showLoader("please wait...".tr());
|
||||
ShowToastDialog.showLoader("please wait...".tr);
|
||||
await signInWithApple().then((value) async {
|
||||
ShowToastDialog.closeLoader();
|
||||
if (value != null) {
|
||||
@@ -231,23 +232,23 @@ class LoginController extends GetxController {
|
||||
);
|
||||
|
||||
Constant.selectedLocation = defaultAddress;
|
||||
Get.offAll(() => const ServiceListScreen());
|
||||
Get.offAll(ServiceListScreen());
|
||||
} else {
|
||||
Get.offAll(() => const LocationPermissionScreen());
|
||||
Get.offAll(LocationPermissionScreen());
|
||||
}
|
||||
} else {
|
||||
await FirebaseAuth.instance.signOut();
|
||||
ShowToastDialog.showToast(
|
||||
"This user is disabled. Please contact admin.".tr(),
|
||||
"This user is disabled. Please contact admin.".tr,
|
||||
);
|
||||
Get.offAll(() => const LoginScreen());
|
||||
Get.offAll(LoginScreen());
|
||||
}
|
||||
} else {
|
||||
await FirebaseAuth.instance.signOut();
|
||||
ShowToastDialog.showToast(
|
||||
"This user does not exist in the customer app.".tr(),
|
||||
"This user does not exist in the customer app.".tr,
|
||||
);
|
||||
Get.offAll(() => const LoginScreen());
|
||||
Get.offAll(LoginScreen());
|
||||
}
|
||||
} else {
|
||||
// User not in DB → go to signup
|
||||
|
||||
Reference in New Issue
Block a user