added buypoint images
This commit is contained in:
@ -8,143 +8,183 @@ 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 {
|
||||
Destination? destination;
|
||||
CameraPage({Key? key, this.destination}) : super(key: key);
|
||||
DestinationController destinationController = Get.find<DestinationController>();
|
||||
Destination? dbDest;
|
||||
CameraPage({Key? key, this.destination, this.dbDest}) : super(key: key);
|
||||
DestinationController destinationController =
|
||||
Get.find<DestinationController>();
|
||||
IndexController indexController = Get.find<IndexController>();
|
||||
|
||||
var settingGoal = false.obs;
|
||||
|
||||
Timer? timer;
|
||||
|
||||
ImageProvider getFinishImage(){
|
||||
if(destinationController.photos.isNotEmpty){
|
||||
ImageProvider getFinishImage() {
|
||||
if (destinationController.photos.isNotEmpty) {
|
||||
return FileImage(destinationController.photos[0]);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
return const AssetImage('assets/images/empty_image.png');
|
||||
}
|
||||
}
|
||||
|
||||
Widget getAction(BuildContext context) {
|
||||
if(destinationController.is_at_goal.value && destinationController.is_in_rog.value){
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
ElevatedButton(
|
||||
onPressed: (){
|
||||
if(settingGoal.value ==false){
|
||||
destinationController.openCamera(context);
|
||||
}
|
||||
},
|
||||
child: Text("take_photo of the clock".tr)
|
||||
),
|
||||
Obx(() =>
|
||||
destinationController.photos.isNotEmpty ?
|
||||
settingGoal.value == false ?
|
||||
ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.red
|
||||
),
|
||||
onPressed: () async {
|
||||
|
||||
print("----- user isss ${indexController.currentUser[0]} -----");
|
||||
print("----cccheckin is --- ${dbDest?.checkedin} ----");
|
||||
|
||||
settingGoal.value = true;
|
||||
try{
|
||||
int userId = 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);
|
||||
|
||||
await ExternalService().makeGoal(userId, _token, _team, destinationController.photos[0].path, formattedDate, _event_code).then((value){
|
||||
print("---called ext api ${value['status']} ------");
|
||||
if(value['status'] == 'OK'){
|
||||
Get.back();
|
||||
destinationController.skip_gps = false;
|
||||
Get.snackbar("目標が保存されました", "目標が正常に追加されました");
|
||||
destinationController.resetRogaining();
|
||||
}
|
||||
else{
|
||||
print("---- status ${value['status']} ---- ");
|
||||
Get.snackbar("目標が追加されていません", "please_try_again");
|
||||
}
|
||||
});
|
||||
}
|
||||
on Exception catch(_){
|
||||
settingGoal.value = false;
|
||||
}
|
||||
finally{
|
||||
settingGoal.value = false;
|
||||
}
|
||||
},
|
||||
child:Text("finish_goal".tr)
|
||||
)
|
||||
:
|
||||
Container(
|
||||
child: const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
)
|
||||
:
|
||||
Container()
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
else{
|
||||
if (destinationController.is_at_goal.value &&
|
||||
destinationController.is_in_rog.value) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
Obx(() =>
|
||||
ElevatedButton(
|
||||
onPressed: (){
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
if (settingGoal.value == false) {
|
||||
destinationController.openCamera(context);
|
||||
},
|
||||
child: destinationController.photos.isNotEmpty ? const Text("再撮影") : const Text("撮影")
|
||||
)
|
||||
),
|
||||
Obx(() =>
|
||||
destinationController.photos.isNotEmpty ?
|
||||
ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.red
|
||||
),
|
||||
onPressed: (){
|
||||
print("##### current destination ${indexController.currentDestinationFeature[0].sub_loc_id} #######");
|
||||
destinationController.makeCheckin(indexController.currentDestinationFeature[0], true, destinationController.photos[0].path);
|
||||
Get.back();
|
||||
destinationController.rogaining_counted.value = true;
|
||||
destinationController.skip_gps = false;
|
||||
destinationController.is_photo_shoot.value = false;
|
||||
Get.snackbar("チェックインした", "正常にチェックインしました");
|
||||
|
||||
// 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();
|
||||
// destinationController.skip_gps = false;
|
||||
// Get.snackbar("Checked in", "Checked in successfuly");
|
||||
// }
|
||||
// else{
|
||||
// print("---- status ${value['status']} ---- ");
|
||||
// Get.snackbar("Checkin not added", "please_try_again");
|
||||
// }
|
||||
// });
|
||||
},
|
||||
child: const Text("チェックイン")
|
||||
):
|
||||
Container()
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
},
|
||||
child: Text("take_photo of the clock".tr)),
|
||||
Obx(() => destinationController.photos.isNotEmpty
|
||||
? settingGoal.value == false
|
||||
? ElevatedButton(
|
||||
style:
|
||||
ElevatedButton.styleFrom(backgroundColor: Colors.red),
|
||||
onPressed: () async {
|
||||
print(
|
||||
"----- user isss ${indexController.currentUser[0]} -----");
|
||||
|
||||
settingGoal.value = true;
|
||||
try {
|
||||
int userId =
|
||||
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);
|
||||
|
||||
await ExternalService()
|
||||
.makeGoal(
|
||||
userId,
|
||||
_token,
|
||||
_team,
|
||||
destinationController.photos[0].path,
|
||||
formattedDate,
|
||||
_event_code)
|
||||
.then((value) {
|
||||
print(
|
||||
"---called ext api ${value['status']} ------");
|
||||
if (value['status'] == 'OK') {
|
||||
Get.back();
|
||||
destinationController.skip_gps = false;
|
||||
Get.snackbar("目標が保存されました", "目標が正常に追加されました");
|
||||
destinationController.resetRogaining();
|
||||
} else {
|
||||
print("---- status ${value['status']} ---- ");
|
||||
Get.snackbar("目標が追加されていません", "please_try_again");
|
||||
}
|
||||
});
|
||||
} on Exception catch (_) {
|
||||
settingGoal.value = false;
|
||||
} finally {
|
||||
settingGoal.value = false;
|
||||
}
|
||||
},
|
||||
child: Text("finish_goal".tr))
|
||||
: Container(
|
||||
child: const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
)
|
||||
: Container())
|
||||
],
|
||||
);
|
||||
} else if (destinationController.is_in_rog.value &&
|
||||
dbDest?.checkedin != null &&
|
||||
dbDest?.checkedin == true) {
|
||||
//make buypoint image
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
Obx(() => ElevatedButton(
|
||||
onPressed: () {
|
||||
destinationController.openCamera(context);
|
||||
},
|
||||
child: destinationController.photos.isNotEmpty
|
||||
? const Text("再撮影")
|
||||
: const Text("撮影"))),
|
||||
Obx(() => destinationController.photos.isNotEmpty
|
||||
? ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(backgroundColor: Colors.red),
|
||||
onPressed: () async {
|
||||
print(
|
||||
"##### current destination ${indexController.currentDestinationFeature[0].sub_loc_id} #######");
|
||||
await destinationController.makeBuyPoint(
|
||||
destination!,
|
||||
destinationController.photos[0].path);
|
||||
Get.back();
|
||||
destinationController.rogaining_counted.value = true;
|
||||
destinationController.skip_gps = false;
|
||||
destinationController.is_photo_shoot.value = false;
|
||||
Get.snackbar("追加した", "領収書の写真を追加しました");
|
||||
},
|
||||
child: const Text("レシートの写真を撮る"))
|
||||
: Container())
|
||||
],
|
||||
);
|
||||
} else {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
Obx(() => ElevatedButton(
|
||||
onPressed: () {
|
||||
destinationController.openCamera(context);
|
||||
},
|
||||
child: destinationController.photos.isNotEmpty
|
||||
? const Text("再撮影")
|
||||
: const Text("撮影"))),
|
||||
Obx(() => destinationController.photos.isNotEmpty
|
||||
? ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(backgroundColor: Colors.red),
|
||||
onPressed: () async {
|
||||
print(
|
||||
"##### current destination ${indexController.currentDestinationFeature[0].sub_loc_id} #######");
|
||||
await destinationController.makeCheckin(
|
||||
indexController.currentDestinationFeature[0],
|
||||
true,
|
||||
destinationController.photos[0].path);
|
||||
Get.back();
|
||||
destinationController.rogaining_counted.value = true;
|
||||
destinationController.skip_gps = false;
|
||||
destinationController.is_photo_shoot.value = false;
|
||||
Get.snackbar("チェックインした", "正常にチェックインしました");
|
||||
|
||||
// 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();
|
||||
// destinationController.skip_gps = false;
|
||||
// Get.snackbar("Checked in", "Checked in successfuly");
|
||||
// }
|
||||
// else{
|
||||
// print("---- status ${value['status']} ---- ");
|
||||
// Get.snackbar("Checkin not added", "please_try_again");
|
||||
// }
|
||||
// });
|
||||
},
|
||||
child: const Text("チェックイン"))
|
||||
: Container())
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -154,94 +194,92 @@ class CameraPage extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if(destinationController.is_in_rog.value){
|
||||
if (destinationController.is_in_rog.value) {
|
||||
return Scaffold(
|
||||
appBar:
|
||||
destinationController.is_in_rog.value && destinationController.rogaining_counted.value == true ?
|
||||
AppBar(
|
||||
title: destination!.cp == -1 ?
|
||||
Text("finishing_rogaining".tr)
|
||||
:
|
||||
Text("cp_pls_take_photo".tr)
|
||||
,
|
||||
leading: IconButton(
|
||||
icon: Text("cancel".tr),
|
||||
onPressed: (){
|
||||
Navigator.of(context).pop();
|
||||
destinationController.skip_10s = true;
|
||||
timer = Timer.periodic(const Duration(seconds: 10), (Timer t){
|
||||
destinationController.skip_10s = false;
|
||||
});
|
||||
},
|
||||
),
|
||||
centerTitle: true,
|
||||
)
|
||||
:
|
||||
AppBar(
|
||||
title: const Text("チェックポイント"),
|
||||
),
|
||||
body: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Center(
|
||||
child: Obx(() =>
|
||||
Container(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
height: 370,
|
||||
decoration: BoxDecoration(
|
||||
image:
|
||||
DecorationImage(
|
||||
image: getFinishImage(),
|
||||
fit: BoxFit.cover
|
||||
)
|
||||
appBar: destinationController.is_in_rog.value &&
|
||||
destinationController.rogaining_counted.value == true
|
||||
? AppBar(
|
||||
title: destination!.cp == -1
|
||||
? Text("finishing_rogaining".tr)
|
||||
: Text("cp_pls_take_photo".tr),
|
||||
leading: IconButton(
|
||||
icon: Text("cancel".tr),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
destinationController.skip_10s = true;
|
||||
timer =
|
||||
Timer.periodic(const Duration(seconds: 10), (Timer t) {
|
||||
destinationController.skip_10s = false;
|
||||
});
|
||||
},
|
||||
),
|
||||
centerTitle: true,
|
||||
)
|
||||
: AppBar(
|
||||
title: const Text("チェックポイント"),
|
||||
),
|
||||
body: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Center(
|
||||
child: Obx(
|
||||
() => Container(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
height: 370,
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: getFinishImage(), fit: BoxFit.cover)),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
getAction(context),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
else {
|
||||
getAction(context),
|
||||
],
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return StartRogaining();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class StartRogaining extends StatelessWidget {
|
||||
StartRogaining({Key? key}) : super(key: key);
|
||||
|
||||
DestinationController destinationController = Get.find<DestinationController>();
|
||||
DestinationController destinationController =
|
||||
Get.find<DestinationController>();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text("Not started yet".tr,),
|
||||
),
|
||||
body: Container(
|
||||
child: Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text("You have not started rogaining yet.".tr, style: const TextStyle(fontSize: 24)),
|
||||
const SizedBox(height: 40.0,),
|
||||
ElevatedButton(
|
||||
onPressed: (){
|
||||
Get.back();
|
||||
destinationController.skip_gps = false;
|
||||
},
|
||||
child: const Text("Back"),
|
||||
),
|
||||
],
|
||||
title: Text(
|
||||
"Not started yet".tr,
|
||||
),
|
||||
),
|
||||
body: Container(
|
||||
child: Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text("You have not started rogaining yet.".tr,
|
||||
style: const TextStyle(fontSize: 24)),
|
||||
const SizedBox(
|
||||
height: 40.0,
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
destinationController.skip_gps = false;
|
||||
},
|
||||
child: const Text("Back"),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -249,32 +287,38 @@ class StartRogaining extends StatelessWidget {
|
||||
class NotAtGoal extends StatelessWidget {
|
||||
NotAtGoal({Key? key}) : super(key: key);
|
||||
|
||||
DestinationController destinationController = Get.find<DestinationController>();
|
||||
DestinationController destinationController =
|
||||
Get.find<DestinationController>();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text("Not reached the goal yet".tr,),
|
||||
),
|
||||
body: Container(
|
||||
child: Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text("You have not reached the goal yet.".tr, style: const TextStyle(fontSize: 24)),
|
||||
const SizedBox(height: 40.0,),
|
||||
ElevatedButton(
|
||||
onPressed: (){
|
||||
Get.back();
|
||||
destinationController.skip_gps = false;
|
||||
},
|
||||
child: const Text("Back"),
|
||||
),
|
||||
],
|
||||
title: Text(
|
||||
"Not reached the goal yet".tr,
|
||||
),
|
||||
),
|
||||
body: Container(
|
||||
child: Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text("You have not reached the goal yet.".tr,
|
||||
style: const TextStyle(fontSize: 24)),
|
||||
const SizedBox(
|
||||
height: 40.0,
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
destinationController.skip_gps = false;
|
||||
},
|
||||
child: const Text("Back"),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user