update for travelmode change bug fixes

This commit is contained in:
Mohamed Nouffer
2022-07-10 23:50:43 +05:30
parent ce105a6754
commit 264cd828f4
9 changed files with 121 additions and 62 deletions

View File

@ -47,10 +47,13 @@ class DestinationWidget extends StatelessWidget {
}
void doDelete() {
destinationController.destination_index_data.forEach((element) {
//print(element["index"]);
destinationController.deleteDestination(element["index"]);
destinationController.currentSelectedDestinations.forEach((element) {
destinationController.deleteDestination(element);
});
// destinationController.destination_index_data.forEach((element) {
// //print(element["index"]);
// destinationController.deleteDestination(element["index"]);
// });
// destinationController.destination_index_data.clear();
}
@ -83,7 +86,7 @@ class DestinationWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
print("---- destinations ${destinationController.destinations[0].name} ------");
print("------ destination widget------ ${destinationController.destinationCount.value} ----------");
return
Obx(() =>
@ -93,18 +96,7 @@ class DestinationWidget extends StatelessWidget {
padding: const EdgeInsets.only(top:45.0),
child: ListView.builder(
itemCount: destinationController.destinationCount.value,
//itemCount: destinationController.destinations.length,
// onReorder: (int oldIndex, int newIndex){
// int action_id = destinationController.destinations[oldIndex]["id"] as int;
// //print(action_id);
// if(oldIndex > newIndex){
// destinationController.makeOrder(context, action_id, newIndex, "up");
// }
// else if(oldIndex < newIndex){
// destinationController.makeOrder(context, action_id, newIndex, "down");
// }
// },
itemBuilder: (BuildContext context, int index) {
return
TimelineTile(
@ -142,29 +134,29 @@ class DestinationWidget extends StatelessWidget {
};
},
onLongPress: (){
print("#### long press #### ${destinationController.destination_index_data.length}");
var match_element = null;
destinationController.destination_index_data.forEach((element) {
if(element["index"] == index){
Destination? match_element = null;
destinationController.currentSelectedDestinations.forEach((element) {
if(element.location_id == destinationController.destinations[index].location_id){
match_element = element;
print("----match----");
return;
}
});
if(match_element != null){
destinationController.destination_index_data.remove(match_element);
return;
destinationController.currentSelectedDestinations.remove(destinationController.destinations[index]);
}
//print("------${destinationController.destination_index_data}----");
Map<String, dynamic> indexed = {'index': index, 'selected':true};
destinationController.destination_index_data.add(indexed);
destinationController.currentSelectedDestinations.add(destinationController.destinations[index]);
destinationController.PopulateDestinations();
},
selectedTileColor: Colors.amberAccent,
selected:getSelection(index),
selected:destinationController.destinations[index].selected,
leading: getImage(index),
title: Text(destinationController.destinations[index].name!),
//subtitle: Text(destinationController.destinations[index].category!),
subtitle: Text(destinationController.destinations[index].category!),
),
),
),
@ -203,7 +195,7 @@ class DestinationWidget extends StatelessWidget {
IconButton(
icon:Icon(Icons.cancel),
//onPressed: (){doDelete();},
onPressed: destinationController.destination_index_data.length > 0 ? doDelete : null,
onPressed: destinationController.currentSelectedDestinations.length > 0 ? doDelete : null,
),
IconButton(
icon:Icon(Icons.move_up),