暫無描述
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 32KB

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