change modes

This commit is contained in:
Mohamed Nouffer
2022-07-09 22:51:34 +05:30
parent 131a8995e0
commit ce105a6754
22 changed files with 828 additions and 293 deletions

View File

@ -33,8 +33,9 @@ class MyApp extends StatelessWidget {
popGesture: Get.isPopGestureEnable, popGesture: Get.isPopGestureEnable,
transitionDuration: const Duration(milliseconds: 230), transitionDuration: const Duration(milliseconds: 230),
initialBinding: IndexBinding(), //HomeBinding(), initialBinding: IndexBinding(), //HomeBinding(),
initialRoute: AppPages.INITIAL, initialRoute: AppPages.TRAVEL,
getPages: AppPages.routes, getPages: AppPages.routes,
enableLog: true,
); );
} }
} }

View File

@ -0,0 +1,77 @@
class Destination {
String? name;
String? address;
String? phone;
String? email;
String? webcontents;
String? videos;
String? category;
int? series;
double? lat;
double? lon;
int? location_id;
int? list_order;
String? photos;
double? checkin_radious;
int? auto_checkin;
Destination({
this.name,
this.address,
this.phone,
this.email,
this.webcontents,
this.videos,
this.category,
this.series,
this.lat,
this.lon,
this.location_id,
this.list_order,
this.photos,
this.checkin_radious,
this.auto_checkin
});
factory Destination.fromMap(Map<String, dynamic> json) => Destination(
name: json['name'],
address: json['address'],
phone: json['phone'],
email: json['email'],
webcontents: json['webcontents'],
videos: json['videos'],
category: json['category'],
series: json['series'],
lat: json['lat'],
lon: json['lon'],
location_id: json['location_id'],
list_order: json['list_order'],
photos: json['category'],
checkin_radious: json['checkin_radious'],
auto_checkin:json['auto_checkin']
);
Map<String, dynamic> toMap(){
return {
'name':name,
'address': address,
'phone': phone,
'email': email,
'webcontents': webcontents,
'videos': videos,
'category':category,
'series':series,
'lat':lat,
'lon':lon,
'location_id':location_id,
'list_order':list_order,
'photos':photos,
'checkin_radious': checkin_radious,
'auto_checkin': auto_checkin
};
}
}

View File

