update to external apis

This commit is contained in:
Mohamed Nouffer
2022-10-19 08:53:17 +05:30
parent 8e30ee6ba7
commit 2d9f7a9633
13 changed files with 209 additions and 50 deletions

View File

@ -1,10 +1,14 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:intl/intl.dart';
import 'package:rogapp/pages/destination/destination_controller.dart';
import 'package:rogapp/pages/index/index_controller.dart';
import 'package:rogapp/services/external_service.dart';
class CameraPage extends StatelessWidget {
CameraPage({Key? key}) : super(key: key);
DestinationController destinationController = Get.find<DestinationController>();
IndexController indexController = Get.find<IndexController>();
ImageProvider getFinishImage(){
if(destinationController.photos.isNotEmpty){
@ -62,7 +66,27 @@ class CameraPage extends StatelessWidget {
primary: Colors.red
),
onPressed: (){
int user_id = indexController.currentUser[0]["user"]["id"];
//print("--- Pressed -----");
String _team = indexController.currentUser[0]["user"]['team_name'];
//print("--- _team : ${_team}-----");
String _event_code = indexController.currentUser[0]["user"]["event_code"];
//print("--- _event_code : ${_event_code}-----");
String _token = indexController.currentUser[0]["token"];
//print("--- _token : ${_token}-----");
DateTime now = DateTime.now();
String formattedDate = DateFormat('yyyy-MM-dd HH:mm:ss').format(now);
ExternalService().makeGoal(user_id, _token, _team, destinationController.photos[0].path, formattedDate, _event_code).then((value){
print("---called ext api ${value['status']} ------");
if(value['status'] == 'OK'){
Get.back();
Get.snackbar("goal_saved", "goal_added_successfuly");
}
else{
Get.snackbar("goal_not_added", "please_try_again");
}
});
},
child: Text("finish_goal".tr)
):

View File

@ -16,6 +16,7 @@ import 'package:rogapp/pages/index/index_controller.dart';
import 'package:rogapp/routes/app_pages.dart';
import 'package:rogapp/services/action_service.dart';
import 'package:rogapp/services/destination_service.dart';
import 'package:rogapp/services/external_service.dart';
import 'package:rogapp/services/maxtrix_service.dart';
import 'package:rogapp/services/reacking_service.dart';
import 'package:rogapp/utils/database_helper.dart';
@ -72,7 +73,6 @@ class DestinationController extends GetxController {
}
else{
//finish rogiain
//is_in_rog.value = true;
if (rogaining_counted.value && distance <=250){
Get.toNamed(AppPages.CAMERA_PAGE);
}
@ -130,6 +130,8 @@ class DestinationController extends GetxController {
for(final d in destinations){
print("-----loc_id- ${d.location_id}----");
if(!checking_in)
{
checking_in = true;
@ -142,6 +144,10 @@ class DestinationController extends GetxController {
double rad = value!.checkin_radious ?? double.infinity;
bool auto_checkin = value.auto_checkin == 0 ? false : true;
print("-----rogaining_counted---${rogaining_counted.value}-----");
print("-----is_in_rog---${is_in_rog}-----");
print("-----dist is ---${dist}-----");
if(d.cp != -1 && is_in_rog == true){
rogaining_counted.value == true;
}
@ -215,24 +221,25 @@ class DestinationController extends GetxController {
}
void makeCheckin(Destination destination, bool action) async {
print("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ressssss ${action}@@@@@@@@@@@");
// print("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ressssss ${action}@@@@@@@@@@@");
DatabaseHelper db = DatabaseHelper.instance;
int res = await db.updateAction(destination, action);
List<Destination> ddd = await db.getDestinationByLatLon(destination.lat!, destination.lon!);
print("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ddddd ${ddd[0].checkedin} @@@@@@@@@@@");
// print("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ddddd ${ddd[0].checkedin} @@@@@@@@@@@");
print("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ressssss ${res}@@@@@@@@@@@");
// print("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ressssss ${res}@@@@@@@@@@@");
PopulateDestinations();
print("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ after populating ${res} @@@@@@@@@@@");
print("---- database update resulr ------ res : ${res}-------");
// print("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ after populating ${res} @@@@@@@@@@@");
// print("---- database update resulr ------ res : ${res}-------");
/// post to NATNAT
if(indexController.currentUser.length > 0){
String cp_num = destination.cp.toString();
String team_name = indexController.currentUser[0]['user']['group'];
ActionService.postCheckin(cp_num, team_name).then((value){
print('------- NATNAT RES ${value} ------------');
int cp_num = int.parse(destination.cp!.toString());
String _team = indexController.currentUser[0]["user"]["team_name"];
String _event_code = indexController.currentUser[0]["user"]["event_code"];
ExternalService().makeCheckpoint(_team, cp_num, _event_code).then((value){
print("------Ext service check point ${value} ------");
});
}
}

View File

@ -12,6 +12,7 @@ import 'package:rogapp/pages/destination_map/destination_map_page.dart';
import 'package:rogapp/pages/drawer/drawer_page.dart';
import 'package:rogapp/pages/index/index_controller.dart';
import 'package:rogapp/routes/app_pages.dart';
import 'package:rogapp/services/external_service.dart';
import 'package:rogapp/widgets/destination_widget.dart';
import 'package:timeline_tile/timeline_tile.dart';
@ -159,13 +160,14 @@ class DestnationPage extends StatelessWidget {
automaticallyImplyLeading: true,
title: Text("app_title".tr),
actions: [
// TextButton(
// onPressed: (){
// //destinationController.openCamera(context);
// Get.toNamed(AppPages.CAMERA_PAGE);
// },
// child: Icon(Icons.ac_unit),
// ),
TextButton(
onPressed: (){
//ExternalService().StartRogaining('team_name', "2222");
//destinationController.openCamera(context);
Get.toNamed(AppPages.CAMERA_PAGE);
},
child: Icon(Icons.ac_unit),
),
Obx(() =>
ToggleButtons(
disabledColor: Colors.grey.shade200,