update to 3.13

This commit is contained in:
Mohamed Nouffer
2023-09-03 23:37:41 +05:30
parent c41dde4c33
commit 56e9861c7a
60 changed files with 3111 additions and 2705 deletions

View File

@ -5,14 +5,14 @@ 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}");
static Future<Map<String, dynamic>> makeAction(int userId, int locationId, bool wanttogo, bool like, bool checkin) async {
print("----- action is ---- $like-- $wanttogo-- $checkin");
Map<String, dynamic> cats = {};
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 serverUrl = ConstValues.currentServer();
String url = "$serverUrl/api/makeaction/?user_id=$userId&location_id=$locationId&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}";
print('++++++++${url}');
print("url is ------ ${url}");
print('++++++++$url');
print("url is ------ $url");
final http.Response response = await http.get(
Uri.parse(url),
headers: <String, String>{
@ -27,11 +27,11 @@ class ActionService{
}
static Future<List<dynamic>?> userAction(int user_id, int location_id) async {
static Future<List<dynamic>?> userAction(int userId, int locationId) async {
List<dynamic> cats = [];
String server_url = ConstValues.currentServer();
String url = '${server_url}/api/useraction/?user_id=${user_id}&location_id=${location_id}';
print('++++++++${url}');
String serverUrl = ConstValues.currentServer();
String url = '$serverUrl/api/useraction/?user_id=$userId&location_id=$locationId';
print('++++++++$url');
//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>{

View File

@ -8,14 +8,14 @@ class AuthService{
static Future<Map<String, dynamic>> changePassword(String oldpassword, String newpassword, String token) async {
Map<String, dynamic> changePassword = {};
String server_url = ConstValues.currentServer();
String url = '${server_url}/api/change-password/';
print('++++++++${url}');
String serverUrl = ConstValues.currentServer();
String url = '$serverUrl/api/change-password/';
print('++++++++$url');
final http.Response response = await http.put(
Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
'Authorization': 'Token ${token}'
'Authorization': 'Token $token'
},
body: jsonEncode(<String, String>{
'old_password': oldpassword,
@ -31,11 +31,11 @@ class AuthService{
static Future<Map<String, dynamic>> login(String email, String password) async {
print("------- in logged email ${email} pwd ${password} ###### --------");
print("------- in logged email $email pwd $password ###### --------");
Map<String, dynamic> cats = {};
String server_url = ConstValues.currentServer();
String url = '${server_url}/api/login/';
print('++++++++${url}');
String serverUrl = ConstValues.currentServer();
String url = '$serverUrl/api/login/';
print('++++++++$url');
//String url = 'http://localhost:8100/api/login/';
final http.Response response = await http.post(
Uri.parse(url),
@ -57,9 +57,9 @@ class AuthService{
static Future<Map<String, dynamic>> register(String email, String password) async {
Map<String, dynamic> cats = {};
String server_url = ConstValues.currentServer();
String url = '${server_url}/api/register/';
print('++++++++${url}');
String serverUrl = ConstValues.currentServer();
String url = '$serverUrl/api/register/';
print('++++++++$url');
final http.Response response = await http.post(
Uri.parse(url),
headers: <String, String>{
@ -79,14 +79,14 @@ class AuthService{
static Future<Map<String, dynamic>> deleteUser(String token) async {
Map<String, dynamic> cats = {};
String server_url = ConstValues.currentServer();
String url = '${server_url}/api/delete-account/';
print('++++++++${url}');
String serverUrl = ConstValues.currentServer();
String url = '$serverUrl/api/delete-account/';
print('++++++++$url');
final http.Response response = await http.get(
Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
'Authorization': 'Token ${token}'
'Authorization': 'Token $token'
}
);
@ -99,10 +99,10 @@ 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}';
print('++++++++${url}');
print("---- UserDetails url is ${url}");
String serverUrl = ConstValues.currentServer();
String url = '$serverUrl/api/userdetials?user_id=$userid';
print('++++++++$url');
print("---- UserDetails url is $url");
final response = await http.get(Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
@ -117,6 +117,28 @@ class AuthService{
}
static Future<List<dynamic>?> userForToken(String token) async {
Map<String, dynamic> cats = {};
String serverUrl = ConstValues.currentServer();
String url = '$serverUrl/api/user/';
print('++++++++$url');
print("---- UserDetails url is $url");
final response = await http.get(Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
'Authorization': 'Token $token'
},
);
if (response.statusCode == 200) {
cats = json.decode(utf8.decode(response.bodyBytes));
print("--- eeeeee $cats ----");
}
return [{"user":cats}];
}

View File

@ -1,5 +1,4 @@
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import '../utils/const.dart';
@ -9,9 +8,9 @@ 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 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}';
print('++++++++${url}');
String serverUrl = ConstValues.currentServer();
String url = '$serverUrl/api/cats/?ln1=$lon1&la1=$lat1&ln2=$lon2&la2=$lat2&ln3=$lon3&la3=$lat3&ln4=$lon4&la4=$lat4';
print('++++++++$url');
final response = await http.get(Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
@ -28,9 +27,9 @@ class CatService{
static Future<List<dynamic>?> loadCatByCity(String cityname)async {
List<dynamic> cats = [];
String server_url = ConstValues.currentServer();
String url = '${server_url}/api/catbycity/?${cityname}';
print('++++++++${url}');
String serverUrl = ConstValues.currentServer();
String url = '$serverUrl/api/catbycity/?$cityname';
print('++++++++$url');
final response = await http.get(Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',

View File

@ -11,11 +11,11 @@ import '../utils/const.dart';
class DestinationService{
static Future<List<dynamic>> getDestinations(int user_id) async {
static Future<List<dynamic>> getDestinations(int userId) async {
List<dynamic> cats = [];
String server_url = ConstValues.currentServer();
String url = "${server_url}/api/destinations/?user_id=${user_id}";
print('++++++++${url}');
String serverUrl = ConstValues.currentServer();
String url = "$serverUrl/api/destinations/?user_id=$userId";
print('++++++++$url');
final http.Response response = await http.get(
Uri.parse(url),
headers: <String, String>{
@ -29,11 +29,11 @@ class DestinationService{
return cats;
}
static Future<Map<String, dynamic>> deleteDestination(int dest_id) async {
static Future<Map<String, dynamic>> deleteDestination(int destId) async {
Map<String, dynamic> cats = {};
String server_url = ConstValues.currentServer();
String url = "${server_url}/api/delete_destination/?dest_id=${dest_id}";
print('++++++++${url}');
String serverUrl = ConstValues.currentServer();
String url = "$serverUrl/api/delete_destination/?dest_id=$destId";
print('++++++++$url');
final http.Response response = await http.get(
Uri.parse(url),
headers: <String, String>{
@ -44,15 +44,15 @@ class DestinationService{
if (response.statusCode == 200) {
cats = json.decode(utf8.decode(response.bodyBytes));
}
print("####### ---- ${cats}");
print("####### ---- $cats");
return cats;
}
static Future<int> updateOrder(int action_id, int order, String dir) async {
static Future<int> updateOrder(int actionId, int order, String dir) async {
int cats = 0;
String server_url = ConstValues.currentServer();
String url = "${server_url}/api/updateorder/?user_action_id=${action_id}&order=${order}&dir=${dir}";
print('++++++++${url}');
String serverUrl = ConstValues.currentServer();
String url = "$serverUrl/api/updateorder/?user_action_id=$actionId&order=$order&dir=$dir";
print('++++++++$url');
final http.Response response = await http.get(
Uri.parse(url),
headers: <String, String>{
@ -69,7 +69,7 @@ class DestinationService{
static Future<List<PointLatLng>>? getDestinationLine(List<Destination> destinations, Map<String, dynamic> mtx) async{
PolylinePoints polylinePoints = PolylinePoints();
if(destinations.length <= 0){
if(destinations.isEmpty){
return [];
}
@ -90,7 +90,7 @@ class DestinationService{
int j = 0;
PolylineWayPoint pwp = PolylineWayPoint(location: "${la},${ln}", stopOver: false);
PolylineWayPoint pwp = PolylineWayPoint(location: "$la,$ln", stopOver: false);
//print("----- UUUUUU ${pwp}");
@ -101,15 +101,15 @@ class DestinationService{
}
final DestinationController destinationController = Get.find<DestinationController>();
int trav_mode = destinationController.travelMode.value;
String _mode = "WALKING";
if(trav_mode == 1){
int travMode = destinationController.travelMode.value;
String mode = "WALKING";
if(travMode == 1){
//_mode = TravelMode.driving;
_mode = "DRIVING";
mode = "DRIVING";
}
else if(trav_mode == 2) {
else if(travMode == 2) {
//_mode = TravelMode.transit;
_mode = "TRANSIT";
mode = "TRANSIT";
}

View File

@ -2,12 +2,10 @@ import 'dart:io';
import 'package:get/get.dart';
import 'package:http/http.dart' as http;
import 'package:intl/intl.dart';
import 'package:rogapp/model/destination.dart';
import 'package:rogapp/model/rog.dart';
import 'package:rogapp/pages/destination/destination_controller.dart';
import 'package:rogapp/pages/index/index_controller.dart';
import 'package:rogapp/utils/database_helper.dart';
import 'package:sqflite/sqlite_api.dart';
import 'dart:convert';
import '../utils/const.dart';
@ -33,100 +31,100 @@ class ExternalService {
final IndexController indexController = Get.find<IndexController>();
Map<String, dynamic> _res = {};
Map<String, dynamic> res = {};
int user_id = indexController.currentUser[0]["user"]["id"];
int userId = indexController.currentUser[0]["user"]["id"];
//print("--- Pressed -----");
String _team = indexController.currentUser[0]["user"]['team_name'];
String team = indexController.currentUser[0]["user"]['team_name'];
//print("--- _team : ${_team}-----");
String _event_code = indexController.currentUser[0]["user"]["event_code"];
String eventCode = indexController.currentUser[0]["user"]["event_code"];
if(indexController.connectionStatusName != "wifi" && indexController.connectionStatusName != "mobile"){
DatabaseHelper db = DatabaseHelper.instance;
Rog _rog = Rog(
Rog rog = Rog(
id:1,
team_name: _team,
event_code : _event_code,
user_id: user_id,
team_name: team,
event_code : eventCode,
user_id: userId,
cp_number: -1,
checkintime: DateTime.now().toUtc().microsecondsSinceEpoch,
image: null,
rog_action_type: 0
);
db.insertRogaining(_rog);
db.insertRogaining(rog);
}
else {
String url = 'https://natnats.mobilous.com/start_from_rogapp';
print('++++++++${url}');
print('++++++++$url');
final http.Response response = await http.post(
Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
},
body: jsonEncode(<String, String>{
'team_name': _team,
'event_code': _event_code
'team_name': team,
'event_code': eventCode
}),
);
print("---- start rogianing api status ---- ${response.statusCode}");
if (response.statusCode == 200) {
_res = json.decode(utf8.decode(response.bodyBytes));
print('----_res : ${_res} ----');
res = json.decode(utf8.decode(response.bodyBytes));
print('----_res : $res ----');
}
}
return _res;
return res;
}
Future<Map<String, dynamic>> makeCheckpoint(int user_id, String token, String checkin_time, String teamname, int cp, String eventcode, String imageurl) async {
Map<String, dynamic> _res = {};
Future<Map<String, dynamic>> makeCheckpoint(int userId, String token, String checkinTime, String teamname, int cp, String eventcode, String imageurl) async {
Map<String, dynamic> res = {};
String url = 'https://natnats.mobilous.com/checkin_from_rogapp';
print('++++++++${url}');
print('++++++++$url');
final IndexController indexController = Get.find<IndexController>();
if(imageurl != null){
if(indexController.connectionStatusName != "wifi" && indexController.connectionStatusName != "mobile"){
DatabaseHelper db = DatabaseHelper.instance;
Rog _rog = Rog(
Rog rog = Rog(
id:1,
team_name: teamname,
event_code : eventcode,
user_id: user_id,
user_id: userId,
cp_number: cp,
checkintime: DateTime.now().toUtc().microsecondsSinceEpoch,
image: imageurl,
rog_action_type: 1,
);
db.insertRogaining(_rog);
db.insertRogaining(rog);
}
else {
String server_url = ConstValues.currentServer();
String url1 = "${server_url}/api/checkinimage/";
final im1Bytes = File(imageurl!).readAsBytesSync();
String serverUrl = ConstValues.currentServer();
String url1 = "$serverUrl/api/checkinimage/";
final im1Bytes = File(imageurl).readAsBytesSync();
String im1_64 = base64Encode(im1Bytes);
final http.Response response = await http.post(
Uri.parse(url1),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
'Authorization': 'Token ${token}'
'Authorization': 'Token $token'
},
// 'id', 'user', 'goalimage', 'goaltime', 'team_name', 'event_code','cp_number'
body: jsonEncode(<String, String>{
'user' : user_id.toString(),
'user' : userId.toString(),
'team_name': teamname,
'event_code': eventcode,
'checkinimage' : im1_64,
'checkintime' : checkin_time,
'checkintime' : checkinTime,
'cp_number' : cp.toString()
}),
);
_res = json.decode(utf8.decode(response.bodyBytes));
res = json.decode(utf8.decode(response.bodyBytes));
print("-----@@@@@ ${_res} -----");
print("-----@@@@@ $res -----");
if(response.statusCode == 201){
//print('---- toekn is ${token} -----');
@ -139,13 +137,13 @@ class ExternalService {
'team_name': teamname,
'cp_number': cp.toString(),
'event_code': eventcode,
'image': _res["checkinimage"].toString().replaceAll('http://localhost:8100', 'http://rogaining.sumasen.net')
'image': res["checkinimage"].toString().replaceAll('http://localhost:8100', 'http://rogaining.sumasen.net')
}),
);
print("--- checnin response ${response2.statusCode}----");
if (response2.statusCode == 200) {
_res = json.decode(utf8.decode(response2.bodyBytes));
print('----checkin res _res : ${_res} ----');
res = json.decode(utf8.decode(response2.bodyBytes));
print('----checkin res _res : $res ----');
}
}
}
@ -153,17 +151,17 @@ class ExternalService {
else{
if(indexController.connectionStatusName != "wifi" || indexController.connectionStatusName != "mobile"){
DatabaseHelper db = DatabaseHelper.instance;
Rog _rog = Rog(
Rog rog = Rog(
id:1,
team_name: teamname,
event_code : eventcode,
user_id: user_id,
user_id: userId,
cp_number: cp,
checkintime: DateTime.now().toUtc().microsecondsSinceEpoch,
image: null,
rog_action_type: 1,
);
db.insertRogaining(_rog);
db.insertRogaining(rog);
}
else {
final http.Response response3 = await http.post(
@ -180,64 +178,64 @@ class ExternalService {
);
print("--- checnin response ${response3.statusCode}----");
if (response3.statusCode == 200) {
_res = json.decode(utf8.decode(response3.bodyBytes));
print('----checkin res _res : ${_res} ----');
res = json.decode(utf8.decode(response3.bodyBytes));
print('----checkin res _res : $res ----');
}
}
}
return _res;
return res;
}
Future<Map<String, dynamic>> makeGoal(int user_id, String token, String teamname, String image, String goal_time, String eventcode) async {
Map<String, dynamic> _res2 = {};
Future<Map<String, dynamic>> makeGoal(int userId, String token, String teamname, String image, String goalTime, String eventcode) async {
Map<String, dynamic> res2 = {};
final IndexController indexController = Get.find<IndexController>();
final DestinationController destinationController = Get.find<DestinationController>();
//if(indexController.connectionStatusName != "wifi" && indexController.connectionStatusName != "mobile"){
DatabaseHelper db = DatabaseHelper.instance;
Rog _rog = Rog(
Rog rog = Rog(
id:1,
team_name: teamname,
event_code : eventcode,
user_id: user_id,
user_id: userId,
cp_number: -1,
checkintime: DateTime.now().toUtc().microsecondsSinceEpoch,
image: image,
rog_action_type: 1,
);
db.insertRogaining(_rog);
db.insertRogaining(rog);
// }
// else{
String server_url = ConstValues.currentServer();
String url1 = "${server_url}/api/goalimage/";
final im1Bytes = File(image!).readAsBytesSync();
String serverUrl = ConstValues.currentServer();
String url1 = "$serverUrl/api/goalimage/";
final im1Bytes = File(image).readAsBytesSync();
String im1_64 = base64Encode(im1Bytes);
final http.Response response = await http.post(
Uri.parse(url1),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
'Authorization': 'Token ${token}'
'Authorization': 'Token $token'
},
// 'id', 'user', 'goalimage', 'goaltime', 'team_name', 'event_code','cp_number'
body: jsonEncode(<String, String>{
'user' : user_id.toString(),
'user' : userId.toString(),
'team_name': teamname,
'event_code': eventcode,
'goaltime' : goal_time,
'goaltime' : goalTime,
'goalimage' : im1_64,
'cp_number' : "-1"
}),
);
String url = 'https://natnats.mobilous.com/goal_from_rogapp';
print('++++++++${url}');
print('++++++++$url');
if (response.statusCode == 201) {
Map<String, dynamic> _res = json.decode(utf8.decode(response.bodyBytes));
print('----_res : ${_res} ----');
print('---- image url ${_res["goalimage"]} ----');
Map<String, dynamic> res = json.decode(utf8.decode(response.bodyBytes));
print('----_res : $res ----');
print('---- image url ${res["goalimage"]} ----');
final http.Response response2 = await http.post(
Uri.parse(url),
headers: <String, String>{
@ -246,26 +244,26 @@ class ExternalService {
body: jsonEncode(<String, String>{
'team_name': teamname,
'event_code': eventcode,
'goal_time' : goal_time,
'image' : _res["goalimage"].toString().replaceAll('http://localhost:8100', 'http://rogaining.sumasen.net')
'goal_time' : goalTime,
'image' : res["goalimage"].toString().replaceAll('http://localhost:8100', 'http://rogaining.sumasen.net')
}
),
);
print('----- response2 is ${response2} --------');
print('----- response2 is $response2 --------');
if (response2.statusCode == 200) {
_res2 = json.decode(utf8.decode(response2.bodyBytes));
res2 = json.decode(utf8.decode(response2.bodyBytes));
}
}
//}
destinationController.resetRogaining();
return _res2;
return res2;
}
static Future<Map<String, dynamic>> usersEventCode(String teamcode, String password) async {
Map<String, dynamic> _res = {};
String url = "https://natnats.mobilous.com/check_event_code?zekken_number=${teamcode}&password=${password}";
print('++++++++${url}');
Map<String, dynamic> res = {};
String url = "https://natnats.mobilous.com/check_event_code?zekken_number=$teamcode&password=$password";
print('++++++++$url');
final http.Response response = await http.get(
Uri.parse(url),
headers: <String, String>{
@ -274,9 +272,9 @@ class ExternalService {
);
if (response.statusCode == 200) {
_res = json.decode(utf8.decode(response.bodyBytes));
res = json.decode(utf8.decode(response.bodyBytes));
}
return _res;
return res;
}
}

View File

@ -8,9 +8,9 @@ class LocationLineService{
static Future<GeoJsonFeature?> loadLocationLines() async {
final geo = GeoJson();
GeoJsonFeature? fs;
String server_url = ConstValues.currentServer();
String url = '${server_url}/api/location_line/';
print('++++++++${url}');
String serverUrl = ConstValues.currentServer();
String url = '$serverUrl/api/location_line/';
print('++++++++$url');
final response = await http.get(Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',

View File

@ -9,9 +9,9 @@ class LocationPolygonervice{
final geo = GeoJson();
GeoJsonFeature? fs;
String server_url = ConstValues.currentServer();
String url = '${server_url}/api/location_polygon/';
print('++++++++${url}');
String serverUrl = ConstValues.currentServer();
String url = '$serverUrl/api/location_polygon/';
print('++++++++$url');
final response = await http.get(Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',

View File

@ -37,31 +37,31 @@ class LocationService{
static Future<GeoJsonFeatureCollection?> loadLocationsFor(String perfecture, String cat) async {
final IndexController indexController = Get.find<IndexController>();
String url = "";
String server_url = ConstValues.currentServer();
String serverUrl = ConstValues.currentServer();
if(cat.isNotEmpty){
if(indexController.currentUser.isNotEmpty){
bool _rog = indexController.currentUser[0]['user']['is_rogaining'];
String r = _rog == true ? 'True': 'False';
bool rog = indexController.currentUser[0]['user']['is_rogaining'];
String r = rog == true ? 'True': 'False';
var grp = indexController.currentUser[0]['user']['event_code'];
url = '${server_url}/api/inperf/?rog=${r}&perf=' + perfecture + '&cat=' + cat;
url = '$serverUrl/api/inperf/?rog=$r&perf=$perfecture&cat=$cat';
}
else {
url = '${server_url}/api/inperf/?perf=' + perfecture + '&cat=' + cat;
url = '$serverUrl/api/inperf/?perf=$perfecture&cat=$cat';
}
}
else{
if(indexController.currentUser.isNotEmpty){
bool _rog = indexController.currentUser[0]['user']['is_rogaining'];
String r = _rog == true ? 'True': 'False';
bool rog = indexController.currentUser[0]['user']['is_rogaining'];
String r = rog == true ? 'True': 'False';
var grp = indexController.currentUser[0]['user']['event_code'];
url = '${server_url}/api/inperf/?rog=${r}&perf=' + perfecture;
url = '$serverUrl/api/inperf/?rog=$r&perf=$perfecture';
}
else {
url = '${server_url}/api/inperf/?perf=' + perfecture;
url = '$serverUrl/api/inperf/?perf=$perfecture';
}
}
print('++++++++${url}');
print('++++++++$url');
final response = await http.get(Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
@ -78,13 +78,13 @@ class LocationService{
static Future<List<dynamic>?> getLocationsExt(String token) async {
List<dynamic> ext = [];
String server_url = ConstValues.currentServer();
String url = '${server_url}/api/locsext/';
print('++++++++${url}');
String serverUrl = ConstValues.currentServer();
String url = '$serverUrl/api/locsext/';
print('++++++++$url');
final response = await http.post(Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
'Authorization': 'Token ${token}'
'Authorization': 'Token $token'
},
body: jsonEncode(<String, String>{
'token': token,
@ -102,30 +102,30 @@ class LocationService{
static Future<GeoJsonFeatureCollection?> loadLocationsSubFor(String subperfecture, String cat) async {
final IndexController indexController = Get.find<IndexController>();
String url = "";
String server_url = ConstValues.currentServer();
String serverUrl = ConstValues.currentServer();
if(cat.isNotEmpty){
if(indexController.currentUser.isNotEmpty){
bool _rog = indexController.currentUser[0]['user']['is_rogaining'];
String r = _rog == true ? 'True': 'False';
bool rog = indexController.currentUser[0]['user']['is_rogaining'];
String r = rog == true ? 'True': 'False';
var grp = indexController.currentUser[0]['user']['event_code'];
url = '${server_url}/api/insubperf?rog=${r}&subperf=' + subperfecture + '&cat=' + cat;
url = '$serverUrl/api/insubperf?rog=$r&subperf=$subperfecture&cat=$cat';
}
else{
url = '${server_url}/api/insubperf?subperf=' + subperfecture + '&cat=' + cat;
url = '$serverUrl/api/insubperf?subperf=$subperfecture&cat=$cat';
}
}
else{
if(indexController.currentUser.isNotEmpty){
bool _rog = indexController.currentUser[0]['user']['is_rogaining'];
String r = _rog == true ? 'True': 'False';
bool rog = indexController.currentUser[0]['user']['is_rogaining'];
String r = rog == true ? 'True': 'False';
var grp = indexController.currentUser[0]['user']['event_code'];
url = '${server_url}/api/insubperf?rog=${r}&subperf=' + subperfecture;
url = '$serverUrl/api/insubperf?rog=$r&subperf=$subperfecture';
}
else{
url = '${server_url}/api/insubperf?subperf=' + subperfecture;
url = '$serverUrl/api/insubperf?subperf=$subperfecture';
}
}
print('++++++++${url}');
print('++++++++$url');
final response = await http.get(Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
@ -142,34 +142,35 @@ 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 {
print("-------- in location for bound -------------");
final IndexController indexController = Get.find<IndexController>();
print("-------- in location for bound -------------");
print("-------- in location for bound current user ${indexController.currentUser} -------------");
String url = "";
String server_url = ConstValues.currentServer();
String serverUrl = ConstValues.currentServer();
if(cat.isNotEmpty){
if(indexController.currentUser.isNotEmpty){
bool _rog = indexController.currentUser[0]['user']['is_rogaining'];
String r = _rog == true ? 'True': 'False';
bool rog = indexController.currentUser[0]['user']['is_rogaining'];
String r = rog == true ? 'True': 'False';
var grp = indexController.currentUser[0]['user']['event_code'];
url = '${server_url}/api/inbound?rog=${r}&grp=$grp&ln1=${lon1}&la1=${lat1}&ln2=${lon2}&la2=${lat2}&ln3=${lon3}&la3=${lat3}&ln4=${lon4}&la4=${lat4}' + '&cat=' + cat;
url = '$serverUrl/api/inbound?rog=$r&grp=$grp&ln1=$lon1&la1=$lat1&ln2=$lon2&la2=$lat2&ln3=$lon3&la3=$lat3&ln4=$lon4&la4=$lat4&cat=$cat';
}
else{
url = '${server_url}/api/inbound?ln1=${lon1}&la1=${lat1}&ln2=${lon2}&la2=${lat2}&ln3=${lon3}&la3=${lat3}&ln4=${lon4}&la4=${lat4}' + '&cat=' + cat;
url = '$serverUrl/api/inbound?ln1=$lon1&la1=$lat1&ln2=$lon2&la2=$lat2&ln3=$lon3&la3=$lat3&ln4=$lon4&la4=$lat4&cat=$cat';
}
}
else{
if(indexController.currentUser.isNotEmpty){
bool _rog = indexController.currentUser[0]['user']['is_rogaining'];
String r = _rog == true ? 'True': 'False';
bool rog = indexController.currentUser[0]['user']['is_rogaining'];
String r = rog == true ? 'True': 'False';
var grp = indexController.currentUser[0]['user']['event_code'];
print("-------- requested user group ${grp} -------------");
url = '${server_url}/api/inbound?rog=${r}&grp=$grp&ln1=${lon1}&la1=${lat1}&ln2=${lon2}&la2=${lat2}&ln3=${lon3}&la3=${lat3}&ln4=${lon4}&la4=${lat4}';
print("-------- requested user group $grp -------------");
url = '$serverUrl/api/inbound?rog=$r&grp=$grp&ln1=$lon1&la1=$lat1&ln2=$lon2&la2=$lat2&ln3=$lon3&la3=$lat3&ln4=$lon4&la4=$lat4';
}
else{
url = '${server_url}/api/inbound?ln1=${lon1}&la1=${lat1}&ln2=${lon2}&la2=${lat2}&ln3=${lon3}&la3=${lat3}&ln4=${lon4}&la4=${lat4}';
url = '$serverUrl/api/inbound?ln1=$lon1&la1=$lat1&ln2=$lon2&la2=$lat2&ln3=$lon3&la3=$lat3&ln4=$lon4&la4=$lat4';
}
}
print('++++++++${url}');
print('++++++++$url');
final response = await http.get(Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
@ -200,31 +201,31 @@ class LocationService{
if(cat == "-all-"){
cat = "";
}
String server_url = ConstValues.currentServer();
print("loadCustomLocations url is ----- ${cat}");
String serverUrl = ConstValues.currentServer();
print("loadCustomLocations url is ----- $cat");
if(cat.isNotEmpty){
if(indexController.currentUser.isNotEmpty){
bool _rog = indexController.currentUser[0]['user']['is_rogaining'];
String r = _rog == true ? 'True': 'False';
bool rog = indexController.currentUser[0]['user']['is_rogaining'];
String r = rog == true ? 'True': 'False';
var grp = indexController.currentUser[0]['user']['event_code'];
url = '${server_url}/api/custom_area/?rog=${r}&&cat=' + cat;
url = '$serverUrl/api/custom_area/?rog=$r&&cat=$cat';
}
else{
url = '${server_url}/api/custom_area/?&cat=' + cat;
url = '$serverUrl/api/custom_area/?&cat=$cat';
}
}
else{
if(indexController.currentUser.isNotEmpty){
bool _rog = indexController.currentUser[0]['user']['is_rogaining'];
String r = _rog == true ? 'True': 'False';
bool rog = indexController.currentUser[0]['user']['is_rogaining'];
String r = rog == true ? 'True': 'False';
var grp = indexController.currentUser[0]['user']['event_code'];
url = '${server_url}/api/customarea?rog=${r}&name=${name}';
url = '$serverUrl/api/customarea?rog=$r&name=$name';
}
else{
url = '${server_url}/api/customarea?name=${name}';
url = '$serverUrl/api/customarea?name=$name';
}
}
print('++++++++${url}');
print('++++++++$url');
final response = await http.get(Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',

View File

@ -18,7 +18,7 @@ class MatrixService{
int i = 0;
for(Destination d in destinations){
print("---- getting matrix for ${d} ------------");
print("---- getting matrix for $d ------------");
if(i==0){
origin = "${d.lat}, ${d.lon}";
@ -37,24 +37,24 @@ class MatrixService{
i++;
}
locs = "optimize:false|${locs}";
locs = "optimize:false|$locs";
String _mode = "walking";
String mode = "walking";
switch (destinationController.travelMode.value) {
case 1:
_mode = "driving";
mode = "driving";
break;
case 2:
_mode = "transit";
mode = "transit";
break;
default:
_mode = "walking";
mode = "walking";
break;
}
Map<String, dynamic> cats = {};
String url = "https://maps.googleapis.com/maps/api/directions/json?destination=${destination}&mode=${_mode}&waypoints=${locs}&origin=${origin}&key=AIzaSyAUBI1ablMKuJwGj2-kSuEhvYxvB1A-mOE";
print('++++++++${url}');
String url = "https://maps.googleapis.com/maps/api/directions/json?destination=$destination&mode=$mode&waypoints=$locs&origin=$origin&key=AIzaSyAUBI1ablMKuJwGj2-kSuEhvYxvB1A-mOE";
print('++++++++$url');
final http.Response response = await http.get(
Uri.parse(url),
headers: <String, String>{

View File

@ -7,9 +7,9 @@ class PerfectureService{
static Future<List<dynamic>?> loadPerfectures() async {
List<dynamic> perfs = [];
String server_url = ConstValues.currentServer();
String url = '${server_url}/api/perf_main/';
print('++++++++${url}');
String serverUrl = ConstValues.currentServer();
String url = '$serverUrl/api/perf_main/';
print('++++++++$url');
final response = await http.get(Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
@ -25,9 +25,9 @@ class PerfectureService{
static Future<List<dynamic>?> loadSubPerfectures(String area) async {
List<dynamic> perfs = [];
String server_url = ConstValues.currentServer();
String url = '${server_url}/api/subperfinmain/?area=' + area;
print('++++++++${url}');
String serverUrl = ConstValues.currentServer();
String url = '$serverUrl/api/subperfinmain/?area=$area';
print('++++++++$url');
final response = await http.get(Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
@ -44,9 +44,9 @@ class PerfectureService{
static Future<List<dynamic>?> getMainPerfExt(String id) async {
List<dynamic> perfs = [];
String server_url = ConstValues.currentServer();
String url = '${server_url}/api/mainperfext/?perf=' + id;
print('++++++++${url}');
String serverUrl = ConstValues.currentServer();
String url = '$serverUrl/api/mainperfext/?perf=$id';
print('++++++++$url');
final response = await http.get(Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
@ -62,9 +62,9 @@ class PerfectureService{
static Future<List<dynamic>?> loadGifuAreas(String perf) async {
List<dynamic> perfs = [];
String server_url = ConstValues.currentServer();
String url = '${server_url}/api/allgifuareas/?perf=' + perf;
print('++++++++${url}');
String serverUrl = ConstValues.currentServer();
String url = '$serverUrl/api/allgifuareas/?perf=$perf';
print('++++++++$url');
final response = await http.get(Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
@ -80,9 +80,9 @@ class PerfectureService{
static Future<List<dynamic>?> loadCustomAreas() async {
List<dynamic> perfs = [];
String server_url = ConstValues.currentServer();
String url = '${server_url}/api/customareanames';
print('++++++++${url}');
String serverUrl = ConstValues.currentServer();
String url = '$serverUrl/api/customareanames';
print('++++++++$url');
final response = await http.get(Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
@ -99,9 +99,9 @@ class PerfectureService{
static Future<List<dynamic>?> getSubExt(String id) async {
List<dynamic> perfs = [];
String server_url = ConstValues.currentServer();
String url = '${server_url}/api/perfext/?sub_perf=' + id;
print('++++++++${url}');
String serverUrl = ConstValues.currentServer();
String url = '$serverUrl/api/perfext/?sub_perf=$id';
print('++++++++$url');
final response = await http.get(Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',

View File

@ -1,26 +1,25 @@
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 {
static Future<Map<String, dynamic>> addTrack(String userId, double lat, double lon) async {
Map<String, dynamic> cats = {};
String server_url = ConstValues.currentServer();
String url = '${server_url}/api/track/';
print('++++++++${url}');
final geom = '{"type": "MULTIPOINT", "coordinates": [[${lon}, ${lat}]]}';
String serverUrl = ConstValues.currentServer();
String url = '$serverUrl/api/track/';
print('++++++++$url');
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,
'user_id': userId,
'geom': geom
}),
);