image chekin
This commit is contained in:
@ -9,6 +9,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:geojson/geojson.dart';
|
||||
import 'package:geolocator/geolocator.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:latlong2/latlong.dart';
|
||||
import 'package:rogapp/model/Rogaining.dart';
|
||||
import 'package:rogapp/model/destination.dart';
|
||||
@ -26,6 +27,7 @@ import 'dart:async';
|
||||
|
||||
import 'package:rogapp/widgets/bottom_sheet_widget.dart';
|
||||
import 'package:sqflite/sqlite_api.dart';
|
||||
import 'package:modal_bottom_sheet/modal_bottom_sheet.dart';
|
||||
|
||||
class DestinationController extends GetxController {
|
||||
|
||||
@ -42,6 +44,7 @@ class DestinationController extends GetxController {
|
||||
var is_in_rog = false.obs;
|
||||
var is_at_start = false.obs;
|
||||
var is_at_goal = false.obs;
|
||||
var is_photo_shoot = false.obs;
|
||||
//List<Rogaining> rogainings = <Rogaining>[].obs;
|
||||
|
||||
bool checking_in = false;
|
||||
@ -139,6 +142,17 @@ class DestinationController extends GetxController {
|
||||
return;
|
||||
}
|
||||
|
||||
if(is_photo_shoot.value == true){
|
||||
showModalBottomSheet(context: Get.context!, isScrollControlled: true,
|
||||
builder:((context) => CameraPage())
|
||||
).whenComplete((){
|
||||
skip_gps = false;
|
||||
chekcs = 0;
|
||||
is_in_checkin.value = false;
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
DatabaseHelper db = DatabaseHelper.instance;
|
||||
List<Destination> ds = await db.getDestinationByLatLon(d.lat!, d.lon!);
|
||||
if(ds.isEmpty){
|
||||
@ -159,7 +173,7 @@ class DestinationController extends GetxController {
|
||||
is_in_checkin.value = false;
|
||||
});
|
||||
}
|
||||
else if(is_in_rog.value == false)
|
||||
else if(is_in_rog.value == true)
|
||||
{
|
||||
print("----- in location popup checkin cp - ${d.cp}----");
|
||||
chekcs = 2;
|
||||
@ -176,10 +190,10 @@ class DestinationController extends GetxController {
|
||||
|
||||
print("---- location checkin radious ${d.checkin_radious} ----");
|
||||
print("---- already checked in ${location_already_checked_in} ----");
|
||||
if(checkin_radious >= distance && location_already_checked_in == false){
|
||||
if(checkin_radious >= distance && location_already_checked_in == false && is_in_rog.value == true){
|
||||
if(auto_checkin){
|
||||
if(!checking_in){
|
||||
makeCheckin(d, true);
|
||||
makeCheckin(d, true,"");
|
||||
if(d.cp != -1){
|
||||
rogaining_counted.value =true;
|
||||
}
|
||||
@ -190,26 +204,36 @@ class DestinationController extends GetxController {
|
||||
print("--- hidden loc ${d.hidden_location} ----");
|
||||
// ask for checkin
|
||||
if(d.hidden_location != null && d.hidden_location == 0 && is_in_rog.value == true && d.cp != -1){
|
||||
chekcs = 3;
|
||||
is_in_checkin.value = true;
|
||||
showModalBottomSheet(context: Get.context!, isScrollControlled: true,
|
||||
builder:((context) => CameraPage())
|
||||
).whenComplete((){
|
||||
skip_gps = false;
|
||||
chekcs = 0;
|
||||
is_in_checkin.value = false;
|
||||
});
|
||||
// chekcs = 3;
|
||||
// is_in_checkin.value = true;
|
||||
// showModalBottomSheet(context: Get.context!, isScrollControlled: true,
|
||||
// builder:((context) => CameraPage())
|
||||
// ).whenComplete((){
|
||||
// skip_gps = false;
|
||||
// chekcs = 0;
|
||||
// is_in_checkin.value = false;
|
||||
// });
|
||||
}
|
||||
else if(is_in_rog.value == true && d.cp != -1){
|
||||
chekcs = 4;
|
||||
is_in_checkin.value = true;
|
||||
showModalBottomSheet(context: Get.context!, isScrollControlled: true,
|
||||
builder:((context) => BottomSheetNew())
|
||||
).whenComplete((){
|
||||
skip_gps = false;
|
||||
chekcs = 0;
|
||||
is_in_checkin.value = false;
|
||||
});
|
||||
showMaterialModalBottomSheet(
|
||||
expand: true,
|
||||
context: Get.context!,
|
||||
backgroundColor: Colors.transparent,
|
||||
builder: (context) => BottomSheetNew()
|
||||
).whenComplete(() {
|
||||
skip_gps = false;
|
||||
chekcs = 0;
|
||||
is_in_checkin.value = false;
|
||||
});
|
||||
// showModalBottomSheet(context: Get.context!, isScrollControlled: true,
|
||||
// builder:((context) => BottomSheetNew())
|
||||
// ).whenComplete((){
|
||||
// skip_gps = false;
|
||||
// chekcs = 0;
|
||||
// is_in_checkin.value = false;
|
||||
// });
|
||||
}
|
||||
|
||||
}
|
||||
@ -349,6 +373,7 @@ class DestinationController extends GetxController {
|
||||
is_in_rog.value = false;
|
||||
is_at_start.value = false;
|
||||
is_at_goal.value = false;
|
||||
destinations.clear();
|
||||
|
||||
_start = 0;
|
||||
chekcs = 0;
|
||||
@ -448,7 +473,7 @@ class DestinationController extends GetxController {
|
||||
if(d.isEmpty){
|
||||
Destination df = festuretoDestination(indexController.currentFeature[0]);
|
||||
print("--- made checkin ${df.location_id} ----");
|
||||
makeCheckin(df, true);
|
||||
makeCheckin(df, true, "");
|
||||
}
|
||||
|
||||
Rogaining rog = Rogaining(
|
||||
@ -466,8 +491,8 @@ class DestinationController extends GetxController {
|
||||
is_in_rog.value = true;
|
||||
}
|
||||
|
||||
void makeCheckin(Destination destination, bool action, {String imageurl = ""}) async {
|
||||
// print("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ressssss ${action}@@@@@@@@@@@");
|
||||
void makeCheckin(Destination destination, bool action, String imageurl) async {
|
||||
//print("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ressssss ${action}@@@@@@@@@@@");
|
||||
DatabaseHelper db = DatabaseHelper.instance;
|
||||
List<Destination> ddd = await db.getDestinationByLatLon(destination.lat!, destination.lon!);
|
||||
|
||||
@ -475,18 +500,30 @@ class DestinationController extends GetxController {
|
||||
destination.checkedin = true;
|
||||
await db.insertDestination(destination);
|
||||
}
|
||||
//int res = await db.updateAction(destination, action);
|
||||
|
||||
PopulateDestinations();
|
||||
|
||||
/// post to NATNAT
|
||||
if(indexController.currentUser.length > 0){
|
||||
int cp_num = int.parse(destination.cp!.toString());
|
||||
String _team = indexController.currentUser[0]["user"]["team_name"];
|
||||
double cp_num = destination.cp!;
|
||||
|
||||
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"];
|
||||
ExternalService().makeCheckpoint(_team, cp_num, _event_code, imageurl).then((value){
|
||||
//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);
|
||||
|
||||
print("------ checkin event ${_event_code} ------");
|
||||
ExternalService().makeCheckpoint(user_id, _token, formattedDate, _team,cp_num.round(), _event_code, imageurl).then((value){
|
||||
print("------Ext service check point ${value} ------");
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user