From 7a154b4390ad69d873aa1b616a446964b0ec2e45 Mon Sep 17 00:00:00 2001 From: Mohamed Nouffer Date: Tue, 7 Nov 2023 17:17:47 +0530 Subject: [PATCH] update image on camera page --- lib/pages/camera/camera_page.dart | 47 +++++++++- .../destination/destination_controller.dart | 2 +- .../destination_map/destination_map_page.dart | 2 +- lib/widgets/bottom_sheet_new.dart | 90 +++++++++---------- lib/widgets/destination_widget.dart | 2 +- lib/widgets/list_widget.dart | 2 +- lib/widgets/map_widget.dart | 2 +- 7 files changed, 94 insertions(+), 53 deletions(-) diff --git a/lib/pages/camera/camera_page.dart b/lib/pages/camera/camera_page.dart index b695692..7ffb839 100644 --- a/lib/pages/camera/camera_page.dart +++ b/lib/pages/camera/camera_page.dart @@ -7,6 +7,38 @@ import 'package:rogapp/model/destination.dart'; import 'package:rogapp/pages/destination/destination_controller.dart'; import 'package:rogapp/pages/index/index_controller.dart'; import 'package:rogapp/services/external_service.dart'; +import 'package:rogapp/utils/const.dart'; + +Image getDisplayImage(Destination destination) { + String serverUrl = ConstValues.currentServer(); + + Image img = Image.asset("assets/images/empty_image.png"); + if (destination.phone == null) { + return img; + } + + if (destination.photos!.contains('http')) { + return Image( + image: NetworkImage( + destination.phone!, + ), + errorBuilder: + (BuildContext context, Object exception, StackTrace? stackTrace) { + return Image.asset("assets/images/empty_image.png"); + }, + ); + } else { + return Image( + image: NetworkImage( + '$serverUrl/media/compressed/${destination.photos}', + ), + errorBuilder: + (BuildContext context, Object exception, StackTrace? stackTrace) { + return Image.asset("assets/images/empty_image.png"); + }, + ); + } +} ImageProvider getFinishImage() { DestinationController destinationController = @@ -23,12 +55,14 @@ class CameraPage extends StatelessWidget { bool? buyPointPhoto = false; Destination destination; Destination? dbDest; + String? initImage; CameraPage( {Key? key, required this.destination, this.dbDest, this.manulaCheckin, - this.buyPointPhoto}) + this.buyPointPhoto, + this.initImage}) : super(key: key); DestinationController destinationController = Get.find(); @@ -200,7 +234,10 @@ class CameraPage extends StatelessWidget { destinationController.rogainingCounted.value = true; destinationController.skipGps = false; destinationController.isPhotoShoot.value = false; - Get.snackbar("チェックインした", "正常にチェックインしました"); + Get.snackbar( + "チェックインしました", + indexController.currentDestinationFeature[0].name ?? + ""); }, child: const Text("チェックイン")) : Container()) @@ -215,6 +252,7 @@ class CameraPage extends StatelessWidget { @override Widget build(BuildContext context) { + print("---- photos ${destination.photos} ----"); if (buyPointPhoto == true) { //print("--- buy point camera ${destination.toString()}"); return BuyPointCamera(destination: destination); @@ -258,7 +296,10 @@ class CameraPage extends StatelessWidget { height: 370, decoration: BoxDecoration( image: DecorationImage( - image: getFinishImage(), fit: BoxFit.cover)), + image: destinationController.photos.isEmpty + ? getDisplayImage(destination).image + : getFinishImage(), + fit: BoxFit.cover)), ), ), ), diff --git a/lib/pages/destination/destination_controller.dart b/lib/pages/destination/destination_controller.dart index f2adaff..464ab6b 100644 --- a/lib/pages/destination/destination_controller.dart +++ b/lib/pages/destination/destination_controller.dart @@ -188,7 +188,7 @@ class DestinationController extends GetxController { isAtStart.value = true; await showModalBottomSheet( constraints: - BoxConstraints.loose(Size(Get.width, Get.height * 0.75)), + BoxConstraints.loose(Size(Get.width, Get.height * 0.85)), context: Get.context!, isScrollControlled: true, builder: ((context) => BottomSheetNew( diff --git a/lib/pages/destination_map/destination_map_page.dart b/lib/pages/destination_map/destination_map_page.dart index 908fd51..3a4a588 100644 --- a/lib/pages/destination_map/destination_map_page.dart +++ b/lib/pages/destination_map/destination_map_page.dart @@ -57,7 +57,7 @@ class DestinationMapPage extends StatelessWidget { context: Get.context!, isScrollControlled: true, constraints: BoxConstraints.loose( - Size(Get.width, Get.height * 0.75)), + Size(Get.width, Get.height * 0.85)), builder: ((context) => BottomSheetNew( destination: d, ))).whenComplete(() { diff --git a/lib/widgets/bottom_sheet_new.dart b/lib/widgets/bottom_sheet_new.dart index 36c35d9..ef75ae1 100644 --- a/lib/widgets/bottom_sheet_new.dart +++ b/lib/widgets/bottom_sheet_new.dart @@ -431,51 +431,51 @@ class BottomSheetNew extends GetView { Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ - Obx( - () => indexController - .currentDestinationFeature.isNotEmpty && - indexController - .currentDestinationFeature[0].cp == - -1 && - indexController.currentDestinationFeature[0] - .checkedin == - false && - destinationController.isAtStart.value == true - ? ElevatedButton( - onPressed: () async { - await destinationController - .resetRogaining(); - //print("~~~~ start button ~~~~"); - destinationController.isInRog.value = true; - destinationController.addToRogaining( - destinationController.currentLat, - destinationController.currentLon, - indexController - .currentDestinationFeature[0] - .location_id!); - saveGameState(); - ExternalService() - .startRogaining() - .then((value) { - Get.back(); - }); - }, - child: Text( - // start - indexController - .currentDestinationFeature[ - 0] - .checkedin != - null || - indexController - .currentDestinationFeature[ - 0] - .checkedin == - true - ? "ロゲイニングを開始" - : "間違った目的地...")) - : Container(), - ), + // Obx( + // () => indexController + // .currentDestinationFeature.isNotEmpty && + // indexController + // .currentDestinationFeature[0].cp == + // -1 && + // indexController.currentDestinationFeature[0] + // .checkedin == + // false && + // destinationController.isAtStart.value == true + // ? ElevatedButton( + // onPressed: () async { + // await destinationController + // .resetRogaining(); + // //print("~~~~ start button ~~~~"); + // destinationController.isInRog.value = true; + // destinationController.addToRogaining( + // destinationController.currentLat, + // destinationController.currentLon, + // indexController + // .currentDestinationFeature[0] + // .location_id!); + // saveGameState(); + // ExternalService() + // .startRogaining() + // .then((value) { + // Get.back(); + // }); + // }, + // child: Text( + // // start + // indexController + // .currentDestinationFeature[ + // 0] + // .checkedin != + // null || + // indexController + // .currentDestinationFeature[ + // 0] + // .checkedin == + // true + // ? "ロゲイニングを開始" + // : "間違った目的地...")) + // : Container(), + // ), Obx( () => destinationController.isAtGoal.value == true && destinationController diff --git a/lib/widgets/destination_widget.dart b/lib/widgets/destination_widget.dart index 8d66521..7a59b0c 100644 --- a/lib/widgets/destination_widget.dart +++ b/lib/widgets/destination_widget.dart @@ -194,7 +194,7 @@ class DestinationWidget extends StatelessWidget { showModalBottomSheet( constraints: BoxConstraints.loose( - Size(Get.width, Get.height * 0.75)), + Size(Get.width, Get.height * 0.85)), context: context, isScrollControlled: true, //builder:((context) => BottomSheetWidget()) diff --git a/lib/widgets/list_widget.dart b/lib/widgets/list_widget.dart index 0fd340a..b01ed80 100644 --- a/lib/widgets/list_widget.dart +++ b/lib/widgets/list_widget.dart @@ -120,7 +120,7 @@ class _ListWidgetState extends State { changeCurrentFeature(gf); showModalBottomSheet( constraints: BoxConstraints.loose( - Size(Get.width, Get.height * 0.75)), + Size(Get.width, Get.height * 0.85)), isScrollControlled: true, context: context, //builder: (context) => BottomSheetWidget(), diff --git a/lib/widgets/map_widget.dart b/lib/widgets/map_widget.dart index 733db93..ec5f6f7 100644 --- a/lib/widgets/map_widget.dart +++ b/lib/widgets/map_widget.dart @@ -45,7 +45,7 @@ class MapWidget extends StatelessWidget { showModalBottomSheet( constraints: - BoxConstraints.loose(Size(Get.width, Get.height * 0.75)), + BoxConstraints.loose(Size(Get.width, Get.height * 0.85)), context: context, isScrollControlled: true, isDismissible: true,