added goal feature

This commit is contained in:
Mohamed Nouffer
2022-10-12 21:46:17 +05:30
parent 0470e1f27f
commit 8e30ee6ba7
29 changed files with 876 additions and 481 deletions

View File

@ -8,31 +8,31 @@ import 'package:rogapp/utils/const.dart';
class LocationService{
static Future<GeoJsonFeatureCollection?> loadLocations() async {
// static Future<GeoJsonFeatureCollection?> loadLocations() async {
final IndexController indexController = Get.find<IndexController>();
// final IndexController indexController = Get.find<IndexController>();
String server_url = ConstValues.currentServer();
String url = "";
if(indexController.currentUser.length > 0){
url = '${server_url}/api/location/?is_rog=True';
}
else {
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',
},
);
// String server_url = ConstValues.currentServer();
// String url = "";
// if(indexController.currentUser.length > 0){
// url = '${server_url}/api/location/?is_rog=True';
// }
// else {
// 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',
// },
// );
if (response.statusCode == 200) {
// if (response.statusCode == 200) {
return featuresFromGeoJson(utf8.decode(response.bodyBytes));
}
return null;
}
// return featuresFromGeoJson(utf8.decode(response.bodyBytes));
// }
// return null;
// }
static Future<GeoJsonFeatureCollection?> loadLocationsFor(String perfecture, String cat) async {
final IndexController indexController = Get.find<IndexController>();
@ -40,18 +40,22 @@ class LocationService{
String server_url = ConstValues.currentServer();
if(cat.isNotEmpty){
if(indexController.currentUser.length > 0){
if(indexController.currentUser.isNotEmpty){
bool _rog = indexController.currentUser[0]['user']['is_rogaining'];
String r = _rog == true ? 'True': 'False';
var grp = indexController.currentUser[0]['user']['group'];
url = '${server_url}/api/inperf/?rog=True&perf=' + perfecture + '&cat=' + cat + "&grp=${grp}";
url = '${server_url}/api/inperf/?rog=${r}&perf=' + perfecture + '&cat=' + cat + "&grp=${grp}";
}
else {
url = '${server_url}/api/inperf/?perf=' + perfecture + '&cat=' + cat;
}
}
else{
if(indexController.currentUser.length > 0){
if(indexController.currentUser.isNotEmpty){
bool _rog = indexController.currentUser[0]['user']['is_rogaining'];
String r = _rog == true ? 'True': 'False';
var grp = indexController.currentUser[0]['user']['group'];
url = '${server_url}/api/inperf/?rog=True&perf=' + perfecture + "&grp=${grp}";
url = '${server_url}/api/inperf/?rog=${r}&perf=' + perfecture + "&grp=${grp}";
}
else {
url = '${server_url}/api/inperf/?perf=' + perfecture;
@ -78,18 +82,22 @@ class LocationService{
String url = "";
String server_url = ConstValues.currentServer();
if(cat.isNotEmpty){
if(indexController.currentUser.length > 0){
if(indexController.currentUser.isNotEmpty){
bool _rog = indexController.currentUser[0]['user']['is_rogaining'];
String r = _rog == true ? 'True': 'False';
var grp = indexController.currentUser[0]['user']['group'];
url = '${server_url}/api/insubperf?rog=True&subperf=' + subperfecture + '&cat=' + cat + "&grp=${grp}";
url = '${server_url}/api/insubperf?rog=${r}&subperf=' + subperfecture + '&cat=' + cat + "&grp=${grp}";
}
else{
url = '${server_url}/api/insubperf?subperf=' + subperfecture + '&cat=' + cat;
}
}
else{
if(indexController.currentUser.length > 0){
if(indexController.currentUser.isNotEmpty){
bool _rog = indexController.currentUser[0]['user']['is_rogaining'];
String r = _rog == true ? 'True': 'False';
var grp = indexController.currentUser[0]['user']['group'];
url = '${server_url}/api/insubperf?rog=True&subperf=' + subperfecture + "&grp=${grp}";
url = '${server_url}/api/insubperf?rog=${r}&subperf=' + subperfecture + "&grp=${grp}";
}
else{
url = '${server_url}/api/insubperf?subperf=' + subperfecture;
@ -117,19 +125,23 @@ class LocationService{
String url = "";
String server_url = ConstValues.currentServer();
if(cat.isNotEmpty){
if(indexController.currentUser.length > 0){
if(indexController.currentUser.isNotEmpty){
bool _rog = indexController.currentUser[0]['user']['is_rogaining'];
String r = _rog == true ? 'True': 'False';
var grp = indexController.currentUser[0]['user']['group'];
url = '${server_url}/api/inbound?rog=True&ln1=${lon1}&la1=${lat1}&ln2=${lon2}&la2=${lat2}&ln3=${lon3}&la3=${lat3}&ln4=${lon4}&la4=${lat4}' + '&cat=' + cat + "&grp=${grp}";
url = '${server_url}/api/inbound?rog=${r}&ln1=${lon1}&la1=${lat1}&ln2=${lon2}&la2=${lat2}&ln3=${lon3}&la3=${lat3}&ln4=${lon4}&la4=${lat4}' + '&cat=' + cat + "&grp=${grp}";
}
else{
url = '${server_url}/api/inbound?ln1=${lon1}&la1=${lat1}&ln2=${lon2}&la2=${lat2}&ln3=${lon3}&la3=${lat3}&ln4=${lon4}&la4=${lat4}' + '&cat=' + cat;
}
}
else{
if(indexController.currentUser.length > 0){
if(indexController.currentUser.isNotEmpty){
bool _rog = indexController.currentUser[0]['user']['is_rogaining'];
String r = _rog == true ? 'True': 'False';
var grp = indexController.currentUser[0]['user']['group'];
print("-------- requested user group ${grp} -------------");
url = '${server_url}/api/inbound?rog=True&ln1=${lon1}&la1=${lat1}&ln2=${lon2}&la2=${lat2}&ln3=${lon3}&la3=${lat3}&ln4=${lon4}&la4=${lat4}' + '&grp=${grp}';
url = '${server_url}/api/inbound?rog=${r}&ln1=${lon1}&la1=${lat1}&ln2=${lon2}&la2=${lat2}&ln3=${lon3}&la3=${lat3}&ln4=${lon4}&la4=${lat4}' + '&grp=${grp}';
}
else{
url = '${server_url}/api/inbound?ln1=${lon1}&la1=${lat1}&ln2=${lon2}&la2=${lat2}&ln3=${lon3}&la3=${lat3}&ln4=${lon4}&la4=${lat4}';
@ -168,18 +180,22 @@ class LocationService{
String server_url = ConstValues.currentServer();
print("loadCustomLocations url is ----- ${cat}");
if(cat.isNotEmpty){
if(indexController.currentUser.length > 0){
if(indexController.currentUser.isNotEmpty){
bool _rog = indexController.currentUser[0]['user']['is_rogaining'];
String r = _rog == true ? 'True': 'False';
var grp = indexController.currentUser[0]['user']['group'];
url = '${server_url}/api/custom_area/?rog=True&&cat=' + cat + "&grp=${grp}";
url = '${server_url}/api/custom_area/?rog=${r}&&cat=' + cat + "&grp=${grp}";
}
else{
url = '${server_url}/api/custom_area/?&cat=' + cat;
}
}
else{
if(indexController.currentUser.length > 0){
if(indexController.currentUser.isNotEmpty){
bool _rog = indexController.currentUser[0]['user']['is_rogaining'];
String r = _rog == true ? 'True': 'False';
var grp = indexController.currentUser[0]['user']['group'];
url = '${server_url}/api/customarea?rog=True&name=${name}' + "&grp=${grp}";
url = '${server_url}/api/customarea?rog=${r}&name=${name}' + "&grp=${grp}";
}
else{
url = '${server_url}/api/customarea?name=${name}';