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

@ -5,6 +5,27 @@ import 'package:rogapp/utils/const.dart';
class ActionService{
static Future<Map<String, dynamic>> postCheckin(String cp_num, String team_name) async{
Map<String, dynamic> checkin_res = {};
String url = 'https://natnats.mobilous.com/post_from_rogapp_ogaki';
//print('---- toekn is ${token} -----');
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_name,
'cp_number': cp_num.toString()
}),
);
if (response.statusCode == 200) {
checkin_res = json.decode(utf8.decode(response.bodyBytes));
}
return checkin_res;
}
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 = {};

View File

@ -6,6 +6,30 @@ import '../utils/const.dart';
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('---- toekn is ${token} -----');
final http.Response response = await http.put(
Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
'Authorization': 'Token ${token}'
},
body: jsonEncode(<String, String>{
'old_password': oldpassword,
'new_password': newpassword
}),
);
if (response.statusCode == 200) {
changePassword = json.decode(utf8.decode(response.bodyBytes));
}
return changePassword;
}
static Future<Map<String, dynamic>> login(String email, String password) async {
Map<String, dynamic> cats = {};
String server_url = ConstValues.currentServer();
@ -51,7 +75,7 @@ class AuthService{
return cats;
}
static Future<List<dynamic>?> UserDetails(int userid) async {
List<dynamic> cats = [];
String server_url = ConstValues.currentServer();

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}';