This commit is contained in:
Mohamed Nouffer
2022-05-24 20:43:41 +05:30
parent ee0440e6b6
commit 3cb7865d3b
60 changed files with 342 additions and 100 deletions

View File

@ -3,6 +3,7 @@ import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:flutter_map/plugin_api.dart';
import 'package:flutter_polyline_points/flutter_polyline_points.dart';
import 'package:geojson/geojson.dart';
import 'package:get/get.dart';
import 'package:latlong2/latlong.dart';
@ -25,6 +26,7 @@ class IndexController extends GetxController {
List<Map<String, dynamic>> currentUser = <Map<String, dynamic>>[].obs;
List<dynamic> currentAction = <dynamic>[].obs;
List<PointLatLng> routePoints = <PointLatLng>[].obs;
var is_loading = false.obs;
@ -32,12 +34,14 @@ class IndexController extends GetxController {
var mode = 0.obs;
var desination_mode = 0.obs;
String dropdownValue = "9";
String subDropdownValue = "-1";
void toggleMode(){
if(mode==0){
if(mode.value==0){
mode += 1;
}
else{
@ -45,6 +49,15 @@ class IndexController extends GetxController {
}
}
void toggleDestinationMode(){
if(desination_mode.value==0){
desination_mode.value += 1;
}
else{
desination_mode.value -= 1;
}
}
@override
void onInit() {
super.onInit();
@ -208,10 +221,10 @@ class IndexController extends GetxController {
void loadLocationsBound(){
String cat = currentCat.isNotEmpty ? currentCat[0] : "";
LatLngBounds bounds = mapController!.bounds!;
print(currentCat);
//print(currentCat);
if(bounds.southEast != null && bounds.southWest != null && bounds.northEast != null && bounds.southEast != null ){
LocationService.loadLocationsBound(bounds.southWest!.latitude, bounds.southWest!.longitude, bounds.northWest.latitude, bounds.northWest.longitude, bounds.northEast!.latitude, bounds.northEast!.longitude, bounds.southEast.latitude, bounds.southEast.longitude, cat).then((value){
print("---value length ------ ${value!.collection.length}");
//print("---value length ------ ${value!.collection.length}");
if(value == null){
return;
}
@ -219,7 +232,7 @@ class IndexController extends GetxController {
Get.showSnackbar(GetSnackBar(message: "Too many points, please zoom in",));
}
if(value != null && value.collection.isNotEmpty){
print("---- added---");
//print("---- added---");
locations.clear();
locations.add(value);
loadCatsv2();

View File

@ -11,6 +11,8 @@ import 'package:rogapp/widgets/cat_widget.dart';
import 'package:rogapp/widgets/list_widget.dart';
import 'package:rogapp/widgets/map_widget.dart';
import 'package:flutter_polyline_points/flutter_polyline_points.dart';
class IndexPage extends GetView<IndexController> {
IndexPage({Key? key}) : super(key: key);
@ -24,7 +26,16 @@ class IndexPage extends GetView<IndexController> {
title: Text("app_title".tr),
actions: [
ElevatedButton(onPressed: (){}, child: CatWidget(indexController: indexController,)),
//CatWidget(indexController: indexController,),
CatWidget(indexController: indexController,),
ElevatedButton(
onPressed: () async{
PolylinePoints polylinePoints = PolylinePoints();
PolylineResult result = await polylinePoints.getRouteBetweenCoordinates("AIzaSyAUBI1ablMKuJwGj2-kSuEhvYxvB1A-mOE", PointLatLng(35.389282, 136.498027), PointLatLng(36.285848, 137.575186));
print(result.points);
indexController.routePoints = result.points;
},
child: Text("Google")
)
],
),
bottomNavigationBar: BottomAppBar(