update for chech in

This commit is contained in:
Mohamed Nouffer
2022-07-14 23:10:24 +05:30
parent 264cd828f4
commit 42accf9f3a
10 changed files with 532 additions and 311 deletions

View File

@ -16,7 +16,8 @@ class Destination {
String? photos; String? photos;
double? checkin_radious; double? checkin_radious;
int? auto_checkin; int? auto_checkin;
bool selected = false; bool? selected = false;
bool? checkedin = false;
Destination({ Destination({
this.name, this.name,
@ -33,28 +34,40 @@ class Destination {
this.list_order, this.list_order,
this.photos, this.photos,
this.checkin_radious, this.checkin_radious,
this.auto_checkin this.auto_checkin,
this.selected,
this.checkedin
}); });
factory Destination.fromMap(Map<String, dynamic> json) => Destination( factory Destination.fromMap(Map<String, dynamic> json) {
name: json['name'],
address: json['address'], bool selec = json['selected'] == 0 ? false : true;
phone: json['phone'], bool checkin = json['checkedin'] == 0 ? false : true;
email: json['email'],
webcontents: json['webcontents'], return Destination(
videos: json['videos'], name: json['name'],
category: json['category'], address: json['address'],
series: json['series'], phone: json['phone'],
lat: json['lat'], email: json['email'],
lon: json['lon'], webcontents: json['webcontents'],
location_id: json['location_id'], videos: json['videos'],
list_order: json['list_order'], category: json['category'],
photos: json['category'], series: json['series'],
checkin_radious: json['checkin_radious'], lat: json['lat'],
auto_checkin:json['auto_checkin'] 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<String, dynamic> toMap(){ Map<String, dynamic> toMap(){
int sel = selected == false ? 0 : 1;
int check = checkedin == false ? 0 : 1;
return { return {
'name':name, 'name':name,
'address': address, 'address': address,
@ -70,7 +83,9 @@ class Destination {
'list_order':list_order, 'list_order':list_order,
'photos':photos, 'photos':photos,
'checkin_radious': checkin_radious, 'checkin_radious': checkin_radious,
'auto_checkin': auto_checkin 'auto_checkin': auto_checkin,
'selected': sel,
'checkedin': check
}; };
} }

View File

@ -61,6 +61,7 @@ class DestinationController extends GetxController {
} }
checkForCheckin(double la, double ln){ checkForCheckin(double la, double ln){
for(final d in destinations){ for(final d in destinations){
double lat = d.lat!; double lat = d.lat!;
double lon = d.lon!; double lon = d.lon!;
@ -74,41 +75,72 @@ class DestinationController extends GetxController {
indexController.currentDestinationFeature.add(value); indexController.currentDestinationFeature.add(value);
//indexController.getAction(); //indexController.getAction();
if(!checking_in){
checking_in = true; if(rad >= dist){
if(rad >= dist){ if(auto_checkin){
if(auto_checkin){ makeCheckin(value, true);
if(indexController.currentAction.isNotEmpty){ }
print(indexController.currentAction[0]); else{
indexController.currentAction[0][0]["checkin"] = true; showModalBottomSheet(context: Get.context!, isScrollControlled: true,
Map<String,dynamic> temp = Map<String,dynamic>.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()) builder:((context) => BottomSheetWidget())
).whenComplete((){ ).whenComplete((){
checking_in = false; 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<String,dynamic> temp = Map<String,dynamic>.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}"); 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<Destination> 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 @override
void onInit() { void onInit() async {
super.onInit(); super.onInit();
checkPermission();
PopulateDestinations(); PopulateDestinations();
print("------ in iniit"); print("------ in iniit");
@ -146,14 +178,16 @@ class DestinationController extends GetxController {
StreamSubscription<Position> positionStream = Geolocator.getPositionStream(locationSettings: locationSettings).listen( StreamSubscription<Position> positionStream = Geolocator.getPositionStream(locationSettings: locationSettings).listen(
(Position? position) { (Position? position) {
double czoom = indexController.rogMapController!.zoom;
indexController.rogMapController!.move(LatLng(position!.latitude, position!.longitude), czoom);
if(isSelected[0]){ if(isSelected[0]){
String user_id = indexController.currentUser[0]["user"]["id"].toString(); double czoom = indexController.rogMapController!.zoom;
TrackingService.addTrack(user_id, position!.latitude, position.longitude).then((val){ indexController.rogMapController!.move(LatLng(position!.latitude, position!.longitude), czoom);
//checkForCheckin(position!.latitude, position.longitude); //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()}'); 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){ void deleteDestination(Destination d){
//int id = destinations[index].location_id!; //int id = destinations[index].location_id!;
//print("---- index ${destinations[index].location_id!}-----"); //print("---- index ${destinations[index].location_id!}-----");
@ -215,11 +257,9 @@ class DestinationController extends GetxController {
DatabaseHelper db = DatabaseHelper.instance; DatabaseHelper db = DatabaseHelper.instance;
db.getDestinations().then((value){ db.getDestinations().then((value){
for(Destination d in value){ for(Destination d in value){
print("-- destination controller Populating destination -- ${d.name}-----::::");
for(Destination s in currentSelectedDestinations){ for(Destination s in currentSelectedDestinations){
if(d.location_id == s.location_id){ if(d.location_id == s.location_id){
d.selected = !d.selected; d.selected = !d.selected!;
} }
} }

View File

@ -90,23 +90,25 @@ class _DestinationPageState extends State<DestinationPage> {
automaticallyImplyLeading: false, automaticallyImplyLeading: false,
title: Text("app_title".tr), title: Text("app_title".tr),
actions: [ actions: [
ToggleButtons( Obx(() =>
disabledColor: Colors.grey.shade200, ToggleButtons(
selectedColor: Colors.red, disabledColor: Colors.grey.shade200,
children: <Widget>[ selectedColor: Colors.red,
Icon(Icons.explore children: <Widget>[
)], Icon(Icons.explore
onPressed: (int index) { )],
setState(() { onPressed: (int index) {
destinationController.isSelected[index] = !destinationController.isSelected[index]; setState(() {
}); destinationController.isSelected[index] = !destinationController.isSelected[index];
}, });
isSelected: destinationController.isSelected, },
), isSelected: destinationController.isSelected,
IconButton(onPressed: (){ ),
showCurrentPosition(); ),
}, // IconButton(onPressed: (){
icon: Icon(Icons.location_on_outlined)) // showCurrentPosition();
// },
// icon: Icon(Icons.location_on_outlined))
], ],
), ),
body: Obx(() => body: Obx(() =>

View File

@ -159,6 +159,8 @@ class _DestinationMapPageState extends State<DestinationMapPage> {
// do something // do something
} }
if (mapEvent is MapEventMoveEnd) { if (mapEvent is MapEventMoveEnd) {
destinationController.isSelected.clear();
destinationController.isSelected.add(false);
//print(DateTime.now().toString() + ' [MapEventMoveStart] END'); //print(DateTime.now().toString() + ' [MapEventMoveStart] END');
//indexController.loadLocationsBound(); //indexController.loadLocationsBound();
} }

View File

@ -47,6 +47,7 @@ class IndexController extends GetxController {
var mode = 0.obs; var mode = 0.obs;
// master mode, rog or selection
var rog_mode = 1.obs; var rog_mode = 1.obs;
var desination_mode = 1.obs; var desination_mode = 1.obs;

View File

@ -34,18 +34,18 @@ class IndexPage extends GetView<IndexController> {
//automaticallyImplyLeading: false, //automaticallyImplyLeading: false,
title: Text("Add locations"), title: Text("Add locations"),
actions: [ actions: [
// RaisedButton( RaisedButton(
// child: Text("db"), child: Text("db"),
// onPressed: (){ onPressed: (){
// DatabaseHelper db = DatabaseHelper.instance; DatabaseHelper db = DatabaseHelper.instance;
// db.getDestinations().then((value){ db.getDestinations().then((value){
// print("-------- lendth in db ${value.length} ---- :::::"); print("-------- lendth in db ${value.length} ---- :::::");
// for(Destination d in value){ for(Destination d in value){
// print("-------- values in db are ${d.toString()} ---- :::::"); print("-------- values in db are ${d.checkedin} ---- :::::");
// }; };
// }); });
// }, },
// ), ),
CatWidget(indexController: indexController,), CatWidget(indexController: indexController,),
], ],
), ),
@ -65,7 +65,6 @@ class IndexPage extends GetView<IndexController> {
onPressed: (){ onPressed: (){
indexController.toggleMode(); indexController.toggleMode();
if(indexController.currentCat.isNotEmpty){ if(indexController.currentCat.isNotEmpty){
print("###############");
print(indexController.currentCat[0].toString()); print(indexController.currentCat[0].toString());
} }

View File

@ -39,7 +39,9 @@ class DatabaseHelper{
list_order INTEGER, list_order INTEGER,
photos TEXT, photos TEXT,
checkin_radious REAL, checkin_radious REAL,
auto_checkin INTEGER auto_checkin INTEGER,
selected INTEGER,
checkedin INTEGER
) )
'''); ''');
} }
@ -85,6 +87,20 @@ class DatabaseHelper{
return res; return res;
} }
Future<int> updateAction(Destination destination, bool checkin)async {
Database db = await instance.database;
int act = checkin == false ? 0 : 1;
Map<String, dynamic> row = {
"checkedin": act
};
return await db.update(
"destination",
row,
where: 'location_id = ?',
whereArgs: [destination.location_id]
);
}
// Future<int?> getPending() async{ // Future<int?> getPending() async{
// Database db = await instance.database; // Database db = await instance.database;
// return await Sqflite.firstIntValue(await db.rawQuery("SELECT COUNT(*) FROM incidents")); // return await Sqflite.firstIntValue(await db.rawQuery("SELECT COUNT(*) FROM incidents"));

View File

@ -18,19 +18,40 @@ class BottomSheetNew extends GetView<BottomSheetController> {
final IndexController indexController = Get.find<IndexController>(); final IndexController indexController = Get.find<IndexController>();
final DestinationController destinationController = Get.find<DestinationController>(); final DestinationController destinationController = Get.find<DestinationController>();
Image getImage(GeoJsonFeature? gf){ Image getImage(){
if(gf!.properties!["photos"] == null || gf.properties!["photos"] == ""){
return Image(image: AssetImage('assets/images/empty_image.png')); 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{ else{
return Image(image: NetworkImage( GeoJsonFeature<dynamic> gf = indexController.currentFeature[0];
gf.properties!["photos"], if(gf!.properties!["photos"] == null || gf.properties!["photos"] == ""){
), return Image(image: AssetImage('assets/images/empty_image.png'));
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");
},
);
} }
}
} }
void _launchURL(url) async { void _launchURL(url) async {
@ -39,162 +60,299 @@ class BottomSheetNew extends GetView<BottomSheetController> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Wrap(
return indexController.rog_mode == 0 ? detailsSheet(context) : destinationSheet(context);
}
SingleChildScrollView destinationSheet(BuildContext context) {
return SingleChildScrollView(
child: Column(
children: [ children: [
Column( Padding(
children: [ padding: const EdgeInsets.all(8.0),
Padding( child: Container(
padding: const EdgeInsets.all(8.0), child: Row(
child: Container( children: [
child: Row( MaterialButton(
children: [ onPressed: () {
MaterialButton( indexController.makePrevious(indexController.currentFeature[0]);
onPressed: () { },
indexController.makePrevious(indexController.currentFeature[0]); color: Colors.blue,
}, textColor: Colors.white,
color: Colors.blue, child: Icon(
textColor: Colors.white, Icons.arrow_back_ios,
child: Icon( size: 14,
Icons.arrow_back_ios, ),
size: 14, padding: EdgeInsets.all(16),
), shape: CircleBorder(),
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( Expanded(
child: SizedBox( child: Container(
height: 260.0, alignment: Alignment.center,
child: Obx(() => getImage(indexController.currentFeature[0])), 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"] ?? '') Row(
: children: [
Container(width: 0.0, height: 0,), 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),
FutureBuilder<Widget>(
future: wantToGo(context),
builder: (context, snapshot) {
return Container(
child: snapshot.data,
);
},
),
),
SizedBox(height: 60.0,)
], ],
) ),
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<Widget>(
future: wantToGo(context),
builder: (context, snapshot) {
return Container(
child: snapshot.data,
);
},
),
),
SizedBox(height: 60.0,)
], ],
); ),
);
}
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()),
)
),
],
),
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<Widget>(
future: wantToGo(context),
builder: (context, snapshot) {
return Container(
child: snapshot.data,
);
},
),
),
SizedBox(height: 60.0,)
],
),
);
} }
Future<Widget> wantToGo(BuildContext context)async { Future<Widget> wantToGo(BuildContext context)async {
DatabaseHelper db = DatabaseHelper.instance; 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 return
isAdded == true ? Container(child: Text("すでに追加されています"),) : // isAdded == true ? Container(child: Text("すでに追加されています"),) :
Row( Row(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
Row( Row(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
indexController.rog_mode == 0 ?
ElevatedButton( ElevatedButton(
onPressed: (){ child: Text("want_to_go".tr),
}, onPressed: (){
child: ElevatedButton( GeoJsonMultiPoint mp = indexController.currentFeature[0].geometry as GeoJsonMultiPoint;
child: Text("want_to_go".tr), LatLng pt = LatLng(mp.geoSerie!.geoPoints[0].latitude, mp.geoSerie!.geoPoints[0].longitude);
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( Destination dest = Destination(
name: indexController.currentFeature[0].properties!["location_name"], name: indexController.currentFeature[0].properties!["location_name"],
address: indexController.currentFeature[0].properties!["address"], address: indexController.currentFeature[0].properties!["address"],
phone: indexController.currentFeature[0].properties!["phone"], phone: indexController.currentFeature[0].properties!["phone"],
email: indexController.currentFeature[0].properties!["email"], email: indexController.currentFeature[0].properties!["email"],
webcontents: indexController.currentFeature[0].properties!["webcontents"], webcontents: indexController.currentFeature[0].properties!["webcontents"],
videos: indexController.currentFeature[0].properties!["videos"], videos: indexController.currentFeature[0].properties!["videos"],
category: indexController.currentFeature[0].properties!["category"], category: indexController.currentFeature[0].properties!["category"],
series: 1, series: 1,
lat: pt.latitude, lat: pt.latitude,
lon: pt.longitude, lon: pt.longitude,
location_id: indexController.currentFeature[0].properties!["location_id"], location_id: indexController.currentFeature[0].properties!["location_id"],
list_order: 1, list_order: 1,
photos: indexController.currentFeature[0].properties!["photos"], photos: indexController.currentFeature[0].properties!["photos"],
checkin_radious: indexController.currentFeature[0].properties!["checkin_radious"], checkin_radious: indexController.currentFeature[0].properties!["checkin_radious"],
auto_checkin: indexController.currentFeature[0].properties!["auto_checkin"] == true ? 1 : 0 auto_checkin: indexController.currentFeature[0].properties!["auto_checkin"] == true ? 1 : 0,
); selected: false,
destinationController.addDestinations(dest); 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<BottomSheetController> {
return Row( return Row(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
Flexible( Row(
child: Row( mainAxisAlignment: MainAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center, children: [
children: [ indexController.currentAction[0][0]["checkin"] == false ?
indexController.currentAction[0][0]["checkin"] == false ? Column(
Column( children: [
Row(
mainAxisSize: MainAxisSize.max,
children: [ 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( ElevatedButton(
onPressed: (){ child: Text("Image"), onPressed: (){
if(indexController.currentAction.isNotEmpty){ final ImagePicker _picker = ImagePicker();
print(indexController.currentAction[0]); _picker.pickImage(source: ImageSource.camera).then((value){
indexController.currentAction[0][0]["checkin"] = true; print("----- image---- ${value!.path}");
Map<String,dynamic> temp = Map<String,dynamic>.from(indexController.currentAction[0][0]); });
indexController.currentAction.clear();
print("---temp---${temp}");
indexController.currentAction.add([temp]);
}
indexController.makeAction(context);
}, },
child: Text("checkin".tr) )
)
], ],
) ),
: ElevatedButton(
ElevatedButton( onPressed: (){
onPressed: (){ if(indexController.currentAction.isNotEmpty){
if(indexController.currentAction.isNotEmpty){ print(indexController.currentAction[0]);
print(indexController.currentAction[0]); indexController.currentAction[0][0]["checkin"] = true;
indexController.currentAction[0][0]["checkin"] = false; Map<String,dynamic> temp = Map<String,dynamic>.from(indexController.currentAction[0][0]);
Map<String,dynamic> temp = Map<String,dynamic>.from(indexController.currentAction[0][0]); indexController.currentAction.clear();
indexController.currentAction.clear(); print("---temp---${temp}");
print("---temp---${temp}"); indexController.currentAction.add([temp]);
indexController.currentAction.add([temp]); }
} indexController.makeAction(context);
indexController.makeAction(context); },
}, child: Text("checkin".tr)
)
],
)
:
ElevatedButton(
onPressed: (){
if(indexController.currentAction.isNotEmpty){
print(indexController.currentAction[0]);
indexController.currentAction[0][0]["checkin"] = false;
Map<String,dynamic> temp = Map<String,dynamic>.from(indexController.currentAction[0][0]);
indexController.currentAction.clear();
print("---temp---${temp}");
indexController.currentAction.add([temp]);
}
indexController.makeAction(context);
},
child: Icon( child: Icon(
Icons.favorite, color: Colors.red) Icons.favorite, color: Colors.red)
, ,
) )
], ],
),
) )
], ],
); );
@ -386,43 +542,34 @@ class BottomSheetNew extends GetView<BottomSheetController> {
); );
} }
Widget getDetails(String label, String text, {bool isurl=false}){
Widget getDetails(BuildContext context, String label, String text, {bool isurl=false}){
return Row( return Row(
mainAxisAlignment: MainAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
Flexible( Text(label),
flex: 1,
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Text(label),
],
),
),
SizedBox(width: 10.0,), SizedBox(width: 10.0,),
Flexible( Flexible(
flex: 3, child: InkWell(
child: Row( onTap: (){
mainAxisAlignment: MainAxisAlignment.start, if(isurl){
children: [ if(indexController.rog_mode == 0){
Expanded( _launchURL(indexController.currentFeature[0].properties!["webcontents"]);
child: InkWell(
onTap: (){
if(isurl){
_launchURL(indexController.currentFeature[0].properties!["webcontents"]);
} }
}, else {
child: Text(text, indexController.currentDestinationFeature[0].webcontents;
style: TextStyle( }
color: Colors.blue,
), }
softWrap: true, },
overflow: TextOverflow.fade, child: Text(text,
style: TextStyle(
color: Colors.blue,
), ),
), overflow: TextOverflow.ellipsis,
maxLines: 5,
),
), ),
],
),
), ),
], ],
); );

View File

@ -24,6 +24,7 @@ class DestinationWidget extends StatelessWidget {
return Image(image: AssetImage('assets/images/empty_image.png')); return Image(image: AssetImage('assets/images/empty_image.png'));
} }
else{ else{
print("------- image is ${destinationController.destinations[index].photos!}------");
return Image(image: NetworkImage( return Image(image: NetworkImage(
destinationController.destinations[index].photos!), destinationController.destinations[index].photos!),
errorBuilder: (BuildContext context, Object exception, StackTrace? stackTrace) { errorBuilder: (BuildContext context, Object exception, StackTrace? stackTrace) {
@ -115,12 +116,11 @@ class DestinationWidget extends StatelessWidget {
child: ListTile( child: ListTile(
onTap: () async { onTap: () async {
{ {
double lat = destinationController.destinations[index].lat as double; Destination? fs = destinationController.destinations[index];
double lon = destinationController.destinations[index].lon as double;
Destination? fs = await destinationController.getDEstinationForLatLong(lat, lon);
print("----fsf-----${fs}"); print("----fsf-----${fs}");
if(fs != null){ if(fs != null){
if(indexController.currentFeature.length > 0) {
if(indexController.currentDestinationFeature.length > 0) {
indexController.currentDestinationFeature.clear(); indexController.currentDestinationFeature.clear();
} }
indexController.currentDestinationFeature.add(fs); indexController.currentDestinationFeature.add(fs);
@ -153,7 +153,7 @@ class DestinationWidget extends StatelessWidget {
}, },
selectedTileColor: Colors.amberAccent, selectedTileColor: Colors.amberAccent,
selected:destinationController.destinations[index].selected, selected:destinationController.destinations[index].selected!,
leading: getImage(index), leading: getImage(index),
title: Text(destinationController.destinations[index].name!), title: Text(destinationController.destinations[index].name!),
subtitle: Text(destinationController.destinations[index].category!), subtitle: Text(destinationController.destinations[index].category!),
@ -161,12 +161,12 @@ class DestinationWidget extends StatelessWidget {
), ),
), ),
startChild: startChild:
destinationController.matrix["rows"] != null ? destinationController.matrix["rows"][0]["elements"] != null ?
Column( Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly, mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [ children: [
Text(destinationController.matrix["rows"][0]["elements"][index]["distance"]["text"].toString()), //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]["duration"]["text"].toString())
], ],
): ):
Container() Container()

View File

@ -136,10 +136,9 @@ class MapWidget extends StatelessWidget {
GeoJsonFeature? fs = indexController.getFeatureForLatLong(marker.point.latitude, marker.point.longitude); GeoJsonFeature? fs = indexController.getFeatureForLatLong(marker.point.latitude, marker.point.longitude);
//print("------- fs ${fs}------"); //print("------- fs ${fs}------");
if(fs != null){ if(fs != null){
if(indexController.currentFeature.length > 0) { indexController.currentFeature.clear();
indexController.currentFeature.clear();
}
indexController.currentFeature.add(fs); indexController.currentFeature.add(fs);
//print("----- fs is ${fs.properties!['photos']}");
indexController.getAction(); indexController.getAction();
showModalBottomSheet( showModalBottomSheet(