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

@ -132,9 +132,19 @@ class BottomSheetNew extends GetView<BottomSheetController> {
Container(width: 0.0, height: 0,),
),
SizedBox(height: 20.0,),
//Obx(() =>
wantToGo(context),
//),
Obx(() =>
//wantToGo(context),
FutureBuilder<Widget>(
future: wantToGo(context),
builder: (context, snapshot) {
return Container(
child: snapshot.data,
);
},
),
),
SizedBox(height: 60.0,)
],
)
@ -143,25 +153,27 @@ class BottomSheetNew extends GetView<BottomSheetController> {
}
Widget wantToGo(BuildContext context){
return Row(
Future<Widget> wantToGo(BuildContext context)async {
DatabaseHelper db = DatabaseHelper.instance;
bool isAdded = await db.isAlreadyAvailable(indexController.currentFeature[0].properties!["location_id"]);
return
isAdded == true ? Container(child: Text("すでに追加されています"),) :
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ElevatedButton(
onPressed: (){
},
child: IconButton(
icon: Icon(Icons.favorite, color: Colors.white, semanticLabel: "want_to_go".tr,),
onPressed: ()
{
child: ElevatedButton(
child: Text("want_to_go".tr),
onPressed: (){
GeoJsonMultiPoint mp = indexController.currentFeature[0].geometry as GeoJsonMultiPoint;
LatLng pt = LatLng(mp.geoSerie!.geoPoints[0].latitude, mp.geoSerie!.geoPoints[0].longitude);
print("--- name---- ${indexController.currentFeature[0].properties!["location_name"]} -----");
Destination dest = Destination(
name: indexController.currentFeature[0].properties!["location_name"],
address: indexController.currentFeature[0].properties!["address"],
@ -181,7 +193,7 @@ class BottomSheetNew extends GetView<BottomSheetController> {
);
destinationController.addDestinations(dest);
},
)
),
),
],
)

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),