update for travelmode change bug fixes
This commit is contained in:
@ -27,6 +27,8 @@ class DestinationController extends GetxController {
|
||||
List<Destination> destinations = <Destination>[].obs;
|
||||
List<Map<String, dynamic>> destination_index_data = <Map<String, dynamic>>[].obs;
|
||||
|
||||
List<Destination> currentSelectedDestinations = <Destination>[].obs;
|
||||
|
||||
bool checking_in = false;
|
||||
List<bool> isSelected = [true].obs;
|
||||
BuildContext? context;
|
||||
@ -159,12 +161,17 @@ class DestinationController extends GetxController {
|
||||
|
||||
}
|
||||
|
||||
void deleteDestination(int index){
|
||||
print("---- index ${index}-----");
|
||||
int id = destinations[index].location_id!;
|
||||
void deleteDestination(Destination d){
|
||||
//int id = destinations[index].location_id!;
|
||||
//print("---- index ${destinations[index].location_id!}-----");
|
||||
for(Destination ss in currentSelectedDestinations){
|
||||
if(ss.location_id == d.location_id){
|
||||
currentSelectedDestinations.remove(ss);
|
||||
break;
|
||||
}
|
||||
}
|
||||
DatabaseHelper db = DatabaseHelper.instance;
|
||||
db.deleteDestination(id).then((value){
|
||||
db.deleteDestination(d.location_id!).then((value){
|
||||
PopulateDestinations();
|
||||
});
|
||||
// DestinationService.deleteDestination(id).then((val){
|
||||
@ -178,36 +185,50 @@ class DestinationController extends GetxController {
|
||||
|
||||
void addDestinations(Destination dest){
|
||||
|
||||
print('------ destination controller in add destination ${dest.name} ---- :::::');
|
||||
|
||||
DatabaseHelper db = DatabaseHelper.instance;
|
||||
db.getDestinationByLatLon(dest.lat!, dest.lon!).then((value){
|
||||
//print("----- available destination for latlon $value[0]");
|
||||
if(value.isNotEmpty){
|
||||
db.deleteDestination(value[0].location_id!).then((value){
|
||||
db.insertDestination(dest).then((value){
|
||||
print("----- delete andinserted destination id $value");
|
||||
print("----- destination controller deleted and inserted destination id $value ---- :::::");
|
||||
PopulateDestinations();
|
||||
});
|
||||
});
|
||||
}
|
||||
else {
|
||||
db.insertDestination(dest).then((value){
|
||||
print("----- new inserted destination id $value");
|
||||
print("----- destination controller added as new ${value}--- :::::");
|
||||
PopulateDestinations();
|
||||
});
|
||||
}
|
||||
});
|
||||
PopulateDestinations();
|
||||
|
||||
}
|
||||
|
||||
void PopulateDestinations(){
|
||||
print("--------- populsting destinations -----------");
|
||||
print("--------- destination controller populsting destinations ----------- ::::::");
|
||||
|
||||
destinations.clear();
|
||||
destinationCount.value = 0;
|
||||
DatabaseHelper db = DatabaseHelper.instance;
|
||||
db.getDestinations().then((value){
|
||||
destinations.clear();
|
||||
destinations = 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;
|
||||
}
|
||||
}
|
||||
|
||||
destinations.add(d);
|
||||
}
|
||||
// destinationCount.value = 0;
|
||||
print("------destinationcount-------- ${destinationCount}--------");
|
||||
destinationCount.value = destinations.length;
|
||||
print("------ destination controller destinationcount-------- ${destinationCount}-------- :::::");
|
||||
|
||||
|
||||
MatrixService.getDestinations(value).then((mat){
|
||||
print(mat);
|
||||
|
||||
Reference in New Issue
Block a user