Snackbar の色を変更。ロゲ開始時のエラーを回避。

This commit is contained in:
2024-04-27 10:48:21 +09:00
parent 72267f29bb
commit aada6262fe
21 changed files with 253 additions and 742 deletions

View File

@ -243,7 +243,10 @@ class CameraPage extends StatelessWidget {
destinationController.skipGps = false;
destinationController.isPhotoShoot.value = false;
Get.snackbar("チェックインしました。",
"${destination.sub_loc_id} : ${destination.name}");
"${destination.sub_loc_id} : ${destination.name}",
backgroundColor: Colors.green,
colorText: Colors.white
);
},
child: const Text("チェックイン"))
: Container())
@ -307,12 +310,18 @@ class CameraPage extends StatelessWidget {
if (value['status'] == 'OK') {
Get.back();
destinationController.skipGps = false;
Get.snackbar("目標が保存されました", "目標が正常に追加されました");
Get.snackbar("目標が保存されました", "目標が正常に追加されました",
backgroundColor: Colors.green,
colorText: Colors.white
);
destinationController.resetRogaining(
isgoal: true);
} else {
//print("---- status ${value['status']} ---- ");
Get.snackbar("目標が追加されていません", "please_try_again");
Get.snackbar("目標が追加されていません", "please_try_again",
backgroundColor: Colors.green,
colorText: Colors.white
);
}
});
} on Exception catch (_) {
@ -358,7 +367,10 @@ class CameraPage extends StatelessWidget {
destinationController.skipGps = false;
destinationController.isPhotoShoot.value = false;
Get.snackbar("お買い物加点を行いました。",
"${destination.sub_loc_id} : ${destination.name}");
"${destination.sub_loc_id} : ${destination.name}",
backgroundColor: Colors.green,
colorText: Colors.white
);
},
child: const Text("レシートの写真を撮ってください"))
: Container())
@ -395,7 +407,10 @@ class CameraPage extends StatelessWidget {
destinationController.skipGps = false;
destinationController.isPhotoShoot.value = false;
Get.snackbar("お買い物加点を行いました。",
"${destination.sub_loc_id} : ${destination.name}");
"${destination.sub_loc_id} : ${destination.name}",
backgroundColor: Colors.green,
colorText: Colors.white
);
},
child: const Text("QRコードを読み取ってください"))
: Container())
@ -430,7 +445,10 @@ class CameraPage extends StatelessWidget {
Get.snackbar(
"チェックインしました",
indexController.currentDestinationFeature[0].name ??
"");
"",
backgroundColor: Colors.green,
colorText: Colors.white
);
},
child: const Text("チェックイン"))
: Container())
@ -677,7 +695,10 @@ class BuyPointCamera extends StatelessWidget {
destinationController.skipGps = false;
destinationController.isPhotoShoot.value = false;
Get.snackbar("お買い物加点を行いました",
"${destination.sub_loc_id} : ${destination.name}");
"${destination.sub_loc_id} : ${destination.name}",
backgroundColor: Colors.green,
colorText: Colors.white
);
},
child: const Text("完了"))
],

View File

