change modes
This commit is contained in:
@ -8,11 +8,13 @@ import 'package:geojson/geojson.dart';
|
||||
import 'package:geolocator/geolocator.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:latlong2/latlong.dart';
|
||||
import 'package:rogapp/model/destination.dart';
|
||||
import 'package:rogapp/pages/index/index_controller.dart';
|
||||
import 'package:rogapp/routes/app_pages.dart';
|
||||
import 'package:rogapp/services/destination_service.dart';
|
||||
import 'package:rogapp/services/maxtrix_service.dart';
|
||||
import 'package:rogapp/services/reacking_service.dart';
|
||||
import 'package:rogapp/utils/database_helper.dart';
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:rogapp/widgets/bottom_sheet_widget.dart';
|
||||
@ -22,7 +24,7 @@ class DestinationController extends GetxController {
|
||||
late LocationSettings locationSettings;
|
||||
|
||||
var destinationCount = 0.obs;
|
||||
List<dynamic> destinations = <dynamic>[].obs;
|
||||
List<Destination> destinations = <Destination>[].obs;
|
||||
List<Map<String, dynamic>> destination_index_data = <Map<String, dynamic>>[].obs;
|
||||
|
||||
bool checking_in = false;
|
||||
@ -34,41 +36,41 @@ class DestinationController extends GetxController {
|
||||
final IndexController indexController = Get.find<IndexController>();
|
||||
|
||||
|
||||
Future<GeoJsonFeature?> getDEstinationForLatLong(double lat, double long)async {
|
||||
Future<Destination?> getDEstinationForLatLong(double lat, double long)async {
|
||||
|
||||
String jjjj = '{"id":1,"type":"Feature","geometry":{"type":"MultiPoint","coordinates":[[136.731357,35.370094]]},"properties":{"location_id":915101,"location_name":"柳津","category":"買い物","zip":"〒501-6100","address":"柳津町字仙右城7696-1"}}';
|
||||
|
||||
for(final d in destinations){
|
||||
var geom = d["location"]["geometry"];
|
||||
var props = d["location"]["properties"];
|
||||
print("--props- ${d["location"]["geometry"]["coordinates"][0][1]}");
|
||||
List<dynamic> geom_multi = [geom];
|
||||
Map<String, dynamic> final_geom = {"features":[{"id":d["id"],"type":"Feature", "geometry": geom, "properties": props}]};
|
||||
//print("----- geom : ${final_geom}");
|
||||
// var geom = d["location"]["geometry"];
|
||||
// var props = d["location"]["properties"];
|
||||
// print("--props- ${d["location"]["geometry"]["coordinates"][0][1]}");
|
||||
// List<dynamic> geom_multi = [geom];
|
||||
// Map<String, dynamic> final_geom = {"features":[{"id":d["id"],"type":"Feature", "geometry": geom, "properties": props}]};
|
||||
// //print("----- geom : ${final_geom}");
|
||||
|
||||
String js = json.encode(final_geom);
|
||||
//print("---features-- ${js}-----");
|
||||
GeoJsonFeatureCollection features = await featuresFromGeoJson(js);
|
||||
GeoJsonMultiPoint p = features.collection[0].geometry as GeoJsonMultiPoint;
|
||||
if(lat == p.geoSerie!.geoPoints[0].latitude && long == p.geoSerie!.geoPoints[0].longitude){
|
||||
return features.collection[0];
|
||||
// String js = json.encode(final_geom);
|
||||
// //print("---features-- ${js}-----");
|
||||
// GeoJsonFeatureCollection features = await featuresFromGeoJson(js);
|
||||
// GeoJsonMultiPoint p = features.collection[0].geometry as GeoJsonMultiPoint;
|
||||
if(lat == d.lat && long == d.lon){
|
||||
return d;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
checkForCheckin(double la, double ln){
|
||||
for(final d in destinations){
|
||||
double lat = d["location"]["geometry"]["coordinates"][0][1] as double;
|
||||
double lon = d["location"]["geometry"]["coordinates"][0][0] as double;
|
||||
double lat = d.lat!;
|
||||
double lon = d.lon!;
|
||||
LatLng p = LatLng(lat, lon);
|
||||
getDEstinationForLatLong(lat, lon).then((value){
|
||||
var distance = Distance();
|
||||
double dist = distance.as(LengthUnit.Meter, LatLng(lat, lon), LatLng(la, ln));
|
||||
double rad = value!.properties!["checkin_radious"] ?? double.infinity;
|
||||
bool auto_checkin = value.properties!["auto_checkin"] ?? false;
|
||||
double rad = value!.checkin_radious ?? double.infinity;
|
||||
bool auto_checkin = value.auto_checkin == 0 ? false : true;
|
||||
|
||||
indexController.currentFeature.add(value);
|
||||
indexController.getAction();
|
||||
indexController.currentDestinationFeature.add(value);
|
||||
//indexController.getAction();
|
||||
|
||||
if(!checking_in){
|
||||
checking_in = true;
|
||||
@ -109,85 +111,134 @@ class DestinationController extends GetxController {
|
||||
|
||||
|
||||
|
||||
// if (defaultTargetPlatform == TargetPlatform.android) {
|
||||
// locationSettings = AndroidSettings(
|
||||
// accuracy: LocationAccuracy.high,
|
||||
// distanceFilter: 30,
|
||||
// forceLocationManager: true,
|
||||
// intervalDuration: const Duration(seconds: 10),
|
||||
// //(Optional) Set foreground notification config to keep the app alive
|
||||
// //when going to the background
|
||||
// foregroundNotificationConfig: const ForegroundNotificationConfig(
|
||||
// notificationText:
|
||||
// "Example app will continue to receive your location even when you aren't using it",
|
||||
// notificationTitle: "Running in Background",
|
||||
// enableWakeLock: true,
|
||||
// )
|
||||
// );
|
||||
// } else if (defaultTargetPlatform == TargetPlatform.iOS || defaultTargetPlatform == TargetPlatform.macOS) {
|
||||
// locationSettings = AppleSettings(
|
||||
// accuracy: LocationAccuracy.high,
|
||||
// activityType: ActivityType.fitness,
|
||||
// distanceFilter: 1,
|
||||
// pauseLocationUpdatesAutomatically: false,
|
||||
// // Only set to true if our app will be started up in the background.
|
||||
// showBackgroundLocationIndicator: true
|
||||
// );
|
||||
// } else {
|
||||
// locationSettings = LocationSettings(
|
||||
// accuracy: LocationAccuracy.high,
|
||||
// distanceFilter: 30,
|
||||
// );
|
||||
// }
|
||||
if (defaultTargetPlatform == TargetPlatform.android) {
|
||||
locationSettings = AndroidSettings(
|
||||
accuracy: LocationAccuracy.high,
|
||||
distanceFilter: 30,
|
||||
forceLocationManager: true,
|
||||
intervalDuration: const Duration(seconds: 10),
|
||||
//(Optional) Set foreground notification config to keep the app alive
|
||||
//when going to the background
|
||||
foregroundNotificationConfig: const ForegroundNotificationConfig(
|
||||
notificationText:
|
||||
"Example app will continue to receive your location even when you aren't using it",
|
||||
notificationTitle: "Running in Background",
|
||||
enableWakeLock: true,
|
||||
)
|
||||
);
|
||||
} else if (defaultTargetPlatform == TargetPlatform.iOS || defaultTargetPlatform == TargetPlatform.macOS) {
|
||||
locationSettings = AppleSettings(
|
||||
accuracy: LocationAccuracy.high,
|
||||
activityType: ActivityType.fitness,
|
||||
distanceFilter: 1,
|
||||
pauseLocationUpdatesAutomatically: false,
|
||||
// Only set to true if our app will be started up in the background.
|
||||
showBackgroundLocationIndicator: true
|
||||
);
|
||||
} else {
|
||||
locationSettings = LocationSettings(
|
||||
accuracy: LocationAccuracy.high,
|
||||
distanceFilter: 30,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// StreamSubscription<Position> positionStream = Geolocator.getPositionStream(locationSettings: locationSettings).listen(
|
||||
// (Position? position) {
|
||||
// if(isSelected[0]){
|
||||
// String user_id = indexController.currentUser[0]["user"]["id"].toString();
|
||||
// TrackingService.addTrack(user_id, position!.latitude, position.longitude).then((val){
|
||||
// //checkForCheckin(position!.latitude, position.longitude);
|
||||
// });
|
||||
StreamSubscription<Position> positionStream = Geolocator.getPositionStream(locationSettings: locationSettings).listen(
|
||||
(Position? position) {
|
||||
double czoom = indexController.rogMapController!.zoom;
|
||||
indexController.rogMapController!.move(LatLng(position!.latitude, position!.longitude), czoom);
|
||||
if(isSelected[0]){
|
||||
String user_id = indexController.currentUser[0]["user"]["id"].toString();
|
||||
TrackingService.addTrack(user_id, position!.latitude, position.longitude).then((val){
|
||||
//checkForCheckin(position!.latitude, position.longitude);
|
||||
});
|
||||
|
||||
// }
|
||||
// print(position == null ? 'Unknown' : 'current position is ${position.latitude.toString()}, ${position.longitude.toString()}');
|
||||
// });
|
||||
}
|
||||
print(position == null ? 'Unknown' : 'current position is ${position.latitude.toString()}, ${position.longitude.toString()}');
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
void deleteDestination(int index){
|
||||
int id = destinations[index]["id"];
|
||||
DestinationService.deleteDestination(id).then((val){
|
||||
destination_index_data.clear();
|
||||
print("---- index ${index}-----");
|
||||
int id = destinations[index].location_id!;
|
||||
//print("---- index ${destinations[index].location_id!}-----");
|
||||
DatabaseHelper db = DatabaseHelper.instance;
|
||||
db.deleteDestination(id).then((value){
|
||||
PopulateDestinations();
|
||||
print("####### dest id : ${id}");
|
||||
});
|
||||
// DestinationService.deleteDestination(id).then((val){
|
||||
// destination_index_data.clear();
|
||||
// PopulateDestinations();
|
||||
// print("####### dest id : ${id}");
|
||||
// });
|
||||
}
|
||||
|
||||
// ---------- database ------------------///
|
||||
|
||||
void addDestinations(Destination dest){
|
||||
|
||||
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");
|
||||
});
|
||||
});
|
||||
}
|
||||
else {
|
||||
db.insertDestination(dest).then((value){
|
||||
print("----- new inserted destination id $value");
|
||||
});
|
||||
}
|
||||
});
|
||||
PopulateDestinations();
|
||||
|
||||
}
|
||||
|
||||
void PopulateDestinations(){
|
||||
print("--------- populsting destinations -----------");
|
||||
if(indexController.currentUser.isNotEmpty){
|
||||
int user_id = indexController.currentUser[0]["user"]["id"];
|
||||
print(user_id);
|
||||
DestinationService.getDestinations(user_id).then((value){
|
||||
destinations.clear();
|
||||
destinations = value;
|
||||
destinationCount.value = 0;
|
||||
destinationCount.value = destinations.length;
|
||||
|
||||
DatabaseHelper db = DatabaseHelper.instance;
|
||||
db.getDestinations().then((value){
|
||||
destinations.clear();
|
||||
destinations = value;
|
||||
// destinationCount.value = 0;
|
||||
print("------destinationcount-------- ${destinationCount}--------");
|
||||
destinationCount.value = destinations.length;
|
||||
|
||||
MatrixService.getDestinations(value).then((mat){
|
||||
print(mat);
|
||||
matrix = mat;
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
// if(indexController.currentUser.isNotEmpty){
|
||||
// int user_id = indexController.currentUser[0]["user"]["id"];
|
||||
// print(user_id);
|
||||
// DestinationService.getDestinations(user_id).then((value){
|
||||
// destinations.clear();
|
||||
// destinations = value;
|
||||
// destinationCount.value = 0;
|
||||
// destinationCount.value = destinations.length;
|
||||
|
||||
MatrixService.getDestinations(value).then((mat){
|
||||
print(mat);
|
||||
matrix = mat;
|
||||
// MatrixService.getDestinations(value).then((mat){
|
||||
// print(mat);
|
||||
// matrix = mat;
|
||||
|
||||
});
|
||||
// });
|
||||
|
||||
//var val = value[2]["location"]["id"];
|
||||
//print("-----current destinations ----- ${val}");
|
||||
});
|
||||
}
|
||||
else{
|
||||
Get.toNamed(AppPages.LOGIN);
|
||||
}
|
||||
// //var val = value[2]["location"]["id"];
|
||||
// //print("-----current destinations ----- ${val}");
|
||||
// });
|
||||
// }
|
||||
// else{
|
||||
// Get.toNamed(AppPages.LOGIN);
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
@ -198,6 +249,66 @@ class DestinationController extends GetxController {
|
||||
destination_index_data.clear();
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void makeNext(Destination pt){
|
||||
|
||||
for(int i=0; i<= destinations.length - 1; i++){
|
||||
Destination p = destinations[i];
|
||||
|
||||
if(p.lat == pt.lat && p.lon == pt.lon ){
|
||||
|
||||
if(indexController.currentDestinationFeature.isNotEmpty){
|
||||
indexController.currentDestinationFeature.clear();
|
||||
}
|
||||
if(i >= destinations.length - 1 ){
|
||||
indexController.currentDestinationFeature.add(destinations[0]);
|
||||
//getAction();
|
||||
}
|
||||
else{
|
||||
indexController.currentDestinationFeature.add(destinations[i + 1]);
|
||||
//getAction();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// void makePrevious(GeoJsonFeature fs){
|
||||
|
||||
// if(rog_mode == 1){
|
||||
// DestinationController destinationController = Get.find<DestinationController>();
|
||||
// print("---- destination index--- ${destinationController.destination_index_data} --------");
|
||||
// }
|
||||
// else {
|
||||
|
||||
// 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 == 0 ){
|
||||
// currentFeature.add(locations[0].collection[locations[0].collection.length -1] as GeoJsonFeature);
|
||||
// getAction();
|
||||
// }
|
||||
// else{
|
||||
// currentFeature.add(locations[0].collection[i - 1] as GeoJsonFeature);
|
||||
// getAction();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -38,18 +38,18 @@ class _DestinationPageState extends State<DestinationPage> {
|
||||
}
|
||||
|
||||
Image getImage(int index){
|
||||
if(destinationController.destinations[index]["location"]["properties"]["photos"] == null || destinationController.destinations[index]["location"]["properties"]["photos"] == ""){
|
||||
if(destinationController.destinations[index].photos == null || destinationController.destinations[index].photos == ""){
|
||||
return Image(image: AssetImage('assets/images/empty_image.png'));
|
||||
}
|
||||
else{
|
||||
return Image(image: NetworkImage(destinationController.destinations[index]["location"]["properties"]["photos"]));
|
||||
return Image(image: NetworkImage(destinationController.destinations[index].photos!));
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
destinationController.context = context;
|
||||
destinationController.PopulateDestinations();
|
||||
//destinationController.context = context;
|
||||
//destinationController.PopulateDestinations();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@ -71,12 +71,7 @@ class _DestinationPageState extends State<DestinationPage> {
|
||||
Expanded(child: IconButton(icon: const Icon(Icons.camera_enhance), onPressed: (){},),),
|
||||
const Expanded(child: Text('')),
|
||||
Expanded(child: IconButton(icon: const Icon(Icons.travel_explore), onPressed: (){
|
||||
if(indexController.currentUser.isNotEmpty){
|
||||
Get.toNamed(AppPages.TRAVEL);
|
||||
}
|
||||
else{
|
||||
Get.toNamed(AppPages.LOGIN);
|
||||
}
|
||||
indexController.switchPage(AppPages.INITIAL);
|
||||
}),),
|
||||
],
|
||||
),
|
||||
@ -92,13 +87,8 @@ class _DestinationPageState extends State<DestinationPage> {
|
||||
),
|
||||
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
|
||||
appBar:AppBar(
|
||||
title: Text("Iternery"),
|
||||
leading: IconButton(
|
||||
icon: Icon(Icons.arrow_back_ios),
|
||||
onPressed: (){
|
||||
indexController.switchPage(AppPages.INITIAL);
|
||||
},
|
||||
),
|
||||
automaticallyImplyLeading: false,
|
||||
title: Text("app_title".tr),
|
||||
actions: [
|
||||
ToggleButtons(
|
||||
disabledColor: Colors.grey.shade200,
|
||||
|
||||
@ -10,12 +10,14 @@ import 'package:geojson/geojson.dart';
|
||||
import 'package:geolocator/geolocator.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:latlong2/latlong.dart';
|
||||
import 'package:rogapp/model/destination.dart';
|
||||
import 'package:rogapp/pages/destination/destination_controller.dart';
|
||||
//import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||
import 'package:rogapp/pages/index/index_controller.dart';
|
||||
import 'package:rogapp/services/destination_service.dart';
|
||||
import 'package:rogapp/widgets/bottom_sheet_new.dart';
|
||||
import 'package:rogapp/widgets/bottom_sheet_widget.dart';
|
||||
import 'package:rogapp/widgets/bread_crum_widget.dart';
|
||||
|
||||
class DestinationMapPage extends StatefulWidget {
|
||||
DestinationMapPage({ Key? key }) : super(key: key);
|
||||
@ -34,40 +36,41 @@ class _DestinationMapPageState extends State<DestinationMapPage> {
|
||||
|
||||
|
||||
|
||||
Widget examplePopup(Marker marker){
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(10),
|
||||
child: Container(
|
||||
constraints: const BoxConstraints(minWidth: 100, maxWidth: 200),
|
||||
color: Colors.white,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
const Text(
|
||||
'Popup for a marker!',
|
||||
overflow: TextOverflow.fade,
|
||||
softWrap: false,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 14.0,
|
||||
),
|
||||
),
|
||||
const Padding(padding: EdgeInsets.symmetric(vertical: 4.0)),
|
||||
Text(
|
||||
'Position: ${marker.point.latitude}, ${marker.point.longitude}',
|
||||
style: const TextStyle(fontSize: 12.0),
|
||||
),
|
||||
Text(
|
||||
'Marker size: ${marker.width}, ${marker.height}',
|
||||
style: const TextStyle(fontSize: 12.0),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
// Widget examplePopup(Marker marker){
|
||||
// return Padding(
|
||||
// padding: const EdgeInsets.all(10),
|
||||
// child: Container(
|
||||
// constraints: const BoxConstraints(minWidth: 100, maxWidth: 200),
|
||||
// color: Colors.white,
|
||||
// child: Column(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// mainAxisAlignment: MainAxisAlignment.start,
|
||||
// mainAxisSize: MainAxisSize.min,
|
||||
// children: <Widget>[
|
||||
// const Text(
|
||||
// 'Popup for a marker!',
|
||||
// overflow: TextOverflow.fade,
|
||||
// softWrap: false,
|
||||
// style: TextStyle(
|
||||
// fontWeight: FontWeight.w500,
|
||||
// fontSize: 14.0,
|
||||
// ),
|
||||
// ),
|
||||
// const Padding(padding: EdgeInsets.symmetric(vertical: 4.0)),
|
||||
// Text(
|
||||
// 'Position: ${marker.point.latitude}, ${marker.point.longitude}',
|
||||
// style: const TextStyle(fontSize: 12.0),
|
||||
// ),
|
||||
// Text(
|
||||
// 'Marker size: ${marker.width}, ${marker.height}',
|
||||
// style: const TextStyle(fontSize: 12.0),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
|
||||
|
||||
|
||||
List<LatLng>? getPoints(){
|
||||
@ -82,21 +85,19 @@ class _DestinationMapPageState extends State<DestinationMapPage> {
|
||||
|
||||
List<Marker>? getMarkers() {
|
||||
List<Marker> pts = [];
|
||||
for(dynamic d in destinationController.destinations){
|
||||
double lat = d["location"]["geometry"]["coordinates"][0][1];
|
||||
double lan = d["location"]["geometry"]["coordinates"][0][0];
|
||||
for(Destination d in destinationController.destinations){
|
||||
//print("-----lat ${lat}, ----- lon ${lan}");
|
||||
Marker m = Marker(point: LatLng(lat, lan), builder:(cts){
|
||||
Marker m = Marker(point: LatLng(d.lat!, d.lon!), builder:(cts){
|
||||
//return Icon(Icons.pin_drop);
|
||||
return IconButton(
|
||||
onPressed: ()async {
|
||||
GeoJsonFeature? fs = await destinationController.getDEstinationForLatLong(lat, lan);
|
||||
Destination? fs = await destinationController.getDEstinationForLatLong(d.lat!, d.lon!);
|
||||
print("----fsf-----${fs}");
|
||||
if(fs != null){
|
||||
if(indexController.currentFeature.length > 0) {
|
||||
indexController.currentFeature.clear();
|
||||
indexController.currentDestinationFeature.clear();
|
||||
}
|
||||
indexController.currentFeature.add(fs);
|
||||
indexController.currentDestinationFeature.add(fs);
|
||||
indexController.getAction();
|
||||
|
||||
showModalBottomSheet(context: context, isScrollControlled: true,
|
||||
@ -116,8 +117,9 @@ class _DestinationMapPageState extends State<DestinationMapPage> {
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
|
||||
DestinationService.getDestinationLine(destinationController.destinations)?.then((value){
|
||||
print("---- loading destination points ------ ${value}");
|
||||
//print("---- loading destination points ------ ${value}");
|
||||
indexController.routePoints.clear();
|
||||
indexController.routePoints = value;
|
||||
});
|
||||
@ -127,65 +129,83 @@ class _DestinationMapPageState extends State<DestinationMapPage> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Obx((() =>
|
||||
FlutterMap(
|
||||
options: MapOptions(
|
||||
onMapCreated: (c){
|
||||
indexController.rogMapController = c;
|
||||
indexController.rogMapController!.onReady.then((_) {
|
||||
subscription = indexController.rogMapController!.mapEventStream.listen((MapEvent mapEvent) {
|
||||
if (mapEvent is MapEventMoveStart) {
|
||||
//print(DateTime.now().toString() + ' [MapEventMoveStart] START');
|
||||
// do something
|
||||
}
|
||||
if (mapEvent is MapEventMoveEnd) {
|
||||
//print(DateTime.now().toString() + ' [MapEventMoveStart] END');
|
||||
//indexController.loadLocationsBound();
|
||||
}
|
||||
});
|
||||
});
|
||||
} ,
|
||||
bounds: indexController.currentBound.length > 0 ? indexController.currentBound[0]: LatLngBounds.fromPoints([LatLng(35.03999881162295, 136.40587119778962), LatLng(36.642756778706904, 137.95226720406063)]),
|
||||
zoom: 1,
|
||||
maxZoom: 20,
|
||||
interactiveFlags: InteractiveFlag.pinchZoom | InteractiveFlag.drag,
|
||||
plugins: [LocationMarkerPlugin(),]
|
||||
),
|
||||
children: [
|
||||
TileLayerWidget(
|
||||
options: TileLayerOptions(
|
||||
urlTemplate: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
|
||||
subdomains: ['a', 'b', 'c'],
|
||||
),
|
||||
),
|
||||
PolylineLayerWidget(
|
||||
options: PolylineLayerOptions(
|
||||
polylines: [
|
||||
Polyline(
|
||||
points: getPoints()!,
|
||||
strokeWidth: 4.0,
|
||||
color: Colors.purple),
|
||||
],
|
||||
),
|
||||
),
|
||||
// PopupMarkerLayerWidget(
|
||||
// options: PopupMarkerLayerOptions(
|
||||
// popupController: _popupLayerController,
|
||||
// markers: _markers,
|
||||
// markerRotateAlignment:
|
||||
// PopupMarkerLayerOptions.rotationAlignmentFor(AnchorAlign.top),
|
||||
// popupBuilder: (BuildContext context, Marker marker) =>
|
||||
|
||||
// examplePopup(marker),
|
||||
// ),
|
||||
// ),
|
||||
MarkerLayerWidget(
|
||||
options: MarkerLayerOptions(
|
||||
markers: getMarkers()!
|
||||
),
|
||||
)
|
||||
],
|
||||
|
||||
)
|
||||
Stack(
|
||||
children: [
|
||||
indexController.is_rog_mapcontroller_loaded.value == false ?
|
||||
Center(child: CircularProgressIndicator())
|
||||
:
|
||||
BreadCrumbWidget(mapController:indexController.rogMapController),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top:50.0),
|
||||
//child: TravelMap(),
|
||||
child:
|
||||
TravelMap(),
|
||||
)
|
||||
],
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
FlutterMap TravelMap() {
|
||||
return FlutterMap(
|
||||
options: MapOptions(
|
||||
onMapCreated: (c){
|
||||
indexController.rogMapController = c;
|
||||
indexController.rogMapController!.onReady.then((_) {
|
||||
indexController.is_rog_mapcontroller_loaded.value = true;
|
||||
subscription = indexController.rogMapController!.mapEventStream.listen((MapEvent mapEvent) {
|
||||
if (mapEvent is MapEventMoveStart) {
|
||||
//print(DateTime.now().toString() + ' [MapEventMoveStart] START');
|
||||
// do something
|
||||
}
|
||||
if (mapEvent is MapEventMoveEnd) {
|
||||
//print(DateTime.now().toString() + ' [MapEventMoveStart] END');
|
||||
//indexController.loadLocationsBound();
|
||||
}
|
||||
});
|
||||
});
|
||||
} ,
|
||||
bounds: indexController.currentBound.length > 0 ? indexController.currentBound[0]: LatLngBounds.fromPoints([LatLng(35.03999881162295, 136.40587119778962), LatLng(36.642756778706904, 137.95226720406063)]),
|
||||
zoom: 1,
|
||||
maxZoom: 20,
|
||||
interactiveFlags: InteractiveFlag.pinchZoom | InteractiveFlag.drag,
|
||||
plugins: [LocationMarkerPlugin(),]
|
||||
),
|
||||
children: [
|
||||
TileLayerWidget(
|
||||
options: TileLayerOptions(
|
||||
urlTemplate: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
|
||||
subdomains: ['a', 'b', 'c'],
|
||||
),
|
||||
),
|
||||
PolylineLayerWidget(
|
||||
options: PolylineLayerOptions(
|
||||
polylines: [
|
||||
Polyline(
|
||||
points: getPoints()!,
|
||||
strokeWidth: 4.0,
|
||||
color: Colors.purple),
|
||||
],
|
||||
),
|
||||
),
|
||||
// PopupMarkerLayerWidget(
|
||||
// options: PopupMarkerLayerOptions(
|
||||
// popupController: _popupLayerController,
|
||||
// markers: _markers,
|
||||
// markerRotateAlignment:
|
||||
// PopupMarkerLayerOptions.rotationAlignmentFor(AnchorAlign.top),
|
||||
// popupBuilder: (BuildContext context, Marker marker) =>
|
||||
|
||||
// examplePopup(marker),
|
||||
// ),
|
||||
// ),
|
||||
MarkerLayerWidget(
|
||||
options: MarkerLayerOptions(
|
||||
markers: getMarkers()!
|
||||
),
|
||||
)
|
||||
],
|
||||
|
||||
);
|
||||
}
|
||||
}
|
||||
12
lib/pages/home/home_binding.dart
Normal file
12
lib/pages/home/home_binding.dart
Normal file
@ -0,0 +1,12 @@
|
||||
|
||||
|
||||
import 'package:get/get.dart';
|
||||
import 'package:rogapp/pages/home/home_controller.dart';
|
||||
|
||||
class HomeBinding extends Bindings{
|
||||
@override
|
||||
void dependencies() {
|
||||
Get.put<HomeController>(HomeController());
|
||||
}
|
||||
|
||||
}
|
||||
7
lib/pages/home/home_controller.dart
Normal file
7
lib/pages/home/home_controller.dart
Normal file
@ -0,0 +1,7 @@
|
||||
|
||||
import 'package:get/get.dart';
|
||||
import 'package:get/get_state_manager/get_state_manager.dart';
|
||||
|
||||
class HomeController extends GetxController{
|
||||
|
||||
}
|
||||
42
lib/pages/home/home_page.dart
Normal file
42
lib/pages/home/home_page.dart
Normal file
@ -0,0 +1,42 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:rogapp/pages/search/search_page.dart';
|
||||
|
||||
class HomePage extends GetView{
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
elevation: 0,
|
||||
backgroundColor: Colors.white,
|
||||
title: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text("app_title".tr,
|
||||
style: const TextStyle(
|
||||
color: Colors.blue
|
||||
),
|
||||
),
|
||||
InkWell(
|
||||
onTap: (){
|
||||
Navigator.push(context, MaterialPageRoute(builder: (context) => const SearchPage()));
|
||||
},
|
||||
child: Container(
|
||||
height: 32,
|
||||
width: 75,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.blue,
|
||||
borderRadius: BorderRadius.circular(25),
|
||||
|
||||
),
|
||||
child: const Center(child: Icon(Icons.search),),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
body: Container(),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@ -7,7 +7,9 @@ import 'package:flutter_polyline_points/flutter_polyline_points.dart';
|
||||
import 'package:geojson/geojson.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:latlong2/latlong.dart';
|
||||
import 'package:rogapp/model/destination.dart';
|
||||
import 'package:rogapp/pages/destination/destination_binding.dart';
|
||||
import 'package:rogapp/pages/destination/destination_controller.dart';
|
||||
import 'package:rogapp/pages/destination/destination_page.dart';
|
||||
import 'package:rogapp/pages/destination_map/destination_map_page.dart';
|
||||
import 'package:rogapp/routes/app_pages.dart';
|
||||
@ -16,10 +18,12 @@ import 'package:rogapp/services/auth_service.dart';
|
||||
import 'package:rogapp/services/cat_service.dart';
|
||||
import 'package:rogapp/services/location_service.dart';
|
||||
import 'package:rogapp/services/perfecture_service.dart';
|
||||
import 'package:rogapp/utils/database_helper.dart';
|
||||
|
||||
class IndexController extends GetxController {
|
||||
List<GeoJsonFeatureCollection> locations = <GeoJsonFeatureCollection>[].obs;
|
||||
List<GeoJsonFeature> currentFeature = <GeoJsonFeature>[].obs;
|
||||
List<Destination> currentDestinationFeature = <Destination>[].obs;
|
||||
List<dynamic> perfectures = <dynamic>[].obs;
|
||||
List<LatLngBounds> currentBound = <LatLngBounds>[].obs;
|
||||
List<dynamic> subPerfs = <dynamic>[].obs;
|
||||
@ -35,14 +39,17 @@ class IndexController extends GetxController {
|
||||
|
||||
var is_loading = false.obs;
|
||||
|
||||
var is_mapController_loaded = false.obs;
|
||||
var is_rog_mapcontroller_loaded = false.obs;
|
||||
|
||||
MapController? mapController;
|
||||
MapController? rogMapController;
|
||||
|
||||
var mode = 0.obs;
|
||||
|
||||
var rog_mode = 0.obs;
|
||||
var rog_mode = 1.obs;
|
||||
|
||||
var desination_mode = 0.obs;
|
||||
var desination_mode = 1.obs;
|
||||
|
||||
|
||||
String dropdownValue = "9";
|
||||
@ -74,13 +81,14 @@ class IndexController extends GetxController {
|
||||
switch (page) {
|
||||
case AppPages.INITIAL :{
|
||||
rog_mode.value = 0;
|
||||
print("-- rog mode is ctrl is ${rog_mode.value}");
|
||||
Get.toNamed(page);
|
||||
}
|
||||
break;
|
||||
case AppPages.TRAVEL : {
|
||||
rog_mode.value = 1;
|
||||
Get.toNamed(page);
|
||||
//Get.off(DestinationPage(), binding: DestinationBinding());
|
||||
//Get.back();
|
||||
Get.off(DestinationPage(), binding: DestinationBinding());
|
||||
|
||||
}
|
||||
break;
|
||||
@ -161,7 +169,13 @@ void login(String email, String password, BuildContext context){
|
||||
if(currentFeature.isNotEmpty){
|
||||
getAction();
|
||||
}
|
||||
Get.toNamed(AppPages.INITIAL);
|
||||
if(rog_mode.value == 1){
|
||||
switchPage(AppPages.TRAVEL);
|
||||
}
|
||||
else{
|
||||
switchPage(AppPages.INITIAL);
|
||||
}
|
||||
//Get.toNamed(AppPages.INITIAL);
|
||||
}else{
|
||||
is_loading.value = false;
|
||||
Get.snackbar(
|
||||
@ -466,7 +480,13 @@ void login(String email, String password, BuildContext context){
|
||||
}
|
||||
|
||||
void makeNext(GeoJsonFeature fs){
|
||||
GeoJsonFeature<GeoJsonMultiPoint> pt = fs as GeoJsonFeature<GeoJsonMultiPoint>;
|
||||
|
||||
if(rog_mode == 1){
|
||||
DestinationController destinationController = Get.find<DestinationController>();
|
||||
print("---- destination index--- ${destinationController.destination_index_data} --------");
|
||||
}
|
||||
else {
|
||||
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;
|
||||
@ -486,34 +506,43 @@ void login(String email, String password, BuildContext context){
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void makePrevious(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(rog_mode == 1){
|
||||
DestinationController destinationController = Get.find<DestinationController>();
|
||||
print("---- destination index--- ${destinationController.destination_index_data} --------");
|
||||
}
|
||||
else {
|
||||
|
||||
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 == 0 ){
|
||||
currentFeature.add(locations[0].collection[locations[0].collection.length -1] as GeoJsonFeature);
|
||||
getAction();
|
||||
}
|
||||
else{
|
||||
currentFeature.add(locations[0].collection[i - 1] as GeoJsonFeature);
|
||||
getAction();
|
||||
}
|
||||
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 == 0 ){
|
||||
currentFeature.add(locations[0].collection[locations[0].collection.length -1] as GeoJsonFeature);
|
||||
getAction();
|
||||
}
|
||||
else{
|
||||
currentFeature.add(locations[0].collection[i - 1] as GeoJsonFeature);
|
||||
getAction();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -23,8 +23,14 @@ 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,
|
||||
title: Text("app_title".tr),
|
||||
title: Text("Add locations"),
|
||||
actions: [
|
||||
CatWidget(indexController: indexController,),
|
||||
],
|
||||
@ -36,14 +42,7 @@ class IndexPage extends GetView<IndexController> {
|
||||
Expanded(child: IconButton(icon: const Icon(Icons.camera_enhance), onPressed: (){},),),
|
||||
const Expanded(child: Text('')),
|
||||
Expanded(child: IconButton(icon: const Icon(Icons.travel_explore), onPressed: (){
|
||||
if(indexController.currentUser.isNotEmpty){
|
||||
indexController.switchPage(AppPages.TRAVEL);
|
||||
//Get.toNamed(AppPages.TRAVEL);
|
||||
}
|
||||
else{
|
||||
indexController.switchPage(AppPages.LOGIN);
|
||||
//Get.toNamed(AppPages.LOGIN);
|
||||
}
|
||||
indexController.switchPage(AppPages.TRAVEL);
|
||||
}),),
|
||||
],
|
||||
),
|
||||
@ -71,12 +70,15 @@ class IndexPage extends GetView<IndexController> {
|
||||
height: 50.0,
|
||||
child: SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Row(
|
||||
child: Obx(() =>
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
BreadCrumbWidget(),
|
||||
indexController.is_mapController_loaded.value == false ?
|
||||
Center(child: CircularProgressIndicator())
|
||||
:
|
||||
BreadCrumbWidget(mapController: indexController.mapController),
|
||||
Container(width: 24.0,),
|
||||
Obx(()=>
|
||||
Row(
|
||||
children: [
|
||||
indexController.currentCat.isNotEmpty ? Text(indexController.currentCat[0].toString()): Text(""),
|
||||
@ -91,8 +93,8 @@ class IndexPage extends GetView<IndexController> {
|
||||
Container(width: 0, height: 0,)
|
||||
],
|
||||
)
|
||||
),
|
||||
],
|
||||
)
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
25
lib/pages/search/search_page.dart
Normal file
25
lib/pages/search/search_page.dart
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class SearchPage extends StatelessWidget {
|
||||
const SearchPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
elevation: 0,
|
||||
backgroundColor: Colors.white,
|
||||
leading: IconButton(
|
||||
onPressed:(){
|
||||
Navigator.pop(context);
|
||||
},
|
||||
icon: const Icon(Icons.arrow_back_ios_new, color: Colors.black,)),
|
||||
title: const CupertinoSearchTextField(),
|
||||
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user