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.

canvasingDetail_screen.dart 35KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923
  1. import 'dart:async';
  2. import 'dart:convert';
  3. import 'dart:ffi';
  4. import 'package:tower_app/Screens/Menu/Canvasing/filing_screen.dart';
  5. import 'package:tower_app/Screens/Menu/Canvasing/navigate_post.dart';
  6. import 'package:tower_app/Screens/Menu/Canvasing/startFiling_post.dart';
  7. import 'package:tower_app/Screens/Menu/Canvasing/updateGPS_post.dart';
  8. import 'package:flutter/cupertino.dart';
  9. import 'package:flutter/material.dart';
  10. import 'package:flutter_map/plugin_api.dart';
  11. import 'package:geolocator/geolocator.dart';
  12. import 'package:google_fonts/google_fonts.dart';
  13. import 'package:latlong2/latlong.dart' as latlong;
  14. import 'package:location/location.dart' as loc;
  15. import 'dart:developer' as logDev;
  16. import 'package:progress_dialog_null_safe/progress_dialog_null_safe.dart';
  17. import 'package:shared_preferences/shared_preferences.dart';
  18. import 'package:sliding_up_panel/sliding_up_panel.dart';
  19. import '../../background.dart';
  20. class CanvasingDetail extends StatefulWidget {
  21. const CanvasingDetail({Key? key}) : super(key: key);
  22. @override
  23. State<CanvasingDetail> createState() => _CanvasingDetail();
  24. }
  25. class _CanvasingDetail extends State<CanvasingDetail> {
  26. late latlong.LatLng point = latlong.LatLng(-6.183580253674716, 106.93103973792664);
  27. late Position position;
  28. late String name, customer, telp, alamat;
  29. bool visibleData = true;
  30. bool visibleMap = false;
  31. bool visibleButtonUpdate = false;
  32. bool visibleNavigate = true;
  33. bool visibleFiling = false;
  34. MapController _mapController = MapController();
  35. @override
  36. void initState() {
  37. //determinePosition();
  38. name = "";
  39. customer = "";
  40. telp = "";
  41. alamat = "";
  42. WidgetsBinding.instance.addPostFrameCallback((_) {
  43. getData();
  44. });
  45. super.initState();
  46. }
  47. Timer? timer;
  48. void initTimer(){
  49. if (timer != null && timer!.isActive) return;
  50. timer = Timer.periodic(Duration(seconds: 10), (timer) {
  51. setState(() {
  52. updatePosition();
  53. });
  54. });
  55. }
  56. @override
  57. void dispose() {
  58. timer?.cancel();
  59. super.dispose();
  60. }
  61. getData() async {
  62. ProgressDialog loading = ProgressDialog(context);
  63. loading = ProgressDialog(context,
  64. type: ProgressDialogType.normal, isDismissible: false, showLogs: true);
  65. loading.style(
  66. message: 'Please Wait .....',
  67. borderRadius: 3,
  68. backgroundColor: Colors.white,
  69. progressWidget: CircularProgressIndicator(),
  70. elevation: 10.0,
  71. padding: EdgeInsets.all(10),
  72. insetAnimCurve: Curves.easeInOut,
  73. progress: 0.0,
  74. maxProgress: 100.0,
  75. progressTextStyle: TextStyle(
  76. color: Colors.black, fontSize: 10.0, fontWeight: FontWeight.w400),
  77. messageTextStyle: TextStyle(
  78. color: Colors.black, fontSize: 15.0, fontWeight: FontWeight.w600));
  79. await loading.show();
  80. final SharedPreferences prefs = await SharedPreferences.getInstance();
  81. setState(() {
  82. name = prefs.getString('name')!;
  83. customer = prefs.getString('customer')!;
  84. telp = prefs.getString('telp')!;
  85. alamat = prefs.getString('alamat')!;
  86. logDev.log(name + ", " + customer + ", " + telp + ", " + alamat, name: "DATANYA APA NIH?");
  87. });
  88. await loading.hide();
  89. }
  90. determinePosition() async {
  91. StreamSubscription<ServiceStatus> serviceStatusStream = Geolocator.getServiceStatusStream().listen(
  92. (ServiceStatus status) {
  93. print(status);
  94. });
  95. ProgressDialog loading = ProgressDialog(context);
  96. loading = ProgressDialog(context, type: ProgressDialogType.normal, isDismissible: false, showLogs: true);
  97. loading.style(
  98. message: 'Please Wait .....',
  99. borderRadius: 3,
  100. backgroundColor: Colors.white,
  101. progressWidget: CircularProgressIndicator(),
  102. elevation: 10.0,
  103. padding: EdgeInsets.all(10),
  104. insetAnimCurve: Curves.easeInOut,
  105. progress: 0.0,
  106. maxProgress: 100.0,
  107. progressTextStyle: TextStyle(color: Colors.black, fontSize: 10.0, fontWeight: FontWeight.w400),
  108. messageTextStyle: TextStyle(color: Colors.black, fontSize: 15.0, fontWeight: FontWeight.w600));
  109. await loading.show();
  110. bool serviceEnabled = await Geolocator.isLocationServiceEnabled();
  111. logDev.log(serviceEnabled.toString(), name: "ON/OFF LOCATION SERVICE");
  112. if (!serviceEnabled) {
  113. return Future.error('Location services are disabled.');
  114. }
  115. LocationPermission permission = await Geolocator.checkPermission();
  116. if (permission == LocationPermission.deniedForever) {
  117. await loading.hide();
  118. //return Future.error('Location permissions are permanently denied, we cannot request permissions.');
  119. return alertDialogPermissionDeniedForever(context);
  120. } else if (permission == LocationPermission.denied) {
  121. permission = await Geolocator.requestPermission();
  122. if (permission != LocationPermission.whileInUse && permission != LocationPermission.always) {
  123. await loading.hide();
  124. //return Future.error('Location permissions are denied (actual value: $permission).');
  125. return alertDialogPermissionDenied(context);
  126. }
  127. }
  128. final SharedPreferences prefs = await SharedPreferences.getInstance();
  129. String? idDetail = prefs.getString('idDetail');
  130. int? user_id = prefs.getInt('user_id');
  131. Navigate_Post.connectToAPI(idDetail!, user_id!).then((valueResult) async {
  132. Map<String, dynamic> object = json.decode(valueResult);
  133. if (object.containsKey("result").toString() == "true") {
  134. String result = object['result'].toString();
  135. String status = object['result']['status'].toString();
  136. logDev.log(result, name: "Status??");
  137. if (status.contains("success")){
  138. String mapsPoint = object['result']['maps'].toString();
  139. double? lat = double.tryParse(mapsPoint.split(",")[0]);
  140. double? long = double.tryParse(mapsPoint.split(",")[1]);
  141. logDev.log(mapsPoint, name: "titik lokasinya");
  142. position = await Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
  143. logDev.log(position.toString(), name: "Position GEOLOCATOR");
  144. if (position.isMocked) {
  145. await loading.hide();
  146. setState(() {
  147. alertDialogFakeGPSDetected(context);
  148. });
  149. } else {
  150. setState(() {
  151. point = latlong.LatLng(lat!,long!);
  152. logDev.log(point.toString(), name: "POINT GEOLOCATOR");
  153. _mapController.move(point, 18);
  154. });
  155. }
  156. await loading.hide();
  157. await loading.hide();
  158. } else if (status.contains("failed")){
  159. setState(() {
  160. alertDialogFailedResponse(context);
  161. });
  162. await loading.hide();
  163. }
  164. } else {
  165. setState(() {
  166. alertDialogFailedResponse(context);
  167. });
  168. await loading.hide();
  169. }
  170. await loading.hide();
  171. });
  172. logDev.log("DAH SELESE BUILD NAVIGATENYA!", name: "UDAH?");
  173. initTimer();
  174. }
  175. Future<void> updatePosition() async {
  176. logDev.log("NAH BARU MULAI!", name: "MULAI?");
  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. final SharedPreferences prefs = await SharedPreferences.getInstance();
  221. String? idDetail = prefs.getString('idDetail');
  222. int? user_id = prefs.getInt('user_id');
  223. point = latlong.LatLng(position.latitude, position.longitude);
  224. logDev.log(point.toString(), name: "UPDATE POINT GEOLOCATOR");
  225. _mapController.move(point, 18);
  226. position = await Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
  227. String titik = position.latitude.toString() + "," + position.longitude.toString();
  228. logDev.log(titik, name: "TITIK UPDATE");
  229. setState(() {
  230. UpdateGPS_Post.connectToAPI(idDetail!, titik, user_id!).then((valueResult) async {
  231. Map<String, dynamic> object = json.decode(valueResult);
  232. if (object.containsKey("result").toString() == "true") {
  233. String status = object['result']['status'].toString();
  234. if (status.contains("success")){
  235. String mapsPoint = object['result']['maps'].toString();
  236. logDev.log(mapsPoint, name: "titik lokasinya");
  237. position = await Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
  238. logDev.log(position.toString(), name: "Position GEOLOCATOR");
  239. if (position.isMocked) {
  240. await loading.hide();
  241. setState(() {
  242. alertDialogFakeGPSDetected(context);
  243. });
  244. } else {
  245. setState(() {
  246. point = latlong.LatLng(double.parse(mapsPoint.split(",")[0]), double.parse(mapsPoint.split(",")[1]));
  247. logDev.log(point.toString(), name: "POINT GEOLOCATOR");
  248. _mapController.move(point, 18);
  249. });
  250. }
  251. await loading.hide();
  252. } else if (status.contains("failed")){
  253. setState(() {
  254. alertDialogFailedResponse(context);
  255. });
  256. await loading.hide();
  257. }
  258. } else {
  259. setState(() {
  260. alertDialogFailedResponse(context);
  261. });
  262. await loading.hide();
  263. }
  264. await loading.hide();
  265. });
  266. });
  267. }
  268. }
  269. PanelController _panelController = PanelController();
  270. void togglePanel() => _panelController.isPanelOpen
  271. ? _panelController.close()
  272. : _panelController.open();
  273. @override
  274. Widget build(BuildContext context) {
  275. var size = MediaQuery.of(context).size;
  276. return Scaffold(
  277. body: SlidingUpPanel(
  278. controller: _panelController,
  279. parallaxEnabled: true,
  280. maxHeight: size.height * 0.2,
  281. minHeight: size.height * 0.2,
  282. body: Container (
  283. child: Stack(
  284. children: [
  285. Visibility(
  286. visible: visibleData,
  287. child: Stack(
  288. children: [
  289. WavyHeader(),
  290. Container(
  291. margin: EdgeInsets.only(
  292. top: (size.height / 6) - 20),
  293. padding: EdgeInsets.fromLTRB(0, 5, 25, 5),
  294. child: Row(
  295. mainAxisAlignment: MainAxisAlignment.end,
  296. crossAxisAlignment: CrossAxisAlignment.end,
  297. children: [
  298. Text(
  299. 'Detail Canvasing\t\t',
  300. maxLines: 1,
  301. style: GoogleFonts.luckiestGuy(
  302. fontSize: 28,
  303. color: Color(0xFF4858A7),
  304. fontStyle: FontStyle.italic,
  305. ),
  306. ),
  307. Image.asset(
  308. 'assets/icons/menu/ic_history.png',
  309. width: 40,
  310. height: 40,
  311. ),
  312. ],
  313. )
  314. ),
  315. SafeArea(
  316. child: Container(
  317. width: MediaQuery.of(context).size.width,
  318. margin: EdgeInsets.only(
  319. top: MediaQuery.of(context).size.height / 5,
  320. left: 10,
  321. right: 10,
  322. bottom : 15,
  323. ),
  324. child: Container(
  325. child: Card(
  326. elevation: 10,
  327. child: Container(
  328. decoration: BoxDecoration(
  329. color: Color(0XFFFAF7EE),
  330. borderRadius: BorderRadius.circular(10)),
  331. child: Column(
  332. children: [
  333. Container(
  334. margin: EdgeInsets.only(left: 10, right: 10, top: 15, bottom: 10),
  335. child: Column(
  336. children: [
  337. Align(
  338. alignment: Alignment.centerLeft,
  339. child: Text(
  340. 'Name',
  341. style: GoogleFonts.inconsolata(
  342. fontSize: 19, fontWeight: FontWeight.bold),
  343. ),
  344. ),
  345. Container(
  346. margin: EdgeInsets.only(top: 7),
  347. width: MediaQuery.of(context).size.width,
  348. height: 35,
  349. decoration: BoxDecoration(
  350. color:
  351. CupertinoColors.systemGrey2,
  352. borderRadius:
  353. BorderRadius.circular(5)),
  354. child: Align(
  355. alignment: Alignment.centerLeft,
  356. child: Text(
  357. '\t\t' + name,
  358. style: GoogleFonts.inconsolata(
  359. fontSize: 17),
  360. ),
  361. ),
  362. ),
  363. ],
  364. ),
  365. ),
  366. Container(
  367. margin: EdgeInsets.only(left: 10, right: 10, top: 15, bottom: 10),
  368. child: Column(
  369. children: [
  370. Align(
  371. alignment: Alignment.centerLeft,
  372. child: Text(
  373. 'Customer',
  374. style: GoogleFonts.inconsolata(
  375. fontSize: 19, fontWeight: FontWeight.bold),
  376. ),
  377. ),
  378. Container(
  379. margin: EdgeInsets.only(top: 7),
  380. width: MediaQuery.of(context).size.width,
  381. height: 35,
  382. decoration: BoxDecoration(
  383. color:
  384. CupertinoColors.systemGrey2,
  385. borderRadius:
  386. BorderRadius.circular(5)),
  387. child: Align(
  388. alignment: Alignment.centerLeft,
  389. child: Text(
  390. '\t\t' + customer,
  391. style: GoogleFonts.inconsolata(
  392. fontSize: 17),
  393. ),
  394. ),
  395. ),
  396. ],
  397. ),
  398. ),
  399. Container(
  400. margin: EdgeInsets.only(left: 10, right: 10, top: 15, bottom: 10),
  401. child: Column(
  402. children: [
  403. Align(
  404. alignment: Alignment.centerLeft,
  405. child: Text(
  406. 'Phone Number',
  407. style: GoogleFonts.inconsolata(
  408. fontSize: 19, fontWeight: FontWeight.bold),
  409. ),
  410. ),
  411. Container(
  412. margin: EdgeInsets.only(top: 7),
  413. width: MediaQuery.of(context).size.width,
  414. height: 35,
  415. decoration: BoxDecoration(
  416. color:
  417. CupertinoColors.systemGrey2,
  418. borderRadius:
  419. BorderRadius.circular(5)),
  420. child: Align(
  421. alignment: Alignment.centerLeft,
  422. child: Text(
  423. '\t\t' + telp,
  424. style: GoogleFonts.inconsolata(
  425. fontSize: 17),
  426. ),
  427. ),
  428. ),
  429. ],
  430. ),
  431. ),
  432. Container(
  433. margin: EdgeInsets.only(left: 10, right: 10, top: 15, bottom: 10),
  434. child: Column(
  435. children: [
  436. Align(
  437. alignment: Alignment.centerLeft,
  438. child: Text(
  439. 'Address',
  440. style: GoogleFonts.inconsolata(
  441. fontSize: 19, fontWeight: FontWeight.bold),
  442. ),
  443. ),
  444. Container(
  445. margin: EdgeInsets.only(top: 7),
  446. width: MediaQuery.of(context).size.width,
  447. height: 35,
  448. decoration: BoxDecoration(
  449. color:
  450. CupertinoColors.systemGrey2,
  451. borderRadius:
  452. BorderRadius.circular(5)),
  453. child: Align(
  454. alignment: Alignment.centerLeft,
  455. child: Text(
  456. '\t\t' + alamat,
  457. style: GoogleFonts.inconsolata(
  458. fontSize: 17),
  459. ),
  460. ),
  461. ),
  462. ],
  463. ),
  464. ),
  465. ],
  466. ),
  467. ),
  468. ),
  469. ),
  470. ),
  471. ),
  472. ],
  473. )),
  474. Visibility(
  475. visible: visibleMap,
  476. child: FlutterMap(
  477. mapController: _mapController,
  478. options: new MapOptions(
  479. onTap: (p, point) async {}, center: point, zoom: 15),
  480. children: [
  481. TileLayer(
  482. minZoom: 1,
  483. maxZoom: 22,
  484. maxNativeZoom: 18,
  485. minNativeZoom: 1,
  486. backgroundColor: Colors.black54,
  487. urlTemplate:
  488. 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
  489. subdomains: ['a', 'b', 'c'],
  490. ),
  491. MarkerLayer(markers: [
  492. Marker(
  493. width: 135,
  494. height: 135,
  495. point: point,
  496. builder: (ctx) => Container(
  497. child: Icon(
  498. Icons.location_on,
  499. color: Colors.red,
  500. ),
  501. ))
  502. ])
  503. ],
  504. ),
  505. ),
  506. Visibility(
  507. visible: visibleButtonUpdate,
  508. child:
  509. Container(
  510. alignment: AlignmentDirectional.bottomEnd,
  511. child: Container(
  512. margin: EdgeInsets.fromLTRB(10, 15, 0, (size.height*0.2) + 15),
  513. child: RawMaterialButton(
  514. onPressed: () {
  515. setState(() {
  516. updatePosition();
  517. });
  518. },
  519. elevation: 5.0,
  520. fillColor: Colors.white,
  521. child: Image.asset('assets/images/location1.png',
  522. height: 40, width: 40),
  523. padding: EdgeInsets.all(5.0),
  524. shape: CircleBorder(),
  525. ),
  526. ),
  527. ),
  528. ),
  529. ],
  530. ),
  531. ),
  532. panel: Center(
  533. child: Column(
  534. children: [
  535. GestureDetector(
  536. onTap: togglePanel,
  537. child: Center(
  538. child: Container(
  539. margin: EdgeInsets.only(top: 15),
  540. height: 5,
  541. width: size.width * 0.1,
  542. decoration: BoxDecoration(
  543. borderRadius: BorderRadius.circular(10),
  544. color: Colors.grey
  545. ),
  546. ),
  547. ),
  548. ),
  549. Container(
  550. width: double.infinity,
  551. margin: EdgeInsets.fromLTRB(10, 10, 10, 10),
  552. //decoration: BoxDecoration(border: Border.all(color: Colors.black), borderRadius: BorderRadius.all(Radius.circular(15))),
  553. child: Column(
  554. children: <Widget>[
  555. ],
  556. ),
  557. ),
  558. Visibility(
  559. visible: visibleNavigate,
  560. child: Container(
  561. margin: EdgeInsets.fromLTRB(10, 15, 10, 15),
  562. child: InkWell(
  563. child: Container(
  564. padding: EdgeInsets.fromLTRB(10, 10, 10, 10),
  565. width: double.infinity,
  566. decoration: BoxDecoration(
  567. borderRadius: BorderRadius.circular(5),
  568. gradient: LinearGradient(colors: [
  569. Color(0xFF2D4059),
  570. Color(0xFF2D4059),
  571. ])),
  572. child: Row(
  573. mainAxisAlignment: MainAxisAlignment.center,
  574. children: [
  575. Text('Start Navigate\t\t',
  576. textAlign: TextAlign.center,
  577. style: TextStyle(
  578. color: Colors.white,
  579. fontSize: 17,
  580. fontWeight: FontWeight.w500)),
  581. Image.asset(
  582. 'assets/images/ic_arrow_white.png',
  583. width: 30,
  584. height: 30,
  585. )
  586. ],
  587. )),
  588. onTap: () async {
  589. setState(() {
  590. determinePosition();
  591. visibleData = !visibleData;
  592. visibleMap = !visibleMap;
  593. visibleButtonUpdate = !visibleButtonUpdate;
  594. visibleNavigate = !visibleNavigate;
  595. visibleFiling = !visibleFiling;
  596. });
  597. /*StartFiling_Post.connectToAPI(idDetail!, user_id!).then((valueResult) async {
  598. Navigator.push(context, MaterialPageRoute(builder: (context) => FilingScreen()));
  599. });*/
  600. },
  601. ),
  602. ),
  603. ),
  604. Visibility(
  605. visible: visibleFiling,
  606. child: Container(
  607. margin: EdgeInsets.fromLTRB(10, 15, 10, 15),
  608. child: InkWell(
  609. child: Container(
  610. padding: EdgeInsets.fromLTRB(10, 10, 10, 10),
  611. width: double.infinity,
  612. decoration: BoxDecoration(
  613. borderRadius: BorderRadius.circular(5),
  614. gradient: LinearGradient(colors: [
  615. Color(0xFF2D4059),
  616. Color(0xFF2D4059),
  617. ])),
  618. child: Row(
  619. mainAxisAlignment: MainAxisAlignment.center,
  620. children: [
  621. Text('Start Filing\t\t',
  622. textAlign: TextAlign.center,
  623. style: TextStyle(
  624. color: Colors.white,
  625. fontSize: 17,
  626. fontWeight: FontWeight.w500)),
  627. Image.asset(
  628. 'assets/images/ic_arrow_white.png',
  629. width: 30,
  630. height: 30,
  631. )
  632. ],
  633. )),
  634. onTap: () async {
  635. final SharedPreferences prefs = await SharedPreferences.getInstance();
  636. String? idDetail = prefs.getString('idDetail');
  637. int? user_id = prefs.getInt('user_id');
  638. StartFiling_Post.connectToAPI(idDetail!, user_id!).then((valueResult) async {
  639. Navigator.push(context, MaterialPageRoute(builder: (context) => FilingScreen()));
  640. });
  641. },
  642. ),
  643. ),
  644. ),
  645. ],
  646. ),
  647. ),
  648. borderRadius: BorderRadius.only(topLeft: Radius.circular(15), topRight: Radius.circular(15)),
  649. ),
  650. );
  651. }
  652. }
  653. alertDialogFailedRetrievedData(BuildContext context) {
  654. Widget okButton = TextButton(
  655. child: Text("Refresh"),
  656. onPressed: () {
  657. Navigator.of(context, rootNavigator: true).pop();
  658. Navigator.pushReplacement(
  659. context, MaterialPageRoute(builder: (context) => CanvasingDetail()));
  660. },
  661. );
  662. Widget noButton = TextButton(
  663. child: Text("Back"),
  664. onPressed: () {
  665. Navigator.of(context, rootNavigator: true).pop();
  666. Navigator.pop(context);
  667. },
  668. );
  669. // set up the AlertDialog
  670. AlertDialog alert = AlertDialog(
  671. title: Text("Employee Self Service"),
  672. content: Text("Failed to Retrieve Data"),
  673. actions: [
  674. noButton,
  675. okButton,
  676. ],
  677. );
  678. // show the dialog
  679. showDialog(
  680. context: context,
  681. barrierDismissible: false,
  682. builder: (BuildContext context) {
  683. return alert;
  684. },
  685. );
  686. }
  687. alertDialogFailedResponse(BuildContext context) {
  688. Widget okButton = TextButton(
  689. child: Text("Refresh"),
  690. onPressed: () {
  691. Navigator.of(context, rootNavigator: true).pop();
  692. Navigator.pushReplacement(
  693. context, MaterialPageRoute(builder: (context) => CanvasingDetail()));
  694. },
  695. );
  696. Widget noButton = TextButton(
  697. child: Text("Back"),
  698. onPressed: () {
  699. Navigator.of(context, rootNavigator: true).pop();
  700. Navigator.pop(context);
  701. },
  702. );
  703. // set up the AlertDialog
  704. AlertDialog alert = AlertDialog(
  705. title: Text("Employee Self Service"),
  706. content: Text("Server Response Error"),
  707. actions: [
  708. noButton,
  709. okButton,
  710. ],
  711. );
  712. // show the dialog
  713. showDialog(
  714. context: context,
  715. barrierDismissible: false,
  716. builder: (BuildContext context) {
  717. return alert;
  718. },
  719. );
  720. }
  721. alertDialogFakeGPSDetected(BuildContext context) {
  722. Widget okButton = TextButton(
  723. child: Text("Refresh"),
  724. onPressed: () {
  725. Navigator.of(context, rootNavigator: true).pop();
  726. Navigator.pushReplacement(
  727. context, MaterialPageRoute(builder: (context) => CanvasingDetail()));
  728. },
  729. );
  730. // set up the AlertDialog
  731. AlertDialog alert = AlertDialog(
  732. title: Text("Employee Self Service"),
  733. content: Text("Fake GPS Detected, Please Use Default GPS!"),
  734. actions: [
  735. okButton,
  736. ],
  737. );
  738. // show the dialog
  739. showDialog(
  740. context: context,
  741. barrierDismissible: false,
  742. builder: (BuildContext context) {
  743. return alert;
  744. },
  745. );
  746. }
  747. alertDialogPermissionDenied(BuildContext context) {
  748. Widget okButton = TextButton(
  749. child: Text("Refresh"),
  750. onPressed: () {
  751. Navigator.of(context, rootNavigator: true).pop();
  752. Navigator.pushReplacement(
  753. context, MaterialPageRoute(builder: (context) => CanvasingDetail()));
  754. },
  755. );
  756. Widget noButton = TextButton(
  757. child: Text("Back"),
  758. onPressed: () {
  759. Navigator.of(context, rootNavigator: true).pop();
  760. Navigator.pop(context);
  761. },
  762. );
  763. // set up the AlertDialog
  764. AlertDialog alert = AlertDialog(
  765. title: Text("Employee Self Service"),
  766. content:
  767. Text("Location permissions are denied, we cannot request permissions"),
  768. actions: [
  769. noButton,
  770. okButton,
  771. ],
  772. );
  773. // show the dialog
  774. showDialog(
  775. context: context,
  776. barrierDismissible: false,
  777. builder: (BuildContext context) {
  778. return alert;
  779. },
  780. );
  781. }
  782. alertDialogPermissionDeniedForever(BuildContext context) {
  783. Widget noButton = TextButton(
  784. child: Text("Back"),
  785. onPressed: () {
  786. Navigator.of(context, rootNavigator: true).pop();
  787. Navigator.pop(context);
  788. },
  789. );
  790. // set up the AlertDialog
  791. AlertDialog alert = AlertDialog(
  792. title: Text("Employee Self Service"),
  793. content: Text(
  794. "Location permissions are permanently denied, we cannot request permissions. Please configure it in your device settings."),
  795. actions: [noButton],
  796. );
  797. // show the dialog
  798. showDialog(
  799. context: context,
  800. barrierDismissible: false,
  801. builder: (BuildContext context) {
  802. return alert;
  803. },
  804. );
  805. }
  806. alertDialogEnableLocaionServices(BuildContext context) {
  807. ProgressDialog loading = ProgressDialog(context);
  808. loading = ProgressDialog(context,
  809. type: ProgressDialogType.normal, isDismissible: false, showLogs: true);
  810. loading.style(
  811. message: 'Please Wait .....',
  812. borderRadius: 3,
  813. backgroundColor: Colors.white,
  814. progressWidget: CircularProgressIndicator(),
  815. elevation: 10.0,
  816. padding: EdgeInsets.all(10),
  817. insetAnimCurve: Curves.easeInOut,
  818. progress: 0.0,
  819. maxProgress: 100.0,
  820. progressTextStyle: TextStyle(
  821. color: Colors.black, fontSize: 10.0, fontWeight: FontWeight.w400),
  822. messageTextStyle: TextStyle(
  823. color: Colors.black, fontSize: 15.0, fontWeight: FontWeight.w600));
  824. Widget okButton = TextButton(
  825. child: Text("Open Settings"),
  826. onPressed: () {
  827. //AppSettings.openLocationSettings();
  828. Navigator.of(context, rootNavigator: true).pop();
  829. loading.hide();
  830. },
  831. );
  832. Widget noButton = TextButton(
  833. child: Text("No, thanks"),
  834. onPressed: () {
  835. Navigator.of(context, rootNavigator: true).pop();
  836. Navigator.pop(context);
  837. loading.hide();
  838. },
  839. );
  840. // set up the AlertDialog
  841. AlertDialog alert = AlertDialog(
  842. title: Text("Employee Self Service"),
  843. content:
  844. Text("For a better experience, please turn on your device location"),
  845. actions: [
  846. noButton,
  847. okButton,
  848. ],
  849. );
  850. // show the dialog
  851. showDialog(
  852. context: context,
  853. barrierDismissible: false,
  854. builder: (BuildContext context) {
  855. return alert;
  856. },
  857. );
  858. }