update
This commit is contained in:
@ -6,7 +6,8 @@ import 'package:rogapp/services/location_service.dart';
|
||||
|
||||
class HomeController extends GetxController {
|
||||
|
||||
List<GeoJsonFeatureCollection> locations = <GeoJsonFeatureCollection>[].obs;
|
||||
List<GeoJsonFeatureCollection> locations = <GeoJsonFeatureCollection>[].obs;
|
||||
List<GeoJsonFeature> currentFeature = <GeoJsonFeature>[].obs;
|
||||
|
||||
|
||||
@override
|
||||
@ -19,13 +20,35 @@ class HomeController extends GetxController {
|
||||
|
||||
GeoJsonFeature? getFeatureForLatLong(double lat, double long){
|
||||
if(locations.length > 0){
|
||||
for(GeoJsonFeature i in locations[0].collection){
|
||||
GeoJsonMultiPoint p = i.geometry as GeoJsonMultiPoint;
|
||||
if(p.geoSerie!.geoPoints[0].latitude == lat && p.geoSerie!.geoPoints[0].longitude == long){
|
||||
return i;
|
||||
for(GeoJsonFeature i in locations[0].collection){
|
||||
GeoJsonMultiPoint p = i.geometry as GeoJsonMultiPoint;
|
||||
if(p.geoSerie!.geoPoints[0].latitude == lat && p.geoSerie!.geoPoints[0].longitude == long){
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void makeNext(GeoJsonFeature fs){
|
||||
GeoJsonFeature<GeoJsonMultiPoint> pt = fs as GeoJsonFeature<GeoJsonMultiPoint>;
|
||||
|
||||
for(int i=0; i<= locations[0].collection.length - 1; i++){
|
||||
GeoJsonMultiPoint p = locations[0].collection[i].geometry as GeoJsonMultiPoint;
|
||||
|
||||
if(p.geoSerie!.geoPoints[0].latitude == pt.geometry!.geoSerie!.geoPoints[0].latitude && p.geoSerie!.geoPoints[0].longitude == pt.geometry!.geoSerie!.geoPoints[0].longitude ){
|
||||
|
||||
if(currentFeature.length > 0){
|
||||
currentFeature.clear();
|
||||
}
|
||||
if(i >= locations[0].collection.length - 1 ){
|
||||
currentFeature.add(locations[0].collection[0] as GeoJsonFeature);
|
||||
}
|
||||
else{
|
||||
currentFeature.add(locations[0].collection[i + 1] as GeoJsonFeature);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -16,6 +16,13 @@ class HomePage extends GetView<HomeController> {
|
||||
|
||||
final HomeController homeController = Get.find<HomeController>();
|
||||
|
||||
void changeCurrentFeature(GeoJsonFeature fs){
|
||||
if(homeController.currentFeature.length > 0){
|
||||
homeController.currentFeature.clear();
|
||||
}
|
||||
homeController.currentFeature.add(fs);
|
||||
}
|
||||
|
||||
Image getImage(int index){
|
||||
if(homeController.locations[0].collection[index].properties!["photos"] == null || homeController.locations[0].collection[index].properties!["photos"] == ""){
|
||||
return Image(image: AssetImage('assets/images/empty_image.png'));
|
||||
@ -79,12 +86,11 @@ class HomePage extends GetView<HomeController> {
|
||||
child: ListTile(
|
||||
onTap: (){
|
||||
GeoJsonFeature gf = homeController.locations[0].collection[index];
|
||||
|
||||
|
||||
changeCurrentFeature(gf);
|
||||
showModalBottomSheet(
|
||||
isScrollControlled: true,
|
||||
context: context,
|
||||
builder: (context) => BottomSheetWidget(pt: gf),
|
||||
builder: (context) => BottomSheetWidget(),
|
||||
);
|
||||
},
|
||||
leading: getImage(index),
|
||||
|
||||
Reference in New Issue
Block a user