Fix 2800 再発のため修正
This commit is contained in:
@ -164,10 +164,10 @@ class IndexController extends GetxController {
|
|||||||
|
|
||||||
void login(String email, String password, BuildContext context) {
|
void login(String email, String password, BuildContext context) {
|
||||||
AuthService.login(email, password).then((value) {
|
AuthService.login(email, password).then((value) {
|
||||||
//print("------- logged in user details ######## $value ###### --------");
|
print("------- logged in user details ######## $value ###### --------");
|
||||||
if (value.isNotEmpty) {
|
if (value.isNotEmpty) {
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
//print("--------- user details login ----- $value");
|
print("--------- user details login ----- $value");
|
||||||
changeUser(value);
|
changeUser(value);
|
||||||
} else {
|
} else {
|
||||||
isLoading.value = false;
|
isLoading.value = false;
|
||||||
@ -251,10 +251,11 @@ class IndexController extends GetxController {
|
|||||||
void saveToDevice(String val) async {
|
void saveToDevice(String val) async {
|
||||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||||
await prefs.setString("user_token", val);
|
await prefs.setString("user_token", val);
|
||||||
|
print("saveToDevice: ${val}");
|
||||||
}
|
}
|
||||||
|
|
||||||
void changeUser(Map<String, dynamic> value, {bool replace = true}) {
|
void changeUser(Map<String, dynamic> value, {bool replace = true}) {
|
||||||
//print("---- change user to $value -----");
|
print("---- change user to $value -----");
|
||||||
currentUser.clear();
|
currentUser.clear();
|
||||||
currentUser.add(value);
|
currentUser.add(value);
|
||||||
if (replace) {
|
if (replace) {
|
||||||
@ -267,13 +268,13 @@ class IndexController extends GetxController {
|
|||||||
} else {
|
} else {
|
||||||
rogMode.value = 1;
|
rogMode.value = 1;
|
||||||
}
|
}
|
||||||
//print('--- c rog mode --- ${rogMode.value}');
|
print('--- c rog mode --- ${rogMode.value}');
|
||||||
Get.toNamed(AppPages.INDEX);
|
Get.toNamed(AppPages.INDEX);
|
||||||
}
|
}
|
||||||
|
|
||||||
loadUserDetailsForToken(String token) async {
|
loadUserDetailsForToken(String token) async {
|
||||||
AuthService.userForToken(token).then((value) {
|
AuthService.userForToken(token).then((value) {
|
||||||
////print("----token val-- $value ------");
|
print("----token val-- $value ------");
|
||||||
if (value![0]["user"].isEmpty) {
|
if (value![0]["user"].isEmpty) {
|
||||||
Get.toNamed(AppPages.LOGIN);
|
Get.toNamed(AppPages.LOGIN);
|
||||||
return;
|
return;
|
||||||
@ -353,52 +354,61 @@ class IndexController extends GetxController {
|
|||||||
|
|
||||||
isLoading.value = true; // ローディング状態をtrueに設定
|
isLoading.value = true; // ローディング状態をtrueに設定
|
||||||
|
|
||||||
LocationService.loadLocationsBound(
|
Future.delayed(const Duration(seconds: 1), () async {
|
||||||
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) {
|
//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})");
|
||||||
// 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リクエストが失敗した場合
|
var value = await LocationService.loadLocationsBound(
|
||||||
Get.snackbar(
|
bounds.southWest.latitude,
|
||||||
"Error",
|
bounds.southWest.longitude,
|
||||||
"Failed to load locations. Please check your internet connection and try again.",
|
bounds.northWest.latitude,
|
||||||
icon: const Icon(Icons.error, size: 40.0, color: Colors.red),
|
bounds.northWest.longitude,
|
||||||
snackPosition: SnackPosition.TOP,
|
bounds.northEast.latitude,
|
||||||
duration: const Duration(milliseconds: 800),
|
bounds.northEast.longitude,
|
||||||
backgroundColor: Colors.yellow,
|
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