@ -92,14 +92,16 @@ class ChangePasswordPage extends StatelessWidget {
Get.snackbar(
"no_values".tr,
"values_required".tr,
icon: const Icon(
backgroundColor: Colors.red,
colorText: Colors.white,
icon: const Icon(
Icons.assistant_photo_outlined,
size: 40.0,
color: Colors.blue),
snackPosition: SnackPosition.TOP,
duration: const Duration(
milliseconds: 800),
backgroundColor: Colors.yellow,
//backgroundColor: Colors.yellow,
//icon:Image(image:AssetImage("assets/images/dora.png"))
);
return;

View File

@ -33,6 +33,7 @@ import 'package:shared_preferences/shared_preferences.dart';
import 'package:image_gallery_saver/image_gallery_saver.dart';
import 'package:rogapp/utils/const.dart';
import 'package:logger/logger.dart';
// 目的地に関連する状態管理とロジックを担当するクラスです。
//
@ -325,6 +326,16 @@ class DestinationController extends GetxController {
ds.isNotEmpty && ds[0].checkedin == true ? true : false;
bool isuserLoggedIn = indexController.currentUser.isNotEmpty ? true : false; // ログイン済みか
/*
// スタートとゴールは除外
debugPrint("startTimer CP=${d.cp}");
if (d.cp == -1 || d.cp == 0 || d.cp == -2) {
skipGps = false;
return;
}
*/
// 初期化。GPS信号が強くても弱くても
if (checkinRadious >= distance || checkinRadious == -1) {
//currentSelectedDestinations.add(d);
@ -835,11 +846,13 @@ class DestinationController extends GetxController {
Get.snackbar(
"ロゲが始まっていません",
"ロゲ開始ボタンをタップして、ロゲイニングを始める必要があります",
icon: const Icon(
backgroundColor: Colors.yellow,
colorText: Colors.white,
icon: const Icon(
Icons.assistant_photo_outlined, size: 40.0, color: Colors.blue),
snackPosition: SnackPosition.TOP,
duration: const Duration(seconds: 3),
backgroundColor: Colors.yellow,
duration: const Duration(seconds: 3)
// backgroundColor: Colors.yellow,
);
}
}
@ -940,6 +953,8 @@ class DestinationController extends GetxController {
}
}
// ロゲイニングにデータを追加する関数です。
//
void addToRogaining(double lat, double lon, int destinationId) async {
@ -966,13 +981,18 @@ class DestinationController extends GetxController {
// 指定されたパスの画像をギャラリーに保存する関数です。
//
_saveImageFromPath(String imagePath) async {
// Read the image file from the given path
File imageFile = File(imagePath);
Uint8List imageBytes = await imageFile.readAsBytes();
try {
// Read the image file from the given path
File imageFile = File(imagePath);
Uint8List imageBytes = await imageFile.readAsBytes();
// Save the image to the gallery
final result = await ImageGallerySaver.saveImage(imageBytes);
//print("--- save result --- ${result}");
// Save the image to the gallery
final result = await ImageGallerySaver.saveImage(imageBytes);
//print("--- save result --- ${result}");
} catch(e, stackTrace){
print('エラーが発生しました: $e');
print('スタックトレース: $stackTrace');
}
}
// 買い物ポイントを作成する関数です。 指定された目的地に対して買い物ポイントの処理を行います。
@ -1009,64 +1029,82 @@ class DestinationController extends GetxController {
}
}
// チェックインを行う関数です。 指定された目的地に対してチェックインの処理を行います。
//
// 要検討:チェックインのリクエストが失敗した場合のエラーハンドリングを追加することをお勧めします。
//
Future<void> makeCheckin(
Destination destination, bool action, String imageurl) async {
// print("~~~~ calling checkin function ~~~~");
// print(
// "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ressssss ${destination.sub_loc_id}@@@@@@@@@@@");
DatabaseHelper db = DatabaseHelper.instance;
List<Destination> ddd =
await db.getDestinationByLatLon(destination.lat!, destination.lon!);
if (ddd.isEmpty) {
destination.checkedin = true;
destination.checkin_image = imageurl;
await db.insertDestination(destination);
// print("~~~~ inserted into db ~~~~");
}
try {
// print("~~~~ calling checkin function ~~~~");
// print(
// "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ressssss ${destination.sub_loc_id}@@@@@@@@@@@");
DatabaseHelper db = DatabaseHelper.instance;
List<Destination> ddd =
await db.getDestinationByLatLon(destination.lat!, destination.lon!);
if (imageurl == null || imageurl.isEmpty) {
if (photos.isNotEmpty) {
// imageurlが空の場合は、destinationcheckin_imageプロパティを使用する
debugPrint("photos = ${photos}");
imageurl = photos[0].path;
if (ddd.isEmpty) {
destination.checkedin = true;
destination.checkin_image = imageurl;
await db.insertDestination(destination);
// print("~~~~ inserted into db ~~~~");
}
debugPrint("imageurl = ${imageurl}");
await _saveImageFromPath(imageurl!);
if (imageurl == null || imageurl.isEmpty) {
if (photos.isNotEmpty) {
// imageurlが空の場合は、destinationのcheckin_imageプロパティを使用する
debugPrint("photos = ${photos}");
imageurl = photos[0].path;
}
debugPrint("imageurl = ${imageurl}");
await _saveImageFromPath(imageurl!);
}
populateDestinations();
/// post to NATNAT
if (indexController.currentUser.isNotEmpty) {
double cpNum = destination.cp!;
int userId = indexController.currentUser[0]["user"]["id"];
//print("--- Pressed -----");
String team = indexController.currentUser[0]["user"]['team_name'];
//print("--- _team : ${_team}-----");
String eventCode = indexController.currentUser[0]["user"]["event_code"];
//print("--- _event_code : ${_event_code}-----");
String token = indexController.currentUser[0]["token"];
//print("--- _token : ${_token}-----");
DateTime now = DateTime.now();
String formattedDate = DateFormat('yyyy-MM-dd HH:mm:ss').format(now);
await addGPStoDB(currentLat, currentLon, isCheckin: 1);
// print("------ checkin event $eventCode ------");
ExternalService()
.makeCheckpoint(
userId,
token,
formattedDate,
team,
cpNum.round(),
eventCode,
imageurl)
.then((value) {
// print("------Ext service check point $value ------");
});
}
// dbService.updateDatabase();
}catch(e, stacktrace){
print("エラー:${e}");
//print("stack : ${stacktrace}");
}finally{
dbService.updateDatabase();
}
populateDestinations();
/// post to NATNAT
if (indexController.currentUser.isNotEmpty) {
double cpNum = destination.cp!;
int userId = indexController.currentUser[0]["user"]["id"];
//print("--- Pressed -----");
String team = indexController.currentUser[0]["user"]['team_name'];
//print("--- _team : ${_team}-----");
String eventCode = indexController.currentUser[0]["user"]["event_code"];
//print("--- _event_code : ${_event_code}-----");
String token = indexController.currentUser[0]["token"];
//print("--- _token : ${_token}-----");
DateTime now = DateTime.now();
String formattedDate = DateFormat('yyyy-MM-dd HH:mm:ss').format(now);
await addGPStoDB(currentLat, currentLon, isCheckin: 1);
// print("------ checkin event $eventCode ------");
ExternalService()
.makeCheckpoint(userId, token, formattedDate, team, cpNum.round(),
eventCode, imageurl)
.then((value) {
// print("------Ext service check point $value ------");
});
}
dbService.updateDatabase();
}
// チェックインを削除する関数です。
@ -1580,11 +1618,13 @@ class DestinationController extends GetxController {
Get.snackbar(
"画面切り替えでエラー",
"画面の切り替えができませんでした",
icon: const Icon(
backgroundColor: Colors.red,
colorText: Colors.white,
icon: const Icon(
Icons.assistant_photo_outlined, size: 40.0, color: Colors.blue),
snackPosition: SnackPosition.TOP,
duration: const Duration(seconds: 3),
backgroundColor: Colors.yellow,
//backgroundColor: Colors.yellow,
);
}

View File

@ -4,6 +4,7 @@ import 'package:rogapp/pages/destination/destination_controller.dart';
import 'package:rogapp/pages/index/index_controller.dart';
import 'package:rogapp/routes/app_pages.dart';
import 'package:rogapp/services/auth_service.dart';
import 'package:rogapp/utils/database_helper.dart';
import 'package:url_launcher/url_launcher.dart';
// SafeAreaウィジェットを使用して、画面の安全領域内にメニューを表示しています。
@ -127,12 +128,26 @@ class DrawerPage extends StatelessWidget {
textConfirm: "確認する",
textCancel: "キャンセルする",
onCancel: () => Get.back(),
onConfirm: () {
onConfirm: () async {
DestinationController destinationController =
Get.find<DestinationController>();
DatabaseHelper databaseHelper = DatabaseHelper.instance;
// ゲーム中のデータを削除
await databaseHelper.deleteAllRogaining();
await databaseHelper.deleteAllDestinations();
destinationController.resetRogaining();
destinationController.deleteDBDestinations();
//destinationController.resetRogaining();
//destinationController.deleteDBDestinations();
Get.back();
Get.snackbar(
"リセット完了",
"すべてリセットされました。ロゲ開始から再開して下さい。",
backgroundColor: Colors.green,
colorText: Colors.white,
duration: const Duration(seconds: 3),
);
},
);
},
@ -161,7 +176,10 @@ class DrawerPage extends StatelessWidget {
indexController.logout();
Get.toNamed(AppPages.TRAVEL);
Get.snackbar("accounted_deleted".tr,
"account_deleted_message".tr);
"account_deleted_message".tr,
backgroundColor: Colors.green,
colorText: Colors.white
);
}
});
},
@ -172,6 +190,7 @@ class DrawerPage extends StatelessWidget {
width: 0,
height: 0,
),
/*
// ユーザーデータ削除のアイテムは、ユーザーがログインしている場合にのみ表示されます。
// タップすると、AuthService.deleteUser()を呼び出してユーザーデータを削除します。
indexController.currentUser.isNotEmpty
@ -215,7 +234,7 @@ class DrawerPage extends StatelessWidget {
// title: Text("point_rank".tr),
// onTap: (){},
// ),
*/
// "rog_web".trというテキストのアイテムは、ユーザーがログインしている場合にのみ表示されます。
// タップすると、_launchURL()メソッドを呼び出して外部のウェブサイトを開きます。
indexController.currentUser.isNotEmpty

View File

@ -101,7 +101,7 @@ class _GpsPageState extends State<GpsPage> {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("GPS way points"),
title: Text("移動履歴"),
),
body: Container(
child: Obx(

View File

@ -205,10 +205,12 @@ class IndexController extends GetxController {
Get.snackbar(
"ログイン失敗",
"ログインIDかパスワードを確認して下さい。",
icon: const Icon(Icons.error, size: 40.0, color: Colors.blue),
backgroundColor: Colors.red,
colorText: Colors.white,
icon: const Icon(Icons.error, size: 40.0, color: Colors.blue),
snackPosition: SnackPosition.TOP,
duration: const Duration(seconds: 3),
backgroundColor: Colors.yellow,
//backgroundColor: Colors.yellow,
//icon:Image(image:AssetImage("assets/images/dora.png"))
);
}
@ -235,10 +237,12 @@ class IndexController extends GetxController {
Get.snackbar(
'failed'.tr,
'password_change_failed_please_try_again'.tr,
icon: const Icon(Icons.error, size: 40.0, color: Colors.blue),
backgroundColor: Colors.red,
colorText: Colors.white,
icon: const Icon(Icons.error, size: 40.0, color: Colors.blue),
snackPosition: SnackPosition.TOP,
duration: const Duration(milliseconds: 800),
backgroundColor: Colors.yellow,
//backgroundColor: Colors.yellow,
//icon:Image(image:AssetImage("assets/images/dora.png"))
);
}
@ -277,10 +281,12 @@ class IndexController extends GetxController {
Get.snackbar(
'failed'.tr,
'user_registration_failed_please_try_again'.tr,
icon: const Icon(Icons.error, size: 40.0, color: Colors.blue),
backgroundColor: Colors.red,
colorText: Colors.white,
icon: const Icon(Icons.error, size: 40.0, color: Colors.blue),
snackPosition: SnackPosition.TOP,
duration: const Duration(milliseconds: 800),
backgroundColor: Colors.yellow,
//backgroundColor: Colors.yellow,
//icon:Image(image:AssetImage("assets/images/dora.png"))
);
}
@ -455,11 +461,13 @@ class IndexController extends GetxController {
Get.snackbar(
"Too many Points",
"please zoom in",
icon: const Icon(
backgroundColor: Colors.yellow,
colorText: Colors.white,
icon: const Icon(
Icons.assistant_photo_outlined, size: 40.0, color: Colors.blue),
snackPosition: SnackPosition.TOP,
duration: const Duration(seconds: 3),
backgroundColor: Colors.yellow,
//backgroundColor: Colors.yellow,
);
showPopup = false;
}

View File

@ -107,7 +107,9 @@ class LoginPage extends StatelessWidget {
"no_values".tr,
"email_and_password_required"
.tr,
icon: const Icon(
backgroundColor: Colors.red,
colorText: Colors.white,
icon: const Icon(
Icons
.assistant_photo_outlined,
size: 40.0,
@ -116,7 +118,7 @@ class LoginPage extends StatelessWidget {
SnackPosition.TOP,
duration: const Duration(
seconds: 3),
backgroundColor: Colors.yellow,
// backgroundColor: Colors.yellow,
//icon:Image(image:AssetImage("assets/images/dora.png"))
);
return;
@ -262,10 +264,11 @@ class LoginPage extends StatelessWidget {
child: Padding(
padding: EdgeInsets.all(8.0),
child: Text(
"※第8回と第9回は、岐阜県からの「清流の国ぎふ」SDGs推進ネットワーク連携促進補助金を受けています",
"※第8回と第9回は、岐阜県の令和5年度「清流の国ぎふ」SDGs推進ネットワーク連携促進補助金を受けています",
style: TextStyle(
//overflow: TextOverflow.ellipsis,
fontSize:
12, // Consider adjusting the font size if the text is too small.
10.0, // Consider adjusting the font size if the text is too small.
// Removed overflow: TextOverflow.ellipsis to allow text wrapping.
),
),

View File

@ -100,6 +100,8 @@ class LoginPopupPage extends StatelessWidget {
"no_values".tr,
"email_and_password_required"
.tr,
backgroundColor: Colors.red,
colorText: Colors.white,
icon: const Icon(
Icons
.assistant_photo_outlined,
@ -109,7 +111,7 @@ class LoginPopupPage extends StatelessWidget {
SnackPosition.TOP,
duration: const Duration(
milliseconds: 800),
backgroundColor: Colors.yellow,
//backgroundColor: Colors.yellow,
//icon:Image(image:AssetImage("assets/images/dora.png"))
);
return;

View File

@ -101,11 +101,13 @@ class RegisterPage extends StatelessWidget {
Get.snackbar(
"No match",
"Passwords does not match",
icon: const Icon(Icons.assistant_photo_outlined,
backgroundColor: Colors.red,
colorText: Colors.white,
icon: const Icon(Icons.assistant_photo_outlined,
size: 40.0, color: Colors.blue),
snackPosition: SnackPosition.TOP,
duration: const Duration(milliseconds: 800),
backgroundColor: Colors.yellow,
// backgroundColor: Colors.yellow,
//icon:Image(image:AssetImage("assets/images/dora.png"))
);
}
@ -114,11 +116,13 @@ class RegisterPage extends StatelessWidget {
Get.snackbar(
"no_values".tr,
"email_and_password_required".tr,
icon: const Icon(Icons.assistant_photo_outlined,
backgroundColor: Colors.red,
colorText: Colors.white,
icon: const Icon(Icons.assistant_photo_outlined,
size: 40.0, color: Colors.blue),
snackPosition: SnackPosition.TOP,
duration: const Duration(milliseconds: 800),
backgroundColor: Colors.yellow,
//backgroundColor: Colors.yellow,
//icon:Image(image:AssetImage("assets/images/dora.png"))
);
return;