From 1e0af0b06b47b906bbebd694a0016b31287b199c Mon Sep 17 00:00:00 2001 From: Akira Date: Thu, 1 Aug 2024 20:31:27 +0900 Subject: [PATCH] =?UTF-8?q?Camera/QR=20code=20=E3=81=AE=E5=8F=8C=E6=96=B9?= =?UTF-8?q?=E3=81=AE=E3=82=B3=E3=83=BC=E3=83=89=E3=82=92=E7=BD=AE=E3=81=84?= =?UTF-8?q?=E3=81=A6=E3=81=84=E3=82=8B=E3=80=82=E5=88=87=E3=82=8A=E6=9B=BF?= =?UTF-8?q?=E3=81=88=E3=81=AF=E3=81=BE=E3=81=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/camera/camera_page.dart | 116 ++++++++++++++++++++++++++++-- 1 file changed, 111 insertions(+), 5 deletions(-) diff --git a/lib/pages/camera/camera_page.dart b/lib/pages/camera/camera_page.dart index f209b0f..205f107 100644 --- a/lib/pages/camera/camera_page.dart +++ b/lib/pages/camera/camera_page.dart @@ -617,18 +617,124 @@ class StartRogaining extends StatelessWidget { // 完了ボタンをタップすると、購入ポイントの処理が行われます。 // 購入なしボタンをタップすると、購入ポイントがキャンセルされます。 // -class BuyPointCamera extends StatefulWidget { - final Destination destination; +class BuyPointCamera extends StatelessWidget { + BuyPointCamera({Key? key, required this.destination}) : super(key: key); - const BuyPointCamera({Key? key, required this.destination}) : super(key: key); + Destination destination; + + DestinationController destinationController = + Get.find(); @override - _BuyPointCameraState createState() => _BuyPointCameraState(); + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + automaticallyImplyLeading: false, + title: Text( + "${destination.sub_loc_id} : ${destination.name}", + ), + ), + body: SingleChildScrollView( + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + Padding( + padding: const EdgeInsets.all(8.0), + child: Center( + child: Obx( + () => Container( + width: MediaQuery.of(context).size.width, + height: 370, + decoration: BoxDecoration( + image: DecorationImage( + // 要修正:getReceiptImage関数の戻り値がnullの場合のエラーハンドリングが不十分です。適切なデフォルト画像を表示するなどの処理を追加してください。 + // + image: getReceiptImage(), fit: BoxFit.cover)), + ), + ), + ), + ), + + Padding( + padding: const EdgeInsets.all(8.0), + child: Text(getTagText(true, destination.tags)), + ), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16.0), + child: Wrap( + spacing: 16.0, + runSpacing: 8.0, + children: [ + Obx(() => ElevatedButton( + onPressed: () { + destinationController.openCamera(context, destination); + }, + style: ElevatedButton.styleFrom( + shape: const CircleBorder(), + padding: const EdgeInsets.all(20), + backgroundColor: destinationController.photos.isEmpty + ? Colors.red + : Colors.grey[300], + ), + child: destinationController.photos.isEmpty + ? const Text("撮影", + style: TextStyle(color: Colors.white)) + : const Text("再撮影", + style: TextStyle(color: Colors.black)), + )), + ElevatedButton( + onPressed: () async { + await destinationController.cancelBuyPoint(destination); + Navigator.of(Get.context!).pop(); + destinationController.rogainingCounted.value = true; + destinationController.skipGps = false; + destinationController.isPhotoShoot.value = false; + }, + child: const Text("買い物なし")), + Obx(() => destinationController.photos.isNotEmpty + ? ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: Colors.red), + onPressed: () async { + await destinationController.makeBuyPoint( + destination, + destinationController.photos[0].path); + Get.back(); + destinationController.rogainingCounted.value = true; + destinationController.skipGps = false; + destinationController.isPhotoShoot.value = false; + Get.snackbar("お買い物加点を行いました", + "${destination.sub_loc_id} : ${destination.name}", + backgroundColor: Colors.green, + colorText: Colors.white); + }, + child: const Text("完了", + style: TextStyle(color: Colors.white))) + : Container()) + ], + ), + ), + ], + ), + ), + ); + } } -class _BuyPointCameraState extends State { +class BuyPointCamera_QR extends StatefulWidget { + final Destination destination; + + const BuyPointCamera_QR({Key? key, required this.destination}) : super(key: key); + + @override + _BuyPointCamera_QRState createState() => _BuyPointCamera_QRState(); +} + + + +class _BuyPointCamera_QRState extends State { final GlobalKey qrKey = GlobalKey(debugLabel: 'QR'); QRViewController? controller; bool isQRScanned = false;