From 4648b0424de6309fd7cf5e5093561e07cab04e64 Mon Sep 17 00:00:00 2001 From: Mohamed Nouffer Date: Mon, 20 Nov 2023 14:01:28 +0530 Subject: [PATCH] updated for tag text --- lib/model/destination.dart | 12 ++++-- lib/pages/camera/camera_page.dart | 43 +++++++++++++++---- .../destination/destination_controller.dart | 3 +- lib/utils/database_helper.dart | 3 +- 4 files changed, 48 insertions(+), 13 deletions(-) diff --git a/lib/model/destination.dart b/lib/model/destination.dart index 0716664..f4242a2 100644 --- a/lib/model/destination.dart +++ b/lib/model/destination.dart @@ -25,6 +25,7 @@ class Destination { String? buypoint_image; bool forced_checkin = false; int recipt_times = 0; + String? tags; Destination( {this.name, @@ -52,13 +53,16 @@ class Destination { this.checkin_image, this.buypoint_image, this.forced_checkin = false, - this.recipt_times = 0}); + this.recipt_times = 0, + this.tags}); factory Destination.fromMap(Map json) { bool selec = json['selected'] == 0 ? false : true; bool checkin = json['checkedin'] == 0 ? false : true; bool forcedCheckin = json['forced_checkin'] == 0 ? false : true; + print("-----tags model----- ${json}"); + return Destination( name: json['name'], address: json['address'], @@ -85,7 +89,8 @@ class Destination { checkin_image: json['checkin_image'], buypoint_image: json["buypoint_image"], forced_checkin: forcedCheckin, - recipt_times: json["recipt_times"]); + recipt_times: json["recipt_times"], + tags: json["tags"]); } Map toMap() { @@ -118,7 +123,8 @@ class Destination { 'checkin_image': checkin_image, 'buypoint_image': buypoint_image, 'forced_checkin': forcedCheckin, - 'recipt_times': recipt_times + 'recipt_times': recipt_times, + 'tags': tags }; } } diff --git a/lib/pages/camera/camera_page.dart b/lib/pages/camera/camera_page.dart index 7ffb839..df9df01 100644 --- a/lib/pages/camera/camera_page.dart +++ b/lib/pages/camera/camera_page.dart @@ -9,6 +9,28 @@ import 'package:rogapp/pages/index/index_controller.dart'; import 'package:rogapp/services/external_service.dart'; import 'package:rogapp/utils/const.dart'; +String getTagText(bool isRecept, String? tags) { + if (tags == null || tags.isEmpty) { + return ""; + } + List tts = tags.split(" "); + List ttt = tags.split(" "); + if (isRecept) { + if (ttt.length > tts.length && ttt.length > 1) { + return ttt[1]; + } + } + if (!isRecept) { + if (ttt.length > tts.length && ttt.length > 1) { + return ttt[0]; + } + } + if (!isRecept) { + return tts[0]; + } + return ""; +} + Image getDisplayImage(Destination destination) { String serverUrl = ConstValues.currentServer(); @@ -257,6 +279,7 @@ class CameraPage extends StatelessWidget { //print("--- buy point camera ${destination.toString()}"); return BuyPointCamera(destination: destination); } else if (destinationController.isInRog.value) { + //print("-----tags camera page----- ${destination.tags}"); //print("--- in normal camera ${destination.toString()}"); return Scaffold( appBar: destinationController.isInRog.value && @@ -305,11 +328,15 @@ class CameraPage extends StatelessWidget { ), ), Padding( - padding: const EdgeInsets.symmetric(vertical: 8.0), - child: Obx(() => destinationController.photos.isEmpty == true - ? const Text("撮影してチェックインしてください。") - : const Text("チェックインをタップしてください。")), - ), + padding: const EdgeInsets.symmetric(vertical: 8.0), + child: Text(getTagText( + false, + destination.tags, + )) + // child: Obx(() => destinationController.photos.isEmpty == true + // ? const Text("撮影してチェックインしてください。") + // : const Text("チェックインをタップしてください。")), + ), getAction(context), ], ), @@ -432,9 +459,9 @@ class BuyPointCamera extends StatelessWidget { ), ), ), - const Padding( - padding: EdgeInsets.all(8.0), - child: Text("次にレシート撮影を行います。"), + Padding( + padding: const EdgeInsets.all(8.0), + child: Text(getTagText(true, destination.tags)), ), Row( mainAxisAlignment: MainAxisAlignment.spaceAround, diff --git a/lib/pages/destination/destination_controller.dart b/lib/pages/destination/destination_controller.dart index f74500d..ddd4808 100644 --- a/lib/pages/destination/destination_controller.dart +++ b/lib/pages/destination/destination_controller.dart @@ -103,7 +103,8 @@ class DestinationController extends GetxController { buy_point: fs.properties!["buy_point"], selected: false, checkedin: false, - hidden_location: fs.properties!["hidden_location"] == true ? 1 : 0); + hidden_location: fs.properties!["hidden_location"] == true ? 1 : 0, + tags: fs.properties!["tags"]); } Future startTimerLocation(GeoJsonFeature fs, double distance) async { diff --git a/lib/utils/database_helper.dart b/lib/utils/database_helper.dart index cea725f..018db48 100644 --- a/lib/utils/database_helper.dart +++ b/lib/utils/database_helper.dart @@ -58,7 +58,8 @@ class DatabaseHelper { checkin_image TEXT, buypoint_image TEXT, forced_checkin INTEGER, - recipt_times INTEGER + recipt_times INTEGER, + tags TEXT ) ''');