Без опису
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

absensi_screen.dart 32KB

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