fix: adding adjustment on the login app
This commit is contained in:
parent
0283806cf3
commit
b77229c26a
|
@ -12,7 +12,7 @@ class MyApp extends StatelessWidget {
|
||||||
return GetMaterialApp(
|
return GetMaterialApp(
|
||||||
title: 'Quiz App',
|
title: 'Quiz App',
|
||||||
locale: Get.locale ?? context.locale,
|
locale: Get.locale ?? context.locale,
|
||||||
fallbackLocale: const Locale('en', 'US'),
|
fallbackLocale: const Locale('id', 'ID'),
|
||||||
localizationsDelegates: context.localizationDelegates,
|
localizationsDelegates: context.localizationDelegates,
|
||||||
supportedLocales: context.supportedLocales,
|
supportedLocales: context.supportedLocales,
|
||||||
initialBinding: InitialBindings(),
|
initialBinding: InitialBindings(),
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
class APIEndpoint {
|
class APIEndpoint {
|
||||||
static const String baseUrl = "http://192.168.1.18:5000";
|
// static const String baseUrl = "http://172.16.106.19:5000";
|
||||||
// static const String baseUrl = "http://103.193.178.121:5000";
|
static const String baseUrl = "http://103.193.178.121:5000";
|
||||||
static const String api = "$baseUrl/api";
|
static const String api = "$baseUrl/api";
|
||||||
|
|
||||||
static const String login = "/login";
|
static const String login = "/login";
|
||||||
|
|
|
@ -107,7 +107,7 @@ class QuizService extends GetxService {
|
||||||
Future<BaseResponseModel<List<QuizListingModel>>?> recommendationQuiz({int page = 1, int amount = 3, String userId = ""}) async {
|
Future<BaseResponseModel<List<QuizListingModel>>?> recommendationQuiz({int page = 1, int amount = 3, String userId = ""}) async {
|
||||||
try {
|
try {
|
||||||
Locale locale = Localizations.localeOf(Get.context!);
|
Locale locale = Localizations.localeOf(Get.context!);
|
||||||
final response = await dio.get("${APIEndpoint.quizRecommendation}?page=$page&limit=$amount&user_id$userId&lang_code=${locale.languageCode}");
|
final response = await dio.get("${APIEndpoint.quizRecommendation}?page=$page&limit=$amount&user_id=$userId&lang_code=${locale.languageCode}");
|
||||||
|
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
final parsedResponse = BaseResponseModel<List<QuizListingModel>>.fromJson(
|
final parsedResponse = BaseResponseModel<List<QuizListingModel>>.fromJson(
|
||||||
|
|
|
@ -3,6 +3,7 @@ import 'package:get/get.dart';
|
||||||
import 'package:quiz_app/app/routes/app_pages.dart';
|
import 'package:quiz_app/app/routes/app_pages.dart';
|
||||||
import 'package:quiz_app/component/global_button.dart';
|
import 'package:quiz_app/component/global_button.dart';
|
||||||
import 'package:quiz_app/core/helper/connection_check.dart';
|
import 'package:quiz_app/core/helper/connection_check.dart';
|
||||||
|
import 'package:quiz_app/core/utils/custom_floating_loading.dart';
|
||||||
import 'package:quiz_app/core/utils/custom_notification.dart';
|
import 'package:quiz_app/core/utils/custom_notification.dart';
|
||||||
import 'package:quiz_app/core/utils/logger.dart';
|
import 'package:quiz_app/core/utils/logger.dart';
|
||||||
import 'package:quiz_app/data/controllers/user_controller.dart';
|
import 'package:quiz_app/data/controllers/user_controller.dart';
|
||||||
|
@ -87,6 +88,7 @@ class LoginController extends GetxController {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
isLoading.value = true;
|
isLoading.value = true;
|
||||||
|
CustomFloatingLoading.showLoadingDialog(Get.context!);
|
||||||
|
|
||||||
final LoginResponseModel response = await _authService.loginWithEmail(
|
final LoginResponseModel response = await _authService.loginWithEmail(
|
||||||
LoginRequestModel(email: email, password: password),
|
LoginRequestModel(email: email, password: password),
|
||||||
|
@ -97,13 +99,12 @@ class LoginController extends GetxController {
|
||||||
await _userStorageService.saveUser(userEntity);
|
await _userStorageService.saveUser(userEntity);
|
||||||
_userController.setUserFromEntity(userEntity);
|
_userController.setUserFromEntity(userEntity);
|
||||||
_userStorageService.isLogged = true;
|
_userStorageService.isLogged = true;
|
||||||
|
CustomFloatingLoading.hideLoadingDialog(Get.context!);
|
||||||
Get.offAllNamed(AppRoutes.mainPage);
|
Get.offAllNamed(AppRoutes.mainPage);
|
||||||
} catch (e, stackTrace) {
|
} catch (e, stackTrace) {
|
||||||
logC.e(e, stackTrace: stackTrace);
|
logC.e(e, stackTrace: stackTrace);
|
||||||
|
CustomFloatingLoading.hideLoadingDialog(Get.context!);
|
||||||
CustomNotification.error(title: "Gagal", message: "Periksa kembali email dan kata sandi Anda");
|
CustomNotification.error(title: "Gagal", message: "Periksa kembali email dan kata sandi Anda");
|
||||||
} finally {
|
|
||||||
isLoading.value = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,15 +114,20 @@ class LoginController extends GetxController {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
CustomFloatingLoading.showLoadingDialog(Get.context!);
|
||||||
final user = await _googleAuthService.signIn();
|
final user = await _googleAuthService.signIn();
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
Get.snackbar("Kesalahan", "Masuk dengan Google dibatalkan");
|
Get.snackbar("Kesalahan", "Masuk dengan Google dibatalkan");
|
||||||
|
|
||||||
|
CustomFloatingLoading.hideLoadingDialog(Get.context!);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final idToken = await user.authentication.then((auth) => auth.idToken);
|
final idToken = await user.authentication.then((auth) => auth.idToken);
|
||||||
if (idToken == null || idToken.isEmpty) {
|
if (idToken == null || idToken.isEmpty) {
|
||||||
Get.snackbar("Kesalahan", "Tidak menerima ID Token dari Google");
|
Get.snackbar("Kesalahan", "Tidak menerima ID Token dari Google");
|
||||||
|
|
||||||
|
CustomFloatingLoading.hideLoadingDialog(Get.context!);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,7 +137,7 @@ class LoginController extends GetxController {
|
||||||
await _userStorageService.saveUser(userEntity);
|
await _userStorageService.saveUser(userEntity);
|
||||||
_userController.setUserFromEntity(userEntity);
|
_userController.setUserFromEntity(userEntity);
|
||||||
_userStorageService.isLogged = true;
|
_userStorageService.isLogged = true;
|
||||||
|
CustomFloatingLoading.hideLoadingDialog(Get.context!);
|
||||||
Get.offAllNamed(AppRoutes.mainPage);
|
Get.offAllNamed(AppRoutes.mainPage);
|
||||||
} catch (e, stackTrace) {
|
} catch (e, stackTrace) {
|
||||||
logC.e("Google Sign-In Error: $e", stackTrace: stackTrace);
|
logC.e("Google Sign-In Error: $e", stackTrace: stackTrace);
|
||||||
|
|
|
@ -29,7 +29,8 @@ void main() {
|
||||||
Locale('ms', 'MY'),
|
Locale('ms', 'MY'),
|
||||||
],
|
],
|
||||||
path: 'assets/translations',
|
path: 'assets/translations',
|
||||||
fallbackLocale: Locale('en', 'US'),
|
fallbackLocale: Locale('id', 'ID'),
|
||||||
|
startLocale: Locale('id', 'ID'),
|
||||||
useOnlyLangCode: false,
|
useOnlyLangCode: false,
|
||||||
child: MyApp(),
|
child: MyApp(),
|
||||||
),
|
),
|
||||||
|
|
Loading…
Reference in New Issue