From f760294a39ae2b9a3a786ead83f887ac6cf7bebd Mon Sep 17 00:00:00 2001 From: Mohamed Nouffer Date: Fri, 15 Sep 2023 17:19:26 +0530 Subject: [PATCH] added cancel buypoints --- lib/pages/camera/camera_page.dart | 12 +++++++++--- lib/pages/destination/destination_controller.dart | 9 ++++++++- lib/utils/database_helper.dart | 14 ++++++++++++++ 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/lib/pages/camera/camera_page.dart b/lib/pages/camera/camera_page.dart index 45b8c90..515796d 100644 --- a/lib/pages/camera/camera_page.dart +++ b/lib/pages/camera/camera_page.dart @@ -416,9 +416,15 @@ class BuyPointCamera extends StatelessWidget { : const Text("撮影")), const SizedBox(width: 10,), ElevatedButton( - onPressed: () { - destinationController.openCamera( - context, destination); + onPressed: () async { + await destinationController.cancelBuyPoint( + destination); + Get.back(); + destinationController.rogaining_counted.value = + true; + destinationController.skip_gps = false; + destinationController.is_photo_shoot.value = + false; }, child: const Text("買い物なし")) ], diff --git a/lib/pages/destination/destination_controller.dart b/lib/pages/destination/destination_controller.dart index f77cf73..e2209c8 100644 --- a/lib/pages/destination/destination_controller.dart +++ b/lib/pages/destination/destination_controller.dart @@ -150,6 +150,7 @@ class DestinationController extends GetxController { : false; bool buyPointImageAdded = dss != null && dss.buypoint_image != null ? true : false; + bool buyPointCanceled = dss != null && dss.buy_point != null && dss.buy_point == 0 ? true : false; bool locationAlreadyCheckedIn = ds.length > 0 && ds[0].checkedin == true ? true : false; bool isuserLoggedIn = indexController.currentUser.isNotEmpty ? true : false; @@ -296,6 +297,7 @@ class DestinationController extends GetxController { buyPointImageAdded == false && ds.isNotEmpty && buyPoint == true && + buyPointCanceled == false && is_in_rog.value == true) { chekcs = 5; is_in_checkin.value = true; @@ -616,9 +618,14 @@ class DestinationController extends GetxController { saveGameState(); } + Future cancelBuyPoint(Destination destination) async { + DatabaseHelper db = DatabaseHelper.instance; + await db.updateCancelBuyPoint(destination); + PopulateDestinations(); + } + Future makeBuyPoint(Destination destination, String imageurl) async { DatabaseHelper db = DatabaseHelper.instance; - await db.updateBuyPoint(destination, imageurl); PopulateDestinations(); await GallerySaver.saveImage(imageurl); diff --git a/lib/utils/database_helper.dart b/lib/utils/database_helper.dart index 422cc72..eb372d3 100644 --- a/lib/utils/database_helper.dart +++ b/lib/utils/database_helper.dart @@ -262,6 +262,20 @@ class DatabaseHelper{ return res; } + Future updateCancelBuyPoint(Destination destination)async { + print("---- updating puypint image in db -----"); + Database db = await instance.database; + Map row = { + "buy_point": 0 + }; + return await db.update( + "destination", + row, + where: 'location_id = ?', + whereArgs: [destination.location_id!] + ); + } + Future updateBuyPoint(Destination destination, String imageUrl)async { print("---- updating puypint image in db -----"); Database db = await instance.database;