Fix 2800 再発のため修正
This commit is contained in:
@ -164,10 +164,10 @@ class IndexController extends GetxController {
|
||||
|
||||
void login(String email, String password, BuildContext context) {
|
||||
AuthService.login(email, password).then((value) {
|
||||
//print("------- logged in user details ######## $value ###### --------");
|
||||
print("------- logged in user details ######## $value ###### --------");
|
||||
if (value.isNotEmpty) {
|
||||
Navigator.pop(context);
|
||||
//print("--------- user details login ----- $value");
|
||||
print("--------- user details login ----- $value");
|
||||
changeUser(value);
|
||||
} else {
|
||||
isLoading.value = false;
|
||||
@ -251,10 +251,11 @@ class IndexController extends GetxController {
|
||||
void saveToDevice(String val) async {
|
||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
await prefs.setString("user_token", val);
|
||||
print("saveToDevice: ${val}");
|
||||
}
|
||||
|
||||
void changeUser(Map<String, dynamic> value, {bool replace = true}) {
|
||||
//print("---- change user to $value -----");
|
||||
print("---- change user to $value -----");
|
||||
currentUser.clear();
|
||||
currentUser.add(value);
|
||||
if (replace) {
|
||||
@ -267,13 +268,13 @@ class IndexController extends GetxController {
|
||||
} else {
|
||||
rogMode.value = 1;
|
||||
}
|
||||
//print('--- c rog mode --- ${rogMode.value}');
|
||||
print('--- c rog mode --- ${rogMode.value}');
|
||||
Get.toNamed(AppPages.INDEX);
|
||||
}
|
||||
|
||||
loadUserDetailsForToken(String token) async {
|
||||
AuthService.userForToken(token).then((value) {
|
||||
////print("----token val-- $value ------");
|
||||
print("----token val-- $value ------");
|
||||
if (value![0]["user"].isEmpty) {
|
||||
Get.toNamed(AppPages.LOGIN);
|
||||
return;
|
||||
@ -353,52 +354,61 @@ class IndexController extends GetxController {
|
||||
|
||||
isLoading.value = true; // ローディング状態をtrueに設定
|
||||
|
||||
LocationService.loadLocationsBound(
|
||||
bounds.southWest.latitude,
|
||||
bounds.southWest.longitude,
|
||||
bounds.northWest.latitude,
|
||||
bounds.northWest.longitude,
|
||||
bounds.northEast.latitude,
|
||||
bounds.northEast.longitude,
|
||||
bounds.southEast.latitude,
|
||||
bounds.southEast.longitude,
|
||||
cat
|
||||
).then((value) {
|
||||
isLoading.value = false; // ローディング状態をfalseに設定
|
||||
|
||||
if (value == null) {
|
||||
// APIからのレスポンスがnullの場合は処理を中断
|
||||
return;
|
||||
}
|
||||
if (value.features.isEmpty) {
|
||||
if (showPopup == false) {
|
||||
return;
|
||||
}
|
||||
Get.snackbar(
|
||||
"Too many Points",
|
||||
"please zoom in",
|
||||
icon: const Icon(Icons.assistant_photo_outlined, size: 40.0, color: Colors.blue),
|
||||
snackPosition: SnackPosition.TOP,
|
||||
duration: const Duration(seconds: 3),
|
||||
backgroundColor: Colors.yellow,
|
||||
);
|
||||
showPopup = false;
|
||||
}
|
||||
if (value.features.isNotEmpty) {
|
||||
locations.add(value);
|
||||
}
|
||||
}).catchError((error) {
|
||||
isLoading.value = false; // ローディング状態をfalseに設定
|
||||
|
||||
// エラーハンドリング: APIリクエストが失敗した場合
|
||||
Get.snackbar(
|
||||
"Error",
|
||||
"Failed to load locations. Please check your internet connection and try again.",
|
||||
icon: const Icon(Icons.error, size: 40.0, color: Colors.red),
|
||||
snackPosition: SnackPosition.TOP,
|
||||
duration: const Duration(milliseconds: 800),
|
||||
backgroundColor: Colors.yellow,
|
||||
Future.delayed(const Duration(seconds: 1), () async {
|
||||
|
||||
//print("bounds --- (${bounds.southWest.latitude},${bounds.southWest.longitude}),(${bounds.northWest.latitude},${bounds.northWest.longitude}),(${bounds.northEast.latitude},${bounds.northEast.longitude}),(${bounds.southEast.latitude},${bounds.southEast.longitude})");
|
||||
|
||||
var value = await LocationService.loadLocationsBound(
|
||||
bounds.southWest.latitude,
|
||||
bounds.southWest.longitude,
|
||||
bounds.northWest.latitude,
|
||||
bounds.northWest.longitude,
|
||||
bounds.northEast.latitude,
|
||||
bounds.northEast.longitude,
|
||||
bounds.southEast.latitude,
|
||||
bounds.southEast.longitude,
|
||||
cat
|
||||
);
|
||||
if ( value == null ) {
|
||||
// エラーハンドリング: APIからのレスポンスがnullの場合
|
||||
/*
|
||||
Get.snackbar(
|
||||
"Error",
|
||||
"Failed to load locations. Please try again. === 1",
|
||||
icon: const Icon(Icons.error, size: 40.0, color: Colors.red),
|
||||
snackPosition: SnackPosition.TOP,
|
||||
duration: const Duration(seconds: 3),
|
||||
backgroundColor: Colors.yellow,
|
||||
);
|
||||
*/
|
||||
// APIからのレスポンスがnullの場合
|
||||
DestinationController destinationController = Get.find<DestinationController>(); // 追加
|
||||
final tk = currentUser[0]["token"]; // 追加
|
||||
if (tk != null) { // 追加
|
||||
destinationController.fixMapBound(tk); // 追加
|
||||
} // 追加
|
||||
// return;
|
||||
}
|
||||
isLoading.value = false; // ローディング状態をfalseに設定
|
||||
|
||||
if (value!=null && value.features.isEmpty) {
|
||||
if (showPopup == false) {
|
||||
return;
|
||||
}
|
||||
Get.snackbar(
|
||||
"Too many Points",
|
||||
"please zoom in",
|
||||
icon: const Icon(Icons.assistant_photo_outlined, size: 40.0, color: Colors.blue),
|
||||
snackPosition: SnackPosition.TOP,
|
||||
duration: const Duration(seconds: 3),
|
||||
backgroundColor: Colors.yellow,
|
||||
);
|
||||
showPopup = false;
|
||||
}
|
||||
if (value!=null && value.features.isNotEmpty) {
|
||||
locations.add(value);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user