added reset button and fix history

This commit is contained in:
Mohamed Nouffer
2023-09-12 22:08:03 +05:30
parent f64ac1ccfd
commit 30fea7cf8a
2 changed files with 128 additions and 84 deletions

View File

@ -335,8 +335,6 @@ class DestinationController extends GetxController {
is_gps_selected.value = true; is_gps_selected.value = true;
skip_gps = false; skip_gps = false;
saveGameState();
_start = 0; _start = 0;
chekcs = 0; chekcs = 0;
rogaining_counted.value = false; rogaining_counted.value = false;
@ -348,16 +346,21 @@ class DestinationController extends GetxController {
print("===== last goal : $last_goal_at ====="); print("===== last goal : $last_goal_at =====");
} }
//deleteDBDestinations();
// currentSelectedDestinations.forEach((element) {
// deleteDestination(element);
// });
}
void deleteAllDestinations() {
DatabaseHelper db = DatabaseHelper.instance;
db.deleteAllDestinations().then((value) { db.deleteAllDestinations().then((value) {
PopulateDestinations(); PopulateDestinations();
startGPSTimer(); startGPSTimer();
startGame(); startGame();
//initGPS(); //initGPS();
}); });
// currentSelectedDestinations.forEach((element) {
// deleteDestination(element);
// });
} }
void openCamera(BuildContext context) { void openCamera(BuildContext context) {
@ -824,7 +827,7 @@ class DestinationController extends GetxController {
}); });
} }
void deleteAllDestinations() { void deleteDBDestinations() {
DatabaseHelper db = DatabaseHelper.instance; DatabaseHelper db = DatabaseHelper.instance;
db.deleteAllDestinations().then((value) { db.deleteAllDestinations().then((value) {
PopulateDestinations(); PopulateDestinations();

View File

@ -1,13 +1,13 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:rogapp/pages/destination/destination_controller.dart';
import 'package:rogapp/pages/index/index_controller.dart'; import 'package:rogapp/pages/index/index_controller.dart';
import 'package:rogapp/routes/app_pages.dart'; import 'package:rogapp/routes/app_pages.dart';
import 'package:rogapp/services/auth_service.dart'; import 'package:rogapp/services/auth_service.dart';
import 'package:url_launcher/url_launcher.dart'; import 'package:url_launcher/url_launcher.dart';
class DrawerPage extends StatelessWidget { class DrawerPage extends StatelessWidget {
DrawerPage({ Key? key }) : super(key: key); DrawerPage({Key? key}) : super(key: key);
final IndexController indexController = Get.find<IndexController>(); final IndexController indexController = Get.find<IndexController>();
@ -27,71 +27,109 @@ class DrawerPage extends StatelessWidget {
Container( Container(
height: 100, height: 100,
color: Colors.amber, color: Colors.amber,
child: Obx(() => child: Obx(() => Center(
Center(
child: Padding( child: Padding(
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
child: child: indexController.currentUser.isEmpty
indexController.currentUser.isEmpty ? ? Flexible(
Flexible(child: Text("drawer_title".tr, style: const TextStyle(color: Colors.black, fontSize: 20),)) child: Text(
: "drawer_title".tr,
Text(indexController.currentUser[0]['user']['email'], style: const TextStyle(color: Colors.black, fontSize: 20),), style: const TextStyle(
), color: Colors.black, fontSize: 20),
) ))
: Text(
indexController.currentUser[0]['user']['email'],
style: const TextStyle(
color: Colors.black, fontSize: 20),
), ),
), ),
Obx(() => )),
indexController.currentUser.isEmpty ? ),
ListTile( Obx(() => indexController.currentUser.isEmpty
? ListTile(
leading: const Icon(Icons.login), leading: const Icon(Icons.login),
title: Text("login".tr), title: Text("login".tr),
onTap: (){ onTap: () {
Get.toNamed(AppPages.LOGIN);
},
) :
ListTile(
leading: const Icon(Icons.login),
title: Text("logout".tr),
onTap: (){
indexController.logout();
Get.toNamed(AppPages.LOGIN); Get.toNamed(AppPages.LOGIN);
}, },
) )
), : ListTile(
indexController.currentUser.isNotEmpty ? leading: const Icon(Icons.login),
ListTile( title: Text("logout".tr),
onTap: () {
indexController.logout();
Get.toNamed(AppPages.LOGIN);
},
)),
indexController.currentUser.isNotEmpty
? ListTile(
leading: const Icon(Icons.password), leading: const Icon(Icons.password),
title: Text("change_password".tr), title: Text("change_password".tr),
onTap: (){ onTap: () {
Get.toNamed(AppPages.CHANGE_PASSWORD); Get.toNamed(AppPages.CHANGE_PASSWORD);
}, },
) : )
const SizedBox(width: 0, height: 0,), : const SizedBox(
indexController.currentUser.isEmpty ? width: 0,
ListTile( height: 0,
),
indexController.currentUser.isEmpty
? ListTile(
leading: const Icon(Icons.person), leading: const Icon(Icons.person),
title: Text("sign_up".tr), title: Text("sign_up".tr),
onTap: (){ onTap: () {
Get.toNamed(AppPages.REGISTER); Get.toNamed(AppPages.REGISTER);
}, },
) : )
const SizedBox(width: 0, height: 0,), : const SizedBox(
indexController.currentUser.isNotEmpty ? width: 0,
ListTile( height: 0,
),
indexController.currentUser.isNotEmpty
? ListTile(
leading: const Icon(Icons.password),
title: const Text("リセット"),
onTap: () {
Get.defaultDialog(
title: "よろしいですか、リセットしますか?",
middleText: "これにより、すべてのゲーム データが削除され、すべての状態が削除されます",
textConfirm: "確認する",
textCancel: "キャンセルする",
onCancel: () => Get.back(),
onConfirm: () {
DestinationController destinationController =
Get.find<DestinationController>();
destinationController.resetRogaining();
destinationController.deleteDBDestinations();
Get.back();
},
);
},
)
: const SizedBox(
width: 0,
height: 0,
),
indexController.currentUser.isNotEmpty
? ListTile(
leading: const Icon(Icons.delete_forever), leading: const Icon(Icons.delete_forever),
title: Text("delete_account".tr), title: Text("delete_account".tr),
onTap: (){ onTap: () {
String _token = indexController.currentUser[0]['token']; String _token = indexController.currentUser[0]['token'];
AuthService.deleteUser(_token).then((value){ AuthService.deleteUser(_token).then((value) {
if(value.isNotEmpty){ if (value.isNotEmpty) {
indexController.logout(); indexController.logout();
Get.toNamed(AppPages.TRAVEL); Get.toNamed(AppPages.TRAVEL);
Get.snackbar("accounted_deleted".tr, "account_deleted_message".tr); Get.snackbar("accounted_deleted".tr,
"account_deleted_message".tr);
} }
}); });
}, },
) : )
const SizedBox(width: 0, height: 0,), : const SizedBox(
width: 0,
height: 0,
),
// ListTile( // ListTile(
// leading: const Icon(Icons.person), // leading: const Icon(Icons.person),
// title: Text("profile".tr), // title: Text("profile".tr),
@ -107,19 +145,22 @@ class DrawerPage extends StatelessWidget {
// title: Text("point_rank".tr), // title: Text("point_rank".tr),
// onTap: (){}, // onTap: (){},
// ), // ),
indexController.currentUser.isNotEmpty ? indexController.currentUser.isNotEmpty
ListTile( ? ListTile(
leading: const Icon(Icons.featured_video), leading: const Icon(Icons.featured_video),
title: Text("rog_web".tr), title: Text("rog_web".tr),
onTap: (){ onTap: () {
_launchURL("https://www.gifuai.net/?page_id=17397"); _launchURL("https://www.gifuai.net/?page_id=17397");
}, },
) : )
const SizedBox(width: 0, height: 0,), : const SizedBox(
width: 0,
height: 0,
),
ListTile( ListTile(
leading: const Icon(Icons.privacy_tip), leading: const Icon(Icons.privacy_tip),
title: Text("privacy".tr), title: Text("privacy".tr),
onTap: (){ onTap: () {
_launchURL("https://rogaining.sumasen.net/api/privacy/"); _launchURL("https://rogaining.sumasen.net/api/privacy/");
}, },
) )