2022-03-14 12:28:57 +05:30
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
import 'package:get/get.dart';
|
2023-09-12 22:08:03 +05:30
|
|
|
|
import 'package:rogapp/pages/destination/destination_controller.dart';
|
2022-09-14 19:51:50 +05:30
|
|
|
|
import 'package:rogapp/pages/index/index_controller.dart';
|
2022-05-12 02:17:08 +05:30
|
|
|
|
import 'package:rogapp/routes/app_pages.dart';
|
2023-01-06 16:48:47 +05:30
|
|
|
|
import 'package:rogapp/services/auth_service.dart';
|
2024-04-27 10:48:21 +09:00
|
|
|
|
import 'package:rogapp/utils/database_helper.dart';
|
2024-07-15 06:54:02 +09:00
|
|
|
|
import 'package:rogapp/widgets/debug_widget.dart';
|
2022-09-22 20:36:56 +05:30
|
|
|
|
import 'package:url_launcher/url_launcher.dart';
|
2024-04-30 22:11:33 +09:00
|
|
|
|
import 'package:rogapp/pages/WebView/WebView_page.dart';
|
2022-03-14 12:28:57 +05:30
|
|
|
|
|
2024-04-20 17:30:26 +09:00
|
|
|
|
// SafeAreaウィジェットを使用して、画面の安全領域内にメニューを表示しています。
|
|
|
|
|
|
// Columnウィジェットを使用して、メニューアイテムを縦に並べています。
|
|
|
|
|
|
//
|
2022-03-14 12:28:57 +05:30
|
|
|
|
class DrawerPage extends StatelessWidget {
|
2023-09-12 22:08:03 +05:30
|
|
|
|
DrawerPage({Key? key}) : super(key: key);
|
2022-03-14 12:28:57 +05:30
|
|
|
|
|
2022-09-14 19:51:50 +05:30
|
|
|
|
final IndexController indexController = Get.find<IndexController>();
|
2022-03-14 12:28:57 +05:30
|
|
|
|
|
2024-07-15 06:54:02 +09:00
|
|
|
|
LogManager logManager = LogManager();
|
|
|
|
|
|
|
2024-04-09 01:58:25 +09:00
|
|
|
|
// 要検討:URLの起動に失敗した場合のエラーハンドリングが不十分です。適切なエラーメッセージを表示するなどの処理を追加してください。
|
|
|
|
|
|
//
|
2024-04-20 17:30:26 +09:00
|
|
|
|
/*
|
2022-09-22 20:36:56 +05:30
|
|
|
|
void _launchURL(url) async {
|
2023-10-06 16:25:21 +05:30
|
|
|
|
if (!await launchUrl(url)) throw 'Could not launch $url';
|
2022-09-22 20:36:56 +05:30
|
|
|
|
}
|
2024-04-20 17:30:26 +09:00
|
|
|
|
*/
|
|
|
|
|
|
|
2024-04-30 22:11:33 +09:00
|
|
|
|
void _launchURL(BuildContext context,String urlString) async {
|
|
|
|
|
|
try {
|
2024-07-15 06:54:02 +09:00
|
|
|
|
logManager.addOperationLog('User clicked ${urlString} on the drawer');
|
2024-04-30 22:11:33 +09:00
|
|
|
|
Uri url = Uri.parse(urlString);
|
|
|
|
|
|
if (await canLaunchUrl(url)) {
|
|
|
|
|
|
await launchUrl(url);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
// URLを開けない場合のフォールバック動作
|
|
|
|
|
|
// 例えば、WebViewを使用してアプリ内でURLを開く
|
|
|
|
|
|
Navigator.push(
|
|
|
|
|
|
context,
|
|
|
|
|
|
MaterialPageRoute(
|
|
|
|
|
|
builder: (context) => WebViewPage(url: urlString),
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
}catch(e){
|
|
|
|
|
|
// エラーメッセージを表示する
|
|
|
|
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
|
|
|
|
SnackBar(content: Text('URLを開けませんでした: $e')),
|
|
|
|
|
|
);
|
2024-04-20 17:30:26 +09:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-09-22 20:36:56 +05:30
|
|
|
|
|
2022-03-14 12:28:57 +05:30
|
|
|
|
@override
|
|
|
|
|
|
Widget build(BuildContext context) {
|
2022-03-15 18:19:34 +05:30
|
|
|
|
return SafeArea(
|
|
|
|
|
|
child: Drawer(
|
2022-04-17 11:45:21 +05:30
|
|
|
|
child: Column(
|
|
|
|
|
|
children: [
|
|
|
|
|
|
Container(
|
|
|
|
|
|
height: 100,
|
|
|
|
|
|
color: Colors.amber,
|
2023-09-12 22:08:03 +05:30
|
|
|
|
child: Obx(() => Center(
|
|
|
|
|
|
child: Padding(
|
|
|
|
|
|
padding: const EdgeInsets.all(8.0),
|
|
|
|
|
|
child: indexController.currentUser.isEmpty
|
|
|
|
|
|
? Flexible(
|
|
|
|
|
|
child: Text(
|
|
|
|
|
|
"drawer_title".tr,
|
|
|
|
|
|
style: const TextStyle(
|
|
|
|
|
|
color: Colors.black, fontSize: 20),
|
|
|
|
|
|
))
|
|
|
|
|
|
: Text(
|
|
|
|
|
|
indexController.currentUser[0]['user']['email'],
|
|
|
|
|
|
style: const TextStyle(
|
|
|
|
|
|
color: Colors.black, fontSize: 20),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
)),
|
2022-04-17 11:45:21 +05:30
|
|
|
|
),
|
2023-09-12 22:08:03 +05:30
|
|
|
|
Obx(() => indexController.currentUser.isEmpty
|
|
|
|
|
|
? ListTile(
|
|
|
|
|
|
leading: const Icon(Icons.login),
|
|
|
|
|
|
title: Text("login".tr),
|
|
|
|
|
|
onTap: () {
|
|
|
|
|
|
Get.toNamed(AppPages.LOGIN);
|
|
|
|
|
|
},
|
|
|
|
|
|
)
|
|
|
|
|
|
: ListTile(
|
|
|
|
|
|
leading: const Icon(Icons.login),
|
|
|
|
|
|
title: Text("logout".tr),
|
|
|
|
|
|
onTap: () {
|
|
|
|
|
|
indexController.logout();
|
|
|
|
|
|
Get.toNamed(AppPages.LOGIN);
|
|
|
|
|
|
},
|
|
|
|
|
|
)),
|
|
|
|
|
|
indexController.currentUser.isNotEmpty
|
|
|
|
|
|
? ListTile(
|
|
|
|
|
|
leading: const Icon(Icons.password),
|
|
|
|
|
|
title: Text("change_password".tr),
|
|
|
|
|
|
onTap: () {
|
|
|
|
|
|
Get.toNamed(AppPages.CHANGE_PASSWORD);
|
|
|
|
|
|
},
|
|
|
|
|
|
)
|
|
|
|
|
|
: const SizedBox(
|
|
|
|
|
|
width: 0,
|
|
|
|
|
|
height: 0,
|
|
|
|
|
|
),
|
|
|
|
|
|
indexController.currentUser.isEmpty
|
|
|
|
|
|
? ListTile(
|
|
|
|
|
|
leading: const Icon(Icons.person),
|
|
|
|
|
|
title: Text("sign_up".tr),
|
|
|
|
|
|
onTap: () {
|
|
|
|
|
|
Get.toNamed(AppPages.REGISTER);
|
|
|
|
|
|
},
|
|
|
|
|
|
)
|
|
|
|
|
|
: const SizedBox(
|
|
|
|
|
|
width: 0,
|
|
|
|
|
|
height: 0,
|
|
|
|
|
|
),
|
|
|
|
|
|
indexController.currentUser.isNotEmpty
|
|
|
|
|
|
? ListTile(
|
|
|
|
|
|
leading: const Icon(Icons.password),
|
2024-07-15 06:54:02 +09:00
|
|
|
|
title: Text('reset_button'.tr),
|
2023-09-12 22:08:03 +05:30
|
|
|
|
onTap: () {
|
2024-07-15 06:54:02 +09:00
|
|
|
|
logManager.addOperationLog('User clicked RESET button on the drawer');
|
2024-04-09 01:58:25 +09:00
|
|
|
|
// 要検討:リセット操作の確認メッセージをローカライズすることを検討してください。
|
|
|
|
|
|
//
|
2023-09-12 22:08:03 +05:30
|
|
|
|
Get.defaultDialog(
|
2024-07-15 06:54:02 +09:00
|
|
|
|
title: "reset_title".tr,
|
|
|
|
|
|
middleText: "reset_message".tr,
|
|
|
|
|
|
textConfirm: "confirm".tr,
|
|
|
|
|
|
textCancel: "cancel".tr,
|
2023-09-12 22:08:03 +05:30
|
|
|
|
onCancel: () => Get.back(),
|
2024-04-27 10:48:21 +09:00
|
|
|
|
onConfirm: () async {
|
2023-09-12 22:08:03 +05:30
|
|
|
|
DestinationController destinationController =
|
|
|
|
|
|
Get.find<DestinationController>();
|
2024-04-27 10:48:21 +09:00
|
|
|
|
DatabaseHelper databaseHelper = DatabaseHelper.instance;
|
|
|
|
|
|
|
|
|
|
|
|
// ゲーム中のデータを削除
|
|
|
|
|
|
await databaseHelper.deleteAllRogaining();
|
|
|
|
|
|
await databaseHelper.deleteAllDestinations();
|
2023-09-12 22:08:03 +05:30
|
|
|
|
destinationController.resetRogaining();
|
2024-04-27 10:48:21 +09:00
|
|
|
|
|
|
|
|
|
|
//destinationController.resetRogaining();
|
|
|
|
|
|
//destinationController.deleteDBDestinations();
|
2023-09-12 22:08:03 +05:30
|
|
|
|
Get.back();
|
2024-04-27 10:48:21 +09:00
|
|
|
|
Get.snackbar(
|
2024-07-15 06:54:02 +09:00
|
|
|
|
"reset_done".tr,
|
|
|
|
|
|
"reset_explain".tr,
|
2024-04-27 10:48:21 +09:00
|
|
|
|
backgroundColor: Colors.green,
|
|
|
|
|
|
colorText: Colors.white,
|
|
|
|
|
|
duration: const Duration(seconds: 3),
|
|
|
|
|
|
);
|
2023-09-12 22:08:03 +05:30
|
|
|
|
},
|
|
|
|
|
|
);
|
|
|
|
|
|
},
|
|
|
|
|
|
)
|
|
|
|
|
|
: const SizedBox(
|
|
|
|
|
|
width: 0,
|
|
|
|
|
|
height: 0,
|
|
|
|
|
|
),
|
|
|
|
|
|
indexController.currentUser.isNotEmpty
|
|
|
|
|
|
? ListTile(
|
|
|
|
|
|
leading: const Icon(Icons.delete_forever),
|
|
|
|
|
|
title: Text("delete_account".tr),
|
|
|
|
|
|
onTap: () {
|
2024-04-20 17:30:26 +09:00
|
|
|
|
Get.defaultDialog(
|
2024-07-15 06:54:02 +09:00
|
|
|
|
title: "delete_account_title".tr,
|
|
|
|
|
|
middleText: "delete_account_middle".tr,
|
|
|
|
|
|
textConfirm: "confirm".tr,
|
|
|
|
|
|
textCancel: "cancel".tr,
|
2024-04-20 17:30:26 +09:00
|
|
|
|
onCancel: () => Get.back(),
|
|
|
|
|
|
onConfirm: () {
|
2024-07-15 06:54:02 +09:00
|
|
|
|
logManager.addOperationLog('User clicked Confirm button on the account delete dialog');
|
2024-04-20 17:30:26 +09:00
|
|
|
|
String token = indexController.currentUser[0]['token'];
|
|
|
|
|
|
AuthService.deleteUser(token).then((value) {
|
|
|
|
|
|
if (value.isNotEmpty) {
|
|
|
|
|
|
indexController.logout();
|
|
|
|
|
|
Get.toNamed(AppPages.TRAVEL);
|
|
|
|
|
|
Get.snackbar("accounted_deleted".tr,
|
2024-04-27 10:48:21 +09:00
|
|
|
|
"account_deleted_message".tr,
|
|
|
|
|
|
backgroundColor: Colors.green,
|
|
|
|
|
|
colorText: Colors.white
|
|
|
|
|
|
);
|
2024-04-20 17:30:26 +09:00
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
);
|
2023-09-12 22:08:03 +05:30
|
|
|
|
},
|
|
|
|
|
|
)
|
|
|
|
|
|
: const SizedBox(
|
|
|
|
|
|
width: 0,
|
|
|
|
|
|
height: 0,
|
|
|
|
|
|
),
|
|
|
|
|
|
indexController.currentUser.isNotEmpty
|
|
|
|
|
|
? ListTile(
|
|
|
|
|
|
leading: const Icon(Icons.featured_video),
|
|
|
|
|
|
title: Text("rog_web".tr),
|
|
|
|
|
|
onTap: () {
|
2024-04-30 22:11:33 +09:00
|
|
|
|
_launchURL(context, "https://www.gifuai.net/?page_id=60043");
|
2023-09-12 22:08:03 +05:30
|
|
|
|
},
|
|
|
|
|
|
)
|
|
|
|
|
|
: const SizedBox(
|
|
|
|
|
|
width: 0,
|
|
|
|
|
|
height: 0,
|
|
|
|
|
|
),
|
2023-01-12 12:32:08 +05:30
|
|
|
|
ListTile(
|
|
|
|
|
|
leading: const Icon(Icons.privacy_tip),
|
|
|
|
|
|
title: Text("privacy".tr),
|
2023-09-12 22:08:03 +05:30
|
|
|
|
onTap: () {
|
2024-04-30 22:11:33 +09:00
|
|
|
|
_launchURL(context, "https://rogaining.sumasen.net/api/privacy/");
|
2023-01-12 12:32:08 +05:30
|
|
|
|
},
|
2024-04-26 18:44:22 +09:00
|
|
|
|
),
|
|
|
|
|
|
ListTile(
|
|
|
|
|
|
leading: const Icon(Icons.settings),
|
2024-07-15 06:54:02 +09:00
|
|
|
|
title: Text('open_settings'.tr),
|
2024-04-26 18:44:22 +09:00
|
|
|
|
onTap: () {
|
|
|
|
|
|
Get.back(); // ドロワーを閉じる
|
|
|
|
|
|
Get.toNamed(Routes.SETTINGS);
|
|
|
|
|
|
},
|
|
|
|
|
|
|
2024-05-15 17:59:25 +09:00
|
|
|
|
),
|
|
|
|
|
|
ListTile(
|
|
|
|
|
|
leading: const Icon(Icons.developer_mode),
|
2024-07-15 06:54:02 +09:00
|
|
|
|
title: const Text('open_settings'),
|
2024-05-15 17:59:25 +09:00
|
|
|
|
onTap: () {
|
|
|
|
|
|
Get.back(); // ドロワーを閉じる
|
|
|
|
|
|
Get.toNamed('/debug'); // デバッグ画面に遷移
|
|
|
|
|
|
},
|
|
|
|
|
|
),
|
2022-09-14 19:51:50 +05:30
|
|
|
|
// ListTile(
|
|
|
|
|
|
// leading: const Icon(Icons.router),
|
|
|
|
|
|
// title: Text("my_route".tr),
|
|
|
|
|
|
// onTap: (){},
|
|
|
|
|
|
// ),
|
|
|
|
|
|
// ListTile(
|
|
|
|
|
|
// leading: const Icon(Icons.history_sharp),
|
|
|
|
|
|
// title: Text("visit_history".tr),
|
|
|
|
|
|
// onTap: (){},
|
|
|
|
|
|
// ),
|
2022-04-17 11:45:21 +05:30
|
|
|
|
],
|
|
|
|
|
|
),
|
2022-03-15 18:19:34 +05:30
|
|
|
|
),
|
2022-03-14 12:28:57 +05:30
|
|
|
|
);
|
|
|
|
|
|
}
|
2023-09-12 22:08:03 +05:30
|
|
|
|
}
|