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

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

View File

@ -51,6 +51,8 @@ class IndexController extends GetxController {
var desination_mode = 1.obs;
bool showPopup = true;
String dropdownValue = "9";
String subDropdownValue = "-1";
@ -372,6 +374,9 @@ void login(String email, String password, BuildContext context){
}
locations.clear();
if(value != null && value.collection.isEmpty){
if(showPopup == false) {
return;
}
Get.snackbar(
"Too many Points",
"please zoom in",
@ -381,6 +386,7 @@ void login(String email, String password, BuildContext context){
backgroundColor: Colors.yellow,
//icon:Image(image:AssetImage("assets/images/dora.png"))
);
showPopup = false;
//Get.showSnackbar(GetSnackBar(message: "Too many points, please zoom in",));
}
if(value != null && value.collection.isNotEmpty){

View File

@ -2,10 +2,12 @@ import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:rogapp/model/destination.dart';
import 'package:rogapp/pages/drawer/drawer_page.dart';
import 'package:rogapp/pages/index/index_controller.dart';
import 'package:rogapp/routes/app_pages.dart';
import 'package:rogapp/services/maxtrix_service.dart';
import 'package:rogapp/utils/database_helper.dart';
import 'package:rogapp/widgets/bread_crum_widget.dart';
import 'package:rogapp/widgets/cat_widget.dart';
import 'package:rogapp/widgets/list_widget.dart';
@ -23,15 +25,27 @@ class IndexPage extends GetView<IndexController> {
return Scaffold(
drawer: const DrawerPage(),
appBar: AppBar(
leading: IconButton(
icon: Icon(Icons.arrow_back_ios),
onPressed: (){
indexController.switchPage(AppPages.TRAVEL);
},
),
automaticallyImplyLeading: false,
// leading: IconButton(
// icon: Icon(Icons.arrow_back_ios),
// onPressed: (){
// indexController.switchPage(AppPages.TRAVEL);
// },
// ),
//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()} ---- :::::");
// };
// });
// },
// ),
CatWidget(indexController: indexController,),
],
),