update reordering
This commit is contained in:
@ -60,24 +60,57 @@ class DestinationWidget extends StatelessWidget {
|
||||
}
|
||||
|
||||
void moveUp() {
|
||||
for(Destination d in destinationController.destinations){
|
||||
// if(d.selected){
|
||||
|
||||
// }
|
||||
Destination? d = null;
|
||||
for(Destination ad in destinationController.destinations){
|
||||
if(ad.selected == true){
|
||||
d = ad;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(d != null){
|
||||
print("--- selected destination is ${d.list_order}");
|
||||
destinationController.makeOrder(d, -1);
|
||||
}
|
||||
destinationController.destination_index_data.forEach((element) {
|
||||
//print(element["index"]);
|
||||
//int action_id = destinationController.destinations[element["index"]]["id"] as int;
|
||||
//destinationController.makeOrder(action_id, (element["index"] as int) - 1, "up");
|
||||
});
|
||||
}
|
||||
|
||||
void moveDown() {
|
||||
destinationController.destination_index_data.forEach((element) {
|
||||
//print(element["index"]);
|
||||
//int action_id = destinationController.destinations[element["index"]]["id"] as int;
|
||||
//destinationController.makeOrder(action_id, (element["index"] as int) + 1, "up");
|
||||
});
|
||||
Destination? d = null;
|
||||
for(Destination ad in destinationController.destinations){
|
||||
if(ad.selected == true){
|
||||
d = ad;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(d != null){
|
||||
print("--- selected destination is ${d.list_order}");
|
||||
destinationController.makeOrder(d, 1);
|
||||
}
|
||||
}
|
||||
|
||||
void clearall(){
|
||||
Get.defaultDialog(
|
||||
title: "are_you_sure_want_to_delete_all".tr,
|
||||
middleText: "all_added_destination_will_be_deleted".tr,
|
||||
backgroundColor: Colors.blue.shade300,
|
||||
titleStyle: TextStyle(color: Colors.white),
|
||||
middleTextStyle: TextStyle(color: Colors.white),
|
||||
textConfirm: "confirm".tr,
|
||||
textCancel: "cancel".tr,
|
||||
cancelTextColor: Colors.white,
|
||||
confirmTextColor: Colors.blue,
|
||||
buttonColor: Colors.white,
|
||||
barrierDismissible: false,
|
||||
radius: 10,
|
||||
content: Column(
|
||||
children: [
|
||||
],
|
||||
),
|
||||
onConfirm: (){
|
||||
destinationController.deleteAllDestinations();
|
||||
Get.back();
|
||||
Get.snackbar("deleted".tr, "all_destinations_are_deleted_successfully".tr);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
void interChange() {
|
||||
@ -148,19 +181,33 @@ class DestinationWidget extends StatelessWidget {
|
||||
},
|
||||
onLongPress: (){
|
||||
|
||||
Destination? match_element = null;
|
||||
destinationController.currentSelectedDestinations.forEach((element) {
|
||||
if(element.location_id == destinationController.destinations[index].location_id){
|
||||
match_element = element;
|
||||
for(Destination d in destinationController.destinations){
|
||||
if(destinationController.currentSelectedDestinations.length > 0){
|
||||
if(destinationController.currentSelectedDestinations[0].location_id == destinationController.destinations[index].location_id){
|
||||
destinationController.currentSelectedDestinations.clear();
|
||||
print("---- fount ----");
|
||||
destinationController.PopulateDestinations();
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
if(match_element != null){
|
||||
destinationController.currentSelectedDestinations.remove(destinationController.destinations[index]);
|
||||
}
|
||||
}
|
||||
|
||||
destinationController.currentSelectedDestinations.add(destinationController.destinations[index]);
|
||||
destinationController.currentSelectedDestinations.clear();
|
||||
destinationController.currentSelectedDestinations.add(destinationController.destinations[index]);
|
||||
|
||||
// Destination? match_element = null;
|
||||
// destinationController.currentSelectedDestinations.forEach((element) {
|
||||
// if(element.location_id == destinationController.destinations[index].location_id){
|
||||
// match_element = element;
|
||||
// return;
|
||||
// }
|
||||
// });
|
||||
|
||||
// if(match_element != null){
|
||||
// destinationController.currentSelectedDestinations.remove(destinationController.destinations[index]);
|
||||
// }
|
||||
// //destinationController.currentSelectedDestinations.clear();
|
||||
// destinationController.currentSelectedDestinations.add(destinationController.destinations[index]);
|
||||
|
||||
destinationController.PopulateDestinations();
|
||||
|
||||
@ -205,6 +252,11 @@ class DestinationWidget extends StatelessWidget {
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
IconButton(
|
||||
icon:Icon(Icons.delete_forever),
|
||||
//onPressed: (){doDelete();},
|
||||
onPressed: clearall,
|
||||
),
|
||||
IconButton(
|
||||
icon:Icon(Icons.cancel),
|
||||
//onPressed: (){doDelete();},
|
||||
@ -212,16 +264,16 @@ class DestinationWidget extends StatelessWidget {
|
||||
),
|
||||
IconButton(
|
||||
icon:Icon(Icons.move_up),
|
||||
onPressed: destinationController.destination_index_data.length > 0 ? moveUp : null,
|
||||
onPressed: destinationController.currentSelectedDestinations.length > 0 ? moveUp : null,
|
||||
),
|
||||
IconButton(
|
||||
icon:Icon(Icons.move_down),
|
||||
onPressed: destinationController.destination_index_data.length > 0 ? moveDown : null,
|
||||
),
|
||||
IconButton(
|
||||
icon:Icon(Icons.sync),
|
||||
onPressed: destinationController.destination_index_data.length == 2 ? interChange : null,
|
||||
onPressed: destinationController.currentSelectedDestinations.length > 0 ? moveDown : null,
|
||||
),
|
||||
// IconButton(
|
||||
// icon:Icon(Icons.sync),
|
||||
// onPressed: destinationController.destination_index_data.length == 2 ? interChange : null,
|
||||
// ),
|
||||
],
|
||||
),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user