This commit is contained in:
Mohamed Nouffer
2022-06-14 14:37:59 +05:30
parent 3d9f20fd66
commit ba70fa0080
22 changed files with 640 additions and 115 deletions

25
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,25 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "rogapp",
"request": "launch",
"type": "dart"
},
{
"name": "rogapp (profile mode)",
"request": "launch",
"type": "dart",
"flutterMode": "profile"
},
{
"name": "rogapp (release mode)",
"request": "launch",
"type": "dart",
"flutterMode": "release"
}
]
}

View File

@ -53,5 +53,7 @@
<string>Photo Library Access Warning</string>
<key>NSCameraUsageDescription</key>
<string>Camera access to take photo</string>
<key>NSMicrophoneUsageDescription</key>
<string>Post videos to profile</string>
</dict>
</plist>

View File

@ -1,15 +1,22 @@
import 'dart:convert';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:geojson/geojson.dart';
import 'package:geolocator/geolocator.dart';
import 'package:get/get.dart';
import 'package:latlong2/latlong.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 'dart:async';
import 'package:rogapp/widgets/bottom_sheet_widget.dart';
class DestinationController extends GetxController {
late LocationSettings locationSettings;
@ -17,21 +24,91 @@ class DestinationController extends GetxController {
List<dynamic> destinations = <dynamic>[].obs;
List<Map<String, dynamic>> destination_index_data = <Map<String, dynamic>>[].obs;
bool checking_in = false;
List<bool> isSelected = [true].obs;
BuildContext? context;
Map<String, dynamic> matrix = {};
final IndexController indexController = Get.find<IndexController>();
Future<GeoJsonFeature?> 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}");
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];
}
}
}
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;
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;
indexController.currentFeature.add(value);
indexController.getAction();
if(!checking_in){
checking_in = true;
if(rad >= dist){
if(auto_checkin){
if(indexController.currentAction.isNotEmpty){
print(indexController.currentAction[0]);
indexController.currentAction[0][0]["checkin"] = true;
Map<String,dynamic> temp = Map<String,dynamic>.from(indexController.currentAction[0][0]);
indexController.currentAction.clear();
print("---temp---${temp}");
indexController.currentAction.add([temp]);
}
indexController.makeAction(Get.context!);
}
else{
showModalBottomSheet(context: Get.context!, isScrollControlled: true,
builder:((context) => BottomSheetWidget())
).whenComplete((){
checking_in = false;
});
}
}
}
print("----- rad is ${rad}");
});
}
}
@override
void onInit() {
PopulateDestinations();
if (defaultTargetPlatform == TargetPlatform.android) {
locationSettings = AndroidSettings(
accuracy: LocationAccuracy.high,
distanceFilter: 1,
distanceFilter: 30,
forceLocationManager: true,
intervalDuration: const Duration(seconds: 10),
//(Optional) Set foreground notification config to keep the app alive
@ -55,13 +132,20 @@ class DestinationController extends GetxController {
} else {
locationSettings = LocationSettings(
accuracy: LocationAccuracy.high,
distanceFilter: 1,
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);
});
}
print(position == null ? 'Unknown' : 'current position is ${position.latitude.toString()}, ${position.longitude.toString()}');
});
@ -80,7 +164,7 @@ class DestinationController extends GetxController {
void PopulateDestinations(){
if(indexController.currentUser.isNotEmpty){
int user_id = indexController.currentUser[0]["user"]["id"] as int;
int user_id = indexController.currentUser[0]["user"]["id"];
//print(user_id);
DestinationService.getDestinations(user_id).then((value){

View File

@ -25,7 +25,6 @@ class _DestinationPageState extends State<DestinationPage> {
final IndexController indexController = Get.find<IndexController>();
final List<int> _items = List<int>.generate(50, (int index) => index);
List<bool> isSelected = [true];
Future<void> showCurrentPosition() async {
LocationPermission permission = await Geolocator.checkPermission();
@ -47,6 +46,12 @@ class _DestinationPageState extends State<DestinationPage> {
}
}
@override
void initState() {
destinationController.context = context;
super.initState();
}
@override
Widget build(BuildContext context) {
final ColorScheme colorScheme = Theme.of(context).colorScheme;
@ -82,6 +87,12 @@ 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);
},
),
actions: [
ToggleButtons(
disabledColor: Colors.grey.shade200,
@ -91,10 +102,10 @@ class _DestinationPageState extends State<DestinationPage> {
)],
onPressed: (int index) {
setState(() {
isSelected[index] = !isSelected[index];
destinationController.isSelected[index] = !destinationController.isSelected[index];
});
},
isSelected: isSelected,
isSelected: destinationController.isSelected,
),
IconButton(onPressed: (){
showCurrentPosition();

View File

@ -4,7 +4,9 @@ import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_map/plugin_api.dart';
import 'package:flutter_map_location_marker/flutter_map_location_marker.dart';
import 'package:flutter_map_marker_popup/flutter_map_marker_popup.dart';
import 'package:flutter_polyline_points/flutter_polyline_points.dart';
import 'package:geojson/geojson.dart';
import 'package:geolocator/geolocator.dart';
import 'package:get/get.dart';
import 'package:latlong2/latlong.dart';
@ -12,10 +14,12 @@ 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_widget.dart';
class DestinationMapPage extends StatefulWidget {
DestinationMapPage({ Key? key }) : super(key: key);
@override
State<DestinationMapPage> createState() => _DestinationMapPageState();
}
@ -25,6 +29,69 @@ class _DestinationMapPageState extends State<DestinationMapPage> {
final DestinationController destinationController = Get.find<DestinationController>();
StreamSubscription? subscription;
final PopupController _popupLayerController = PopupController();
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),
),
],
),
),
);
}
final List<LatLng> _markerPositions = [
LatLng(35.728728732933455, 137.06878077038706),
LatLng(35.958218259568305, 137.06187578986646),
LatLng(35.76795686324816, 137.08949571194879),
];
List<Marker> get _markers => _markerPositions
.map(
(markerPosition) => Marker(
point: markerPosition,
width: 40,
height: 40,
builder: (_) => const Icon(Icons.location_on, size: 40),
anchorPos: AnchorPos.align(AnchorAlign.top),
),
)
.toList();
List<LatLng>? getPoints(){
//print("##### --- route point ${indexController.routePoints.length}");
@ -41,9 +108,29 @@ class _DestinationMapPageState extends State<DestinationMapPage> {
for(dynamic 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}");
Marker m = Marker(point: LatLng(lat, lan), builder:(cts){
return Icon(Icons.pin_drop);
//return Icon(Icons.pin_drop);
return IconButton(
onPressed: ()async {
GeoJsonFeature? fs = await destinationController.getDEstinationForLatLong(lat, lan);
print("----fsf-----${fs}");
if(fs != null){
if(indexController.currentFeature.length > 0) {
indexController.currentFeature.clear();
}
indexController.currentFeature.add(fs);
indexController.getAction();
showModalBottomSheet(context: context, isScrollControlled: true,
builder:((context) => BottomSheetWidget())
);
}
},
icon: Icon(Icons.pin_drop));
});
pts.add(m);
}
return pts;
@ -85,15 +172,15 @@ class _DestinationMapPageState extends State<DestinationMapPage> {
interactiveFlags: InteractiveFlag.pinchZoom | InteractiveFlag.drag,
plugins: [LocationMarkerPlugin(),]
),
layers: [
TileLayerOptions(
urlTemplate:
'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
subdomains: ['a', 'b', 'c']),
MarkerLayerOptions(
markers: getMarkers()!,
children: [
TileLayerWidget(
options: TileLayerOptions(
urlTemplate: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
subdomains: ['a', 'b', 'c'],
),
PolylineLayerOptions(
),
PolylineLayerWidget(
options: PolylineLayerOptions(
polylines: [
Polyline(
points: getPoints()!,
@ -101,8 +188,25 @@ class _DestinationMapPageState extends State<DestinationMapPage> {
color: Colors.purple),
],
),
LocationMarkerLayerOptions(),
),
// 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

@ -21,6 +21,7 @@ class IndexController extends GetxController {
List<LatLngBounds> currentBound = <LatLngBounds>[].obs;
List<dynamic> subPerfs = <dynamic>[].obs;
List<dynamic> areas = <dynamic>[].obs;
List<dynamic> customAreas = <dynamic>[].obs;
List<dynamic> cats = <dynamic>[].obs;
List<String> currentCat = <String>[].obs;
@ -36,6 +37,8 @@ class IndexController extends GetxController {
var mode = 0.obs;
var rog_mode = 0.obs;
var desination_mode = 0.obs;
@ -43,6 +46,8 @@ class IndexController extends GetxController {
String subDropdownValue = "-1";
String areaDropdownValue = "-1";
late Worker _ever;
void toggleMode(){
if(mode.value==0){
mode += 1;
@ -61,9 +66,33 @@ class IndexController extends GetxController {
}
}
void switchPage(String page){
//print("######## ${currentUser[0]["user"]["id"]}");
switch (page) {
case AppPages.INITIAL :{
rog_mode.value = 0;
Get.toNamed(page);
}
break;
case AppPages.TRAVEL : {
rog_mode.value = 1;
Get.toNamed(page);
}
break;
case AppPages.LOGIN :{
rog_mode.value = 2;
Get.toNamed(page);
}
break;
default:{
rog_mode.value = 0;
Get.toNamed(AppPages.INITIAL);
}
}
}
@override
void onInit() {
super.onInit();
// if(locations.length == 0){
// LocationService.loadLocations().then((value){
@ -71,16 +100,51 @@ class IndexController extends GetxController {
// //print(value);
// });
// }
_ever = ever(rog_mode, (_) => print("$_ has been changed (ever)"));
if(perfectures.length == 0){
PerfectureService.loadPerfectures().then((value){
perfectures.add(value);
loadAreaFor("9");
//loadSubPerfFor("9");
});
}
//loadCats();
super.onInit();
}
LatLngBounds boundsFromLatLngList(List<LatLng> list) {
double? x0, x1, y0, y1;
for (LatLng latLng in list) {
if (x0 == null || x1 == null || y0 == null || y1 == null) {
x0 = x1 = latLng.latitude;
y0 = y1 = latLng.longitude;
} else {
if (latLng.latitude > x1) x1 = latLng.latitude;
if (latLng.latitude < x0) x0 = latLng.latitude;
if (latLng.longitude > y1) y1 = latLng.longitude;
if (latLng.longitude < y0) y0 = latLng.longitude;
}
}
return LatLngBounds(LatLng(x1!, y1!), LatLng(x0!, y0!));
}
List<LatLng> getLocationsList(){
List<LatLng> locs = [];
for(int i=0; i<= locations[0].collection.length - 1; i++){
GeoJsonMultiPoint p = locations[0].collection[i].geometry as GeoJsonMultiPoint;
LatLng latLng = LatLng(p.geoSerie!.geoPoints[0].latitude, p.geoSerie!.geoPoints[0].longitude);
locs.add(latLng);
}
return locs;
}
void login(String email, String password, BuildContext context){
AuthService.login(email, password).then((value){
if(value.isNotEmpty){
@ -88,6 +152,7 @@ class IndexController extends GetxController {
currentUser.add(value);
is_loading.value = false;
Navigator.pop(context);
loadUserDetails();
if(currentFeature.isNotEmpty){
getAction();
}
@ -107,6 +172,7 @@ class IndexController extends GetxController {
currentUser.add(value);
is_loading.value = false;
Navigator.pop(context);
loadUserDetails();
Get.toNamed(AppPages.INITIAL);
}else{
is_loading.value = false;
@ -121,26 +187,13 @@ class IndexController extends GetxController {
bool wanttogo = currentAction[0][0]["wanttogo"];
bool like = currentAction[0][0]["like"];
bool checkin = currentAction[0][0]["checkin"];
print("----userid----${user_id}");
if(user_id > 0){
ActionService.makeAction(user_id, location_id, wanttogo, like, checkin).then((value){
print("----action value----${value}");
});
}
}
// void loadCats(){
// dynamic initVal = {'category':'---'};
// CatService.loadCats().then((value) {
// //value!.add(initVal);
// print("###########");
// print(value);
// cats.add(value);
// });
// }
void loadCatsv2(){
dynamic initVal = {'category':'---'};
@ -148,7 +201,6 @@ class IndexController extends GetxController {
if(bounds.southEast != null && bounds.southWest != null && bounds.northEast != null && bounds.southEast != null ){
cats.clear();
CatService.loadCats(bounds.southWest!.latitude, bounds.southWest!.longitude, bounds.northWest.latitude, bounds.northWest.longitude, bounds.northEast!.latitude, bounds.northEast!.longitude, bounds.southEast.latitude, bounds.southEast.longitude).then((value) {
print("###########");
print(value);
cats.add(value);
});
@ -181,11 +233,30 @@ class IndexController extends GetxController {
areas.clear();
dynamic initVal = {'id':'-1', 'adm2_ja':'----'};
PerfectureService.loadGifuAreas(perf).then((value){
print(value);
value!.add(initVal);
areas.add(value);
//loadSubPerfFor("9");
//subDropdownValue = getSubInitialVal();
});
}
void loadUserDetails(){
if(currentUser.length > 0){
int user_id = currentUser[0]["user"]["id"] as int;
AuthService.UserDetails(user_id).then((value){
//print("--------- user details ----- ${value}");
bool paid = value![0]["paid"] as bool;
if(paid){
loadCustomAreas();
}
});
}
}
void loadCustomAreas(){
customAreas.clear();
PerfectureService.loadCustomAreas().then((value){
print("--- loading custom areas ${value}");
customAreas.add(value);
});
}
@ -235,12 +306,20 @@ class IndexController extends GetxController {
});
}
void loadCustomLocation(String customarea, MapController mapController) async {
void loadCustomLocation(String customarea) async {
String cat = currentCat.isNotEmpty == true ? currentCat[0] : "";
print(currentCat);
LocationService.loadCustomLocations(cat).then((value){
print("----- ${customarea}");
LocationService.loadCustomLocations(customarea, cat).then((value){
locations.clear();
locations.add(value!);
List<LatLng> locs = getLocationsList();
LatLngBounds bounds = boundsFromLatLngList(locs);
mapController!.fitBounds(bounds);
setBound(bounds);
Future.delayed(Duration(microseconds: 400), () {
mapController!.fitBounds(bounds);
});
});
}
@ -312,8 +391,9 @@ class IndexController extends GetxController {
is_loading.value = false;
}
void populateForCustomArea(String customarea, MapController mapController){
loadCustomLocation("cus", mapController);
void populateSubPerForArea(String area, MapController mapController){
loadSubPerfFor(area);
//loadCustomLocation("cus", mapController);
//zoomtoSubPerf(subperf);
is_loading.value = false;
}
@ -337,6 +417,7 @@ class IndexController extends GetxController {
return;
}
int user_id = currentUser[0]["user"]["id"] as int;
print("---- loc id ${currentFeature[0].properties}");
int location_id = currentFeature[0].properties!["location_id"] as int;
ActionService.userAction(user_id, location_id).then((value){
print("------${value}");

View File

@ -37,10 +37,12 @@ class IndexPage extends GetView<IndexController> {
const Expanded(child: Text('')),
Expanded(child: IconButton(icon: const Icon(Icons.travel_explore), onPressed: (){
if(indexController.currentUser.isNotEmpty){
Get.toNamed(AppPages.TRAVEL);
indexController.switchPage(AppPages.TRAVEL);
//Get.toNamed(AppPages.TRAVEL);
}
else{
Get.toNamed(AppPages.LOGIN);
indexController.switchPage(AppPages.LOGIN);
//Get.toNamed(AppPages.LOGIN);
}
}),),
],

View File

@ -1,7 +1,9 @@
import 'package:get/get.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_page.dart';
import 'package:rogapp/pages/index/index_binding.dart';
import 'package:rogapp/pages/index/index_controller.dart';
import 'package:rogapp/pages/index/index_page.dart';
import 'package:rogapp/pages/landing/landing_page.dart';
import 'package:rogapp/pages/loading/loading_page.dart';
@ -14,6 +16,7 @@ import 'package:rogapp/spa/spa_page.dart';
part 'app_routes.dart';
class AppPages {
// ignore: constant_identifier_names
static const INITIAL = Routes.INDEX;
// ignore: constant_identifier_names

View File

@ -1,13 +1,16 @@
import 'dart:convert';
import 'package:http/http.dart' as http;
import 'package:rogapp/utils/const.dart';
class ActionService{
static Future<Map<String, dynamic>> makeAction(int user_id, int location_id, bool wanttogo, bool like, bool checkin) async {
print("----- action is ---- ${like}-- ${wanttogo}-- ${checkin}");
Map<String, dynamic> cats = {};
//String url = "http://container.intranet.sumasen.net:8100/api/makeaction/?user_id=${user_id}&location_id=${location_id}&wanttogo=${wanttogo}&like=${like}&checkin=${checkin}";
String url = "http://localhost:8100/api/makeaction/?user_id=${user_id}&location_id=${location_id}&wanttogo=${wanttogo}&like=${like}&checkin=${checkin}";
String server_url = ConstValues.currentServer();
String url = "${server_url}/api/makeaction/?user_id=${user_id}&location_id=${location_id}&wanttogo=${wanttogo}&like=${like}&checkin=${checkin}";
//String url = "http://localhost:8100/api/makeaction/?user_id=${user_id}&location_id=${location_id}&wanttogo=${wanttogo}&like=${like}&checkin=${checkin}";
final http.Response response = await http.get(
Uri.parse(url),
headers: <String, String>{
@ -24,8 +27,9 @@ class ActionService{
static Future<List<dynamic>?> userAction(int user_id, int location_id) async {
List<dynamic> cats = [];
//String url = 'http://container.intranet.sumasen.net:8100/api/useraction/?user_id=${user_id}&location_id=${location_id}';
String url = 'http://localhost:8100/api/useraction/?user_id=${user_id}&location_id=${location_id}';
String server_url = ConstValues.currentServer();
String url = '${server_url}/api/useraction/?user_id=${user_id}&location_id=${location_id}';
//String url = 'http://localhost:8100/api/useraction/?user_id=${user_id}&location_id=${location_id}';
final response = await http.get(Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',

View File

@ -1,13 +1,16 @@
import 'dart:convert';
import 'package:http/http.dart' as http;
import '../utils/const.dart';
class AuthService{
static Future<Map<String, dynamic>> login(String email, String password) async {
Map<String, dynamic> cats = {};
//String url = 'http://container.intranet.sumasen.net:8100/api/login/';
String url = 'http://localhost:8100/api/login/';
String server_url = ConstValues.currentServer();
String url = '${server_url}/api/login/';
//String url = 'http://localhost:8100/api/login/';
final http.Response response = await http.post(
Uri.parse(url),
headers: <String, String>{
@ -28,8 +31,9 @@ class AuthService{
static Future<Map<String, dynamic>> register(String email, String password) async {
Map<String, dynamic> cats = {};
//String url = 'http://container.intranet.sumasen.net:8100/api/register/';
String url = 'http://localhost:8100/api/register/';
String server_url = ConstValues.currentServer();
String url = '${server_url}/api/register/';
//String url = 'http://localhost:8100/api/register/';
final http.Response response = await http.post(
Uri.parse(url),
headers: <String, String>{
@ -48,6 +52,30 @@ class AuthService{
}
static Future<List<dynamic>?> UserDetails(int userid) async {
List<dynamic> cats = [];
String server_url = ConstValues.currentServer();
String url = '${server_url}/api/userdetials?user_id=${userid}';
//String url = 'http://localhost:8100/api/userdetials?user_id=${userid}';
//String url = 'http://container.intranet.sumasen.net:8100/api/cats/';
print("---- cat url is ${url}");
final response = await http.get(Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
},
);
if (response.statusCode == 200) {
cats = json.decode(utf8.decode(response.bodyBytes));
}
return cats;
}

View File

@ -2,13 +2,16 @@ import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import '../utils/const.dart';
class CatService{
static Future<List<dynamic>?> loadCats(double lat1, double lon1, double lat2, double lon2, double lat3, double lon3, double lat4, double lon4) async {
List<dynamic> cats = [];
//String url = 'http://container.intranet.sumasen.net:8100/api/cats/?ln1=${lon1}&la1=${lat1}&ln2=${lon2}&la2=${lat2}&ln3=${lon3}&la3=${lat3}&ln4=${lon4}&la4=${lat4}';
String url = 'http://localhost:8100/api/cats/?ln1=${lon1}&la1=${lat1}&ln2=${lon2}&la2=${lat2}&ln3=${lon3}&la3=${lat3}&ln4=${lon4}&la4=${lat4}';
String server_url = ConstValues.currentServer();
String url = '${server_url}/api/cats/?ln1=${lon1}&la1=${lat1}&ln2=${lon2}&la2=${lat2}&ln3=${lon3}&la3=${lat3}&ln4=${lon4}&la4=${lat4}';
//String url = 'http://localhost:8100/api/cats/?ln1=${lon1}&la1=${lat1}&ln2=${lon2}&la2=${lat2}&ln3=${lon3}&la3=${lat3}&ln4=${lon4}&la4=${lat4}';
//String url = 'http://container.intranet.sumasen.net:8100/api/cats/';

View File

@ -4,13 +4,16 @@ import 'package:flutter_polyline_points/flutter_polyline_points.dart';
//import 'package:google_maps_webservice/directions.dart';
import 'package:http/http.dart' as http;
import '../utils/const.dart';
class DestinationService{
static Future<List<dynamic>> getDestinations(int user_id) async {
List<dynamic> cats = [];
//String url = "http://container.intranet.sumasen.net:8100/api/destinations/?user_id=${user_id}";
String url = "http://localhost:8100/api/destinations/?user_id=${user_id}";
String server_url = ConstValues.currentServer();
String url = "${server_url}/api/destinations/?user_id=${user_id}";
//String url = "http://localhost:8100/api/destinations/?user_id=${user_id}";
final http.Response response = await http.get(
Uri.parse(url),
headers: <String, String>{
@ -26,8 +29,9 @@ class DestinationService{
static Future<Map<String, dynamic>> deleteDestination(int dest_id) async {
Map<String, dynamic> cats = {};
//String url = "http://container.intranet.sumasen.net:8100/api/delete_destination/?dest_id=${dest_id}";
String url = "http://localhost:8100/api/delete_destination/?dest_id=${dest_id}";
String server_url = ConstValues.currentServer();
String url = "${server_url}/api/delete_destination/?dest_id=${dest_id}";
//String url = "http://localhost:8100/api/delete_destination/?dest_id=${dest_id}";
final http.Response response = await http.get(
Uri.parse(url),
headers: <String, String>{
@ -44,8 +48,9 @@ class DestinationService{
static Future<int> updateOrder(int action_id, int order, String dir) async {
int cats = 0;
//String url = "http://container.intranet.sumasen.net: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}";
String server_url = ConstValues.currentServer();
String url = "${server_url}/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(
Uri.parse(url),
headers: <String, String>{

View File

@ -1,14 +1,16 @@
import 'package:geojson/geojson.dart';
import 'package:http/http.dart' as http;
import '../utils/const.dart';
class LocationLineService{
static Future<GeoJsonFeature?> loadLocationLines() async {
final geo = GeoJson();
GeoJsonFeature? fs;
//String url = 'http://container.intranet.sumasen.net:8100/api/location_line/';
String url = 'http://localhost:8100/api/location_line/';
String server_url = ConstValues.currentServer();
String url = '${server_url}/api/location_line/';
//String url = 'http://localhost:8100/api/location_line/';
final response = await http.get(Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',

View File

@ -1,14 +1,17 @@
import 'package:geojson/geojson.dart';
import 'package:http/http.dart' as http;
import '../utils/const.dart';
class LocationPolygonervice{
static Future<GeoJsonFeature?> loadLocationLines() async {
final geo = GeoJson();
GeoJsonFeature? fs;
//String url = 'http://container.intranet.sumasen.net:8100/api/location_polygon/';
String url = 'http://localhost:8100/api/location_polygon/';
String server_url = ConstValues.currentServer();
String url = '${server_url}/api/location_polygon/';
//String url = 'http://localhost:8100/api/location_polygon/';
final response = await http.get(Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',

View File

@ -2,12 +2,14 @@ import 'dart:convert';
import 'package:geojson/geojson.dart';
import 'package:http/http.dart' as http;
import 'package:rogapp/utils/const.dart';
class LocationService{
static Future<GeoJsonFeatureCollection?> loadLocations() async {
//String url = 'http://container.intranet.sumasen.net:8100/api/location/';
String url = 'http://localhost:8100/api/location/';
String server_url = ConstValues.currentServer();
String url = '${server_url}/api/location/';
//String url = 'http://localhost:8100/api/location/';
final response = await http.get(Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
@ -23,13 +25,14 @@ class LocationService{
static Future<GeoJsonFeatureCollection?> loadLocationsFor(String perfecture, String cat) async {
String url = "";
String server_url = ConstValues.currentServer();
if(cat.isNotEmpty){
//url = 'http://container.intranet.sumasen.net:8100/api/inperf/?perf=' + perfecture + '&cat=' + cat;
url = 'http://localhost:8100/api/inperf/?perf=' + perfecture + '&cat=' + cat;
url = '${server_url}/api/inperf/?perf=' + perfecture + '&cat=' + cat;
//url = 'http://localhost:8100/api/inperf/?perf=' + perfecture + '&cat=' + cat;
}
else{
//url = 'http://container.intranet.sumasen.net:8100/api/inperf/?perf=' + perfecture;
url = 'http://localhost:8100/api/inperf/?perf=' + perfecture;
url = '${server_url}/api/inperf/?perf=' + perfecture;
//url = 'http://localhost:8100/api/inperf/?perf=' + perfecture;
}
//print("----- url ---- ${url} --- ${cat}");
//String url = 'http://localhost:8100/api/inperf/?perf=' + perfecture + '&cat=' + cat;
@ -50,14 +53,15 @@ class LocationService{
static Future<GeoJsonFeatureCollection?> loadLocationsSubFor(String subperfecture, String cat) async {
String url = "";
String server_url = ConstValues.currentServer();
if(cat.isNotEmpty){
//url = 'http://container.intranet.sumasen.net:8100/api/insubperf?subperf=' + subperfecture + '&cat=' + cat;
url = 'http://localhost:8100/api/insubperf?subperf=' + subperfecture + '&cat=' + cat;
url = '${server_url}/api/insubperf?subperf=' + subperfecture + '&cat=' + cat;
//url = 'http://localhost:8100/api/insubperf?subperf=' + subperfecture + '&cat=' + cat;
}
else{
print("------ loading location in sub----");
//url = 'http://container.intranet.sumasen.net:8100/api/insubperf?subperf=' + subperfecture;
url = 'http://localhost:8100/api/insubperf?subperf=' + subperfecture;
url = '${server_url}/api/insubperf?subperf=' + subperfecture;
//url = 'http://localhost:8100/api/insubperf?subperf=' + subperfecture;
}
final response = await http.get(Uri.parse(url),
headers: <String, String>{
@ -76,14 +80,15 @@ class LocationService{
static Future<GeoJsonFeatureCollection?> loadLocationsBound(double lat1, double lon1, double lat2, double lon2, double lat3, double lon3, double lat4, double lon4, String cat) async {
String url = "";
String server_url = ConstValues.currentServer();
print("cat is ----- ${cat}");
if(cat.isNotEmpty){
//url = 'http://container.intranet.sumasen.net:8100/api/inbound?ln1=${lon1}&la1=${lat1}&ln2=${lon2}&la2=${lat2}&ln3=${lon3}&la3=${lat3}&ln4=${lon4}&la4=${lat4}' + '&cat=' + cat;
url = 'http://localhost:8100/api/inbound?ln1=${lon1}&la1=${lat1}&ln2=${lon2}&la2=${lat2}&ln3=${lon3}&la3=${lat3}&ln4=${lon4}&la4=${lat4}' + '&cat=' + cat;
url = '${server_url}/api/inbound?ln1=${lon1}&la1=${lat1}&ln2=${lon2}&la2=${lat2}&ln3=${lon3}&la3=${lat3}&ln4=${lon4}&la4=${lat4}' + '&cat=' + cat;
//url = 'http://localhost:8100/api/inbound?ln1=${lon1}&la1=${lat1}&ln2=${lon2}&la2=${lat2}&ln3=${lon3}&la3=${lat3}&ln4=${lon4}&la4=${lat4}' + '&cat=' + cat;
}
else{
//url = 'http://container.intranet.sumasen.net:8100/api/inbound?ln1=${lon1}&la1=${lat1}&ln2=${lon2}&la2=${lat2}&ln3=${lon3}&la3=${lat3}&ln4=${lon4}&la4=${lat4}';
url = 'http://localhost:8100/api/inbound?ln1=${lon1}&la1=${lat1}&ln2=${lon2}&la2=${lat2}&ln3=${lon3}&la3=${lat3}&ln4=${lon4}&la4=${lat4}';
url = '${server_url}/api/inbound?ln1=${lon1}&la1=${lat1}&ln2=${lon2}&la2=${lat2}&ln3=${lon3}&la3=${lat3}&ln4=${lon4}&la4=${lat4}';
//url = 'http://localhost:8100/api/inbound?ln1=${lon1}&la1=${lat1}&ln2=${lon2}&la2=${lat2}&ln3=${lon3}&la3=${lat3}&ln4=${lon4}&la4=${lat4}';
}
print("----url --- ${url}");
final response = await http.get(Uri.parse(url),
@ -109,16 +114,17 @@ class LocationService{
}
static Future<GeoJsonFeatureCollection?> loadCustomLocations(String cat) async {
static Future<GeoJsonFeatureCollection?> loadCustomLocations(String name, String cat) async {
String url = "";
String server_url = ConstValues.currentServer();
print("cat is ----- ${cat}");
if(cat.isNotEmpty){
//url = 'http://container.intranet.sumasen.net:8100/api/custom_area/?&cat=' + cat;
url = 'http://localhost:8100/api/custom_area/?&cat=' + cat;
url = '${server_url}/api/custom_area/?&cat=' + cat;
//url = 'http://localhost:8100/api/customarea?name=${name}&cat=' + cat;
}
else{
//url = 'http://container.intranet.sumasen.net:8100/api/custom_area/';
url = 'http://localhost:8100/api/custom_area/';
url = '${server_url}/api/customarea?name=${name}&';
//url = 'http://localhost:8100/api/customarea?name=${name}&';
}
print("----url --- ${url}");
final response = await http.get(Uri.parse(url),

View File

@ -1,13 +1,15 @@
import 'dart:convert';
import 'package:http/http.dart' as http;
import 'package:rogapp/utils/const.dart';
class PerfectureService{
static Future<List<dynamic>?> loadPerfectures() async {
List<dynamic> perfs = [];
//String url = 'http://container.intranet.sumasen.net:8100/api/perf_main/';
String url = 'http://localhost:8100/api/perf_main/';
String server_url = ConstValues.currentServer();
String url = '${server_url}/api/perf_main/';
//String url = 'http://localhost:8100/api/perf_main/';
final response = await http.get(Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
@ -23,8 +25,9 @@ class PerfectureService{
static Future<List<dynamic>?> loadSubPerfectures(String area) async {
List<dynamic> perfs = [];
//String url = 'http://container.intranet.sumasen.net:8100/api/subperfinmain/?perf=' + sub;
String url = 'http://localhost:8100/api/subperfinmain/?area=' + area;
String server_url = ConstValues.currentServer();
String url = '${server_url}/api/subperfinmain/?area=' + area;
//String url = 'http://localhost:8100/api/subperfinmain/?area=' + area;
final response = await http.get(Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
@ -41,8 +44,9 @@ class PerfectureService{
static Future<List<dynamic>?> getMainPerfExt(String id) async {
List<dynamic> perfs = [];
//String url = 'http://container.intranet.sumasen.net:8100/api/mainperfext/?perf=' + id;
String url = 'http://localhost:8100/api/mainperfext/?perf=' + id;
String server_url = ConstValues.currentServer();
String url = '${server_url}/api/mainperfext/?perf=' + id;
//String url = 'http://localhost:8100/api/mainperfext/?perf=' + id;
final response = await http.get(Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
@ -58,8 +62,27 @@ class PerfectureService{
static Future<List<dynamic>?> loadGifuAreas(String perf) async {
List<dynamic> perfs = [];
//String url = 'http://container.intranet.sumasen.net:8100/api/allgifuareas/?perf' + perf;
String url = 'http://localhost:8100/api/allgifuareas/?perf=' + perf;
String server_url = ConstValues.currentServer();
String url = '${server_url}/api/allgifuareas/?perf=' + perf;
//String url = 'http://localhost:8100/api/allgifuareas/?perf=' + perf;
final response = await http.get(Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
},
);
if (response.statusCode == 200) {
perfs = json.decode(utf8.decode(response.bodyBytes));
}
return perfs;
}
static Future<List<dynamic>?> loadCustomAreas() async {
List<dynamic> perfs = [];
String server_url = ConstValues.currentServer();
String url = '${server_url}/api/customareanames';
//String url = 'http://localhost:8100/api/customareanames';
final response = await http.get(Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
@ -76,8 +99,9 @@ class PerfectureService{
static Future<List<dynamic>?> getSubExt(String id) async {
List<dynamic> perfs = [];
//String url = 'http://container.intranet.sumasen.net:8100/api/perfext/?sub_perf=' + id;
String url = 'http://localhost:8100/api/perfext/?sub_perf=' + id;
String server_url = ConstValues.currentServer();
String url = '${server_url}/api/perfext/?sub_perf=' + id;
//String url = 'http://localhost:8100/api/perfext/?sub_perf=' + id;
final response = await http.get(Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',

View File

@ -0,0 +1,34 @@
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'package:rogapp/utils/const.dart';
class TrackingService {
static Future<Map<String, dynamic>> addTrack(String user_id, double lat, double lon) async {
Map<String, dynamic> cats = {};
String server_url = ConstValues.currentServer();
String url = '${server_url}/api/track/';
//String url = 'http://localhost:8100/api/track/';
final geom = '{"type": "MULTIPOINT", "coordinates": [[${lon}, ${lat}]]}';
final http.Response response = await http.post(
Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
},
body: jsonEncode(<String, String>{
'user_id': user_id,
'geom': geom
}),
);
if (response.statusCode == 200) {
cats = json.decode(utf8.decode(response.bodyBytes));
}
return cats;
}
}

12
lib/utils/const.dart Normal file
View File

@ -0,0 +1,12 @@
class ConstValues{
static const server_uri = "http://container.intranet.sumasen.net:8100";
static const dev_server = "http://localhost:8100";
static const dev_ip_server = "http://192.168.8.100:8100";
static String currentServer(){
return dev_ip_server;
}
}

View File

@ -3,6 +3,7 @@ import 'dart:io';
import 'package:flutter/material.dart';
import 'package:geojson/geojson.dart';
import 'package:get/get.dart';
import 'package:image_picker/image_picker.dart';
import 'package:rogapp/pages/index/index_controller.dart';
import 'package:rogapp/routes/app_pages.dart';
import 'package:url_launcher/url_launcher.dart';
@ -206,6 +207,16 @@ class BottomSheetWidget extends StatelessWidget {
indexController.currentAction.isNotEmpty ?
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
indexController.rog_mode == 0 ?
Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.end,
children: [
indexController.currentAction[0][0]["wanttogo"] == false ?
ElevatedButton(
@ -277,7 +288,32 @@ class BottomSheetWidget extends StatelessWidget {
)
),
],
)
:
Container(width: 0, height: 0,),
indexController.rog_mode == 1 ?
indexController.currentAction[0][0]["checkin"] == false ?
Column(
children: [
Row(
mainAxisSize: MainAxisSize.max,
children: [
ElevatedButton(
child: Text("Image"), onPressed: (){
final ImagePicker _picker = ImagePicker();
_picker.pickImage(source: ImageSource.camera).then((value){
print("----- image---- ${value!.path}");
});
},
)
],
),
ElevatedButton(
onPressed: (){
if(indexController.currentAction.isNotEmpty){
@ -291,7 +327,10 @@ class BottomSheetWidget extends StatelessWidget {
indexController.makeAction(context);
},
child: Text("checkin".tr)
) :
)
],
)
:
ElevatedButton(
onPressed: (){
if(indexController.currentAction.isNotEmpty){
@ -309,7 +348,8 @@ class BottomSheetWidget extends StatelessWidget {
Icons.favorite, color: Colors.red)
,
)
):
Container(width: 0, height: 0,),
],
): Row(
mainAxisAlignment: MainAxisAlignment.center,

View File

@ -1,9 +1,11 @@
import 'dart:ffi';
import 'package:flutter/material.dart';
import 'package:geojson/geojson.dart';
import 'package:get/get.dart';
import 'package:rogapp/pages/destination/destination_controller.dart';
import 'package:rogapp/pages/index/index_controller.dart';
import 'package:rogapp/widgets/bottom_sheet_widget.dart';
import 'package:timeline_tile/timeline_tile.dart';
class DestinationWidget extends StatelessWidget {
@ -110,6 +112,25 @@ class DestinationWidget extends StatelessWidget {
minHeight: 80,
),
child: ListTile(
onTap: () async {
{
double lat = destinationController.destinations[index]["location"]["geometry"]["coordinates"][0][1] as double;
double lon = destinationController.destinations[index]["location"]["geometry"]["coordinates"][0][0] as double;
GeoJsonFeature? fs = await destinationController.getDEstinationForLatLong(lat, lon);
print("----fsf-----${fs}");
if(fs != null){
if(indexController.currentFeature.length > 0) {
indexController.currentFeature.clear();
}
indexController.currentFeature.add(fs);
indexController.getAction();
showModalBottomSheet(context: context, isScrollControlled: true,
builder:((context) => BottomSheetWidget())
);
}
};
},
onLongPress: (){
print("#### long press #### ${destinationController.destination_index_data.length}");

View File

@ -20,6 +20,14 @@ class PerfectureWidget extends StatefulWidget {
class _PerfectureWidgetState extends State<PerfectureWidget> {
bool isNumeric(String s) {
if (s == null) {
return false;
}
return double.tryParse(s) != null;
}
List<DropdownMenuItem<String>> getDropdownItems() {
List<DropdownMenuItem<String>> dropDownItems = [];
@ -64,7 +72,22 @@ class _PerfectureWidgetState extends State<PerfectureWidget> {
dropDownItems.add(newDropdown);
}
}
if(widget.indexController.customAreas.isNotEmpty){
for (Map<String, dynamic> currency in widget.indexController.customAreas[0]) {
var newDropdown = DropdownMenuItem(
child: Text(currency["event_name"].toString()),
value: currency["event_name"].toString(),
);
dropDownItems.add(newDropdown);
}
}
return dropDownItems;
}
@ -94,7 +117,7 @@ class _PerfectureWidgetState extends State<PerfectureWidget> {
items: getDropdownItems()
),
// Custom events area
// Gifu areas
widget.indexController.areas.isNotEmpty ?
DropdownButton<String>(
value: widget.indexController.areaDropdownValue,
@ -107,10 +130,17 @@ class _PerfectureWidgetState extends State<PerfectureWidget> {
color: Colors.deepPurpleAccent,
),
onChanged: (String? newValue) {
if (isNumeric(newValue!)){
}
else{
widget.indexController.loadCustomLocation(newValue);
}
setState(() {
if(newValue != null){
widget.indexController.is_loading.value = true;
widget.indexController.populateForCustomArea(newValue, widget.mapController);
widget.indexController.areaDropdownValue = newValue;
widget.indexController.populateSubPerForArea(newValue, widget.mapController);
}
});
},

View File

@ -62,6 +62,7 @@ dependencies:
flutter_breadcrumb: ^1.0.1
timeline_tile: ^2.0.0
google_maps_flutter: ^2.1.5
#flutter_map_marker_popup: any
flutter_polyline_points: ^1.0.0
google_maps_webservice: ^0.0.19