@ -8,11 +8,13 @@ import 'package:geojson/geojson.dart';
import 'package:geolocator/geolocator.dart'; import 'package:geolocator/geolocator.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:latlong2/latlong.dart'; import 'package:latlong2/latlong.dart';
import 'package:rogapp/model/destination.dart';
import 'package:rogapp/pages/index/index_controller.dart'; import 'package:rogapp/pages/index/index_controller.dart';
import 'package:rogapp/routes/app_pages.dart'; import 'package:rogapp/routes/app_pages.dart';
import 'package:rogapp/services/destination_service.dart'; import 'package:rogapp/services/destination_service.dart';
import 'package:rogapp/services/maxtrix_service.dart'; import 'package:rogapp/services/maxtrix_service.dart';
import 'package:rogapp/services/reacking_service.dart'; import 'package:rogapp/services/reacking_service.dart';
import 'package:rogapp/utils/database_helper.dart';
import 'dart:async'; import 'dart:async';
import 'package:rogapp/widgets/bottom_sheet_widget.dart'; import 'package:rogapp/widgets/bottom_sheet_widget.dart';
@ -22,7 +24,7 @@ class DestinationController extends GetxController {
late LocationSettings locationSettings; late LocationSettings locationSettings;
var destinationCount = 0.obs; 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; List<Map<String, dynamic>> destination_index_data = <Map<String, dynamic>>[].obs;
bool checking_in = false; bool checking_in = false;
@ -34,41 +36,41 @@ class DestinationController extends GetxController {
final IndexController indexController = Get.find<IndexController>(); 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"}}'; 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){ for(final d in destinations){
var geom = d["location"]["geometry"]; // var geom = d["location"]["geometry"];
var props = d["location"]["properties"]; // var props = d["location"]["properties"];
print("--props- ${d["location"]["geometry"]["coordinates"][0][1]}"); // print("--props- ${d["location"]["geometry"]["coordinates"][0][1]}");
List<dynamic> geom_multi = [geom]; // List<dynamic> geom_multi = [geom];
Map<String, dynamic> final_geom = {"features":[{"id":d["id"],"type":"Feature", "geometry": geom, "properties": props}]}; // Map<String, dynamic> final_geom = {"features":[{"id":d["id"],"type":"Feature", "geometry": geom, "properties": props}]};
//print("----- geom : ${final_geom}"); // //print("----- geom : ${final_geom}");
String js = json.encode(final_geom); // String js = json.encode(final_geom);
//print("---features-- ${js}-----"); // //print("---features-- ${js}-----");
GeoJsonFeatureCollection features = await featuresFromGeoJson(js); // GeoJsonFeatureCollection features = await featuresFromGeoJson(js);
GeoJsonMultiPoint p = features.collection[0].geometry as GeoJsonMultiPoint; // GeoJsonMultiPoint p = features.collection[0].geometry as GeoJsonMultiPoint;
if(lat == p.geoSerie!.geoPoints[0].latitude && long == p.geoSerie!.geoPoints[0].longitude){ if(lat == d.lat && long == d.lon){
return features.collection[0]; return d;
} }
} }
} }
checkForCheckin(double la, double ln){ checkForCheckin(double la, double ln){
for(final d in destinations){ for(final d in destinations){
double lat = d["location"]["geometry"]["coordinates"][0][1] as double; double lat = d.lat!;
double lon = d["location"]["geometry"]["coordinates"][0][0] as double; double lon = d.lon!;
LatLng p = LatLng(lat, lon); LatLng p = LatLng(lat, lon);
getDEstinationForLatLong(lat, lon).then((value){ getDEstinationForLatLong(lat, lon).then((value){
var distance = Distance(); var distance = Distance();
double dist = distance.as(LengthUnit.Meter, LatLng(lat, lon), LatLng(la, ln)); double dist = distance.as(LengthUnit.Meter, LatLng(lat, lon), LatLng(la, ln));
double rad = value!.properties!["checkin_radious"] ?? double.infinity; double rad = value!.checkin_radious ?? double.infinity;
bool auto_checkin = value.properties!["auto_checkin"] ?? false; bool auto_checkin = value.auto_checkin == 0 ? false : true;
indexController.currentFeature.add(value); indexController.currentDestinationFeature.add(value);
indexController.getAction(); //indexController.getAction();
if(!checking_in){ if(!checking_in){
checking_in = true; checking_in = true;
@ -109,85 +111,134 @@ class DestinationController extends GetxController {
// if (defaultTargetPlatform == TargetPlatform.android) { if (defaultTargetPlatform == TargetPlatform.android) {
// locationSettings = AndroidSettings( locationSettings = AndroidSettings(
// accuracy: LocationAccuracy.high, accuracy: LocationAccuracy.high,
// distanceFilter: 30, distanceFilter: 30,
// forceLocationManager: true, forceLocationManager: true,
// intervalDuration: const Duration(seconds: 10), intervalDuration: const Duration(seconds: 10),
// //(Optional) Set foreground notification config to keep the app alive //(Optional) Set foreground notification config to keep the app alive
// //when going to the background //when going to the background
// foregroundNotificationConfig: const ForegroundNotificationConfig( foregroundNotificationConfig: const ForegroundNotificationConfig(
// notificationText: notificationText:
// "Example app will continue to receive your location even when you aren't using it", "Example app will continue to receive your location even when you aren't using it",
// notificationTitle: "Running in Background", notificationTitle: "Running in Background",
// enableWakeLock: true, enableWakeLock: true,
// ) )
// ); );
// } else if (defaultTargetPlatform == TargetPlatform.iOS || defaultTargetPlatform == TargetPlatform.macOS) { } else if (defaultTargetPlatform == TargetPlatform.iOS || defaultTargetPlatform == TargetPlatform.macOS) {
// locationSettings = AppleSettings( locationSettings = AppleSettings(
// accuracy: LocationAccuracy.high, accuracy: LocationAccuracy.high,
// activityType: ActivityType.fitness, activityType: ActivityType.fitness,
// distanceFilter: 1, distanceFilter: 1,
// pauseLocationUpdatesAutomatically: false, pauseLocationUpdatesAutomatically: false,
// // Only set to true if our app will be started up in the background. // Only set to true if our app will be started up in the background.
// showBackgroundLocationIndicator: true showBackgroundLocationIndicator: true
// ); );
// } else { } else {
// locationSettings = LocationSettings( locationSettings = LocationSettings(
// accuracy: LocationAccuracy.high, accuracy: LocationAccuracy.high,
// distanceFilter: 30, distanceFilter: 30,
// ); );
// } }
// StreamSubscription<Position> positionStream = Geolocator.getPositionStream(locationSettings: locationSettings).listen( StreamSubscription<Position> positionStream = Geolocator.getPositionStream(locationSettings: locationSettings).listen(
// (Position? position) { (Position? position) {
// if(isSelected[0]){ double czoom = indexController.rogMapController!.zoom;
// String user_id = indexController.currentUser[0]["user"]["id"].toString(); indexController.rogMapController!.move(LatLng(position!.latitude, position!.longitude), czoom);
// TrackingService.addTrack(user_id, position!.latitude, position.longitude).then((val){ if(isSelected[0]){
// //checkForCheckin(position!.latitude, position.longitude); 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){ void deleteDestination(int index){
int id = destinations[index]["id"]; print("---- index ${index}-----");
DestinationService.deleteDestination(id).then((val){ int id = destinations[index].location_id!;
destination_index_data.clear(); //print("---- index ${destinations[index].location_id!}-----");
DatabaseHelper db = DatabaseHelper.instance;
db.deleteDestination(id).then((value){
PopulateDestinations(); 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(){ void PopulateDestinations(){
print("--------- populsting destinations -----------"); print("--------- populsting destinations -----------");
if(indexController.currentUser.isNotEmpty){
int user_id = indexController.currentUser[0]["user"]["id"]; DatabaseHelper db = DatabaseHelper.instance;
print(user_id); db.getDestinations().then((value){
DestinationService.getDestinations(user_id).then((value){ destinations.clear();
destinations.clear(); destinations = value;
destinations = value; // destinationCount.value = 0;
destinationCount.value = 0; print("------destinationcount-------- ${destinationCount}--------");
destinationCount.value = destinations.length; 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){ // MatrixService.getDestinations(value).then((mat){
print(mat); // print(mat);
matrix = mat; // matrix = mat;
}); // });
//var val = value[2]["location"]["id"]; // //var val = value[2]["location"]["id"];
//print("-----current destinations ----- ${val}"); // //print("-----current destinations ----- ${val}");
}); // });
} // }
else{ // else{
Get.toNamed(AppPages.LOGIN); // Get.toNamed(AppPages.LOGIN);
} // }
} }
@ -198,6 +249,66 @@ class DestinationController extends GetxController {
destination_index_data.clear(); 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();
// }
// }
// }
// }
// }
} }

View File

@ -38,18 +38,18 @@ class _DestinationPageState extends State<DestinationPage> {
} }
Image getImage(int index){ 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')); return Image(image: AssetImage('assets/images/empty_image.png'));
} }
else{ else{
return Image(image: NetworkImage(destinationController.destinations[index]["location"]["properties"]["photos"])); return Image(image: NetworkImage(destinationController.destinations[index].photos!));
} }
} }
@override @override
void initState() { void initState() {
destinationController.context = context; //destinationController.context = context;
destinationController.PopulateDestinations(); //destinationController.PopulateDestinations();
super.initState(); super.initState();
} }
@ -71,12 +71,7 @@ class _DestinationPageState extends State<DestinationPage> {
Expanded(child: IconButton(icon: const Icon(Icons.camera_enhance), onPressed: (){},),), Expanded(child: IconButton(icon: const Icon(Icons.camera_enhance), onPressed: (){},),),
const Expanded(child: Text('')), const Expanded(child: Text('')),
Expanded(child: IconButton(icon: const Icon(Icons.travel_explore), onPressed: (){ Expanded(child: IconButton(icon: const Icon(Icons.travel_explore), onPressed: (){
if(indexController.currentUser.isNotEmpty){ indexController.switchPage(AppPages.INITIAL);
Get.toNamed(AppPages.TRAVEL);
}
else{
Get.toNamed(AppPages.LOGIN);
}
}),), }),),
], ],
), ),
@ -92,13 +87,8 @@ class _DestinationPageState extends State<DestinationPage> {
), ),
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
appBar:AppBar( appBar:AppBar(
title: Text("Iternery"), automaticallyImplyLeading: false,
leading: IconButton( title: Text("app_title".tr),
icon: Icon(Icons.arrow_back_ios),
onPressed: (){
indexController.switchPage(AppPages.INITIAL);
},
),
actions: [ actions: [
ToggleButtons( ToggleButtons(
disabledColor: Colors.grey.shade200, disabledColor: Colors.grey.shade200,

View File

@ -10,12 +10,14 @@ import 'package:geojson/geojson.dart';
import 'package:geolocator/geolocator.dart'; import 'package:geolocator/geolocator.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:latlong2/latlong.dart'; import 'package:latlong2/latlong.dart';
import 'package:rogapp/model/destination.dart';
import 'package:rogapp/pages/destination/destination_controller.dart'; import 'package:rogapp/pages/destination/destination_controller.dart';
//import 'package:google_maps_flutter/google_maps_flutter.dart'; //import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:rogapp/pages/index/index_controller.dart'; import 'package:rogapp/pages/index/index_controller.dart';
import 'package:rogapp/services/destination_service.dart'; import 'package:rogapp/services/destination_service.dart';
import 'package:rogapp/widgets/bottom_sheet_new.dart'; import 'package:rogapp/widgets/bottom_sheet_new.dart';
import 'package:rogapp/widgets/bottom_sheet_widget.dart'; import 'package:rogapp/widgets/bottom_sheet_widget.dart';
import 'package:rogapp/widgets/bread_crum_widget.dart';
class DestinationMapPage extends StatefulWidget { class DestinationMapPage extends StatefulWidget {
DestinationMapPage({ Key? key }) : super(key: key); DestinationMapPage({ Key? key }) : super(key: key);
@ -34,40 +36,41 @@ class _DestinationMapPageState extends State<DestinationMapPage> {
Widget examplePopup(Marker marker){ // Widget examplePopup(Marker marker){
return Padding( // return Padding(
padding: const EdgeInsets.all(10), // padding: const EdgeInsets.all(10),
child: Container( // child: Container(
constraints: const BoxConstraints(minWidth: 100, maxWidth: 200), // constraints: const BoxConstraints(minWidth: 100, maxWidth: 200),
color: Colors.white, // color: Colors.white,
child: Column( // child: Column(
crossAxisAlignment: CrossAxisAlignment.start, // crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start, // mainAxisAlignment: MainAxisAlignment.start,
mainAxisSize: MainAxisSize.min, // mainAxisSize: MainAxisSize.min,
children: <Widget>[ // children: <Widget>[
const Text( // const Text(
'Popup for a marker!', // 'Popup for a marker!',
overflow: TextOverflow.fade, // overflow: TextOverflow.fade,
softWrap: false, // softWrap: false,
style: TextStyle( // style: TextStyle(
fontWeight: FontWeight.w500, // fontWeight: FontWeight.w500,
fontSize: 14.0, // fontSize: 14.0,
), // ),
), // ),
const Padding(padding: EdgeInsets.symmetric(vertical: 4.0)), // const Padding(padding: EdgeInsets.symmetric(vertical: 4.0)),
Text( // Text(
'Position: ${marker.point.latitude}, ${marker.point.longitude}', // 'Position: ${marker.point.latitude}, ${marker.point.longitude}',
style: const TextStyle(fontSize: 12.0), // style: const TextStyle(fontSize: 12.0),
), // ),
Text( // Text(
'Marker size: ${marker.width}, ${marker.height}', // 'Marker size: ${marker.width}, ${marker.height}',
style: const TextStyle(fontSize: 12.0), // style: const TextStyle(fontSize: 12.0),
), // ),
], // ],
), // ),
), // ),
); // );
} // }
List<LatLng>? getPoints(){ List<LatLng>? getPoints(){
@ -82,21 +85,19 @@ class _DestinationMapPageState extends State<DestinationMapPage> {
List<Marker>? getMarkers() { List<Marker>? getMarkers() {
List<Marker> pts = []; List<Marker> pts = [];
for(dynamic d in destinationController.destinations){ for(Destination d in destinationController.destinations){
double lat = d["location"]["geometry"]["coordinates"][0][1];
double lan = d["location"]["geometry"]["coordinates"][0][0];
//print("-----lat ${lat}, ----- lon ${lan}"); //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 Icon(Icons.pin_drop);
return IconButton( return IconButton(
onPressed: ()async { onPressed: ()async {
GeoJsonFeature? fs = await destinationController.getDEstinationForLatLong(lat, lan); Destination? fs = await destinationController.getDEstinationForLatLong(d.lat!, d.lon!);
print("----fsf-----${fs}"); print("----fsf-----${fs}");
if(fs != null){ if(fs != null){
if(indexController.currentFeature.length > 0) { if(indexController.currentFeature.length > 0) {
indexController.currentFeature.clear(); indexController.currentDestinationFeature.clear();
} }
indexController.currentFeature.add(fs); indexController.currentDestinationFeature.add(fs);
indexController.getAction(); indexController.getAction();
showModalBottomSheet(context: context, isScrollControlled: true, showModalBottomSheet(context: context, isScrollControlled: true,
@ -116,8 +117,9 @@ class _DestinationMapPageState extends State<DestinationMapPage> {
@override @override
void initState() { void initState() {
DestinationService.getDestinationLine(destinationController.destinations)?.then((value){ DestinationService.getDestinationLine(destinationController.destinations)?.then((value){
print("---- loading destination points ------ ${value}"); //print("---- loading destination points ------ ${value}");
indexController.routePoints.clear(); indexController.routePoints.clear();
indexController.routePoints = value; indexController.routePoints = value;
}); });
@ -127,65 +129,83 @@ class _DestinationMapPageState extends State<DestinationMapPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Obx((() => return Obx((() =>
FlutterMap( Stack(
options: MapOptions( children: [
onMapCreated: (c){ indexController.is_rog_mapcontroller_loaded.value == false ?
indexController.rogMapController = c; Center(child: CircularProgressIndicator())
indexController.rogMapController!.onReady.then((_) { :
subscription = indexController.rogMapController!.mapEventStream.listen((MapEvent mapEvent) { BreadCrumbWidget(mapController:indexController.rogMapController),
if (mapEvent is MapEventMoveStart) { Padding(
//print(DateTime.now().toString() + ' [MapEventMoveStart] START'); padding: const EdgeInsets.only(top:50.0),
// do something //child: TravelMap(),
} child:
if (mapEvent is MapEventMoveEnd) { TravelMap(),
//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()!
),
)
],
)
)); ));
} }
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()!
),
)
],
);
}
} }

View 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());
}
}

View File

@ -0,0 +1,7 @@
import 'package:get/get.dart';
import 'package:get/get_state_manager/get_state_manager.dart';
class HomeController extends GetxController{
}

View 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(),
);
}
}

View File

@ -7,7 +7,9 @@ import 'package:flutter_polyline_points/flutter_polyline_points.dart';
import 'package:geojson/geojson.dart'; import 'package:geojson/geojson.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:latlong2/latlong.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_binding.dart';
import 'package:rogapp/pages/destination/destination_controller.dart';
import 'package:rogapp/pages/destination/destination_page.dart'; import 'package:rogapp/pages/destination/destination_page.dart';
import 'package:rogapp/pages/destination_map/destination_map_page.dart'; import 'package:rogapp/pages/destination_map/destination_map_page.dart';
import 'package:rogapp/routes/app_pages.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/cat_service.dart';
import 'package:rogapp/services/location_service.dart'; import 'package:rogapp/services/location_service.dart';
import 'package:rogapp/services/perfecture_service.dart'; import 'package:rogapp/services/perfecture_service.dart';
import 'package:rogapp/utils/database_helper.dart';
class IndexController extends GetxController { class IndexController extends GetxController {
List<GeoJsonFeatureCollection> locations = <GeoJsonFeatureCollection>[].obs; List<GeoJsonFeatureCollection> locations = <GeoJsonFeatureCollection>[].obs;
List<GeoJsonFeature> currentFeature = <GeoJsonFeature>[].obs; List<GeoJsonFeature> currentFeature = <GeoJsonFeature>[].obs;
List<Destination> currentDestinationFeature = <Destination>[].obs;
List<dynamic> perfectures = <dynamic>[].obs; List<dynamic> perfectures = <dynamic>[].obs;
List<LatLngBounds> currentBound = <LatLngBounds>[].obs; List<LatLngBounds> currentBound = <LatLngBounds>[].obs;
List<dynamic> subPerfs = <dynamic>[].obs; List<dynamic> subPerfs = <dynamic>[].obs;
@ -35,14 +39,17 @@ class IndexController extends GetxController {
var is_loading = false.obs; var is_loading = false.obs;
var is_mapController_loaded = false.obs;
var is_rog_mapcontroller_loaded = false.obs;
MapController? mapController; MapController? mapController;
MapController? rogMapController; MapController? rogMapController;
var mode = 0.obs; 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"; String dropdownValue = "9";
@ -74,13 +81,14 @@ class IndexController extends GetxController {
switch (page) { switch (page) {
case AppPages.INITIAL :{ case AppPages.INITIAL :{
rog_mode.value = 0; rog_mode.value = 0;
print("-- rog mode is ctrl is ${rog_mode.value}");
Get.toNamed(page); Get.toNamed(page);
} }
break; break;
case AppPages.TRAVEL : { case AppPages.TRAVEL : {
rog_mode.value = 1; rog_mode.value = 1;
Get.toNamed(page); //Get.back();
//Get.off(DestinationPage(), binding: DestinationBinding()); Get.off(DestinationPage(), binding: DestinationBinding());
} }
break; break;
@ -161,7 +169,13 @@ void login(String email, String password, BuildContext context){
if(currentFeature.isNotEmpty){ if(currentFeature.isNotEmpty){
getAction(); getAction();
} }
Get.toNamed(AppPages.INITIAL); if(rog_mode.value == 1){
switchPage(AppPages.TRAVEL);
}
else{
switchPage(AppPages.INITIAL);
}
//Get.toNamed(AppPages.INITIAL);
}else{ }else{
is_loading.value = false; is_loading.value = false;
Get.snackbar( Get.snackbar(
@ -466,7 +480,13 @@ void login(String email, String password, BuildContext context){
} }
void makeNext(GeoJsonFeature fs){ 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++){ for(int i=0; i<= locations[0].collection.length - 1; i++){
GeoJsonMultiPoint p = locations[0].collection[i].geometry as GeoJsonMultiPoint; 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){ void makePrevious(GeoJsonFeature fs){
GeoJsonFeature<GeoJsonMultiPoint> pt = fs as GeoJsonFeature<GeoJsonMultiPoint>;
for(int i=0; i<= locations[0].collection.length - 1; i++){ if(rog_mode == 1){
GeoJsonMultiPoint p = locations[0].collection[i].geometry as GeoJsonMultiPoint; 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 ){ GeoJsonFeature<GeoJsonMultiPoint> pt = fs as GeoJsonFeature<GeoJsonMultiPoint>;
if(currentFeature.length > 0){ for(int i=0; i<= locations[0].collection.length - 1; i++){
currentFeature.clear(); GeoJsonMultiPoint p = locations[0].collection[i].geometry as GeoJsonMultiPoint;
}
if(i == 0 ){ if(p.geoSerie!.geoPoints[0].latitude == pt.geometry!.geoSerie!.geoPoints[0].latitude && p.geoSerie!.geoPoints[0].longitude == pt.geometry!.geoSerie!.geoPoints[0].longitude ){
currentFeature.add(locations[0].collection[locations[0].collection.length -1] as GeoJsonFeature);
getAction(); if(currentFeature.length > 0){
} currentFeature.clear();
else{ }
currentFeature.add(locations[0].collection[i - 1] as GeoJsonFeature); if(i == 0 ){
getAction(); currentFeature.add(locations[0].collection[locations[0].collection.length -1] as GeoJsonFeature);
} getAction();
}
else{
currentFeature.add(locations[0].collection[i - 1] as GeoJsonFeature);
getAction();
}
}
} }
} }
} }
} }

View File

@ -23,8 +23,14 @@ class IndexPage extends GetView<IndexController> {
return Scaffold( return Scaffold(
drawer: const DrawerPage(), drawer: const DrawerPage(),
appBar: AppBar( appBar: AppBar(
leading: IconButton(
icon: Icon(Icons.arrow_back_ios),
onPressed: (){
indexController.switchPage(AppPages.TRAVEL);
},
),
automaticallyImplyLeading: false, automaticallyImplyLeading: false,
title: Text("app_title".tr), title: Text("Add locations"),
actions: [ actions: [
CatWidget(indexController: indexController,), CatWidget(indexController: indexController,),
], ],
@ -36,14 +42,7 @@ class IndexPage extends GetView<IndexController> {
Expanded(child: IconButton(icon: const Icon(Icons.camera_enhance), onPressed: (){},),), Expanded(child: IconButton(icon: const Icon(Icons.camera_enhance), onPressed: (){},),),
const Expanded(child: Text('')), const Expanded(child: Text('')),
Expanded(child: IconButton(icon: const Icon(Icons.travel_explore), onPressed: (){ Expanded(child: IconButton(icon: const Icon(Icons.travel_explore), onPressed: (){
if(indexController.currentUser.isNotEmpty){ indexController.switchPage(AppPages.TRAVEL);
indexController.switchPage(AppPages.TRAVEL);
//Get.toNamed(AppPages.TRAVEL);
}
else{
indexController.switchPage(AppPages.LOGIN);
//Get.toNamed(AppPages.LOGIN);
}
}),), }),),
], ],
), ),
@ -71,12 +70,15 @@ class IndexPage extends GetView<IndexController> {
height: 50.0, height: 50.0,
child: SingleChildScrollView( child: SingleChildScrollView(
scrollDirection: Axis.horizontal, scrollDirection: Axis.horizontal,
child: Row( child: Obx(() =>
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
BreadCrumbWidget(), indexController.is_mapController_loaded.value == false ?
Center(child: CircularProgressIndicator())
:
BreadCrumbWidget(mapController: indexController.mapController),
Container(width: 24.0,), Container(width: 24.0,),
Obx(()=>
Row( Row(
children: [ children: [
indexController.currentCat.isNotEmpty ? Text(indexController.currentCat[0].toString()): Text(""), indexController.currentCat.isNotEmpty ? Text(indexController.currentCat[0].toString()): Text(""),
@ -91,8 +93,8 @@ class IndexPage extends GetView<IndexController> {
Container(width: 0, height: 0,) Container(width: 0, height: 0,)
], ],
) )
),
], ],
)
), ),
), ),
), ),

View 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(),
),
);
}
}

View File

@ -2,6 +2,8 @@ import 'package:get/get.dart';
import 'package:get/get_navigation/src/routes/get_route.dart'; import 'package:get/get_navigation/src/routes/get_route.dart';
import 'package:rogapp/pages/destination/destination_binding.dart'; import 'package:rogapp/pages/destination/destination_binding.dart';
import 'package:rogapp/pages/destination/destination_page.dart'; import 'package:rogapp/pages/destination/destination_page.dart';
import 'package:rogapp/pages/home/home_binding.dart';
import 'package:rogapp/pages/home/home_page.dart';
import 'package:rogapp/pages/index/index_binding.dart'; import 'package:rogapp/pages/index/index_binding.dart';
import 'package:rogapp/pages/index/index_controller.dart'; import 'package:rogapp/pages/index/index_controller.dart';
import 'package:rogapp/pages/index/index_page.dart'; import 'package:rogapp/pages/index/index_page.dart';
@ -27,6 +29,7 @@ class AppPages {
static const TRAVEL = Routes.TRAVEL; static const TRAVEL = Routes.TRAVEL;
static const LOADING = Routes.LOADING; static const LOADING = Routes.LOADING;
static const DESTINATION_MAP = Routes.DESTINATION_MAP; static const DESTINATION_MAP = Routes.DESTINATION_MAP;
static const HOME = Routes.HOME;
static final routes = [ static final routes = [
// GetPage( // GetPage(
@ -42,7 +45,7 @@ class AppPages {
GetPage( GetPage(
name: Routes.INDEX, name: Routes.INDEX,
page: () => IndexPage(), page: () => IndexPage(),
binding: IndexBinding(), //binding: IndexBinding(),
), ),
GetPage( GetPage(
name: Routes.SPA, name: Routes.SPA,
@ -79,5 +82,10 @@ class AppPages {
page: () => DestinationPage(), page: () => DestinationPage(),
//binding: DestinationBinding(), //binding: DestinationBinding(),
), ),
GetPage(
name: Routes.HOME,
page: () => HomePage(),
binding: HomeBinding(),
),
]; ];
} }

View File

@ -14,4 +14,5 @@ abstract class Routes {
static const TRAVEL = '/travel'; static const TRAVEL = '/travel';
static const LOADING = '/loading'; static const LOADING = '/loading';
static const DESTINATION_MAP = '/destination_map'; static const DESTINATION_MAP = '/destination_map';
static const HOME = '/home';
} }

View File

@ -2,6 +2,7 @@ import 'dart:convert';
import 'package:flutter_polyline_points/flutter_polyline_points.dart'; import 'package:flutter_polyline_points/flutter_polyline_points.dart';
//import 'package:google_maps_webservice/directions.dart'; //import 'package:google_maps_webservice/directions.dart';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
import 'package:rogapp/model/destination.dart';
import '../utils/const.dart'; import '../utils/const.dart';
@ -49,6 +50,7 @@ class DestinationService{
int cats = 0; int cats = 0;
String server_url = ConstValues.currentServer(); String server_url = ConstValues.currentServer();
String url = "${server_url}/api/updateorder/?user_action_id=${action_id}&order=${order}&dir=${dir}"; String url = "${server_url}/api/updateorder/?user_action_id=${action_id}&order=${order}&dir=${dir}";
print("---- url is ${url} -----");
//String url = "http://localhost:8100/api/updateorder/?user_action_id=${action_id}&order=${order}&dir=${dir}"; //String url = "http://localhost:8100/api/updateorder/?user_action_id=${action_id}&order=${order}&dir=${dir}";
final http.Response response = await http.get( final http.Response response = await http.get(
Uri.parse(url), Uri.parse(url),
@ -63,12 +65,12 @@ class DestinationService{
return cats; return cats;
} }
static Future<List<PointLatLng>>? getDestinationLine(List<dynamic> destinations) async{ static Future<List<PointLatLng>>? getDestinationLine(List<Destination> destinations) async{
PolylinePoints polylinePoints = PolylinePoints(); PolylinePoints polylinePoints = PolylinePoints();
//print("##### @@@@@ ${destinations[0]["location"]["geometry"]["coordinates"][0][1]}"); print("##### @@@@@ ${destinations[0].lat}");
PointLatLng origin = PointLatLng(destinations[0]["location"]["geometry"]["coordinates"][0][1], destinations[0]["location"]["geometry"]["coordinates"][0][0]); PointLatLng origin = PointLatLng(destinations[0].lat!, destinations[0].lon!);
PointLatLng dest = PointLatLng(destinations[destinations.length -1]["location"]["geometry"]["coordinates"][0][1], destinations[destinations.length -1]["location"]["geometry"]["coordinates"][0][0]); PointLatLng dest = PointLatLng(destinations[destinations.length -1].lat!, destinations[destinations.length -1].lon!);
List<PolylineWayPoint> wayPoints = []; List<PolylineWayPoint> wayPoints = [];
@ -78,8 +80,8 @@ class DestinationService{
i+=1; i+=1;
continue; continue;
} }
double la = d["location"]["geometry"]["coordinates"][0][1]as double; double la = d.lat;
double ln = d["location"]["geometry"]["coordinates"][0][0] as double; double ln = d.lon;
PolylineWayPoint pwp = PolylineWayPoint(location: "${la},${ln}", stopOver: true); PolylineWayPoint pwp = PolylineWayPoint(location: "${la},${ln}", stopOver: true);
//print("----- UUUUUU ${pwp}"); //print("----- UUUUUU ${pwp}");
//PointLatLng wp = PointLatLng(d["Location"]["geometry"][0][1], d["Location"]["geometry"][0][0]); //PointLatLng wp = PointLatLng(d["Location"]["geometry"][0][1], d["Location"]["geometry"][0][0]);

View File

@ -1,23 +1,24 @@
import 'dart:convert'; import 'dart:convert';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
import 'package:rogapp/model/destination.dart';
class MatrixService{ class MatrixService{
static Future<Map<String, dynamic>> getDestinations(List<dynamic> destinations) async { static Future<Map<String, dynamic>> getDestinations(List<Destination> destinations) async {
String locs = ""; String locs = "";
String origin = ""; String origin = "";
int i = 0; int i = 0;
for(Map<String, dynamic> loc in destinations){ for(Destination d in destinations){
if(i==0){ if(i==0){
origin = "${loc["location"]["geometry"]["coordinates"][0][1]}, ${loc["location"]["geometry"]["coordinates"][0][0]}"; origin = "${d.lat}, ${d.lon}";
} }
print("lat is ${loc["location"]["geometry"]["coordinates"][0][1]}, long is ${loc["location"]["geometry"]["coordinates"][0][0]}"); print("lat is ${d.lat}, long is ${d.lon}");
locs += "${loc["location"]["geometry"]["coordinates"][0][1]}, ${loc["location"]["geometry"]["coordinates"][0][0]}|"; locs += "${d.lat}, ${d.lon}|";
i++; i++;
} }

View File

@ -0,0 +1,87 @@
import 'dart:io';
import 'package:path_provider/path_provider.dart';
import 'package:rogapp/model/destination.dart';
import 'package:sqflite/sqflite.dart';
import 'package:path/path.dart';
class DatabaseHelper{
DatabaseHelper._privateConstructor();
static final DatabaseHelper instance = DatabaseHelper._privateConstructor();
static Database? _database;
Future<Database> get database async => _database ??= await _initDatabase();
Future<Database> _initDatabase() async {
Directory documentDirectory = await getApplicationDocumentsDirectory();
String path = join(documentDirectory.path, 'rog.db');
// return await openDatabase(
// path,
// version: 1,
// onCreate: _onCreate,
// );
return openDatabase(join(await getDatabasesPath(), 'rog.db',), version: 1, onCreate: _onCreate);
}
Future _onCreate(Database db, int version) async {
await db.execute('''
CREATE TABLE destination(
location_id INTEGER PRIMARY KEY,
name TEXT,
address TEXT,
phone TEXT,
email TEXT,
webcontents TEXT,
videos TEXT,
category TEXT,
series INTEGER,
lat REAL,
lon REAL,
list_order INTEGER,
photos TEXT,
checkin_radious REAL,
auto_checkin INTEGER
)
''');
}
Future<List<Destination>> getDestinations() async {
Database db = await instance.database;
var dest = await db.query('destination');
List<Destination> destList = dest.isNotEmpty ?
dest.map((e) => Destination.fromMap(e)).toList() : [];
print("--------- ${destList}");
return destList;
}
Future<List<Destination>> getDestinationByLatLon(double lat, double lon) async {
Database db = await instance.database;
var dest = await db.query('destination', where: "lat = ${lat} and lon= ${lon}");
List<Destination> destList = dest.isNotEmpty
? dest.map((e) => Destination.fromMap(e)).toList() : [];
return destList;
}
Future<int> deleteDestination(int location_id) async {
Database db = await instance.database;
var dest = await db.delete('destination', where: "location_id = ${location_id}");
int ret = dest > 0 ? dest : -1;
return ret;
}
Future<int> insertDestination(Destination dest) async {
Database db = await instance.database;
int res = await db.insert(
'destination',
dest.toMap(),
conflictAlgorithm: ConflictAlgorithm.replace,
);
return res;
}
// Future<int?> getPending() async{
// Database db = await instance.database;
// return await Sqflite.firstIntValue(await db.rawQuery("SELECT COUNT(*) FROM incidents"));
// }
}

View File

@ -3,8 +3,12 @@ import 'package:geojson/geojson.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:get/get_state_manager/get_state_manager.dart'; import 'package:get/get_state_manager/get_state_manager.dart';
import 'package:image_picker/image_picker.dart'; import 'package:image_picker/image_picker.dart';
import 'package:latlong2/latlong.dart';
import 'package:rogapp/model/destination.dart';
import 'package:rogapp/pages/destination/destination_controller.dart';
import 'package:rogapp/pages/index/index_controller.dart'; import 'package:rogapp/pages/index/index_controller.dart';
import 'package:rogapp/routes/app_pages.dart'; import 'package:rogapp/routes/app_pages.dart';
import 'package:rogapp/utils/database_helper.dart';
import 'package:rogapp/widgets/bottom_sheet_controller.dart'; import 'package:rogapp/widgets/bottom_sheet_controller.dart';
import 'package:url_launcher/url_launcher.dart'; import 'package:url_launcher/url_launcher.dart';
@ -12,6 +16,7 @@ class BottomSheetNew extends GetView<BottomSheetController> {
BottomSheetNew({ Key? key }) : super(key: key); BottomSheetNew({ Key? key }) : super(key: key);
final IndexController indexController = Get.find<IndexController>(); final IndexController indexController = Get.find<IndexController>();
final DestinationController destinationController = Get.find<DestinationController>();
Image getImage(GeoJsonFeature? gf){ Image getImage(GeoJsonFeature? gf){
if(gf!.properties!["photos"] == null || gf.properties!["photos"] == ""){ if(gf!.properties!["photos"] == null || gf.properties!["photos"] == ""){
@ -70,6 +75,7 @@ class BottomSheetNew extends GetView<BottomSheetController> {
), ),
MaterialButton( MaterialButton(
onPressed: () { onPressed: () {
print("----- next is ${indexController.currentFeature[0]} ------");
indexController.makeNext(indexController.currentFeature[0]); indexController.makeNext(indexController.currentFeature[0]);
}, },
color: Colors.blue, color: Colors.blue,
@ -125,15 +131,10 @@ class BottomSheetNew extends GetView<BottomSheetController> {
: :
Container(width: 0.0, height: 0,), Container(width: 0.0, height: 0,),
), ),
Obx(() => SizedBox(height: 20.0,),
indexController.rog_mode.value == 0 ? //Obx(() =>
indexController.currentAction.isNotEmpty ? wantToGo(context),
getDoubleAction(context) //),
:
getSingleAction()
:
getCheckin(context),
),
SizedBox(height: 60.0,) SizedBox(height: 60.0,)
], ],
) )
@ -141,7 +142,57 @@ class BottomSheetNew extends GetView<BottomSheetController> {
); );
} }
Widget wantToGo(BuildContext context){
return 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: ()
{
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"],
phone: indexController.currentFeature[0].properties!["phone"],
email: indexController.currentFeature[0].properties!["email"],
webcontents: indexController.currentFeature[0].properties!["webcontents"],
videos: indexController.currentFeature[0].properties!["videos"],
category: indexController.currentFeature[0].properties!["category"],
series: 1,
lat: pt.latitude,
lon: pt.longitude,
location_id: indexController.currentFeature[0].properties!["location_id"],
list_order: 1,
photos: indexController.currentFeature[0].properties!["photos"],
checkin_radious: indexController.currentFeature[0].properties!["checkin_radious"],
auto_checkin: indexController.currentFeature[0].properties!["auto_checkin"] == true ? 1 : 0
);
destinationController.addDestinations(dest);
},
)
),
],
)
],
);
}
Widget getCheckin(BuildContext context){ Widget getCheckin(BuildContext context){
print("------ currentAction ----- ${indexController.currentAction}-----");
return Row( return Row(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [

View File

@ -1,25 +1,34 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:flutter_breadcrumb/flutter_breadcrumb.dart'; import 'package:flutter_breadcrumb/flutter_breadcrumb.dart';
import 'package:rogapp/pages/index/index_controller.dart'; import 'package:rogapp/pages/index/index_controller.dart';
import 'package:rogapp/widgets/perfecture_widget.dart'; import 'package:rogapp/widgets/perfecture_widget.dart';
class BreadCrumbWidget extends StatelessWidget { class BreadCrumbWidget extends StatelessWidget {
BreadCrumbWidget({Key? key}) : super(key: key); BreadCrumbWidget({Key? key, this.mapController}) : super(key: key);
final MapController? mapController;
final IndexController indexController = Get.find<IndexController>(); final IndexController indexController = Get.find<IndexController>();
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Obx(()=> indexController.perfectures.isNotEmpty ? print("------ map controller is ${mapController}------------");
BreadCrumb.builder( return
itemCount: indexController.perfectures.length, Obx(()=>
builder: (index){ indexController.perfectures.isNotEmpty && mapController != null ?
return BreadCrumbItem( BreadCrumb.builder(
content: PerfectureWidget(indexController: indexController, mapController: indexController.mapController!) //Text('Item$index') itemCount: indexController.perfectures.length,
); builder: (index){
} return
): BreadCrumbItem(
const Text("Empty")); content: PerfectureWidget(indexController: indexController, mapController: mapController!) //Text('Item$index')
);
}
):
const Text("Empty")
);
} }
} }

View File

@ -3,6 +3,7 @@ import 'dart:ffi';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:geojson/geojson.dart'; import 'package:geojson/geojson.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:rogapp/model/destination.dart';
import 'package:rogapp/pages/destination/destination_controller.dart'; import 'package:rogapp/pages/destination/destination_controller.dart';
import 'package:rogapp/pages/index/index_controller.dart'; import 'package:rogapp/pages/index/index_controller.dart';
import 'package:rogapp/widgets/bottom_sheet_new.dart'; import 'package:rogapp/widgets/bottom_sheet_new.dart';
@ -19,12 +20,12 @@ class DestinationWidget extends StatelessWidget {
final List<int> _items = List<int>.generate(50, (int index) => index); final List<int> _items = List<int>.generate(50, (int index) => index);
Image getImage(int index){ 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')); return Image(image: AssetImage('assets/images/empty_image.png'));
} }
else{ else{
return Image(image: NetworkImage( return Image(image: NetworkImage(
destinationController.destinations[index]["location"]["properties"]["photos"]), destinationController.destinations[index].photos!),
errorBuilder: (BuildContext context, Object exception, StackTrace? stackTrace) { errorBuilder: (BuildContext context, Object exception, StackTrace? stackTrace) {
return Image.asset("assets/images/empty_image.png"); return Image.asset("assets/images/empty_image.png");
}, },
@ -56,31 +57,34 @@ class DestinationWidget extends StatelessWidget {
void moveUp() { void moveUp() {
destinationController.destination_index_data.forEach((element) { destinationController.destination_index_data.forEach((element) {
//print(element["index"]); //print(element["index"]);
int action_id = destinationController.destinations[element["index"]]["id"] as int; //int action_id = destinationController.destinations[element["index"]]["id"] as int;
destinationController.makeOrder(action_id, (element["index"] as int) - 1, "up"); //destinationController.makeOrder(action_id, (element["index"] as int) - 1, "up");
}); });
} }
void moveDown() { void moveDown() {
destinationController.destination_index_data.forEach((element) { destinationController.destination_index_data.forEach((element) {
//print(element["index"]); //print(element["index"]);
int action_id = destinationController.destinations[element["index"]]["id"] as int; //int action_id = destinationController.destinations[element["index"]]["id"] as int;
destinationController.makeOrder(action_id, (element["index"] as int) + 1, "up"); //destinationController.makeOrder(action_id, (element["index"] as int) + 1, "up");
}); });
} }
void interChange() { void interChange() {
int first_index = -1; // int first_index = -1;
destinationController.destination_index_data.forEach((element) { // destinationController.destination_index_data.forEach((element) {
//print(element["index"]); // //print(element["index"]);
int action_id = destinationController.destinations[element["index"]]["id"] as int; // int action_id = destinationController.destinations[element["index"]]["id"] as int;
destinationController.makeOrder(action_id, (element["index"] as int) + 1, "up"); // destinationController.makeOrder(action_id, (element["index"] as int) + 1, "up");
}); // });
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
print("---- destinations ${destinationController.destinations[0].name} ------");
return return
Obx(() => Obx(() =>
Stack( Stack(
@ -119,16 +123,16 @@ class DestinationWidget extends StatelessWidget {
child: ListTile( child: ListTile(
onTap: () async { onTap: () async {
{ {
double lat = destinationController.destinations[index]["location"]["geometry"]["coordinates"][0][1] as double; double lat = destinationController.destinations[index].lat as double;
double lon = destinationController.destinations[index]["location"]["geometry"]["coordinates"][0][0] as double; double lon = destinationController.destinations[index].lon as double;
GeoJsonFeature? fs = await destinationController.getDEstinationForLatLong(lat, lon); Destination? fs = await destinationController.getDEstinationForLatLong(lat, lon);
print("----fsf-----${fs}"); print("----fsf-----${fs}");
if(fs != null){ if(fs != null){
if(indexController.currentFeature.length > 0) { if(indexController.currentFeature.length > 0) {
indexController.currentFeature.clear(); indexController.currentDestinationFeature.clear();
} }
indexController.currentFeature.add(fs); indexController.currentDestinationFeature.add(fs);
indexController.getAction(); //indexController.getAction();
showModalBottomSheet(context: context, isScrollControlled: true, showModalBottomSheet(context: context, isScrollControlled: true,
//builder:((context) => BottomSheetWidget()) //builder:((context) => BottomSheetWidget())
@ -159,8 +163,8 @@ class DestinationWidget extends StatelessWidget {
selectedTileColor: Colors.amberAccent, selectedTileColor: Colors.amberAccent,
selected:getSelection(index), selected:getSelection(index),
leading: getImage(index), leading: getImage(index),
title: Text(destinationController.destinations[index]["location"]["properties"]["location_name"]), title: Text(destinationController.destinations[index].name!),
subtitle: Text(destinationController.destinations[index]["location"]["properties"]["category"]), //subtitle: Text(destinationController.destinations[index].category!),
), ),
), ),
), ),

View File

@ -0,0 +1,45 @@
import 'package:flutter/material.dart';
import 'package:rogapp/pages/search/search_page.dart';
class FakeSearch extends StatelessWidget {
const FakeSearch({
Key? key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return InkWell(
onTap: (){
Navigator.push(context, MaterialPageRoute(builder: (context) => const SearchPage()));
},
child: Container(
height: 35,
decoration: BoxDecoration(
border: Border.all(color:Colors.blue, width: 1.4),
borderRadius: BorderRadius.circular(25)
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Padding(
padding: EdgeInsets.symmetric(horizontal: 8.0),
child: Icon(Icons.search, color: Colors.grey,),
),
const Text("What are you looking for", style: TextStyle(fontSize: 16, color: Colors.grey),),
Container(
height: 32,
width: 75,
decoration: BoxDecoration(
color: Colors.blue,
borderRadius: BorderRadius.circular(25),
),
child: const Center(child: Text("Search", style: TextStyle(fontSize: 16, color: Colors.white),)),
)
],
),
),
);
}
}

View File

@ -22,6 +22,9 @@ class MapWidget extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
print("---------- rog mode is ${indexController.rog_mode.value.toString()}----------");
final PopupController _popupController = PopupController(); final PopupController _popupController = PopupController();
return Stack( return Stack(
children: [ children: [
@ -37,6 +40,7 @@ class MapWidget extends StatelessWidget {
indexController.mapController = c; indexController.mapController = c;
indexController.mapController!.onReady.then((_) { indexController.mapController!.onReady.then((_) {
indexController.is_mapController_loaded.value = true;
subscription = indexController.mapController!.mapEventStream.listen((MapEvent mapEvent) { subscription = indexController.mapController!.mapEventStream.listen((MapEvent mapEvent) {
if (mapEvent is MapEventMoveStart) { if (mapEvent is MapEventMoveStart) {
//print(DateTime.now().toString() + ' [MapEventMoveStart] START'); //print(DateTime.now().toString() + ' [MapEventMoveStart] START');
@ -130,7 +134,7 @@ class MapWidget extends StatelessWidget {
rotate: true, rotate: true,
onMarkerTap: (marker){ onMarkerTap: (marker){
GeoJsonFeature? fs = indexController.getFeatureForLatLong(marker.point.latitude, marker.point.longitude); GeoJsonFeature? fs = indexController.getFeatureForLatLong(marker.point.latitude, marker.point.longitude);
print(fs); //print("------- fs ${fs}------");
if(fs != null){ if(fs != null){
if(indexController.currentFeature.length > 0) { if(indexController.currentFeature.length > 0) {
indexController.currentFeature.clear(); indexController.currentFeature.clear();

View File

@ -9,6 +9,7 @@ class PerfectureWidget extends StatefulWidget {
IndexController indexController; IndexController indexController;
MapController mapController; MapController mapController;
PerfectureWidget({Key? key, required this.indexController, required this.mapController}) : super(key: key){ PerfectureWidget({Key? key, required this.indexController, required this.mapController}) : super(key: key){
//indexController.zoomtoMainPerf("9", mapController); //indexController.zoomtoMainPerf("9", mapController);
} }
@ -19,6 +20,11 @@ class PerfectureWidget extends StatefulWidget {
class _PerfectureWidgetState extends State<PerfectureWidget> { class _PerfectureWidgetState extends State<PerfectureWidget> {
@override
void initState() {
super.initState();
}
bool isNumeric(String s) { bool isNumeric(String s) {
if (s == null) { if (s == null) {
@ -93,6 +99,7 @@ class _PerfectureWidgetState extends State<PerfectureWidget> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Obx(() => return Obx(() =>
Row( Row(
children: [ children: [