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

@ -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<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,
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<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}");
});
}
}
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
void onInit() {
void onInit() async {
super.onInit();
checkPermission();
PopulateDestinations();
print("------ in iniit");
@ -146,14 +178,16 @@ class DestinationController extends GetxController {
StreamSubscription<Position> 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!;
}
}

View File

@ -90,23 +90,25 @@ class _DestinationPageState extends State<DestinationPage> {
automaticallyImplyLeading: false,
title: Text("app_title".tr),
actions: [
ToggleButtons(
disabledColor: Colors.grey.shade200,
selectedColor: Colors.red,
children: <Widget>[
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: <Widget>[
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(() =>

View File

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

View File

@ -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;

View File

@ -34,18 +34,18 @@ class IndexPage extends GetView<IndexController> {
//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<IndexController> {
onPressed: (){
indexController.toggleMode();
if(indexController.currentCat.isNotEmpty){
print("###############");
print(indexController.currentCat[0].toString());
}