Ingen beskrivning
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

detailsurvey_screen.dart 58KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099
  1. import 'dart:async';
  2. import 'dart:convert';
  3. import 'dart:io';
  4. import 'package:path/path.dart' as path;
  5. import 'package:flutter_map/flutter_map.dart';
  6. import 'package:image_picker/image_picker.dart';
  7. import 'package:latlong2/latlong.dart' as latlong;
  8. import 'package:flutter/material.dart';
  9. import 'package:fluttertoast/fluttertoast.dart';
  10. import 'package:geolocator/geolocator.dart';
  11. import 'package:google_fonts/google_fonts.dart';
  12. import 'package:progress_dialog_null_safe/progress_dialog_null_safe.dart';
  13. import 'package:shared_preferences/shared_preferences.dart';
  14. import 'package:tower_app/Screens/Menu/Survey/getdetailtsurvey_post.dart';
  15. import 'package:tower_app/Screens/Menu/Survey/sendSurvey_post.dart';
  16. import 'package:tower_app/Screens/Menu/Survey/surveylist_screen.dart';
  17. import 'package:tower_app/Screens/Settings/RequestHttp/getDetail_post.dart';
  18. import 'dart:developer' as logDev;
  19. import '../../background.dart';
  20. import '../Canvasing/canvasingDetail_screen.dart';
  21. TextEditingController isiDesaTeksController = TextEditingController();
  22. TextEditingController isiKecamatanTeksController = TextEditingController();
  23. TextEditingController isiKabupatenTeksController = TextEditingController();
  24. TextEditingController isiProvinsiTeksController = TextEditingController();
  25. TextEditingController isiJumlahPendudukTeksController = TextEditingController();
  26. TextEditingController isiSignal2TeksController = TextEditingController();
  27. TextEditingController isiSignal3TeksController = TextEditingController();
  28. TextEditingController isiSignal4TeksController = TextEditingController();
  29. TextEditingController isiCatatanTeksController = TextEditingController();
  30. class DetailSurveyScreen extends StatefulWidget {
  31. const DetailSurveyScreen({Key? key}) : super(key: key);
  32. @override
  33. State<DetailSurveyScreen> createState() => _DetailSurveyScreen();
  34. }
  35. class _DetailSurveyScreen extends State<DetailSurveyScreen> {
  36. bool visibleNamaDesa = true;
  37. bool visibleEditDesa = true;
  38. bool visibleFormDesa = false;
  39. bool visibleNamaKecamatan = true;
  40. bool visibleEditKecamatan = true;
  41. bool visibleFormKecamatan = false;
  42. bool visibleNamaKabupaten = true;
  43. bool visibleEditKabupaten = true;
  44. bool visibleFormKabupaten = false;
  45. bool visibleNamaProvinsi = true;
  46. bool visibleEditProvinsi = true;
  47. bool visibleFormProvinsi = false;
  48. final List<TextEditingController> _jenisTempat = [];
  49. final List<TextEditingController> _km = [];
  50. final List<InkWell> _ambilFoto = [];
  51. File? _imagePath;
  52. final List<String> _pathFoto = [];
  53. final List<String> _base64Foto = [];
  54. latlong.LatLng point = latlong.LatLng(-6.183580253674716, 106.93103973792664);
  55. late Position position;
  56. MapController _mapController = MapController();
  57. late String titik;
  58. late String survey_name;
  59. late String nama_desa, nama_kecamatan, nama_kabupaten, nama_provinsi, posisi, signal2G, signal3G, signal4G, catatan;
  60. late int jumlah_penduduk;
  61. initState(){
  62. isiDesaTeksController.clear();
  63. isiKecamatanTeksController.clear();
  64. isiKabupatenTeksController.clear();
  65. isiProvinsiTeksController.clear();
  66. isiJumlahPendudukTeksController.clear();
  67. isiSignal2TeksController.clear();
  68. isiSignal3TeksController.clear();
  69. isiSignal4TeksController.clear();
  70. isiCatatanTeksController.clear();
  71. survey_name = "Survey";
  72. nama_desa = "";
  73. nama_kecamatan = "";
  74. nama_kabupaten = "";
  75. nama_provinsi = "";
  76. posisi = "";
  77. signal2G = "";
  78. signal3G = "";
  79. signal4G = "";
  80. catatan = "";
  81. jumlah_penduduk = 0;
  82. titik = "";
  83. WidgetsBinding.instance.addPostFrameCallback((_) {
  84. getSurveyName();
  85. //getDetailSurvey();
  86. });
  87. super.initState();
  88. }
  89. getSurveyName() async {
  90. ProgressDialog loading = ProgressDialog(context);
  91. loading = ProgressDialog(context, type: ProgressDialogType.normal, isDismissible: false, showLogs: true);
  92. loading.style(
  93. message: 'Please Wait .....',
  94. borderRadius: 3,
  95. backgroundColor: Colors.white,
  96. progressWidget: CircularProgressIndicator(),
  97. elevation: 10.0,
  98. padding: EdgeInsets.all(10),
  99. insetAnimCurve: Curves.easeInOut,
  100. progress: 0.0,
  101. maxProgress: 100.0,
  102. progressTextStyle: TextStyle(color: Colors.black, fontSize: 10.0, fontWeight: FontWeight.w400),
  103. messageTextStyle: TextStyle(color: Colors.black, fontSize: 15.0, fontWeight: FontWeight.w600));
  104. await loading.show();
  105. final SharedPreferences prefs = await SharedPreferences.getInstance();
  106. survey_name = prefs.getString('nameDetail')!;
  107. logDev.log(survey_name, name: "Nama Survey");
  108. getDetailSurvey();
  109. }
  110. getDetailSurvey() async {
  111. ProgressDialog loading = ProgressDialog(context);
  112. loading = ProgressDialog(context, type: ProgressDialogType.normal, isDismissible: false, showLogs: true);
  113. loading.style(
  114. message: 'Please Wait .....',
  115. borderRadius: 3,
  116. backgroundColor: Colors.white,
  117. progressWidget: CircularProgressIndicator(),
  118. elevation: 10.0,
  119. padding: EdgeInsets.all(10),
  120. insetAnimCurve: Curves.easeInOut,
  121. progress: 0.0,
  122. maxProgress: 100.0,
  123. progressTextStyle: TextStyle(color: Colors.black, fontSize: 10.0, fontWeight: FontWeight.w400),
  124. messageTextStyle: TextStyle(color: Colors.black, fontSize: 15.0, fontWeight: FontWeight.w600));
  125. final SharedPreferences prefs = await SharedPreferences.getInstance();
  126. int? idDetail = prefs.getInt('idDetail');
  127. GetDetailSurvey_Post.connectToAPI(idDetail!).then((valueResult) async {
  128. Map<String, dynamic> object = jsonDecode(valueResult);
  129. String status = object['result']['status'].toString();
  130. if (status.contains("failed")) {
  131. await loading.hide();
  132. alertDialogFailedRetrievedData(context);
  133. } else if (status.contains("success")) {
  134. logDev.log(status, name: "SUCCeSS?");
  135. //List <dynamic> allData = object['result']['data'];
  136. setState(() {
  137. nama_desa = object['result']['data']['desa'].toString();
  138. logDev.log(nama_desa, name:"NAMA DESA?");
  139. nama_kecamatan = object['result']['data']['kecamatan'].toString();
  140. nama_kabupaten = object['result']['data']['kabupaten'].toString();
  141. nama_provinsi = object['result']['data']['provinsi'].toString();
  142. jumlah_penduduk = object['result']['data']['jumlah_penduduk'];
  143. posisi = object['result']['data']['posisi'].toString();
  144. signal2G = object['result']['data']['signal_2G'].toString();
  145. signal3G = object['result']['data']['signal_3G'].toString();
  146. signal4G = object['result']['data']['signal_4G'].toString();
  147. catatan = object['result']['data']['catatan'].toString();
  148. point = latlong.LatLng(double.parse(posisi.split(",")[0]), double.parse(posisi.split(",")[1]));
  149. });
  150. }
  151. await loading.hide();
  152. });
  153. }
  154. @override
  155. Widget build(BuildContext context) {
  156. var size = MediaQuery.sizeOf(context);
  157. return Scaffold(
  158. body: SingleChildScrollView(
  159. child: Column(
  160. children: <Widget>[
  161. Stack(
  162. children: [
  163. WavyHeader(),
  164. Container(
  165. margin: EdgeInsets.only(top: MediaQuery.of(context).size.height/6 - 20),
  166. padding: EdgeInsets.fromLTRB(20, 5, 25, 5),
  167. child: Row(
  168. mainAxisAlignment: MainAxisAlignment.end,
  169. crossAxisAlignment: CrossAxisAlignment.end,
  170. children: [
  171. Text(
  172. //'Survey\t\t',
  173. "Detail Survey\t\t",
  174. maxLines: 2,
  175. style: GoogleFonts.luckiestGuy(
  176. fontSize: 28,
  177. color: Color(0xFF4858A7),
  178. fontStyle: FontStyle.italic,
  179. ),
  180. ),
  181. Image.asset("assets/icons/menu/survey_3.png",
  182. width: 40,
  183. height: 40,
  184. ),
  185. ],
  186. )),
  187. SafeArea(
  188. child: Container(
  189. width: MediaQuery.of(context).size.width,
  190. margin: EdgeInsets.only(
  191. top: MediaQuery.of(context).size.height / 5,
  192. left: 10,
  193. right: 10,
  194. bottom : 15,
  195. ),
  196. child: Column(
  197. children: [
  198. Container(
  199. child: Card(
  200. elevation: 10,
  201. child: Container(
  202. decoration: BoxDecoration(
  203. color: Color(0XFFFAF7EE),
  204. borderRadius: BorderRadius.circular(10)),
  205. child: Column(
  206. children: [
  207. Container(
  208. margin: EdgeInsets.only(
  209. left: 10, right: 10, top: 15, bottom: 10),
  210. child: Text(survey_name, style:
  211. GoogleFonts.ubuntu(fontSize: 19, fontWeight: FontWeight.bold, /*decoration: TextDecoration.underline*/
  212. decorationStyle: TextDecorationStyle.dashed),),
  213. ),
  214. Container(
  215. margin: EdgeInsets.only(left: 10, right: 10, top: 15),
  216. child: Column(
  217. children: [
  218. Align(
  219. alignment: Alignment.centerLeft,
  220. child: Text(
  221. 'Desa',
  222. style: GoogleFonts.inconsolata(
  223. fontSize: 16, fontWeight: FontWeight.bold, ),
  224. ),
  225. ),
  226. Container(
  227. width: size.width,
  228. decoration: BoxDecoration(borderRadius: BorderRadius.circular(5), shape: BoxShape.rectangle, color: Colors.white),
  229. padding: EdgeInsets.all(10),
  230. child:
  231. Align(
  232. alignment: Alignment.centerLeft,
  233. child: Text(
  234. nama_desa,
  235. style: GoogleFonts.inconsolata(
  236. fontSize: 16, fontWeight: FontWeight.bold, ),
  237. ),
  238. ),
  239. ),
  240. ],
  241. ),
  242. ),
  243. Container(
  244. margin: EdgeInsets.only(left: 10, right: 10, top: 15),
  245. child: Column(
  246. children: [
  247. Align(
  248. alignment: Alignment.centerLeft,
  249. child: Text(
  250. 'Kecamatan',
  251. style: GoogleFonts.inconsolata(
  252. fontSize: 16, fontWeight: FontWeight.bold, ),
  253. ),
  254. ),
  255. Container(
  256. width: size.width,
  257. decoration: BoxDecoration(borderRadius: BorderRadius.circular(5), shape: BoxShape.rectangle, color: Colors.white),
  258. padding: EdgeInsets.all(10),
  259. child:
  260. Align(
  261. alignment: Alignment.centerLeft,
  262. child: Text(
  263. nama_kecamatan,
  264. style: GoogleFonts.inconsolata(
  265. fontSize: 16, fontWeight: FontWeight.bold, ),
  266. ),
  267. ),
  268. ),
  269. ],
  270. ),
  271. ),
  272. Container(
  273. margin: EdgeInsets.only(left: 10, right: 10, top: 15),
  274. child: Column(
  275. children: [
  276. Align(
  277. alignment: Alignment.centerLeft,
  278. child: Text(
  279. 'Kabupaten',
  280. style: GoogleFonts.inconsolata(
  281. fontSize: 16, fontWeight: FontWeight.bold, ),
  282. ),
  283. ),
  284. Container(
  285. width: size.width,
  286. decoration: BoxDecoration(borderRadius: BorderRadius.circular(5), shape: BoxShape.rectangle, color: Colors.white),
  287. padding: EdgeInsets.all(10),
  288. child:
  289. Align(
  290. alignment: Alignment.centerLeft,
  291. child: Text(
  292. nama_kabupaten,
  293. style: GoogleFonts.inconsolata(
  294. fontSize: 16, fontWeight: FontWeight.bold, ),
  295. ),
  296. ),
  297. ),
  298. ],
  299. ),
  300. ),
  301. Container(
  302. margin: EdgeInsets.only(left: 10, right: 10, top: 15),
  303. child: Column(
  304. children: [
  305. Align(
  306. alignment: Alignment.centerLeft,
  307. child: Text(
  308. 'Provinsi',
  309. style: GoogleFonts.inconsolata(
  310. fontSize: 16, fontWeight: FontWeight.bold, ),
  311. ),
  312. ),
  313. Container(
  314. width: size.width,
  315. decoration: BoxDecoration(borderRadius: BorderRadius.circular(5), shape: BoxShape.rectangle, color: Colors.white),
  316. padding: EdgeInsets.all(10),
  317. child:
  318. Align(
  319. alignment: Alignment.centerLeft,
  320. child: Text(
  321. nama_provinsi,
  322. style: GoogleFonts.inconsolata(
  323. fontSize: 16, fontWeight: FontWeight.bold, ),
  324. ),
  325. ),
  326. ),
  327. ],
  328. ),
  329. ),
  330. Container(
  331. margin: EdgeInsets.only(left: 10, right: 10, top: 15),
  332. child: Column(
  333. children: [
  334. Align(
  335. alignment: Alignment.centerLeft,
  336. child: Text(
  337. 'Jumlah Penduduk',
  338. style: GoogleFonts.inconsolata(
  339. fontSize: 16, fontWeight: FontWeight.bold, ),
  340. ),
  341. ),
  342. Container(
  343. width: size.width,
  344. decoration: BoxDecoration(borderRadius: BorderRadius.circular(5), shape: BoxShape.rectangle, color: Colors.white),
  345. padding: EdgeInsets.all(10),
  346. child:
  347. Align(
  348. alignment: Alignment.centerLeft,
  349. child: Text(
  350. jumlah_penduduk.toString(),
  351. style: GoogleFonts.inconsolata(
  352. fontSize: 16, fontWeight: FontWeight.bold, ),
  353. ),
  354. ),
  355. ),
  356. ],
  357. ),
  358. ),
  359. Container(
  360. margin: EdgeInsets.only(left: 10, right: 10, top: 15),
  361. child: Column(
  362. children: [
  363. Align(
  364. alignment: Alignment.centerLeft,
  365. child: Text(
  366. 'Posisi',
  367. style: GoogleFonts.inconsolata(
  368. fontSize: 16, fontWeight: FontWeight.bold),
  369. )),
  370. Container(
  371. height: size.height*0.4,
  372. width: size.width,
  373. margin: EdgeInsets.only(top: 2),
  374. decoration: BoxDecoration(
  375. borderRadius: BorderRadius.circular(5)
  376. ),
  377. child: Stack(
  378. children:[
  379. FlutterMap(
  380. mapController: _mapController,
  381. options: new MapOptions(
  382. onTap: (p, point) async {}, center: point, zoom: 15),
  383. children: [
  384. TileLayer(
  385. minZoom: 1,
  386. maxZoom: 22,
  387. maxNativeZoom: 18,
  388. minNativeZoom: 1,
  389. backgroundColor: Colors.black54,
  390. urlTemplate: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
  391. subdomains: ['a', 'b', 'c'],
  392. ),
  393. MarkerLayer(markers: [
  394. Marker(
  395. width: 135,
  396. height: 135,
  397. point: point,
  398. builder: (ctx) => Container(
  399. child: Icon(
  400. Icons.location_on,
  401. color: Colors.red,
  402. ),
  403. ))
  404. ])
  405. ],
  406. ),
  407. /*Container(
  408. alignment: AlignmentDirectional.bottomEnd,
  409. child: Container(
  410. margin: EdgeInsets.only(bottom: 10),
  411. *//*margin: EdgeInsets.fromLTRB(10, 15, 0, (size.height*0.4) + 15),*//*
  412. child: RawMaterialButton(
  413. onPressed: () {
  414. setState(() {
  415. updatePosition();
  416. });
  417. },
  418. elevation: 5.0,
  419. fillColor: Colors.white,
  420. child: Image.asset('assets/images/location1.png',
  421. height: 35, width: 35),
  422. padding: EdgeInsets.all(5.0),
  423. shape: CircleBorder(),
  424. ),
  425. ),
  426. ),*/]
  427. )
  428. ),
  429. ],
  430. ),
  431. ),
  432. Container(
  433. margin: EdgeInsets.only(
  434. left: 10, right: 10, top: 5),
  435. child:Align(
  436. alignment: Alignment.center,
  437. child: Text(
  438. posisi,
  439. overflow: TextOverflow.fade,
  440. softWrap: true,
  441. style: GoogleFonts.inconsolata(
  442. fontSize: 16, fontWeight: FontWeight.bold),
  443. )
  444. )
  445. ),
  446. Container(
  447. margin: EdgeInsets.only(left: 10, right: 10, top: 15),
  448. child: Column(
  449. children: [
  450. Align(
  451. alignment: Alignment.centerLeft,
  452. child: Text(
  453. 'Signal 2G (dBm)',
  454. style: GoogleFonts.inconsolata(
  455. fontSize: 16, fontWeight: FontWeight.bold, ),
  456. ),
  457. ),
  458. Container(
  459. width: size.width,
  460. decoration: BoxDecoration(borderRadius: BorderRadius.circular(5), shape: BoxShape.rectangle, color: Colors.white),
  461. padding: EdgeInsets.all(10),
  462. child:
  463. Align(
  464. alignment: Alignment.centerLeft,
  465. child: Text(
  466. signal2G,
  467. style: GoogleFonts.inconsolata(
  468. fontSize: 16, fontWeight: FontWeight.bold, ),
  469. ),
  470. ),
  471. ),
  472. ],
  473. ),
  474. ),
  475. Container(
  476. margin: EdgeInsets.only(left: 10, right: 10, top: 15),
  477. child: Column(
  478. children: [
  479. Align(
  480. alignment: Alignment.centerLeft,
  481. child: Text(
  482. 'Signal 3G (dBm)',
  483. style: GoogleFonts.inconsolata(
  484. fontSize: 16, fontWeight: FontWeight.bold, ),
  485. ),
  486. ),
  487. Container(
  488. width: size.width,
  489. decoration: BoxDecoration(borderRadius: BorderRadius.circular(5), shape: BoxShape.rectangle, color: Colors.white),
  490. padding: EdgeInsets.all(10),
  491. child:
  492. Align(
  493. alignment: Alignment.centerLeft,
  494. child: Text(
  495. signal3G,
  496. style: GoogleFonts.inconsolata(
  497. fontSize: 16, fontWeight: FontWeight.bold, ),
  498. ),
  499. ),
  500. ),
  501. ],
  502. ),
  503. ),
  504. Container(
  505. margin: EdgeInsets.only(left: 10, right: 10, top: 15),
  506. child: Column(
  507. children: [
  508. Align(
  509. alignment: Alignment.centerLeft,
  510. child: Text(
  511. 'Signal 4G (dBm)',
  512. style: GoogleFonts.inconsolata(
  513. fontSize: 16, fontWeight: FontWeight.bold, ),
  514. ),
  515. ),
  516. Container(
  517. width: size.width,
  518. decoration: BoxDecoration(borderRadius: BorderRadius.circular(5), shape: BoxShape.rectangle, color: Colors.white),
  519. padding: EdgeInsets.all(10),
  520. child:
  521. Align(
  522. alignment: Alignment.centerLeft,
  523. child: Text(
  524. signal4G,
  525. style: GoogleFonts.inconsolata(
  526. fontSize: 16, fontWeight: FontWeight.bold, ),
  527. ),
  528. ),
  529. ),
  530. ],
  531. ),
  532. ),
  533. Container(
  534. margin: EdgeInsets.only(left: 10, right: 10, top: 15),
  535. child: Column(
  536. children: [
  537. Align(
  538. alignment: Alignment.centerLeft,
  539. child: Text(
  540. 'Tempat Keramaian (Contoh: Sekolah, Pasar, dll)',
  541. style: GoogleFonts.inconsolata(
  542. fontSize: 16, fontWeight: FontWeight.bold),
  543. ),
  544. ),
  545. ListView.builder(
  546. shrinkWrap: true,
  547. itemCount: _jenisTempat.length,
  548. itemBuilder: (context, i) {
  549. return Padding(
  550. padding: const EdgeInsets.only(top: 2),
  551. child: Row(
  552. children: [
  553. Expanded(
  554. flex: 7,
  555. child: Container(
  556. padding: const EdgeInsets.symmetric(horizontal: 10),
  557. //height: 60,
  558. alignment: Alignment.center,
  559. decoration: BoxDecoration(
  560. color: Colors.white,
  561. borderRadius: BorderRadius.circular(5),
  562. ),
  563. child: TextFormField(
  564. controller: _jenisTempat[i],
  565. autofocus: false,
  566. style: const TextStyle(color: Colors.black),
  567. decoration: const InputDecoration(
  568. border: InputBorder.none,
  569. hintText: "Jenis Tempat",
  570. hintStyle: TextStyle(
  571. color: Color.fromARGB(255, 132, 140, 155)),
  572. ),
  573. ),
  574. ),
  575. ),
  576. SizedBox(width: 5),
  577. Expanded(
  578. flex: 3,
  579. child: Container(
  580. padding: const EdgeInsets.symmetric(horizontal: 10),
  581. //height: 60,
  582. alignment: Alignment.center,
  583. decoration: BoxDecoration(
  584. color: Colors.white,
  585. borderRadius: BorderRadius.circular(5),
  586. ),
  587. child: TextFormField(
  588. controller: _km[i],
  589. autofocus: false,
  590. style: const TextStyle(color: Colors.black),
  591. decoration: const InputDecoration(
  592. border: InputBorder.none,
  593. hintText: "KM",
  594. hintStyle: TextStyle(
  595. color: Color.fromARGB(255, 132, 140, 155)),
  596. ),
  597. ),
  598. ),
  599. ),
  600. /* i != 0
  601. ? GestureDetector(
  602. onTap: (){
  603. setState(() {
  604. _removeItemTempat(i);
  605. });
  606. },
  607. child: const Icon(
  608. Icons.delete,
  609. color: Color(0xFF6B74D6),
  610. size: 40,
  611. ),
  612. )
  613. : const SizedBox()*/
  614. ],
  615. ),
  616. );
  617. },
  618. ),
  619. const SizedBox(
  620. height: 10,
  621. ),
  622. /*GestureDetector(
  623. onTap: () {
  624. setState(() {
  625. _addFieldTempat();
  626. });
  627. },
  628. child: Center(
  629. child: Container(
  630. width: size.width,
  631. padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10),
  632. decoration: BoxDecoration(
  633. color: Colors.blueAccent,
  634. borderRadius: BorderRadius.circular(5)),
  635. child: Align(
  636. alignment: Alignment.center,
  637. child: Text("Tambah Data Tempat+",
  638. style:
  639. GoogleFonts.nunito(color: const Color(0xFFF8F8FF))),
  640. ),
  641. ),
  642. ),
  643. ),*/
  644. ],
  645. ),
  646. ),
  647. Container(
  648. margin: EdgeInsets.only(left: 10, right: 10, top: 15),
  649. child: Column(
  650. children: [
  651. Align(
  652. alignment: Alignment.centerLeft,
  653. child: Text(
  654. 'Catatan',
  655. style: GoogleFonts.inconsolata(
  656. fontSize: 16, fontWeight: FontWeight.bold, ),
  657. ),
  658. ),
  659. Container(
  660. width: size.width,
  661. decoration: BoxDecoration(borderRadius: BorderRadius.circular(5), shape: BoxShape.rectangle, color: Colors.white),
  662. padding: EdgeInsets.all(10),
  663. child:
  664. Align(
  665. alignment: Alignment.centerLeft,
  666. child: Text(
  667. catatan,
  668. style: GoogleFonts.inconsolata(
  669. fontSize: 16, fontWeight: FontWeight.bold, ),
  670. ),
  671. ),
  672. ),
  673. ],
  674. ),
  675. ),
  676. Container(
  677. margin: EdgeInsets.only(left: 10, right: 10, top: 15, bottom: 15),
  678. child: Column(
  679. children: [
  680. Align(
  681. alignment: Alignment.centerLeft,
  682. child: Text(
  683. 'Foto',
  684. style: GoogleFonts.inconsolata(
  685. fontSize: 16,
  686. fontWeight: FontWeight.bold,
  687. ),
  688. ),
  689. ),
  690. ListView.builder(
  691. shrinkWrap: true,
  692. itemCount: _ambilFoto.length,
  693. itemBuilder: (context, i) {
  694. return Padding(
  695. padding: const EdgeInsets.only(top: 2),
  696. child: Row(
  697. crossAxisAlignment: CrossAxisAlignment.start,
  698. children: [
  699. Expanded(
  700. child:
  701. Column(
  702. children:[
  703. Visibility (
  704. child: Align(
  705. alignment: Alignment.centerLeft,
  706. child:
  707. InkWell(
  708. child: Container(
  709. padding: EdgeInsets.all(5),
  710. //width: size.width * 0.5,
  711. decoration: BoxDecoration(
  712. borderRadius: BorderRadius.circular(5),
  713. gradient: LinearGradient(
  714. colors: [
  715. Colors.redAccent,
  716. Colors.redAccent
  717. ],
  718. ),
  719. ),
  720. child: Row(
  721. mainAxisAlignment: MainAxisAlignment.center,
  722. children: [
  723. Text(
  724. "Ambil Foto\t\t",
  725. textAlign: TextAlign.center,
  726. style: TextStyle(
  727. color: Colors.white,
  728. //fontSize: 17,
  729. fontWeight: FontWeight.w500,
  730. ),
  731. ),
  732. const Icon(
  733. Icons.camera_alt,
  734. //color: Color(0xFF6B74D6),
  735. size: 25,
  736. ),
  737. ],
  738. ),
  739. ),
  740. onTap: () async {
  741. final ImagePicker _picker = ImagePicker();
  742. final XFile? imagePicked = await _picker.pickImage(
  743. source: ImageSource.camera);
  744. if (imagePicked != null) {
  745. _imagePath = File(imagePicked.path);
  746. logDev.log(_imagePath.toString(), name: "IMAGE PATH");
  747. List<int> imageBytes = _imagePath!.readAsBytesSync();
  748. String base64Image = base64Encode(imageBytes);
  749. //logDev.log(base64Image, name: "String base64");
  750. setState(() {
  751. logDev.log(_ambilFoto.length.toString(), name: "ada berapa banyak buttonambil foto");
  752. _pathFoto[i] = path.basename(_imagePath.toString());
  753. _base64Foto[i] = base64Image;
  754. logDev.log(_pathFoto.length.toString(), name: "Banyak path foto");
  755. logDev.log(_base64Foto.length.toString(), name: "Banyak Base64");
  756. logDev.log(_pathFoto.toString(), name: "Isi Path FOTO");
  757. });
  758. } else if (imagePicked == null) {
  759. //_imagePath = await getImageFileFromAssets('assets/images/ic_administrator.png') as File?;
  760. }
  761. },
  762. ),
  763. ),
  764. ),
  765. Visibility(
  766. child: Align(
  767. alignment: Alignment.centerLeft,
  768. child:
  769. FittedBox(
  770. fit: BoxFit.scaleDown, // Sesuaikan teks agar tidak melebihi lebar container
  771. child: Text(
  772. _pathFoto[i]
  773. /*style: TextStyle(fontSize: size.width),*/
  774. ),
  775. ),
  776. )
  777. ),
  778. ]
  779. )
  780. ),
  781. /*GestureDetector(
  782. onTap: () {
  783. setState(() {
  784. _removeItemFoto(i);
  785. logDev.log(_pathFoto.length.toString(), name: "Banyak path foto");
  786. logDev.log(_pathFoto.toString(), name: "Isi Path FOTO");
  787. });
  788. },
  789. child:
  790. const Icon(
  791. Icons.delete,
  792. color: Color(0xFF6B74D6),
  793. size: 40,
  794. )
  795. )*/
  796. ],
  797. ),
  798. );
  799. },
  800. ),
  801. const SizedBox(
  802. height: 5,
  803. ),
  804. /*GestureDetector(
  805. onTap: () {
  806. setState(() {
  807. _addFieldFoto();
  808. });
  809. },
  810. child: Center(
  811. child: Container(
  812. width: MediaQuery.of(context).size.width,
  813. padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10),
  814. decoration: BoxDecoration(
  815. color: Colors.blueAccent,
  816. borderRadius: BorderRadius.circular(5),
  817. ),
  818. child: Align(
  819. alignment: Alignment.center,
  820. child: Text(
  821. "Tambah Foto+",
  822. style: GoogleFonts.nunito(
  823. color: const Color(0xFFF8F8FF),
  824. ),
  825. ),
  826. ),
  827. ),
  828. ),
  829. ),*/
  830. ],
  831. ),
  832. ),
  833. ],
  834. ),
  835. ),
  836. ),
  837. ),
  838. ],
  839. ),
  840. ),
  841. ),
  842. ],
  843. ),
  844. ],
  845. )),
  846. );
  847. }
  848. //Validasi Form Survey
  849. bool validateFormSurvey(BuildContext context) {
  850. bool result = true;
  851. if (nama_desa == "" && visibleFormDesa == false) {
  852. Fluttertoast.showToast(
  853. msg: "Nama Desa Harus Diisi!",
  854. toastLength: Toast.LENGTH_SHORT,
  855. gravity: ToastGravity.CENTER,
  856. timeInSecForIosWeb: 1,
  857. textColor: Colors.white,
  858. fontSize: 16.0);
  859. result = false;
  860. } else if (visibleFormDesa == true){
  861. Fluttertoast.showToast(
  862. msg: "Mohon Konfirmasi Data Desa Terlebih Dahulu!",
  863. toastLength: Toast.LENGTH_SHORT,
  864. gravity: ToastGravity.CENTER,
  865. timeInSecForIosWeb: 1,
  866. textColor: Colors.white,
  867. fontSize: 16.0);
  868. result = false;
  869. } else if (nama_kecamatan == "" && visibleFormKecamatan == false) {
  870. Fluttertoast.showToast(
  871. msg: "Nama Kecamatan Harus Diisi!",
  872. toastLength: Toast.LENGTH_SHORT,
  873. gravity: ToastGravity.CENTER,
  874. timeInSecForIosWeb: 1,
  875. textColor: Colors.white,
  876. fontSize: 16.0);
  877. result = false;
  878. } else if (visibleFormKecamatan == true){
  879. Fluttertoast.showToast(
  880. msg: "Mohon Konfirmasi Data Kecamatan Terlebih Dahulu!",
  881. toastLength: Toast.LENGTH_SHORT,
  882. gravity: ToastGravity.CENTER,
  883. timeInSecForIosWeb: 1,
  884. textColor: Colors.white,
  885. fontSize: 16.0);
  886. result = false;
  887. } else if (nama_kabupaten == "" && visibleFormKabupaten == false) {
  888. Fluttertoast.showToast(
  889. msg: "Nama Kabupaten Harus Diisi!",
  890. toastLength: Toast.LENGTH_SHORT,
  891. gravity: ToastGravity.CENTER,
  892. timeInSecForIosWeb: 1,
  893. textColor: Colors.white,
  894. fontSize: 16.0);
  895. result = false;
  896. } else if (visibleFormKabupaten == true){
  897. Fluttertoast.showToast(
  898. msg: "Mohon Konfirmasi Data Kabupaten Terlebih Dahulu!",
  899. toastLength: Toast.LENGTH_SHORT,
  900. gravity: ToastGravity.CENTER,
  901. timeInSecForIosWeb: 1,
  902. textColor: Colors.white,
  903. fontSize: 16.0);
  904. result = false;
  905. } else if (nama_provinsi == "" && visibleFormProvinsi == false) {
  906. Fluttertoast.showToast(
  907. msg: "Nama Provinsi Harus Diisi!",
  908. toastLength: Toast.LENGTH_SHORT,
  909. gravity: ToastGravity.CENTER,
  910. timeInSecForIosWeb: 1,
  911. textColor: Colors.white,
  912. fontSize: 16.0);
  913. result = false;
  914. } else if (visibleFormProvinsi == true){
  915. Fluttertoast.showToast(
  916. msg: "Mohon Konfirmasi Data Provinsi Terlebih Dahulu!",
  917. toastLength: Toast.LENGTH_SHORT,
  918. gravity: ToastGravity.CENTER,
  919. timeInSecForIosWeb: 1,
  920. textColor: Colors.white,
  921. fontSize: 16.0);
  922. result = false;
  923. } else if (isiJumlahPendudukTeksController.text.toString().isEmpty) {
  924. Fluttertoast.showToast(
  925. msg: "Jumlah Penduduk Harus Diisi!",
  926. toastLength: Toast.LENGTH_SHORT,
  927. gravity: ToastGravity.CENTER,
  928. timeInSecForIosWeb: 1,
  929. textColor: Colors.white,
  930. fontSize: 16.0);
  931. result = false;
  932. } else if (isiSignal2TeksController.text.toString().isEmpty) {
  933. Fluttertoast.showToast(
  934. msg: "Signal 2G Harus Diisi!",
  935. toastLength: Toast.LENGTH_SHORT,
  936. gravity: ToastGravity.CENTER,
  937. timeInSecForIosWeb: 1,
  938. textColor: Colors.white,
  939. fontSize: 16.0);
  940. result = false;
  941. } else if (isiSignal3TeksController.text.toString().isEmpty) {
  942. Fluttertoast.showToast(
  943. msg: "Signal 3G Harus Diisi!",
  944. toastLength: Toast.LENGTH_SHORT,
  945. gravity: ToastGravity.CENTER,
  946. timeInSecForIosWeb: 1,
  947. textColor: Colors.white,
  948. fontSize: 16.0);
  949. result = false;
  950. } else if (isiSignal4TeksController.text.toString().isEmpty) {
  951. Fluttertoast.showToast(
  952. msg: "Signal 4G Harus Diisi!",
  953. toastLength: Toast.LENGTH_SHORT,
  954. gravity: ToastGravity.CENTER,
  955. timeInSecForIosWeb: 1,
  956. textColor: Colors.white,
  957. fontSize: 16.0);
  958. result = false;
  959. } else if (_jenisTempat[0].text.toString().isEmpty){
  960. Fluttertoast.showToast(
  961. msg: "Tempat Keramaian Harus Diisi!",
  962. toastLength: Toast.LENGTH_SHORT,
  963. gravity: ToastGravity.CENTER,
  964. timeInSecForIosWeb: 1,
  965. textColor: Colors.white,
  966. fontSize: 16.0);
  967. result = false;
  968. } else if (_km[0].text.toString().isEmpty){
  969. Fluttertoast.showToast(
  970. msg: "Tempat Keramaian Harus Diisi!",
  971. toastLength: Toast.LENGTH_SHORT,
  972. gravity: ToastGravity.CENTER,
  973. timeInSecForIosWeb: 1,
  974. textColor: Colors.white,
  975. fontSize: 16.0);
  976. result = false;
  977. } else if (isiCatatanTeksController.text.toString().isEmpty) {
  978. Fluttertoast.showToast(
  979. msg: "Catatan Harus Diisi!",
  980. toastLength: Toast.LENGTH_SHORT,
  981. gravity: ToastGravity.CENTER,
  982. timeInSecForIosWeb: 1,
  983. textColor: Colors.white,
  984. fontSize: 16.0);
  985. result = false;
  986. }
  987. return result;
  988. }
  989. }
  990. alertDialogFailedRetrievedData(BuildContext context){
  991. Widget okButton = TextButton(
  992. child: Text("Refresh"),
  993. onPressed: () {
  994. Navigator.of(context, rootNavigator: true).pop();
  995. Navigator.pushReplacement(context, MaterialPageRoute(
  996. builder: (context) => DetailSurveyScreen()));
  997. },
  998. );
  999. Widget noButton = TextButton(
  1000. child: Text("Back"),
  1001. onPressed: () {
  1002. Navigator.of(context, rootNavigator: true).pop();
  1003. Navigator.pop(context);
  1004. },
  1005. );
  1006. // set up the AlertDialog
  1007. AlertDialog alert = AlertDialog(
  1008. title: Text("Tower Application"),
  1009. content: Text("Failed to Retrieve Data"),
  1010. actions: [
  1011. noButton,
  1012. okButton,
  1013. ],
  1014. );
  1015. // show the dialog
  1016. showDialog(
  1017. context: context,
  1018. barrierDismissible: false,
  1019. builder: (BuildContext context) {
  1020. return alert;
  1021. },
  1022. );
  1023. }
  1024. alertDialogFailedResponse(BuildContext context){
  1025. Widget okButton = TextButton(
  1026. child: Text("Refresh"),
  1027. onPressed: () {
  1028. Navigator.of(context, rootNavigator: true).pop();
  1029. Navigator.pushReplacement(context, MaterialPageRoute(
  1030. builder: (context) => DetailSurveyScreen()));
  1031. },
  1032. );
  1033. Widget noButton = TextButton(
  1034. child: Text("Back"),
  1035. onPressed: () {
  1036. Navigator.of(context, rootNavigator: true).pop();
  1037. Navigator.pop(context);
  1038. },
  1039. );
  1040. // set up the AlertDialog
  1041. AlertDialog alert = AlertDialog(
  1042. title: Text("Tower Application"),
  1043. content: Text("Server Response Error"),
  1044. actions: [
  1045. noButton,
  1046. okButton,
  1047. ],
  1048. );
  1049. // show the dialog
  1050. showDialog(
  1051. context: context,
  1052. barrierDismissible: false,
  1053. builder: (BuildContext context) {
  1054. return alert;
  1055. },
  1056. );
  1057. }