From 42accf9f3aed73811b80f39db9f150fa3d220d4f Mon Sep 17 00:00:00 2001 From: Mohamed Nouffer Date: Thu, 14 Jul 2022 23:10:24 +0530 Subject: [PATCH] update for chech in --- lib/model/destination.dart | 55 +- .../destination/destination_controller.dart | 94 ++- lib/pages/destination/destination_page.dart | 36 +- .../destination_map/destination_map_page.dart | 2 + lib/pages/index/index_controller.dart | 1 + lib/pages/index/index_page.dart | 25 +- lib/utils/database_helper.dart | 18 +- lib/widgets/bottom_sheet_new.dart | 591 +++++++++++------- lib/widgets/destination_widget.dart | 16 +- lib/widgets/map_widget.dart | 5 +- 10 files changed, 532 insertions(+), 311 deletions(-) diff --git a/lib/model/destination.dart b/lib/model/destination.dart index f5fafc3..fc59041 100644 --- a/lib/model/destination.dart +++ b/lib/model/destination.dart @@ -16,7 +16,8 @@ class Destination { String? photos; double? checkin_radious; int? auto_checkin; - bool selected = false; + bool? selected = false; + bool? checkedin = false; Destination({ this.name, @@ -33,28 +34,40 @@ class Destination { this.list_order, this.photos, this.checkin_radious, - this.auto_checkin + this.auto_checkin, + this.selected, + this.checkedin }); - factory Destination.fromMap(Map json) => Destination( - name: json['name'], - address: json['address'], - phone: json['phone'], - email: json['email'], - webcontents: json['webcontents'], - videos: json['videos'], - category: json['category'], - series: json['series'], - lat: json['lat'], - lon: json['lon'], - location_id: json['location_id'], - list_order: json['list_order'], - photos: json['category'], - checkin_radious: json['checkin_radious'], - auto_checkin:json['auto_checkin'] - ); + factory Destination.fromMap(Map json) { + + bool selec = json['selected'] == 0 ? false : true; + bool checkin = json['checkedin'] == 0 ? false : true; + + return Destination( + name: json['name'], + address: json['address'], + phone: json['phone'], + email: json['email'], + webcontents: json['webcontents'], + videos: json['videos'], + category: json['category'], + series: json['series'], + lat: json['lat'], + lon: json['lon'], + location_id: json['location_id'], + list_order: json['list_order'], + photos: json['photos'], + checkin_radious: json['checkin_radious'], + auto_checkin:json['auto_checkin'], + selected: selec, + checkedin: checkin + ); + } Map toMap(){ + int sel = selected == false ? 0 : 1; + int check = checkedin == false ? 0 : 1; return { 'name':name, 'address': address, @@ -70,7 +83,9 @@ class Destination { 'list_order':list_order, 'photos':photos, 'checkin_radious': checkin_radious, - 'auto_checkin': auto_checkin + 'auto_checkin': auto_checkin, + 'selected': sel, + 'checkedin': check }; } diff --git a/lib/pages/destination/destination_controller.dart b/lib/pages/destination/destination_controller.dart index 940a718..bc4f226 100644 --- a/lib/pages/destination/destination_controller.dart +++ b/lib/pages/destination/destination_controller.dart @@ -61,6 +61,7 @@ class DestinationController extends GetxController { } checkForCheckin(double la, double ln){ + for(final d in destinations){ double lat = d.lat!; double lon = d.lon!; @@ -74,40 +75,71 @@ class DestinationController extends GetxController { indexController.currentDestinationFeature.add(value); //indexController.getAction(); - if(!checking_in){ - checking_in = true; - if(rad >= dist){ - if(auto_checkin){ - if(indexController.currentAction.isNotEmpty){ - print(indexController.currentAction[0]); - indexController.currentAction[0][0]["checkin"] = true; - Map temp = Map.from(indexController.currentAction[0][0]); - indexController.currentAction.clear(); - print("---temp---${temp}"); - indexController.currentAction.add([temp]); - } - indexController.makeAction(Get.context!); - } - else{ - showModalBottomSheet(context: Get.context!, isScrollControlled: true, + + if(rad >= dist){ + if(auto_checkin){ + makeCheckin(value, true); + } + else{ + showModalBottomSheet(context: Get.context!, isScrollControlled: true, builder:((context) => BottomSheetWidget()) ).whenComplete((){ checking_in = false; }); - } } } + + + // if(!checking_in){ + // checking_in = true; + // if(rad >= dist){ + // if(auto_checkin){ + // if(indexController.currentAction.isNotEmpty){ + // print(indexController.currentAction[0]); + // indexController.currentAction[0][0]["checkin"] = true; + // Map temp = Map.from(indexController.currentAction[0][0]); + // indexController.currentAction.clear(); + // print("---temp---${temp}"); + // indexController.currentAction.add([temp]); + // } + // indexController.makeAction(Get.context!); + // } + // else{ + // showModalBottomSheet(context: Get.context!, isScrollControlled: true, + // builder:((context) => BottomSheetWidget()) + // ).whenComplete((){ + // checking_in = false; + // }); + // } + // } + // } print("----- rad is ${rad}"); }); } } + void makeCheckin(Destination destination, bool action) async { + print("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ressssss ${action}@@@@@@@@@@@"); + DatabaseHelper db = DatabaseHelper.instance; + int res = await db.updateAction(destination, action); + + List ddd = await db.getDestinationByLatLon(destination.lat!, destination.lon!); + print("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ddddd ${ddd[0].checkedin} @@@@@@@@@@@"); + + print("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ressssss ${res}@@@@@@@@@@@"); + PopulateDestinations(); + print("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ after populating ${res} @@@@@@@@@@@"); + print("---- database update resulr ------ res : ${res}-------"); + } + @override - void onInit() { + void onInit() async { super.onInit(); + checkPermission(); PopulateDestinations(); + print("------ in iniit"); @@ -146,14 +178,16 @@ class DestinationController extends GetxController { StreamSubscription positionStream = Geolocator.getPositionStream(locationSettings: locationSettings).listen( + (Position? position) { - double czoom = indexController.rogMapController!.zoom; - indexController.rogMapController!.move(LatLng(position!.latitude, position!.longitude), czoom); if(isSelected[0]){ - String user_id = indexController.currentUser[0]["user"]["id"].toString(); - TrackingService.addTrack(user_id, position!.latitude, position.longitude).then((val){ - //checkForCheckin(position!.latitude, position.longitude); - }); + double czoom = indexController.rogMapController!.zoom; + indexController.rogMapController!.move(LatLng(position!.latitude, position!.longitude), czoom); + //String user_id = indexController.currentUser[0]["user"]["id"].toString(); + //TrackingService.addTrack(user_id, position!.latitude, position.longitude).then((val){ + print("---- postion is ${position.latitude}, ${position.longitude}"); + checkForCheckin(position!.latitude, position.longitude); + //}); } print(position == null ? 'Unknown' : 'current position is ${position.latitude.toString()}, ${position.longitude.toString()}'); @@ -161,6 +195,14 @@ class DestinationController extends GetxController { } + void checkPermission() async { + LocationPermission permission = await Geolocator.checkPermission(); + if (permission != LocationPermission.whileInUse || + permission != LocationPermission.always) { + permission = await Geolocator.requestPermission(); + } + } + void deleteDestination(Destination d){ //int id = destinations[index].location_id!; //print("---- index ${destinations[index].location_id!}-----"); @@ -215,11 +257,9 @@ class DestinationController extends GetxController { DatabaseHelper db = DatabaseHelper.instance; db.getDestinations().then((value){ for(Destination d in value){ - print("-- destination controller Populating destination -- ${d.name}-----::::"); - for(Destination s in currentSelectedDestinations){ if(d.location_id == s.location_id){ - d.selected = !d.selected; + d.selected = !d.selected!; } } diff --git a/lib/pages/destination/destination_page.dart b/lib/pages/destination/destination_page.dart index accb54e..140e340 100644 --- a/lib/pages/destination/destination_page.dart +++ b/lib/pages/destination/destination_page.dart @@ -90,23 +90,25 @@ class _DestinationPageState extends State { automaticallyImplyLeading: false, title: Text("app_title".tr), actions: [ - ToggleButtons( - disabledColor: Colors.grey.shade200, - selectedColor: Colors.red, - children: [ - Icon(Icons.explore - )], - onPressed: (int index) { - setState(() { - destinationController.isSelected[index] = !destinationController.isSelected[index]; - }); - }, - isSelected: destinationController.isSelected, - ), - IconButton(onPressed: (){ - showCurrentPosition(); - }, - icon: Icon(Icons.location_on_outlined)) + Obx(() => + ToggleButtons( + disabledColor: Colors.grey.shade200, + selectedColor: Colors.red, + children: [ + Icon(Icons.explore + )], + onPressed: (int index) { + setState(() { + destinationController.isSelected[index] = !destinationController.isSelected[index]; + }); + }, + isSelected: destinationController.isSelected, + ), + ), + // IconButton(onPressed: (){ + // showCurrentPosition(); + // }, + // icon: Icon(Icons.location_on_outlined)) ], ), body: Obx(() => diff --git a/lib/pages/destination_map/destination_map_page.dart b/lib/pages/destination_map/destination_map_page.dart index 6c0daf9..eaaa24f 100644 --- a/lib/pages/destination_map/destination_map_page.dart +++ b/lib/pages/destination_map/destination_map_page.dart @@ -159,6 +159,8 @@ class _DestinationMapPageState extends State { // do something } if (mapEvent is MapEventMoveEnd) { + destinationController.isSelected.clear(); + destinationController.isSelected.add(false); //print(DateTime.now().toString() + ' [MapEventMoveStart] END'); //indexController.loadLocationsBound(); } diff --git a/lib/pages/index/index_controller.dart b/lib/pages/index/index_controller.dart index c92ef65..2952200 100644 --- a/lib/pages/index/index_controller.dart +++ b/lib/pages/index/index_controller.dart @@ -47,6 +47,7 @@ class IndexController extends GetxController { var mode = 0.obs; + // master mode, rog or selection var rog_mode = 1.obs; var desination_mode = 1.obs; diff --git a/lib/pages/index/index_page.dart b/lib/pages/index/index_page.dart index 8bc2e0f..a7c3206 100644 --- a/lib/pages/index/index_page.dart +++ b/lib/pages/index/index_page.dart @@ -34,18 +34,18 @@ class IndexPage extends GetView { //automaticallyImplyLeading: false, title: Text("Add locations"), actions: [ - // RaisedButton( - // child: Text("db"), - // onPressed: (){ - // DatabaseHelper db = DatabaseHelper.instance; - // db.getDestinations().then((value){ - // print("-------- lendth in db ${value.length} ---- :::::"); - // for(Destination d in value){ - // print("-------- values in db are ${d.toString()} ---- :::::"); - // }; - // }); - // }, - // ), + RaisedButton( + child: Text("db"), + onPressed: (){ + DatabaseHelper db = DatabaseHelper.instance; + db.getDestinations().then((value){ + print("-------- lendth in db ${value.length} ---- :::::"); + for(Destination d in value){ + print("-------- values in db are ${d.checkedin} ---- :::::"); + }; + }); + }, + ), CatWidget(indexController: indexController,), ], ), @@ -65,7 +65,6 @@ class IndexPage extends GetView { onPressed: (){ indexController.toggleMode(); if(indexController.currentCat.isNotEmpty){ - print("###############"); print(indexController.currentCat[0].toString()); } diff --git a/lib/utils/database_helper.dart b/lib/utils/database_helper.dart index e33cdbe..d4efa4f 100644 --- a/lib/utils/database_helper.dart +++ b/lib/utils/database_helper.dart @@ -39,7 +39,9 @@ class DatabaseHelper{ list_order INTEGER, photos TEXT, checkin_radious REAL, - auto_checkin INTEGER + auto_checkin INTEGER, + selected INTEGER, + checkedin INTEGER ) '''); } @@ -85,6 +87,20 @@ class DatabaseHelper{ return res; } + Future updateAction(Destination destination, bool checkin)async { + Database db = await instance.database; + int act = checkin == false ? 0 : 1; + Map row = { + "checkedin": act + }; + return await db.update( + "destination", + row, + where: 'location_id = ?', + whereArgs: [destination.location_id] + ); + } + // Future getPending() async{ // Database db = await instance.database; // return await Sqflite.firstIntValue(await db.rawQuery("SELECT COUNT(*) FROM incidents")); diff --git a/lib/widgets/bottom_sheet_new.dart b/lib/widgets/bottom_sheet_new.dart index 0b1b4ab..906cb08 100644 --- a/lib/widgets/bottom_sheet_new.dart +++ b/lib/widgets/bottom_sheet_new.dart @@ -18,19 +18,40 @@ class BottomSheetNew extends GetView { final IndexController indexController = Get.find(); final DestinationController destinationController = Get.find(); - Image getImage(GeoJsonFeature? gf){ - if(gf!.properties!["photos"] == null || gf.properties!["photos"] == ""){ - return Image(image: AssetImage('assets/images/empty_image.png')); + Image getImage(){ + + if(indexController.rog_mode == 1){ + if(indexController.currentDestinationFeature.length <= 0 || indexController.currentDestinationFeature[0].photos! == ""){ + return Image(image: AssetImage('assets/images/empty_image.png')); + } + else{ + print("@@@@@@@@@@@@@ rog mode -------------------- ${indexController.currentDestinationFeature[0].photos} @@@@@@@@@@@"); + return Image(image: NetworkImage( + indexController.currentDestinationFeature[0].photos!, + ), + errorBuilder: (BuildContext context, Object exception, StackTrace? stackTrace) { + return Image.asset("assets/images/empty_image.png"); + }, + ); + } } else{ - return Image(image: NetworkImage( - gf.properties!["photos"], - ), - errorBuilder: (BuildContext context, Object exception, StackTrace? stackTrace) { - return Image.asset("assets/images/empty_image.png"); - }, - ); + GeoJsonFeature gf = indexController.currentFeature[0]; + if(gf!.properties!["photos"] == null || gf.properties!["photos"] == ""){ + return Image(image: AssetImage('assets/images/empty_image.png')); + } + else{ + return Image(image: NetworkImage( + gf.properties!["photos"], + ), + errorBuilder: (BuildContext context, Object exception, StackTrace? stackTrace) { + return Image.asset("assets/images/empty_image.png"); + }, + ); } + } + + } void _launchURL(url) async { @@ -39,162 +60,299 @@ class BottomSheetNew extends GetView { @override Widget build(BuildContext context) { - return Wrap( + + return indexController.rog_mode == 0 ? detailsSheet(context) : destinationSheet(context); + } + + SingleChildScrollView destinationSheet(BuildContext context) { + return SingleChildScrollView( + child: Column( children: [ - Column( - children: [ - Padding( - padding: const EdgeInsets.all(8.0), - child: Container( - child: Row( - children: [ - MaterialButton( - onPressed: () { - indexController.makePrevious(indexController.currentFeature[0]); - }, - color: Colors.blue, - textColor: Colors.white, - child: Icon( - Icons.arrow_back_ios, - size: 14, - ), - padding: EdgeInsets.all(16), - shape: CircleBorder(), - ), - Expanded( - child: Container( - alignment: Alignment.center, - child: Obx(() => - Text(indexController.currentFeature[0].properties!["location_name"], style: TextStyle( - fontSize: 15.0, - fontWeight: FontWeight.bold, - ), - ) - ), - ), - ), - MaterialButton( - onPressed: () { - print("----- next is ${indexController.currentFeature[0]} ------"); - indexController.makeNext(indexController.currentFeature[0]); - }, - color: Colors.blue, - textColor: Colors.white, - child: Icon( - Icons.arrow_forward_ios, - size: 14, - ), - padding: EdgeInsets.all(16), - shape: CircleBorder(), - ), - ], + Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Row( + children: [ + MaterialButton( + onPressed: () { + indexController.makePrevious(indexController.currentFeature[0]); + }, + color: Colors.blue, + textColor: Colors.white, + child: Icon( + Icons.arrow_back_ios, + size: 14, + ), + padding: EdgeInsets.all(16), + shape: CircleBorder(), ), - ), - ), - Row( - children: [ Expanded( - child: SizedBox( - height: 260.0, - child: Obx(() => getImage(indexController.currentFeature[0])), - ) + child: Container( + alignment: Alignment.center, + child: Obx(() => + Text(indexController.currentDestinationFeature[0].name!, style: TextStyle( + fontSize: 15.0, + fontWeight: FontWeight.bold, + ), + ) + ), + ), + ), + MaterialButton( + onPressed: () { + print("----- next is ${indexController.currentFeature[0]} ------"); + //indexController.makeNext(indexController.currentFeature[0]); + }, + color: Colors.blue, + textColor: Colors.white, + child: Icon( + Icons.arrow_forward_ios, + size: 14, + ), + padding: EdgeInsets.all(16), + shape: CircleBorder(), ), ], ), - Obx(() => - (indexController.currentFeature[0].properties!["address"] as String).isNotEmpty ? - getDetails("address".tr, indexController.currentFeature[0].properties!["address"] ?? '') - : - Container(width: 0.0, height: 0,), + ), + ), + Row( + children: [ + Expanded( + child: SizedBox( + height: 260.0, + child: Obx(() => getImage()), + ) ), - Obx(() => - (indexController.currentFeature[0].properties!["phone"] as String).isNotEmpty ? - getDetails("telephone".tr, indexController.currentFeature[0].properties!["phone"] ?? '') - : - Container(width: 0.0, height: 0,), - ), - Obx(() => - (indexController.currentFeature[0].properties!["email"] as String).isNotEmpty ? - getDetails("email".tr, indexController.currentFeature[0].properties!["email"] ?? '') - : - Container(width: 0.0, height: 0,), - ), - Obx(() => - (indexController.currentFeature[0].properties!["webcontents"] as String).isNotEmpty ? - getDetails("web".tr, indexController.currentFeature[0].properties!["webcontents"] ?? '', isurl: true) - : - Container(width: 0.0, height: 0,), - ), - Obx(() => - (indexController.currentFeature[0].properties!["videos"] as String).isNotEmpty ? - getDetails("video".tr, indexController.currentFeature[0].properties!["videos"] ?? '', isurl: true) - : - Container(width: 0.0, height: 0,), - ), - SizedBox(height: 20.0,), - Obx(() => - //wantToGo(context), + ], + ), + Obx(() => + indexController.currentDestinationFeature[0].address!.isNotEmpty ? + getDetails(context, "address".tr, indexController.currentDestinationFeature[0].address! ?? '') + : + Container(width: 0.0, height: 0,), + ), + Obx(() => + indexController.currentDestinationFeature[0].phone!.isNotEmpty ? + getDetails(context, "telephone".tr, indexController.currentDestinationFeature[0].phone! ?? '') + : + Container(width: 0.0, height: 0,), + ), + Obx(() => + indexController.currentDestinationFeature[0].email!.isNotEmpty ? + getDetails(context, "email".tr, indexController.currentDestinationFeature[0].email! ?? '') + : + Container(width: 0.0, height: 0,), + ), + Obx(() => + indexController.currentDestinationFeature[0].webcontents!.isNotEmpty ? + getDetails(context, "web".tr, indexController.currentDestinationFeature[0].webcontents! ?? '', isurl: true) + : + Container(width: 0.0, height: 0,), + ), + Obx(() => + indexController.currentDestinationFeature[0].videos!.isNotEmpty ? + getDetails(context, "video".tr, indexController.currentDestinationFeature[0].videos! ?? '', isurl: true) + : + Container(width: 0.0, height: 0,), + ), + SizedBox(height: 20.0,), + Obx(() => + //wantToGo(context), + + FutureBuilder( + future: wantToGo(context), + builder: (context, snapshot) { + return Container( + child: snapshot.data, + ); + }, + ), + + ), + SizedBox(height: 60.0,) + ], + ), + ); + } - FutureBuilder( - future: wantToGo(context), - builder: (context, snapshot) { - return Container( - child: snapshot.data, - ); - }, + SingleChildScrollView detailsSheet(BuildContext context) { + return SingleChildScrollView( + child: Column( + children: [ + Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Row( + children: [ + MaterialButton( + onPressed: () { + indexController.makePrevious(indexController.currentFeature[0]); + }, + color: Colors.blue, + textColor: Colors.white, + child: Icon( + Icons.arrow_back_ios, + size: 14, + ), + padding: EdgeInsets.all(16), + shape: CircleBorder(), + ), + Expanded( + child: Container( + alignment: Alignment.center, + child: Obx(() => + Text(indexController.currentFeature[0].properties!["location_name"], style: TextStyle( + fontSize: 15.0, + fontWeight: FontWeight.bold, + ), + ) + ), + ), + ), + MaterialButton( + onPressed: () { + print("----- next is ${indexController.currentFeature[0]} ------"); + indexController.makeNext(indexController.currentFeature[0]); + }, + color: Colors.blue, + textColor: Colors.white, + child: Icon( + Icons.arrow_forward_ios, + size: 14, + ), + padding: EdgeInsets.all(16), + shape: CircleBorder(), + ), + ], ), - + ), + ), + Row( + children: [ + Expanded( + child: SizedBox( + height: 260.0, + child: Obx(() => getImage()), + ) ), - SizedBox(height: 60.0,) ], - ) + ), + Obx(() => + (indexController.currentFeature[0].properties!["address"] as String).isNotEmpty ? + getDetails(context, "address".tr, indexController.currentFeature[0].properties!["address"] ?? '') + : + Container(width: 0.0, height: 0,), + ), + Obx(() => + (indexController.currentFeature[0].properties!["phone"] as String).isNotEmpty ? + getDetails(context, "telephone".tr, indexController.currentFeature[0].properties!["phone"] ?? '') + : + Container(width: 0.0, height: 0,), + ), + Obx(() => + (indexController.currentFeature[0].properties!["email"] as String).isNotEmpty ? + getDetails(context, "email".tr, indexController.currentFeature[0].properties!["email"] ?? '') + : + Container(width: 0.0, height: 0,), + ), + Obx(() => + (indexController.currentFeature[0].properties!["webcontents"] as String).isNotEmpty ? + getDetails(context, "web".tr, indexController.currentFeature[0].properties!["webcontents"] ?? '', isurl: true) + : + Container(width: 0.0, height: 0,), + ), + Obx(() => + (indexController.currentFeature[0].properties!["videos"] as String).isNotEmpty ? + getDetails(context, "video".tr, indexController.currentFeature[0].properties!["videos"] ?? '', isurl: true) + : + Container(width: 0.0, height: 0,), + ), + SizedBox(height: 20.0,), + Obx(() => + //wantToGo(context), + + FutureBuilder( + future: wantToGo(context), + builder: (context, snapshot) { + return Container( + child: snapshot.data, + ); + }, + ), + + ), + SizedBox(height: 60.0,) ], - ); + ), + ); } Future wantToGo(BuildContext context)async { + DatabaseHelper db = DatabaseHelper.instance; - bool isAdded = await db.isAlreadyAvailable(indexController.currentFeature[0].properties!["location_id"]); + //bool isAdded = await db.isAlreadyAvailable(indexController.currentFeature[0].properties!["location_id"]); return - isAdded == true ? Container(child: Text("すでに追加されています"),) : +// isAdded == true ? Container(child: Text("すでに追加されています"),) : Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - + indexController.rog_mode == 0 ? ElevatedButton( - onPressed: (){ - }, - child: ElevatedButton( - child: Text("want_to_go".tr), - onPressed: (){ - GeoJsonMultiPoint mp = indexController.currentFeature[0].geometry as GeoJsonMultiPoint; - LatLng pt = LatLng(mp.geoSerie!.geoPoints[0].latitude, mp.geoSerie!.geoPoints[0].longitude); + child: Text("want_to_go".tr), + onPressed: (){ + GeoJsonMultiPoint mp = indexController.currentFeature[0].geometry as GeoJsonMultiPoint; + LatLng pt = LatLng(mp.geoSerie!.geoPoints[0].latitude, mp.geoSerie!.geoPoints[0].longitude); - Destination dest = Destination( - name: indexController.currentFeature[0].properties!["location_name"], - address: indexController.currentFeature[0].properties!["address"], - phone: indexController.currentFeature[0].properties!["phone"], - email: indexController.currentFeature[0].properties!["email"], - webcontents: indexController.currentFeature[0].properties!["webcontents"], - videos: indexController.currentFeature[0].properties!["videos"], - category: indexController.currentFeature[0].properties!["category"], - series: 1, - lat: pt.latitude, - lon: pt.longitude, - location_id: indexController.currentFeature[0].properties!["location_id"], - list_order: 1, - photos: indexController.currentFeature[0].properties!["photos"], - checkin_radious: indexController.currentFeature[0].properties!["checkin_radious"], - auto_checkin: indexController.currentFeature[0].properties!["auto_checkin"] == true ? 1 : 0 - ); - destinationController.addDestinations(dest); - }, - ), - ), + Destination dest = Destination( + name: indexController.currentFeature[0].properties!["location_name"], + address: indexController.currentFeature[0].properties!["address"], + phone: indexController.currentFeature[0].properties!["phone"], + email: indexController.currentFeature[0].properties!["email"], + webcontents: indexController.currentFeature[0].properties!["webcontents"], + videos: indexController.currentFeature[0].properties!["videos"], + category: indexController.currentFeature[0].properties!["category"], + series: 1, + lat: pt.latitude, + lon: pt.longitude, + location_id: indexController.currentFeature[0].properties!["location_id"], + list_order: 1, + photos: indexController.currentFeature[0].properties!["photos"], + checkin_radious: indexController.currentFeature[0].properties!["checkin_radious"], + auto_checkin: indexController.currentFeature[0].properties!["auto_checkin"] == true ? 1 : 0, + selected: false, + checkedin: false + ); + destinationController.addDestinations(dest); + }, + ): + Container(), + SizedBox(width: 20.0,) , + Obx((() => + + indexController.rog_mode == 1 ? + ElevatedButton( + onPressed: () async { + Destination dest = indexController.currentDestinationFeature[0]!; + //print("------ curent destination is ${dest!.checkedIn}-------"); + if(dest != null){ + print("------ curent destination is ${dest!.checkedin}-------::::::::::"); + destinationController.makeCheckin(dest, !dest.checkedin!); + } + }, + child: indexController.currentDestinationFeature[0].checkedin == false ? + Text("Check in") + : + Text("Check out") + ): + Container() + + ) + ) ], ) ], @@ -208,63 +366,61 @@ class BottomSheetNew extends GetView { return Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - Flexible( - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - indexController.currentAction[0][0]["checkin"] == false ? - Column( + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + indexController.currentAction[0][0]["checkin"] == false ? + Column( + children: [ + Row( + mainAxisSize: MainAxisSize.max, children: [ - Row( - mainAxisSize: MainAxisSize.max, - children: [ - ElevatedButton( - child: Text("Image"), onPressed: (){ - final ImagePicker _picker = ImagePicker(); - _picker.pickImage(source: ImageSource.camera).then((value){ - print("----- image---- ${value!.path}"); - }); - }, - ) - ], - ), ElevatedButton( - onPressed: (){ - if(indexController.currentAction.isNotEmpty){ - print(indexController.currentAction[0]); - indexController.currentAction[0][0]["checkin"] = true; - Map temp = Map.from(indexController.currentAction[0][0]); - indexController.currentAction.clear(); - print("---temp---${temp}"); - indexController.currentAction.add([temp]); - } - indexController.makeAction(context); + child: Text("Image"), onPressed: (){ + final ImagePicker _picker = ImagePicker(); + _picker.pickImage(source: ImageSource.camera).then((value){ + print("----- image---- ${value!.path}"); + }); }, - child: Text("checkin".tr) - ) + ) ], - ) - : - ElevatedButton( - onPressed: (){ - if(indexController.currentAction.isNotEmpty){ - print(indexController.currentAction[0]); - indexController.currentAction[0][0]["checkin"] = false; - Map temp = Map.from(indexController.currentAction[0][0]); - indexController.currentAction.clear(); - print("---temp---${temp}"); - indexController.currentAction.add([temp]); - } - indexController.makeAction(context); - }, - - child: Icon( - Icons.favorite, color: Colors.red) + ), + ElevatedButton( + onPressed: (){ + if(indexController.currentAction.isNotEmpty){ + print(indexController.currentAction[0]); + indexController.currentAction[0][0]["checkin"] = true; + Map temp = Map.from(indexController.currentAction[0][0]); + indexController.currentAction.clear(); + print("---temp---${temp}"); + indexController.currentAction.add([temp]); + } + indexController.makeAction(context); + }, + child: Text("checkin".tr) + ) + ], + ) + : + ElevatedButton( + onPressed: (){ + if(indexController.currentAction.isNotEmpty){ + print(indexController.currentAction[0]); + indexController.currentAction[0][0]["checkin"] = false; + Map temp = Map.from(indexController.currentAction[0][0]); + indexController.currentAction.clear(); + print("---temp---${temp}"); + indexController.currentAction.add([temp]); + } + indexController.makeAction(context); + }, + + child: Icon( + Icons.favorite, color: Colors.red) - , - ) - ], - ), + , + ) + ], ) ], ); @@ -385,44 +541,35 @@ class BottomSheetNew extends GetView { ), ); } + - Widget getDetails(String label, String text, {bool isurl=false}){ + Widget getDetails(BuildContext context, String label, String text, {bool isurl=false}){ return Row( - mainAxisAlignment: MainAxisAlignment.end, + mainAxisAlignment: MainAxisAlignment.center, children: [ - Flexible( - flex: 1, - child: Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - Text(label), - ], - ), - ), + Text(label), SizedBox(width: 10.0,), Flexible( - flex: 3, - child: Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Expanded( - child: InkWell( - onTap: (){ - if(isurl){ - _launchURL(indexController.currentFeature[0].properties!["webcontents"]); + child: InkWell( + onTap: (){ + if(isurl){ + if(indexController.rog_mode == 0){ + _launchURL(indexController.currentFeature[0].properties!["webcontents"]); } - }, - child: Text(text, - style: TextStyle( - color: Colors.blue, - ), - softWrap: true, - overflow: TextOverflow.fade, + else { + indexController.currentDestinationFeature[0].webcontents; + } + + } + }, + child: Text(text, + style: TextStyle( + color: Colors.blue, ), - ), + overflow: TextOverflow.ellipsis, + maxLines: 5, + ), ), - ], - ), ), ], ); diff --git a/lib/widgets/destination_widget.dart b/lib/widgets/destination_widget.dart index 092f3d6..056594c 100644 --- a/lib/widgets/destination_widget.dart +++ b/lib/widgets/destination_widget.dart @@ -24,6 +24,7 @@ class DestinationWidget extends StatelessWidget { return Image(image: AssetImage('assets/images/empty_image.png')); } else{ + print("------- image is ${destinationController.destinations[index].photos!}------"); return Image(image: NetworkImage( destinationController.destinations[index].photos!), errorBuilder: (BuildContext context, Object exception, StackTrace? stackTrace) { @@ -115,12 +116,11 @@ class DestinationWidget extends StatelessWidget { child: ListTile( onTap: () async { { - double lat = destinationController.destinations[index].lat as double; - double lon = destinationController.destinations[index].lon as double; - Destination? fs = await destinationController.getDEstinationForLatLong(lat, lon); + Destination? fs = destinationController.destinations[index]; print("----fsf-----${fs}"); if(fs != null){ - if(indexController.currentFeature.length > 0) { + + if(indexController.currentDestinationFeature.length > 0) { indexController.currentDestinationFeature.clear(); } indexController.currentDestinationFeature.add(fs); @@ -153,7 +153,7 @@ class DestinationWidget extends StatelessWidget { }, selectedTileColor: Colors.amberAccent, - selected:destinationController.destinations[index].selected, + selected:destinationController.destinations[index].selected!, leading: getImage(index), title: Text(destinationController.destinations[index].name!), subtitle: Text(destinationController.destinations[index].category!), @@ -161,12 +161,12 @@ class DestinationWidget extends StatelessWidget { ), ), startChild: - destinationController.matrix["rows"] != null ? + destinationController.matrix["rows"][0]["elements"] != null ? Column( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ - Text(destinationController.matrix["rows"][0]["elements"][index]["distance"]["text"].toString()), - Text(destinationController.matrix["rows"][0]["elements"][index]["duration"]["text"].toString()) + //Text(destinationController.matrix["rows"][0]["elements"][index]["distance"]["text"].toString()), + //Text(destinationController.matrix["rows"][0]["elements"][index]["duration"]["text"].toString()) ], ): Container() diff --git a/lib/widgets/map_widget.dart b/lib/widgets/map_widget.dart index b360a06..609312b 100644 --- a/lib/widgets/map_widget.dart +++ b/lib/widgets/map_widget.dart @@ -136,10 +136,9 @@ class MapWidget extends StatelessWidget { GeoJsonFeature? fs = indexController.getFeatureForLatLong(marker.point.latitude, marker.point.longitude); //print("------- fs ${fs}------"); if(fs != null){ - if(indexController.currentFeature.length > 0) { - indexController.currentFeature.clear(); - } + indexController.currentFeature.clear(); indexController.currentFeature.add(fs); + //print("----- fs is ${fs.properties!['photos']}"); indexController.getAction(); showModalBottomSheet(