updated and fix checking, buy point

This commit is contained in:
Mohamed Nouffer
2023-09-14 22:53:51 +05:30
parent aa7b13b76a
commit b54c29eb4b
10 changed files with 247 additions and 95 deletions

View File

@ -8,11 +8,23 @@ import 'package:rogapp/pages/destination/destination_controller.dart';
import 'package:rogapp/pages/index/index_controller.dart';
import 'package:rogapp/services/external_service.dart';
ImageProvider getFinishImage() {
DestinationController destinationController =
Get.find<DestinationController>();
if (destinationController.photos.isNotEmpty) {
return FileImage(destinationController.photos[0]);
} else {
return const AssetImage('assets/images/empty_image.png');
}
}
class CameraPage extends StatelessWidget {
bool? manulaCheckin = false;
bool? buyPointPhoto = false;
Destination? destination;
Destination? dbDest;
CameraPage({Key? key, this.destination, this.dbDest}) : super(key: key);
CameraPage({Key? key, this.destination, this.dbDest, this.manulaCheckin, this.buyPointPhoto})
: super(key: key);
DestinationController destinationController =
Get.find<DestinationController>();
IndexController indexController = Get.find<IndexController>();
@ -21,17 +33,40 @@ class CameraPage extends StatelessWidget {
Timer? timer;
ImageProvider getFinishImage() {
if (destinationController.photos.isNotEmpty) {
return FileImage(destinationController.photos[0]);
} else {
return const AssetImage('assets/images/empty_image.png');
}
}
Widget getAction(BuildContext context) {
print("----cccheckin is --- ${dbDest?.checkedin} ----");
//print("----cccheckin is --- ${dbDest?.checkedin} ----");
if (manulaCheckin == true) {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Obx(() => ElevatedButton(
onPressed: () {
destinationController.openCamera(context, destination);
},
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(
destination!,
true,
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())
],
);
}
if (destinationController.is_at_goal.value &&
destinationController.is_in_rog.value) {
@ -41,7 +76,7 @@ class CameraPage extends StatelessWidget {
ElevatedButton(
onPressed: () {
if (settingGoal.value == false) {
destinationController.openCamera(context);
destinationController.openCamera(context, destination);
}
},
child: Text("take_photo of the clock".tr)),
@ -111,13 +146,13 @@ class CameraPage extends StatelessWidget {
} else if (destinationController.is_in_rog.value &&
dbDest?.checkedin != null &&
dbDest?.checkedin == true) {
//make buypoint image
//make buypoint image
return Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Obx(() => ElevatedButton(
onPressed: () {
destinationController.openCamera(context);
destinationController.openCamera(context, destination);
},
child: destinationController.photos.isNotEmpty
? const Text("再撮影")
@ -129,8 +164,7 @@ class CameraPage extends StatelessWidget {
print(
"##### current destination ${indexController.currentDestinationFeature[0].sub_loc_id} #######");
await destinationController.makeBuyPoint(
destination!,
destinationController.photos[0].path);
destination!, destinationController.photos[0].path);
Get.back();
destinationController.rogaining_counted.value = true;
destinationController.skip_gps = false;
@ -147,7 +181,7 @@ class CameraPage extends StatelessWidget {
children: [
Obx(() => ElevatedButton(
onPressed: () {
destinationController.openCamera(context);
destinationController.openCamera(context, destination);
},
child: destinationController.photos.isNotEmpty
? const Text("再撮影")
@ -167,19 +201,6 @@ class CameraPage extends StatelessWidget {
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())
@ -194,7 +215,12 @@ class CameraPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
if (destinationController.is_in_rog.value) {
if(buyPointPhoto == true){
print("--- buy point camera ${destination.toString()}");
return BuyPointCamera(destination: destination!);
}
else if (destinationController.is_in_rog.value) {
print("--- in normal camera ${destination.toString()}");
return Scaffold(
appBar: destinationController.is_in_rog.value &&
destinationController.rogaining_counted.value == true
@ -284,8 +310,50 @@ class StartRogaining extends StatelessWidget {
}
}
class NotAtGoal extends StatelessWidget {
NotAtGoal({Key? key}) : super(key: key);
// class NotAtGoal extends StatelessWidget {
// NotAtGoal({Key? key}) : super(key: key);
// 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"),
// ),
// ],
// ),
// ),
// ),
// );
// }
// }
class BuyPointCamera extends StatelessWidget {
BuyPointCamera({Key? key, required this.destination}) : super(key: key);
Destination destination;
DestinationController destinationController =
Get.find<DestinationController>();
@ -295,30 +363,58 @@ class NotAtGoal extends StatelessWidget {
return Scaffold(
appBar: AppBar(
title: Text(
"Not reached the goal yet".tr,
"CPです。撮影してください。\n ${destination.sub_loc_id} : ${destination.location_id}",
),
),
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,
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)),
),
),
),
ElevatedButton(
onPressed: () {
Get.back();
destinationController.skip_gps = false;
},
child: const Text("Back"),
),
],
),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: const Text("チェックインしました。"),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Obx(() => ElevatedButton(
onPressed: () {
destinationController.openCamera(context, destination);
},
child: destinationController.photos.isNotEmpty
? const Text("再撮影")
: const Text("撮影"))),
Obx(() => destinationController.photos.isNotEmpty
? ElevatedButton(
style: ElevatedButton.styleFrom(backgroundColor: Colors.red),
onPressed: () async {
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())
],
),
],
),
);
}
}