BASE: Initialize Localization.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import 'dart:convert';
|
||||
import 'package:customer/screen_ui/location_enable_screens/location_permission_screen.dart';
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:firebase_auth/firebase_auth.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
@@ -32,18 +33,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, password: password);
|
||||
|
||||
@@ -68,23 +69,23 @@ 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) {
|
||||
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);
|
||||
ShowToastDialog.showToast(e.message?.tr() ?? "Login failed. Please try again.".tr());
|
||||
}
|
||||
} finally {
|
||||
isLoading.value = false;
|
||||
@@ -93,7 +94,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) {
|
||||
@@ -131,12 +132,12 @@ 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 {
|
||||
@@ -156,7 +157,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) {
|
||||
@@ -197,12 +198,12 @@ 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 {
|
||||
|
||||
Reference in New Issue
Block a user