No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

absensi_screen.dart 29KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883
  1. import 'dart:async';
  2. import 'dart:convert';
  3. import 'package:flutter/material.dart';
  4. import 'package:flutter_map/plugin_api.dart';
  5. import 'package:geolocator/geolocator.dart';
  6. import 'package:google_fonts/google_fonts.dart';
  7. import 'package:hris_selfservice_mobile/Screens/Menu/Absensi/RequestHttp/checkIn_post.dart';
  8. import 'package:hris_selfservice_mobile/Screens/Menu/Absensi/RequestHttp/checkStatus_post.dart';
  9. import 'package:hris_selfservice_mobile/Screens/Menu/Absensi/absensi_history_screen.dart';
  10. import 'package:latlong2/latlong.dart' as latlong;
  11. import 'dart:developer' as logDev;
  12. import 'package:progress_dialog_null_safe/progress_dialog_null_safe.dart';
  13. import 'RequestHttp/checkOut_post.dart';
  14. class AbsensiScreen extends StatefulWidget {
  15. const AbsensiScreen({Key? key}) : super(key: key);
  16. @override
  17. State<AbsensiScreen> createState() => _AbsensiScreenState();
  18. }
  19. class _AbsensiScreenState extends State<AbsensiScreen> {
  20. //Visibility Button Check In & Check Out
  21. bool visibleCheckIn = false;
  22. bool visibleCheckOut = false;
  23. latlong.LatLng point = latlong.LatLng(-6.183580253674716, 106.93103973792664);
  24. late Position position;
  25. MapController _mapController = MapController();
  26. @override
  27. void initState() {
  28. WidgetsBinding.instance.addPostFrameCallback((_) {
  29. determinePosition();
  30. });
  31. super.initState();
  32. }
  33. determinePosition() async {
  34. ProgressDialog loading = ProgressDialog(context);
  35. loading = ProgressDialog(context,
  36. type: ProgressDialogType.normal, isDismissible: false, showLogs: true);
  37. loading.style(
  38. message: 'Please Wait .....',
  39. borderRadius: 3,
  40. backgroundColor: Colors.white,
  41. progressWidget: CircularProgressIndicator(),
  42. elevation: 10.0,
  43. padding: EdgeInsets.all(10),
  44. insetAnimCurve: Curves.easeInOut,
  45. progress: 0.0,
  46. maxProgress: 100.0,
  47. progressTextStyle: TextStyle(
  48. color: Colors.black, fontSize: 10.0, fontWeight: FontWeight.w400),
  49. messageTextStyle: TextStyle(
  50. color: Colors.black, fontSize: 15.0, fontWeight: FontWeight.w600));
  51. bool serviceEnabled;
  52. LocationPermission permission;
  53. loading.show();
  54. serviceEnabled = await Geolocator.isLocationServiceEnabled();
  55. if (!serviceEnabled) {
  56. loading.hide();
  57. return Future.error('Location services are disabled.');
  58. }
  59. permission = await Geolocator.checkPermission();
  60. if (permission == LocationPermission.deniedForever) {
  61. loading.hide();
  62. //return Future.error('Location permissions are permanently denied, we cannot request permissions.');
  63. return alertDialogPermissionDeniedForever(context);
  64. } else if (permission == LocationPermission.denied) {
  65. permission = await Geolocator.requestPermission();
  66. if (permission != LocationPermission.whileInUse && permission != LocationPermission.always) {
  67. loading.hide();
  68. //return Future.error('Location permissions are denied (actual value: $permission).');
  69. return alertDialogPermissionDenied(context);
  70. }
  71. }
  72. position = await Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
  73. logDev.log(position.toString(), name: "Position GEOLOCATOR");
  74. if (position.isMocked) {
  75. loading.hide();
  76. setState(() {
  77. alertDialogFakeGPSDetected(context);
  78. });
  79. } else {
  80. point = latlong.LatLng(position.latitude, position.longitude);
  81. logDev.log(point.toString(), name: "POINT GEOLOCATOR");
  82. _mapController.move(point, 18);
  83. //Check Status
  84. CheckStatus_Post.connectToAPI().then((valueResult) async {
  85. Map<String, dynamic> object = json.decode(valueResult);
  86. if (object.containsKey("result").toString() == "true") {
  87. String result = object['result'].toString();
  88. logDev.log(result, name: "Status Absensi Result");
  89. if (result.contains("belum")) {
  90. setState(() {
  91. visibleCheckIn = !visibleCheckIn;
  92. visibleCheckOut = visibleCheckOut;
  93. });
  94. loading.hide();
  95. } else if (result.contains("sudah")) {
  96. setState(() {
  97. visibleCheckIn = visibleCheckIn;
  98. visibleCheckOut = !visibleCheckOut;
  99. });
  100. loading.hide();
  101. }
  102. } else {
  103. setState(() {
  104. alertDialogFailedResponse(context);
  105. });
  106. loading.hide();
  107. }
  108. });
  109. //loading.hide();
  110. }
  111. }
  112. updatePosition() async {
  113. ProgressDialog loading = ProgressDialog(context);
  114. loading = ProgressDialog(context,
  115. type: ProgressDialogType.normal, isDismissible: false, showLogs: true);
  116. loading.style(
  117. message: 'Please Wait .....',
  118. borderRadius: 3,
  119. backgroundColor: Colors.white,
  120. progressWidget: CircularProgressIndicator(),
  121. elevation: 10.0,
  122. padding: EdgeInsets.all(10),
  123. insetAnimCurve: Curves.easeInOut,
  124. progress: 0.0,
  125. maxProgress: 100.0,
  126. progressTextStyle: TextStyle(
  127. color: Colors.black, fontSize: 10.0, fontWeight: FontWeight.w400),
  128. messageTextStyle: TextStyle(
  129. color: Colors.black, fontSize: 15.0, fontWeight: FontWeight.w600));
  130. bool serviceEnabled;
  131. LocationPermission permission;
  132. loading.show();
  133. serviceEnabled = await Geolocator.isLocationServiceEnabled();
  134. if (!serviceEnabled) {
  135. loading.hide();
  136. return Future.error('Location services are disabled.');
  137. }
  138. permission = await Geolocator.checkPermission();
  139. if (permission == LocationPermission.deniedForever) {
  140. loading.hide();
  141. //return Future.error('Location permissions are permanently denied, we cannot request permissions.');
  142. return alertDialogPermissionDeniedForever(context);
  143. } else if (permission == LocationPermission.denied) {
  144. permission = await Geolocator.requestPermission();
  145. if (permission != LocationPermission.whileInUse && permission != LocationPermission.always) {
  146. loading.hide();
  147. //return Future.error('Location permissions are denied (actual value: $permission).');
  148. return alertDialogPermissionDenied(context);
  149. }
  150. }
  151. position = await Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
  152. logDev.log(position.toString(), name: "Position GEOLOCATOR");
  153. if (position.isMocked) {
  154. loading.hide();
  155. setState(() {
  156. alertDialogFakeGPSDetected(context);
  157. });
  158. } else {
  159. setState((){
  160. point = latlong.LatLng(position.latitude, position.longitude);
  161. logDev.log(point.toString(), name: "POINT GEOLOCATOR");
  162. _mapController.move(point, 18);
  163. });
  164. loading.hide();
  165. }
  166. }
  167. goCheckIn() {
  168. ProgressDialog loading = ProgressDialog(context);
  169. loading = ProgressDialog(context,
  170. type: ProgressDialogType.normal, isDismissible: false, showLogs: true);
  171. loading.style(
  172. message: 'Please Wait .....',
  173. borderRadius: 3,
  174. backgroundColor: Colors.white,
  175. progressWidget: CircularProgressIndicator(),
  176. elevation: 10.0,
  177. padding: EdgeInsets.all(10),
  178. insetAnimCurve: Curves.easeInOut,
  179. progress: 0.0,
  180. maxProgress: 100.0,
  181. progressTextStyle: TextStyle(
  182. color: Colors.black, fontSize: 10.0, fontWeight: FontWeight.w400),
  183. messageTextStyle: TextStyle(
  184. color: Colors.black, fontSize: 15.0, fontWeight: FontWeight.w600));
  185. loading.show();
  186. CheckIn_Post.connectToAPI().then((valueResult) async {
  187. Map<String, dynamic> object = json.decode(valueResult);
  188. if (object.containsKey("result").toString() == "true") {
  189. String result = object['result'].toString();
  190. logDev.log(result, name: "Check In Result");
  191. if (result.contains("failed")) {
  192. loading.hide();
  193. setState(() {
  194. alertDialogFailedRetrievedData(context);
  195. });
  196. } else if (result.contains("Anda sudah check in")) {
  197. loading.hide();
  198. setState(() {
  199. alertDialogFailedCheckIn(context);
  200. });
  201. } else {
  202. loading.hide();
  203. setState(() {
  204. alertDialogSuccessCheckIn(context);
  205. });
  206. }
  207. } else {
  208. setState(() {
  209. alertDialogFailedResponse(context);
  210. });
  211. loading.hide();
  212. }
  213. });
  214. }
  215. goCheckOut() {
  216. ProgressDialog loading = ProgressDialog(context);
  217. loading = ProgressDialog(context,
  218. type: ProgressDialogType.normal, isDismissible: false, showLogs: true);
  219. loading.style(
  220. message: 'Please Wait .....',
  221. borderRadius: 3,
  222. backgroundColor: Colors.white,
  223. progressWidget: CircularProgressIndicator(),
  224. elevation: 10.0,
  225. padding: EdgeInsets.all(10),
  226. insetAnimCurve: Curves.easeInOut,
  227. progress: 0.0,
  228. maxProgress: 100.0,
  229. progressTextStyle: TextStyle(
  230. color: Colors.black, fontSize: 10.0, fontWeight: FontWeight.w400),
  231. messageTextStyle: TextStyle(
  232. color: Colors.black, fontSize: 15.0, fontWeight: FontWeight.w600));
  233. loading.show();
  234. CheckOut_Post.connectToAPI().then((valueResult) async {
  235. Map<String, dynamic> object = json.decode(valueResult);
  236. if (object.containsKey("result").toString() == "true") {
  237. String result = object['result'].toString();
  238. logDev.log(result, name: "Check Out Result");
  239. if (result.contains("failed")) {
  240. loading.hide();
  241. setState(() {
  242. alertDialogFailedRetrievedData(context);
  243. });
  244. } else if (result.contains("Anda belum check in")) {
  245. loading.hide();
  246. setState(() {
  247. alertDialogFailedCheckOut(context);
  248. });
  249. } else {
  250. loading.hide();
  251. setState(() {
  252. alertDialogSuccessCheckOut(context);
  253. });
  254. }
  255. } else {
  256. setState(() {
  257. alertDialogFailedResponse(context);
  258. });
  259. loading.hide();
  260. }
  261. });
  262. }
  263. @override
  264. Widget build(BuildContext context) {
  265. var size = MediaQuery.of(context).size;
  266. return Scaffold(
  267. body: SingleChildScrollView(
  268. child: Column(
  269. children: [
  270. Container(
  271. height: size.height * 0.6,
  272. child: Stack(
  273. children: [
  274. FlutterMap(
  275. mapController: _mapController,
  276. options: new MapOptions(
  277. onTap: (p, point) async {}, center: point, zoom: 15),
  278. children: [
  279. TileLayer(
  280. minZoom: 1,
  281. maxZoom: 22,
  282. maxNativeZoom: 18,
  283. minNativeZoom: 1,
  284. backgroundColor: Colors.black54,
  285. urlTemplate:
  286. 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
  287. subdomains: ['a', 'b', 'c'],
  288. ),
  289. MarkerLayer(markers: [
  290. Marker(
  291. width: 135,
  292. height: 135,
  293. point: point,
  294. builder: (ctx) => Container(
  295. child: Icon(
  296. Icons.location_on,
  297. color: Colors.red,
  298. ),
  299. ))
  300. ])
  301. ],
  302. ),
  303. Align(
  304. alignment: AlignmentDirectional.bottomEnd,
  305. child: Container(
  306. margin: EdgeInsets.fromLTRB(10, 15, 0, 15),
  307. child: RawMaterialButton(
  308. onPressed: () {
  309. setState(() {
  310. updatePosition();
  311. });
  312. },
  313. elevation: 5.0,
  314. fillColor: Colors.white,
  315. child: Image.asset('assets/images/location1.png',
  316. height: 40, width: 40),
  317. padding: EdgeInsets.all(5.0),
  318. shape: CircleBorder(),
  319. ),
  320. ),
  321. )
  322. ],
  323. ),
  324. ),
  325. Container(
  326. width: double.infinity,
  327. margin: EdgeInsets.fromLTRB(10, 15, 10, 10),
  328. decoration:
  329. BoxDecoration(border: Border.all(color: Colors.black)),
  330. child: Column(
  331. children: <Widget>[
  332. Container(
  333. child: Text(
  334. "Attendance Today",
  335. style: GoogleFonts.patrickHand(
  336. fontSize: 21, color: Colors.white),
  337. ),
  338. width: double.infinity,
  339. alignment: Alignment.center,
  340. decoration: BoxDecoration(
  341. gradient: LinearGradient(
  342. begin: Alignment.topRight,
  343. end: Alignment.bottomRight,
  344. colors: [
  345. /*Color(0xFFD21404),
  346. Color(0xFFFD7267),*/
  347. Color(0xFF4858A7),
  348. Color(0xFF6474C6),
  349. ]),
  350. border: Border.all(color: Colors.black)),
  351. ),
  352. Container(
  353. width: double.infinity,
  354. padding: EdgeInsets.all(15),
  355. decoration:
  356. BoxDecoration(border: Border.all(color: Colors.black)),
  357. child: Column(
  358. children: [
  359. Row(
  360. mainAxisAlignment: MainAxisAlignment.spaceAround,
  361. children: [
  362. Expanded(
  363. flex: 5,
  364. child: Column(
  365. children: [
  366. Text('Check In',
  367. style: GoogleFonts.fredokaOne(
  368. fontSize: 19)),
  369. Text('07.15',
  370. style: GoogleFonts.barlowSemiCondensed(
  371. fontSize: 19)),
  372. ],
  373. )),
  374. Expanded(
  375. flex: 5,
  376. child: Column(
  377. children: [
  378. Text('Check Out',
  379. style: GoogleFonts.fredokaOne(
  380. fontSize: 19)),
  381. Text('16.45',
  382. style: GoogleFonts.barlowSemiCondensed(
  383. fontSize: 19)),
  384. ],
  385. )),
  386. ],
  387. ),
  388. Row(
  389. children: [
  390. Visibility(
  391. visible: visibleCheckIn,
  392. child: Container(
  393. margin: EdgeInsets.fromLTRB(0, 10, 0, 0),
  394. width: size.width - 54,
  395. child: ElevatedButton(
  396. onPressed: () {
  397. goCheckIn();
  398. },
  399. child: Text('Check In'),
  400. style: ButtonStyle(
  401. backgroundColor: MaterialStateProperty.all(
  402. Color(0xFF6474C6))),
  403. ),
  404. ),
  405. ),
  406. Visibility(
  407. visible: visibleCheckOut,
  408. child: Container(
  409. margin: EdgeInsets.fromLTRB(0, 10, 0, 0),
  410. width: size.width - 54,
  411. child: ElevatedButton(
  412. onPressed: () {
  413. goCheckOut();
  414. },
  415. child: Text('Check Out'),
  416. style: ButtonStyle(
  417. backgroundColor: MaterialStateProperty.all(
  418. Color(0xFF6474C6))),
  419. ),
  420. ),
  421. ),
  422. ],
  423. )
  424. ],
  425. ),
  426. )
  427. ],
  428. ),
  429. ),
  430. /*Container(
  431. width: double.infinity,
  432. margin: EdgeInsets.fromLTRB(10, 10, 10, 0),
  433. padding: EdgeInsets.all(15),
  434. decoration:
  435. BoxDecoration(border: Border.all(color: Colors.black)),
  436. child: Column(
  437. children: [
  438. Row(
  439. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  440. children: [
  441. Text('Rabu, 23 November 2022', maxLines: 1),
  442. Column(
  443. children: [Text('Check In'), Text('07.00')],
  444. ),
  445. Column(
  446. children: [
  447. Text('Check Out'),
  448. Text('16.30'),
  449. ],
  450. ),
  451. ],
  452. ),
  453. Text('Location : Global Service Indonesia', maxLines: 1),
  454. ],
  455. )),
  456. Container(
  457. width: double.infinity,
  458. margin: EdgeInsets.fromLTRB(10, 10, 10, 0),
  459. padding: EdgeInsets.all(15),
  460. decoration:
  461. BoxDecoration(border: Border.all(color: Colors.black)),
  462. child: Column(
  463. children: [
  464. Row(
  465. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  466. children: [
  467. Text('Rabu, 23 November 2022', maxLines: 1),
  468. Column(
  469. children: [Text('Check In'), Text('07.00')],
  470. ),
  471. Column(
  472. children: [
  473. Text('Check Out'),
  474. Text('16.30'),
  475. ],
  476. ),
  477. ],
  478. ),
  479. Text('Location : Global Service Indonesia', maxLines: 1),
  480. ],
  481. )),
  482. Container(
  483. width: double.infinity,
  484. margin: EdgeInsets.fromLTRB(10, 10, 10, 0),
  485. padding: EdgeInsets.all(15),
  486. decoration:
  487. BoxDecoration(border: Border.all(color: Colors.black)),
  488. child: Column(
  489. children: [
  490. Row(
  491. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  492. children: [
  493. Text('Rabu, 23 November 2022', maxLines: 1),
  494. Column(
  495. children: [Text('Check In'), Text('07.00')],
  496. ),
  497. Column(
  498. children: [
  499. Text('Check Out'),
  500. Text('16.30'),
  501. ],
  502. ),
  503. ],
  504. ),
  505. Text('Location : Global Service Indonesia', maxLines: 1),
  506. ],
  507. )),
  508. Container(
  509. width: double.infinity,
  510. margin: EdgeInsets.fromLTRB(10, 10, 10, 0),
  511. padding: EdgeInsets.all(15),
  512. decoration:
  513. BoxDecoration(border: Border.all(color: Colors.black)),
  514. child: Column(
  515. children: [
  516. Row(
  517. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  518. children: [
  519. Text('Rabu, 23 November 2022', maxLines: 1),
  520. Column(
  521. children: [Text('Check In'), Text('07.00')],
  522. ),
  523. Column(
  524. children: [
  525. Text('Check Out'),
  526. Text('16.30'),
  527. ],
  528. ),
  529. ],
  530. ),
  531. Text('Location : Global Service Indonesia', maxLines: 1),
  532. ],
  533. )),*/
  534. Container(
  535. margin: EdgeInsets.fromLTRB(10, 15, 10, 15),
  536. child: InkWell(
  537. child: Container(
  538. padding: EdgeInsets.fromLTRB(10, 10, 10, 10),
  539. width: double.infinity,
  540. decoration: BoxDecoration(
  541. borderRadius: BorderRadius.circular(5),
  542. gradient: LinearGradient(colors: [
  543. Color(0xFF2D4059),
  544. Color(0xFF2D4059),
  545. /*Color(0xFFEAFFD0),
  546. Color(0xFF95E1D3),*/
  547. ])),
  548. child: Row(
  549. mainAxisAlignment: MainAxisAlignment.center,
  550. children: [
  551. Text(' See Attendance History \t\t',
  552. textAlign: TextAlign.center,
  553. style: TextStyle(
  554. color: Colors.white,
  555. fontSize: 17,
  556. fontWeight: FontWeight.w500)),
  557. Image.asset(
  558. 'assets/images/ic_arrow_white.png',
  559. width: 30,
  560. height: 30,
  561. )
  562. ],
  563. )),
  564. onTap: () {
  565. Navigator.push(
  566. context,
  567. MaterialPageRoute(
  568. builder: (context) => HistoryAbsensi()));
  569. },
  570. ),
  571. ),
  572. ],
  573. ),
  574. ),
  575. );
  576. }
  577. }
  578. alertDialogFailedRetrievedData(BuildContext context) {
  579. Widget okButton = TextButton(
  580. child: Text("Refresh"),
  581. onPressed: () {
  582. Navigator.of(context, rootNavigator: true).pop();
  583. Navigator.pushReplacement(
  584. context, MaterialPageRoute(builder: (context) => AbsensiScreen()));
  585. },
  586. );
  587. Widget noButton = TextButton(
  588. child: Text("Back"),
  589. onPressed: () {
  590. Navigator.of(context, rootNavigator: true).pop();
  591. Navigator.pop(context);
  592. },
  593. );
  594. // set up the AlertDialog
  595. AlertDialog alert = AlertDialog(
  596. title: Text("Employee Self Service"),
  597. content: Text("Failed to Retrieve Data"),
  598. actions: [
  599. noButton,
  600. okButton,
  601. ],
  602. );
  603. // show the dialog
  604. showDialog(
  605. context: context,
  606. builder: (BuildContext context) {
  607. return alert;
  608. },
  609. );
  610. }
  611. alertDialogFailedResponse(BuildContext context) {
  612. Widget okButton = TextButton(
  613. child: Text("Refresh"),
  614. onPressed: () {
  615. Navigator.of(context, rootNavigator: true).pop();
  616. Navigator.pushReplacement(
  617. context, MaterialPageRoute(builder: (context) => AbsensiScreen()));
  618. },
  619. );
  620. Widget noButton = TextButton(
  621. child: Text("Back"),
  622. onPressed: () {
  623. Navigator.of(context, rootNavigator: true).pop();
  624. Navigator.pop(context);
  625. },
  626. );
  627. // set up the AlertDialog
  628. AlertDialog alert = AlertDialog(
  629. title: Text("Employee Self Service"),
  630. content: Text("Server Response Error"),
  631. actions: [
  632. noButton,
  633. okButton,
  634. ],
  635. );
  636. // show the dialog
  637. showDialog(
  638. context: context,
  639. builder: (BuildContext context) {
  640. return alert;
  641. },
  642. );
  643. }
  644. alertDialogSuccessCheckIn(BuildContext context) {
  645. Widget okButton = TextButton(
  646. child: Text("Ok"),
  647. onPressed: () {
  648. Navigator.of(context, rootNavigator: true).pop();
  649. Navigator.pushReplacement(
  650. context, MaterialPageRoute(builder: (context) => AbsensiScreen()));
  651. },
  652. );
  653. // set up the AlertDialog
  654. AlertDialog alert = AlertDialog(
  655. title: Text("Employee Self Service"),
  656. content: Text("Successfully Checked In"),
  657. actions: [
  658. okButton,
  659. ],
  660. );
  661. // show the dialog
  662. showDialog(
  663. context: context,
  664. builder: (BuildContext context) {
  665. return alert;
  666. },
  667. );
  668. }
  669. alertDialogSuccessCheckOut(BuildContext context) {
  670. Widget okButton = TextButton(
  671. child: Text("Ok"),
  672. onPressed: () {
  673. Navigator.of(context, rootNavigator: true).pop();
  674. Navigator.pushReplacement(
  675. context, MaterialPageRoute(builder: (context) => AbsensiScreen()));
  676. },
  677. );
  678. // set up the AlertDialog
  679. AlertDialog alert = AlertDialog(
  680. title: Text("Employee Self Service"),
  681. content: Text("Successfully Checked Out"),
  682. actions: [
  683. okButton,
  684. ],
  685. );
  686. // show the dialog
  687. showDialog(
  688. context: context,
  689. builder: (BuildContext context) {
  690. return alert;
  691. },
  692. );
  693. }
  694. alertDialogFailedCheckIn(BuildContext context) {
  695. Widget okButton = TextButton(
  696. child: Text("Ok"),
  697. onPressed: () {
  698. Navigator.of(context, rootNavigator: true).pop();
  699. Navigator.pushReplacement(
  700. context, MaterialPageRoute(builder: (context) => AbsensiScreen()));
  701. },
  702. );
  703. // set up the AlertDialog
  704. AlertDialog alert = AlertDialog(
  705. title: Text("Employee Self Service"),
  706. content: Text("You've already checked in"),
  707. actions: [
  708. okButton,
  709. ],
  710. );
  711. // show the dialog
  712. showDialog(
  713. context: context,
  714. builder: (BuildContext context) {
  715. return alert;
  716. },
  717. );
  718. }
  719. alertDialogFailedCheckOut(BuildContext context) {
  720. Widget okButton = TextButton(
  721. child: Text("Ok"),
  722. onPressed: () {
  723. Navigator.of(context, rootNavigator: true).pop();
  724. Navigator.pushReplacement(
  725. context, MaterialPageRoute(builder: (context) => AbsensiScreen()));
  726. },
  727. );
  728. // set up the AlertDialog
  729. AlertDialog alert = AlertDialog(
  730. title: Text("Employee Self Service"),
  731. content: Text("You haven't checked in"),
  732. actions: [
  733. okButton,
  734. ],
  735. );
  736. // show the dialog
  737. showDialog(
  738. context: context,
  739. builder: (BuildContext context) {
  740. return alert;
  741. },
  742. );
  743. }
  744. alertDialogFakeGPSDetected(BuildContext context) {
  745. Widget okButton = TextButton(
  746. child: Text("Refresh"),
  747. onPressed: () {
  748. Navigator.of(context, rootNavigator: true).pop();
  749. Navigator.pushReplacement(
  750. context, MaterialPageRoute(builder: (context) => AbsensiScreen()));
  751. },
  752. );
  753. // set up the AlertDialog
  754. AlertDialog alert = AlertDialog(
  755. title: Text("Employee Self Service"),
  756. content: Text("Fake GPS Detected, Please Use Default GPS!"),
  757. actions: [
  758. okButton,
  759. ],
  760. );
  761. // show the dialog
  762. showDialog(
  763. context: context,
  764. builder: (BuildContext context) {
  765. return alert;
  766. },
  767. );
  768. }
  769. alertDialogPermissionDenied(BuildContext context) {
  770. Widget okButton = TextButton(
  771. child: Text("Refresh"),
  772. onPressed: () {
  773. Navigator.of(context, rootNavigator: true).pop();
  774. Navigator.pushReplacement(
  775. context, MaterialPageRoute(builder: (context) => AbsensiScreen()));
  776. },
  777. );
  778. Widget noButton = TextButton(
  779. child: Text("Back"),
  780. onPressed: () {
  781. Navigator.of(context, rootNavigator: true).pop();
  782. Navigator.pop(context);
  783. },
  784. );
  785. // set up the AlertDialog
  786. AlertDialog alert = AlertDialog(
  787. title: Text("Employee Self Service"),
  788. content:
  789. Text("Location permissions are denied, we cannot request permissions"),
  790. actions: [
  791. noButton,
  792. okButton,
  793. ],
  794. );
  795. // show the dialog
  796. showDialog(
  797. context: context,
  798. builder: (BuildContext context) {
  799. return alert;
  800. },
  801. );
  802. }
  803. alertDialogPermissionDeniedForever(BuildContext context) {
  804. Widget noButton = TextButton(
  805. child: Text("Back"),
  806. onPressed: () {
  807. Navigator.of(context, rootNavigator: true).pop();
  808. Navigator.pop(context);
  809. },
  810. );
  811. // set up the AlertDialog
  812. AlertDialog alert = AlertDialog(
  813. title: Text("Employee Self Service"),
  814. content: Text(
  815. "Location permissions are permanently denied, we cannot request permissions.\nPlease configure it in your device settings."),
  816. actions: [noButton],
  817. );
  818. // show the dialog
  819. showDialog(
  820. context: context,
  821. builder: (BuildContext context) {
  822. return alert;
  823. },
  824. );
  825. }