Nav apraksta
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

editsurvey_screen.dart 103KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787
  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/sendSurvey_post.dart';
  15. import 'package:tower_app/Screens/Menu/Survey/surveylist_screen.dart';
  16. import 'dart:developer' as logDev;
  17. import '../../background.dart';
  18. import '../Canvasing/canvasingDetail_screen.dart';
  19. TextEditingController isiDesaTeksController = TextEditingController();
  20. TextEditingController isiKecamatanTeksController = TextEditingController();
  21. TextEditingController isiKabupatenTeksController = TextEditingController();
  22. TextEditingController isiProvinsiTeksController = TextEditingController();
  23. TextEditingController isiJumlahPendudukTeksController = TextEditingController();
  24. TextEditingController isiSignal2TeksController = TextEditingController();
  25. TextEditingController isiSignal3TeksController = TextEditingController();
  26. TextEditingController isiSignal4TeksController = TextEditingController();
  27. TextEditingController isiCatatanTeksController = TextEditingController();
  28. class EditSurveyScreen extends StatefulWidget {
  29. const EditSurveyScreen({Key? key}) : super(key: key);
  30. @override
  31. State<EditSurveyScreen> createState() => _EditSurveyScreen();
  32. }
  33. class _EditSurveyScreen extends State<EditSurveyScreen> {
  34. bool visibleNamaDesa = true;
  35. bool visibleEditDesa = true;
  36. bool visibleFormDesa = false;
  37. bool visibleNamaKecamatan = true;
  38. bool visibleEditKecamatan = true;
  39. bool visibleFormKecamatan = false;
  40. bool visibleNamaKabupaten = true;
  41. bool visibleEditKabupaten = true;
  42. bool visibleFormKabupaten = false;
  43. bool visibleNamaProvinsi = true;
  44. bool visibleEditProvinsi = true;
  45. bool visibleFormProvinsi = false;
  46. final List<TextEditingController> _jenisTempat = [];
  47. final List<TextEditingController> _km = [];
  48. final List<InkWell> _ambilFoto = [];
  49. File? _imagePath;
  50. final List<TextEditingController> _keteranganFoto = [];
  51. final List<String> _pathFoto = [];
  52. final List<String> _base64Foto = [];
  53. latlong.LatLng point = latlong.LatLng(-6.183580253674716, 106.93103973792664);
  54. late Position position;
  55. MapController _mapController = MapController();
  56. late String titik;
  57. late String survey_name;
  58. late String nama_desa, nama_kecamatan, nama_kabupaten, nama_provinsi;
  59. initState(){
  60. isiDesaTeksController.clear();
  61. isiKecamatanTeksController.clear();
  62. isiKabupatenTeksController.clear();
  63. isiProvinsiTeksController.clear();
  64. isiJumlahPendudukTeksController.clear();
  65. isiSignal2TeksController.clear();
  66. isiSignal3TeksController.clear();
  67. isiSignal4TeksController.clear();
  68. isiCatatanTeksController.clear();
  69. survey_name = "Survey";
  70. nama_desa = "";
  71. nama_kecamatan = "";
  72. nama_kabupaten = "";
  73. nama_provinsi = "";
  74. titik = "";
  75. WidgetsBinding.instance.addPostFrameCallback((_) {
  76. getSurveyName();
  77. _addFieldTempat();
  78. });
  79. super.initState();
  80. }
  81. _addFieldTempat(){
  82. setState(() {
  83. _jenisTempat.add(TextEditingController());
  84. _km.add(TextEditingController());
  85. });
  86. }
  87. _removeItemTempat(i){
  88. setState(() {
  89. _jenisTempat.removeAt(i);
  90. _km.removeAt(i);
  91. });
  92. }
  93. _addFieldFoto(){
  94. setState(() {
  95. _ambilFoto.add(InkWell());
  96. _pathFoto.add(" ");
  97. _base64Foto.add(" ");
  98. _keteranganFoto.add(TextEditingController());
  99. });
  100. }
  101. _removeItemFoto(i){
  102. setState(() {
  103. _ambilFoto.removeAt(i);
  104. _pathFoto.removeAt(i);
  105. _base64Foto.removeAt(i);
  106. _keteranganFoto.removeAt(i);
  107. });
  108. }
  109. /*Timer? timer;
  110. void initTimer(){
  111. if (timer != null && timer!.isActive) return;
  112. timer = Timer.periodic(Duration(seconds: 10), (timer) {
  113. setState(() {
  114. updatePosition();
  115. });
  116. });
  117. }
  118. @override
  119. void dispose() {
  120. timer?.cancel();
  121. super.dispose();
  122. }*/
  123. getSurveyName() async {
  124. ProgressDialog loading = ProgressDialog(context);
  125. loading = ProgressDialog(context, type: ProgressDialogType.normal, isDismissible: false, showLogs: true);
  126. loading.style(
  127. message: 'Please Wait .....',
  128. borderRadius: 3,
  129. backgroundColor: Colors.white,
  130. progressWidget: CircularProgressIndicator(),
  131. elevation: 10.0,
  132. padding: EdgeInsets.all(10),
  133. insetAnimCurve: Curves.easeInOut,
  134. progress: 0.0,
  135. maxProgress: 100.0,
  136. progressTextStyle: TextStyle(color: Colors.black, fontSize: 10.0, fontWeight: FontWeight.w400),
  137. messageTextStyle: TextStyle(color: Colors.black, fontSize: 15.0, fontWeight: FontWeight.w600));
  138. await loading.show();
  139. final SharedPreferences prefs = await SharedPreferences.getInstance();
  140. survey_name = prefs.getString('nameDetail')!;
  141. logDev.log(survey_name, name: "Nama Survey");
  142. determinePosition();
  143. }
  144. determinePosition() async {
  145. StreamSubscription<ServiceStatus> serviceStatusStream = Geolocator.getServiceStatusStream().listen(
  146. (ServiceStatus status) {
  147. print(status);
  148. });
  149. ProgressDialog loading = ProgressDialog(context);
  150. loading = ProgressDialog(context, type: ProgressDialogType.normal, isDismissible: false, showLogs: true);
  151. loading.style(
  152. message: 'Please Wait .....',
  153. borderRadius: 3,
  154. backgroundColor: Colors.white,
  155. progressWidget: CircularProgressIndicator(),
  156. elevation: 10.0,
  157. padding: EdgeInsets.all(10),
  158. insetAnimCurve: Curves.easeInOut,
  159. progress: 0.0,
  160. maxProgress: 100.0,
  161. progressTextStyle: TextStyle(color: Colors.black, fontSize: 10.0, fontWeight: FontWeight.w400),
  162. messageTextStyle: TextStyle(color: Colors.black, fontSize: 15.0, fontWeight: FontWeight.w600));
  163. bool serviceEnabled = await Geolocator.isLocationServiceEnabled();
  164. logDev.log(serviceEnabled.toString(), name: "ON/OFF LOCATION SERVICE");
  165. if (!serviceEnabled) {
  166. return Future.error('Location services are disabled.');
  167. }
  168. LocationPermission permission = await Geolocator.checkPermission();
  169. if (permission == LocationPermission.deniedForever) {
  170. await loading.hide();
  171. //return Future.error('Location permissions are permanently denied, we cannot request permissions.');
  172. return alertDialogPermissionDeniedForever(context);
  173. } else if (permission == LocationPermission.denied) {
  174. permission = await Geolocator.requestPermission();
  175. if (permission != LocationPermission.whileInUse && permission != LocationPermission.always) {
  176. await loading.hide();
  177. //return Future.error('Location permissions are denied (actual value: $permission).');
  178. return alertDialogPermissionDenied(context);
  179. }
  180. }
  181. position = await Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
  182. logDev.log(position.toString(), name: "Position GEOLOCATOR");
  183. if (position.isMocked) {
  184. await loading.hide();
  185. setState(() {
  186. alertDialogFakeGPSDetected(context);
  187. });
  188. } else {
  189. setState(() {
  190. point = latlong.LatLng(position.latitude, position.longitude);
  191. logDev.log(point.toString(), name: "POINT GEOLOCATOR");
  192. _mapController.move(point, 18);
  193. titik = position.latitude.toString() + "," + position.longitude.toString();
  194. });
  195. }
  196. logDev.log("DAH SELESE BUILD NAVIGATENYA!", name: "UDAH?");
  197. await loading.hide();
  198. //initTimer();
  199. }
  200. Future<void> updatePosition() async {
  201. logDev.log("NAH BARU MULAI!", name: "MULAI?");
  202. ProgressDialog loading = ProgressDialog(context);
  203. loading = ProgressDialog(context,
  204. type: ProgressDialogType.normal, isDismissible: false, showLogs: true);
  205. loading.style(
  206. message: 'Please Wait .....',
  207. borderRadius: 3,
  208. backgroundColor: Colors.white,
  209. progressWidget: CircularProgressIndicator(),
  210. elevation: 10.0,
  211. padding: EdgeInsets.all(10),
  212. insetAnimCurve: Curves.easeInOut,
  213. progress: 0.0,
  214. maxProgress: 100.0,
  215. progressTextStyle: TextStyle(
  216. color: Colors.black, fontSize: 10.0, fontWeight: FontWeight.w400),
  217. messageTextStyle: TextStyle(
  218. color: Colors.black, fontSize: 15.0, fontWeight: FontWeight.w600));
  219. bool serviceEnabled;
  220. LocationPermission permission;
  221. serviceEnabled = await Geolocator.isLocationServiceEnabled();
  222. if (!serviceEnabled) {
  223. await loading.hide();
  224. return Future.error('Location services are disabled.');
  225. }
  226. permission = await Geolocator.checkPermission();
  227. if (permission == LocationPermission.deniedForever) {
  228. await loading.hide();
  229. return alertDialogPermissionDeniedForever(context);
  230. } else if (permission == LocationPermission.denied) {
  231. permission = await Geolocator.requestPermission();
  232. if (permission != LocationPermission.whileInUse && permission != LocationPermission.always) {
  233. await loading.hide();
  234. return alertDialogPermissionDenied(context);
  235. }
  236. }
  237. position = await Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
  238. if (position.isMocked) {
  239. await loading.hide();
  240. setState(() {
  241. alertDialogFakeGPSDetected(context);
  242. });
  243. } else {
  244. await loading.hide();
  245. point = latlong.LatLng(position.latitude, position.longitude);
  246. logDev.log(point.toString(), name: "UPDATE POINT GEOLOCATOR");
  247. _mapController.move(point, 18);
  248. position = await Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
  249. String titik = position.latitude.toString() + "," + position.longitude.toString();
  250. logDev.log(titik, name: "TITIK UPDATE");
  251. setState(() async {
  252. if (position.isMocked) {
  253. await loading.hide();
  254. setState(() {
  255. alertDialogFakeGPSDetected(context);
  256. });
  257. } else {
  258. setState(() {
  259. point = latlong.LatLng(position.latitude, position.longitude);
  260. logDev.log(point.toString(), name: "POINT GEOLOCATOR");
  261. _mapController.move(point, 18);
  262. titik = position.latitude.toString() + "," + position.longitude.toString();
  263. });
  264. }
  265. });
  266. }
  267. }
  268. @override
  269. Widget build(BuildContext context) {
  270. var size = MediaQuery.sizeOf(context);
  271. return Scaffold(
  272. body: SingleChildScrollView(
  273. child: Column(
  274. children: <Widget>[
  275. Stack(
  276. children: [
  277. WavyHeader(),
  278. Container(
  279. margin: EdgeInsets.only(top: MediaQuery.of(context).size.height/6 - 20),
  280. padding: EdgeInsets.fromLTRB(20, 5, 25, 5),
  281. child: Row(
  282. mainAxisAlignment: MainAxisAlignment.end,
  283. crossAxisAlignment: CrossAxisAlignment.end,
  284. children: [
  285. Text(
  286. //'Survey\t\t',
  287. "Edit Survey\t\t",
  288. maxLines: 2,
  289. style: GoogleFonts.luckiestGuy(
  290. fontSize: 28,
  291. color: Color(0xFF4858A7),
  292. fontStyle: FontStyle.italic,
  293. ),
  294. ),
  295. Image.asset("assets/icons/menu/survey_3.png",
  296. width: 40,
  297. height: 40,
  298. ),
  299. ],
  300. )),
  301. SafeArea(
  302. child: Container(
  303. width: MediaQuery.of(context).size.width,
  304. margin: EdgeInsets.only(
  305. top: MediaQuery.of(context).size.height / 5,
  306. left: 10,
  307. right: 10,
  308. bottom : 15,
  309. ),
  310. child: Column(
  311. children: [
  312. Container(
  313. child: Card(
  314. elevation: 10,
  315. child: Container(
  316. decoration: BoxDecoration(
  317. color: Color(0XFFFAF7EE),
  318. borderRadius: BorderRadius.circular(10)),
  319. child: Column(
  320. children: [
  321. Container(
  322. margin: EdgeInsets.only(
  323. left: 10, right: 10, top: 15, bottom: 10),
  324. child: Text(survey_name, style:
  325. GoogleFonts.ubuntu(fontSize: 19, fontWeight: FontWeight.bold, /*decoration: TextDecoration.underline*/
  326. decorationStyle: TextDecorationStyle.dashed),),
  327. ),
  328. Container(
  329. margin: EdgeInsets.only(left: 10, right: 10, top: 15),
  330. child: Column(
  331. children: [
  332. Container(
  333. width: size.width,
  334. child:
  335. Row (
  336. children: [
  337. Align(
  338. alignment: Alignment.centerLeft,
  339. child: Text(
  340. 'Desa',
  341. style: GoogleFonts.inconsolata(
  342. fontSize: 16, fontWeight: FontWeight.bold, ),
  343. ),
  344. ),
  345. SizedBox(width: 15),
  346. Align(
  347. alignment: Alignment.centerLeft,
  348. child: Visibility(
  349. visible: visibleEditDesa,
  350. child:
  351. InkWell(
  352. child: Container(
  353. width: 25,
  354. height: 25,
  355. alignment: Alignment.center,
  356. margin: EdgeInsets.only(top: 2),
  357. decoration: BoxDecoration(
  358. shape: BoxShape.rectangle,
  359. color: Colors.blueAccent,
  360. borderRadius: BorderRadius.circular(5),
  361. ),
  362. child: const Icon(
  363. Icons.edit,
  364. color: Color(0XFFFAF7EE),
  365. size: 20,
  366. )
  367. ),
  368. onTap: (){
  369. setState(() {
  370. visibleNamaDesa = !visibleNamaDesa;
  371. visibleEditDesa = !visibleEditDesa;
  372. visibleFormDesa = !visibleFormDesa;
  373. });
  374. },
  375. )
  376. ),
  377. )
  378. ],
  379. )
  380. ),
  381. Stack(
  382. children: [
  383. Container(
  384. margin: EdgeInsets.only (top: 5),
  385. width: size.width,
  386. child:Visibility(
  387. visible: visibleNamaDesa,
  388. child: Text(nama_desa,
  389. overflow: TextOverflow.fade,
  390. softWrap: true),
  391. ),
  392. ),
  393. Visibility(
  394. visible: visibleFormDesa,
  395. child:
  396. Container(
  397. width: size.width,
  398. margin: EdgeInsets.only(top: 5),
  399. child: Row(
  400. children:[
  401. Expanded(
  402. flex: 8,
  403. child: Container(
  404. decoration: BoxDecoration(
  405. color: Colors.white,
  406. borderRadius:
  407. BorderRadius.circular(5)),
  408. child: Padding(
  409. padding: EdgeInsets.only(
  410. left: 10,
  411. right: 10,
  412. top: 2,
  413. bottom: 5),
  414. child: TextFormField(
  415. keyboardType:
  416. TextInputType.multiline,
  417. controller: isiDesaTeksController,
  418. maxLines: null,
  419. textInputAction:
  420. TextInputAction.done,
  421. decoration: InputDecoration(
  422. border:
  423. InputBorder.none,
  424. hintText: "desa")),
  425. )
  426. )),
  427. Expanded(
  428. flex:2,
  429. child:
  430. InkWell(
  431. child: Container(
  432. child: const Icon(
  433. Icons.check_box_rounded,
  434. color: Colors.blueAccent,
  435. //color: Color(0xFF6B74D6),
  436. size: 40,
  437. )
  438. ),
  439. onTap: (){
  440. setState(() {
  441. visibleNamaDesa = !visibleNamaDesa;
  442. visibleEditDesa = !visibleEditDesa;
  443. visibleFormDesa = !visibleFormDesa;
  444. nama_desa = isiDesaTeksController.text.toString();
  445. });
  446. },
  447. )
  448. ),
  449. ]
  450. ),
  451. ))
  452. ],
  453. )
  454. ],
  455. ),
  456. ),
  457. Container(
  458. margin: EdgeInsets.only(left: 10, right: 10, top: 15),
  459. child: Column(
  460. children: [
  461. Container(
  462. width: size.width,
  463. child:
  464. Row(
  465. children: [
  466. Align(
  467. alignment: Alignment.centerLeft,
  468. child: Text(
  469. 'Kecamatan',
  470. style: GoogleFonts.inconsolata(
  471. fontSize: 16, fontWeight: FontWeight.bold),
  472. ),
  473. ),
  474. SizedBox(width: 15),
  475. Align(
  476. alignment: Alignment.centerLeft,
  477. child: Visibility(
  478. visible: visibleEditKecamatan,
  479. child:
  480. InkWell(
  481. child: Container(
  482. width: 25,
  483. height: 25,
  484. alignment: Alignment.center,
  485. margin: EdgeInsets.only(top: 2),
  486. decoration: BoxDecoration(
  487. shape: BoxShape.rectangle,
  488. color: Colors.blueAccent,
  489. borderRadius: BorderRadius.circular(5),
  490. ),
  491. child: const Icon(
  492. Icons.edit,
  493. color: Color(0XFFFAF7EE),
  494. size: 20,
  495. )
  496. ),
  497. onTap: (){
  498. setState(() {
  499. visibleNamaKecamatan = !visibleNamaKecamatan;
  500. visibleEditKecamatan = !visibleEditKecamatan;
  501. visibleFormKecamatan = !visibleFormKecamatan;
  502. });
  503. },
  504. )
  505. ),
  506. )
  507. ],
  508. )
  509. ),
  510. Stack(
  511. children: [
  512. Container(
  513. margin: EdgeInsets.only (top: 5),
  514. width: size.width,
  515. child:Visibility(
  516. visible: visibleNamaKecamatan,
  517. child: Text(nama_kecamatan,
  518. overflow: TextOverflow.fade,
  519. softWrap: true),
  520. ),
  521. ),
  522. Visibility(
  523. visible: visibleFormKecamatan,
  524. child:
  525. Container(
  526. width: size.width,
  527. margin: EdgeInsets.only(top: 5),
  528. child: Row(
  529. children:[
  530. Expanded(
  531. flex: 8,
  532. child: Container(
  533. decoration: BoxDecoration(
  534. color: Colors.white,
  535. borderRadius:
  536. BorderRadius.circular(5)),
  537. child: Padding(
  538. padding: EdgeInsets.only(
  539. left: 10,
  540. right: 10,
  541. top: 2,
  542. bottom: 5),
  543. child: TextFormField(
  544. keyboardType:
  545. TextInputType.multiline,
  546. controller: isiKecamatanTeksController,
  547. maxLines: null,
  548. textInputAction:
  549. TextInputAction.done,
  550. decoration: InputDecoration(
  551. border:
  552. InputBorder.none,
  553. hintText: "kecamatan")),
  554. )
  555. )),
  556. Expanded(
  557. flex:2,
  558. child:
  559. InkWell(
  560. child: Container(
  561. child: const Icon(
  562. Icons.check_box_rounded,
  563. color: Colors.blueAccent,
  564. //color: Color(0xFF6B74D6),
  565. size: 40,
  566. )
  567. ),
  568. onTap: (){
  569. setState(() {
  570. visibleNamaKecamatan = !visibleNamaKecamatan;
  571. visibleEditKecamatan = !visibleEditKecamatan;
  572. visibleFormKecamatan = !visibleFormKecamatan;
  573. nama_kecamatan = isiKecamatanTeksController.text.toString();
  574. });
  575. },
  576. )
  577. ),
  578. ]
  579. ),
  580. ))
  581. ],
  582. )
  583. ],
  584. ),
  585. ),
  586. Container(
  587. margin: EdgeInsets.only(left: 10, right: 10, top: 15),
  588. child: Column(
  589. children: [
  590. Container(
  591. width: size.width,
  592. child:
  593. Row(
  594. children:[
  595. Align(
  596. alignment: Alignment.centerLeft,
  597. child: Text(
  598. 'Kabupaten',
  599. style: GoogleFonts.inconsolata(
  600. fontSize: 16, fontWeight: FontWeight.bold),
  601. ),
  602. ),
  603. SizedBox(width: 15),
  604. Align(
  605. alignment: Alignment.centerLeft,
  606. child: Visibility(
  607. visible: visibleEditKabupaten,
  608. child:
  609. InkWell(
  610. child: Container(
  611. width: 25,
  612. height: 25,
  613. alignment: Alignment.center,
  614. margin: EdgeInsets.only(top: 2),
  615. decoration: BoxDecoration(
  616. shape: BoxShape.rectangle,
  617. color: Colors.blueAccent,
  618. borderRadius: BorderRadius.circular(5),
  619. ),
  620. child: const Icon(
  621. Icons.edit,
  622. color: Color(0XFFFAF7EE),
  623. size: 20,
  624. )
  625. ),
  626. onTap: (){
  627. setState(() {
  628. visibleNamaKabupaten = !visibleNamaKabupaten;
  629. visibleEditKabupaten = !visibleEditKabupaten;
  630. visibleFormKabupaten = !visibleFormKabupaten;
  631. });
  632. },
  633. )
  634. ),
  635. )
  636. ]
  637. )
  638. ),
  639. Stack(
  640. children:[
  641. Container(
  642. margin: EdgeInsets.only(top: 5),
  643. width: size.width,
  644. child:Visibility(
  645. visible: visibleNamaKabupaten,
  646. child: Text(nama_kabupaten,
  647. overflow: TextOverflow.fade,
  648. softWrap: true),
  649. ),
  650. ),
  651. Visibility(
  652. visible: visibleFormKabupaten,
  653. child:
  654. Container(
  655. width: size.width,
  656. margin: EdgeInsets.only(top: 5),
  657. child: Row(
  658. children:[
  659. Expanded(
  660. flex: 8,
  661. child: Container(
  662. decoration: BoxDecoration(
  663. color: Colors.white,
  664. borderRadius:
  665. BorderRadius.circular(5)),
  666. child: Padding(
  667. padding: EdgeInsets.only(
  668. left: 10,
  669. right: 10,
  670. top: 2,
  671. bottom: 5),
  672. child: TextFormField(
  673. keyboardType:
  674. TextInputType.multiline,
  675. controller: isiKabupatenTeksController,
  676. maxLines: null,
  677. textInputAction:
  678. TextInputAction.done,
  679. decoration: InputDecoration(
  680. border:
  681. InputBorder.none,
  682. hintText: "kabupaten")),
  683. )
  684. )),
  685. Expanded(
  686. flex:2,
  687. child:
  688. InkWell(
  689. child: Container(
  690. child: const Icon(
  691. Icons.check_box_rounded,
  692. color: Colors.blueAccent,
  693. //color: Color(0xFF6B74D6),
  694. size: 40,
  695. )
  696. ),
  697. onTap: (){
  698. setState(() {
  699. visibleNamaKabupaten = !visibleNamaKabupaten;
  700. visibleEditKabupaten = !visibleEditKabupaten;
  701. visibleFormKabupaten = !visibleFormKabupaten;
  702. nama_kabupaten = isiKabupatenTeksController.text.toString();
  703. });
  704. },
  705. )
  706. ),
  707. ]
  708. ),
  709. ))
  710. ]
  711. )
  712. ],
  713. ),
  714. ),
  715. Container(
  716. margin: EdgeInsets.only(left: 10, right: 10, top: 15),
  717. child: Column(
  718. children: [
  719. Container(
  720. width: size.width,
  721. child:
  722. Row(
  723. children:[
  724. Align(
  725. alignment: Alignment.centerLeft,
  726. child: Text(
  727. 'Provinsi',
  728. style: GoogleFonts.inconsolata(
  729. fontSize: 16, fontWeight: FontWeight.bold),
  730. ),
  731. ),
  732. SizedBox(width: 15),
  733. Align(
  734. alignment: Alignment.centerLeft,
  735. child: Visibility(
  736. visible: visibleEditProvinsi,
  737. child:
  738. InkWell(
  739. child: Container(
  740. width: 25,
  741. height: 25,
  742. alignment: Alignment.center,
  743. margin: EdgeInsets.only(top: 2),
  744. decoration: BoxDecoration(
  745. shape: BoxShape.rectangle,
  746. color: Colors.blueAccent,
  747. borderRadius: BorderRadius.circular(5),
  748. ),
  749. child: const Icon(
  750. Icons.edit,
  751. color: Color(0XFFFAF7EE),
  752. size: 20,
  753. )
  754. ),
  755. onTap: (){
  756. setState(() {
  757. visibleNamaProvinsi = !visibleNamaProvinsi;
  758. visibleEditProvinsi = !visibleEditProvinsi;
  759. visibleFormProvinsi = !visibleFormProvinsi;
  760. });
  761. },
  762. )
  763. ),
  764. )
  765. ]
  766. )
  767. ),
  768. Stack(
  769. children:[
  770. Container(
  771. margin: EdgeInsets.only(top:5),
  772. width: size.width,
  773. child: Visibility(
  774. visible: visibleNamaProvinsi,
  775. child: Text(nama_provinsi,
  776. overflow: TextOverflow.fade,
  777. softWrap: true),
  778. ),
  779. ),
  780. Visibility(
  781. visible: visibleFormProvinsi,
  782. child:
  783. Container(
  784. width: size.width,
  785. margin: EdgeInsets.only(top: 2),
  786. child: Row(
  787. children:[
  788. Expanded(
  789. flex: 8,
  790. child: Container(
  791. decoration: BoxDecoration(
  792. color: Colors.white,
  793. borderRadius:
  794. BorderRadius.circular(5)),
  795. child: Padding(
  796. padding: EdgeInsets.only(
  797. left: 10,
  798. right: 10,
  799. top: 2,
  800. bottom: 5),
  801. child: TextFormField(
  802. keyboardType:
  803. TextInputType.multiline,
  804. controller: isiProvinsiTeksController,
  805. maxLines: null,
  806. textInputAction:
  807. TextInputAction.done,
  808. decoration: InputDecoration(
  809. border:
  810. InputBorder.none,
  811. hintText: "provinsi")),
  812. )
  813. )),
  814. Expanded(
  815. flex:2,
  816. child:
  817. InkWell(
  818. child: Container(
  819. child: const Icon(
  820. Icons.check_box_rounded,
  821. color: Colors.blueAccent,
  822. //color: Color(0xFF6B74D6),
  823. size: 40,
  824. )
  825. ),
  826. onTap: (){
  827. setState(() {
  828. visibleNamaProvinsi = !visibleNamaProvinsi;
  829. visibleEditProvinsi = !visibleEditProvinsi;
  830. visibleFormProvinsi = !visibleFormProvinsi;
  831. nama_provinsi = isiProvinsiTeksController.text.toString();
  832. });
  833. },
  834. )
  835. ),
  836. ]
  837. ),
  838. ))
  839. ]
  840. )
  841. ],
  842. ),
  843. ),
  844. Container(
  845. margin: EdgeInsets.only(left: 10, right: 10, top: 15),
  846. child: Column(
  847. children: [
  848. Align(
  849. alignment: Alignment.centerLeft,
  850. child: Text(
  851. 'Jumlah Penduduk',
  852. style: GoogleFonts.inconsolata(
  853. fontSize: 16, fontWeight: FontWeight.bold),
  854. )),
  855. Container(
  856. margin: EdgeInsets.only(top: 2),
  857. decoration: BoxDecoration(
  858. color: Colors.white,
  859. borderRadius:
  860. BorderRadius.circular(5)),
  861. child: Padding(
  862. padding: EdgeInsets.only(
  863. left: 10,
  864. right: 10,
  865. top: 5,
  866. bottom: 5),
  867. child: TextFormField(
  868. keyboardType: TextInputType.number,
  869. controller: isiJumlahPendudukTeksController,
  870. maxLines: null,
  871. textInputAction:
  872. TextInputAction.done,
  873. decoration: InputDecoration(
  874. border:
  875. InputBorder.none,
  876. hintText: "jumlah penduduk")),
  877. )
  878. )
  879. ],
  880. ),
  881. ),
  882. Container(
  883. margin: EdgeInsets.only(left: 10, right: 10, top: 15),
  884. child: Column(
  885. children: [
  886. Align(
  887. alignment: Alignment.centerLeft,
  888. child: Text(
  889. 'Posisi',
  890. style: GoogleFonts.inconsolata(
  891. fontSize: 16, fontWeight: FontWeight.bold),
  892. )),
  893. Container(
  894. height: size.height*0.4,
  895. width: size.width,
  896. margin: EdgeInsets.only(top: 2),
  897. decoration: BoxDecoration(
  898. borderRadius: BorderRadius.circular(5)
  899. ),
  900. child: Stack(
  901. children:[
  902. FlutterMap(
  903. mapController: _mapController,
  904. options: new MapOptions(
  905. onTap: (p, point) async {}, center: point, zoom: 15),
  906. children: [
  907. TileLayer(
  908. minZoom: 1,
  909. maxZoom: 22,
  910. maxNativeZoom: 18,
  911. minNativeZoom: 1,
  912. backgroundColor: Colors.black54,
  913. urlTemplate: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
  914. subdomains: ['a', 'b', 'c'],
  915. ),
  916. MarkerLayer(markers: [
  917. Marker(
  918. width: 135,
  919. height: 135,
  920. point: point,
  921. builder: (ctx) => Container(
  922. child: Icon(
  923. Icons.location_on,
  924. color: Colors.red,
  925. ),
  926. ))
  927. ])
  928. ],
  929. ),
  930. Container(
  931. alignment: AlignmentDirectional.bottomEnd,
  932. child: Container(
  933. margin: EdgeInsets.only(bottom: 10),
  934. /*margin: EdgeInsets.fromLTRB(10, 15, 0, (size.height*0.4) + 15),*/
  935. child: RawMaterialButton(
  936. onPressed: () {
  937. setState(() {
  938. updatePosition();
  939. });
  940. },
  941. elevation: 5.0,
  942. fillColor: Colors.white,
  943. child: Image.asset('assets/images/location1.png',
  944. height: 35, width: 35),
  945. padding: EdgeInsets.all(5.0),
  946. shape: CircleBorder(),
  947. ),
  948. ),
  949. ),]
  950. )
  951. ),
  952. ],
  953. ),
  954. ),
  955. Container(
  956. margin: EdgeInsets.only(
  957. left: 10, right: 10, top: 5),
  958. child:Align(
  959. alignment: Alignment.center,
  960. child: Text(
  961. titik,
  962. overflow: TextOverflow.fade,
  963. softWrap: true,
  964. style: GoogleFonts.inconsolata(
  965. fontSize: 16, fontWeight: FontWeight.bold),
  966. )
  967. )
  968. ),
  969. Container(
  970. margin: EdgeInsets.only(left: 10, right: 10, top: 15),
  971. child: Column(
  972. children: [
  973. Align(
  974. alignment: Alignment.centerLeft,
  975. child: Text(
  976. 'Signal 2G (dBm)',
  977. style: GoogleFonts.inconsolata(
  978. fontSize: 16, fontWeight: FontWeight.bold),
  979. )),
  980. Container(
  981. margin: EdgeInsets.only(top: 2),
  982. decoration: BoxDecoration(
  983. color: Colors.white,
  984. borderRadius:
  985. BorderRadius.circular(5)),
  986. child: Padding(
  987. padding: EdgeInsets.only(
  988. left: 10,
  989. right: 10,
  990. top: 5,
  991. bottom: 5),
  992. child: TextFormField(
  993. keyboardType:
  994. TextInputType.multiline,
  995. controller: isiSignal2TeksController,
  996. maxLines: null,
  997. textInputAction:
  998. TextInputAction.done,
  999. decoration: InputDecoration(
  1000. border:
  1001. InputBorder.none,
  1002. hintText: "signal 2G")),
  1003. )
  1004. )
  1005. ],
  1006. ),
  1007. ),
  1008. Container(
  1009. margin: EdgeInsets.only(left: 10, right: 10, top: 15),
  1010. child: Column(
  1011. children: [
  1012. Align(
  1013. alignment: Alignment.centerLeft,
  1014. child: Text(
  1015. 'Signal 3G (dBm)',
  1016. style: GoogleFonts.inconsolata(
  1017. fontSize: 16, fontWeight: FontWeight.bold),
  1018. )),
  1019. Container(
  1020. margin: EdgeInsets.only(top: 7),
  1021. decoration: BoxDecoration(
  1022. color: Colors.white,
  1023. borderRadius:
  1024. BorderRadius.circular(5)),
  1025. child: Padding(
  1026. padding: EdgeInsets.only(
  1027. left: 10,
  1028. right: 10,
  1029. top: 5,
  1030. bottom: 5),
  1031. child: TextFormField(
  1032. keyboardType:
  1033. TextInputType.multiline,
  1034. controller: isiSignal3TeksController,
  1035. maxLines: null,
  1036. textInputAction:
  1037. TextInputAction.done,
  1038. decoration: InputDecoration(
  1039. border:
  1040. InputBorder.none,
  1041. hintText: "signal 3G")),
  1042. )
  1043. )
  1044. ],
  1045. ),
  1046. ),
  1047. Container(
  1048. margin: EdgeInsets.only(left: 10, right: 10, top: 15),
  1049. child: Column(
  1050. children: [
  1051. Align(
  1052. alignment: Alignment.centerLeft,
  1053. child: Text(
  1054. 'Signal 4G (dBm)',
  1055. style: GoogleFonts.inconsolata(
  1056. fontSize: 16, fontWeight: FontWeight.bold),
  1057. )),
  1058. Container(
  1059. margin: EdgeInsets.only(top: 2),
  1060. decoration: BoxDecoration(
  1061. color: Colors.white,
  1062. borderRadius:
  1063. BorderRadius.circular(5)),
  1064. child: Padding(
  1065. padding: EdgeInsets.only(
  1066. left: 10,
  1067. right: 10,
  1068. top: 5,
  1069. bottom: 5),
  1070. child: TextFormField(
  1071. keyboardType:
  1072. TextInputType.multiline,
  1073. controller: isiSignal4TeksController,
  1074. maxLines: null,
  1075. textInputAction:
  1076. TextInputAction.done,
  1077. decoration: InputDecoration(
  1078. border:
  1079. InputBorder.none,
  1080. hintText: "signal 4G")),
  1081. )
  1082. )
  1083. ],
  1084. ),
  1085. ),
  1086. Container(
  1087. margin: EdgeInsets.only(left: 10, right: 10, top: 15),
  1088. child: Column(
  1089. children: [
  1090. Align(
  1091. alignment: Alignment.centerLeft,
  1092. child: Text(
  1093. 'Tempat Keramaian (Contoh: Sekolah, Pasar, dll)',
  1094. style: GoogleFonts.inconsolata(
  1095. fontSize: 16, fontWeight: FontWeight.bold),
  1096. ),
  1097. ),
  1098. ListView.builder(
  1099. shrinkWrap: true,
  1100. itemCount: _jenisTempat.length,
  1101. itemBuilder: (context, i) {
  1102. return Padding(
  1103. padding: const EdgeInsets.only(top: 2),
  1104. child: Row(
  1105. children: [
  1106. Expanded(
  1107. flex: 7,
  1108. child: Container(
  1109. padding: const EdgeInsets.symmetric(horizontal: 10),
  1110. //height: 60,
  1111. alignment: Alignment.center,
  1112. decoration: BoxDecoration(
  1113. color: Colors.white,
  1114. borderRadius: BorderRadius.circular(5),
  1115. ),
  1116. child: TextFormField(
  1117. controller: _jenisTempat[i],
  1118. autofocus: false,
  1119. style: const TextStyle(color: Colors.black),
  1120. decoration: const InputDecoration(
  1121. border: InputBorder.none,
  1122. hintText: "Jenis Tempat",
  1123. hintStyle: TextStyle(
  1124. color: Color.fromARGB(255, 132, 140, 155)),
  1125. ),
  1126. ),
  1127. ),
  1128. ),
  1129. SizedBox(width: 5),
  1130. Expanded(
  1131. flex: 3,
  1132. child: Container(
  1133. padding: const EdgeInsets.symmetric(horizontal: 10),
  1134. //height: 60,
  1135. alignment: Alignment.center,
  1136. decoration: BoxDecoration(
  1137. color: Colors.white,
  1138. borderRadius: BorderRadius.circular(5),
  1139. ),
  1140. child: TextFormField(
  1141. controller: _km[i],
  1142. autofocus: false,
  1143. style: const TextStyle(color: Colors.black),
  1144. decoration: const InputDecoration(
  1145. border: InputBorder.none,
  1146. hintText: "KM",
  1147. hintStyle: TextStyle(
  1148. color: Color.fromARGB(255, 132, 140, 155)),
  1149. ),
  1150. ),
  1151. ),
  1152. ),
  1153. i != 0
  1154. ? GestureDetector(
  1155. onTap: (){
  1156. setState(() {
  1157. _removeItemTempat(i);
  1158. });
  1159. },
  1160. child: const Icon(
  1161. Icons.delete,
  1162. color: Color(0xFF6B74D6),
  1163. size: 40,
  1164. ),
  1165. )
  1166. : const SizedBox()
  1167. ],
  1168. ),
  1169. );
  1170. },
  1171. ),
  1172. const SizedBox(
  1173. height: 10,
  1174. ),
  1175. GestureDetector(
  1176. onTap: () {
  1177. setState(() {
  1178. _addFieldTempat();
  1179. });
  1180. },
  1181. child: Center(
  1182. child: Container(
  1183. width: size.width,
  1184. padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10),
  1185. decoration: BoxDecoration(
  1186. color: Colors.blueAccent,
  1187. borderRadius: BorderRadius.circular(5)),
  1188. child: Align(
  1189. alignment: Alignment.center,
  1190. child: Text("Tambah Data Tempat+",
  1191. style:
  1192. GoogleFonts.nunito(color: const Color(0xFFF8F8FF))),
  1193. ),
  1194. ),
  1195. ),
  1196. ),
  1197. ],
  1198. ),
  1199. ),
  1200. Container(
  1201. margin: EdgeInsets.only(left: 10, right: 10, top: 15),
  1202. child: Column(
  1203. children: [
  1204. Align(
  1205. alignment: Alignment.centerLeft,
  1206. child: Text(
  1207. 'Catatan',
  1208. style: GoogleFonts.inconsolata(
  1209. fontSize: 16, fontWeight: FontWeight.bold),
  1210. )),
  1211. Container(
  1212. margin: EdgeInsets.only(top: 2),
  1213. decoration: BoxDecoration(
  1214. color: Colors.white,
  1215. borderRadius:
  1216. BorderRadius.circular(5)),
  1217. child: Padding(
  1218. padding: EdgeInsets.only(
  1219. left: 10,
  1220. right: 10,
  1221. top: 5,
  1222. bottom: 5),
  1223. child: TextFormField(
  1224. keyboardType:
  1225. TextInputType.multiline,
  1226. controller: isiCatatanTeksController,
  1227. maxLines: null,
  1228. textInputAction:
  1229. TextInputAction.done,
  1230. decoration: InputDecoration(
  1231. border:
  1232. InputBorder.none,
  1233. hintText: "catatan")),
  1234. )
  1235. )
  1236. ],
  1237. ),
  1238. ),
  1239. Container(
  1240. margin: EdgeInsets.only(left: 10, right: 10, top: 15),
  1241. child: Column(
  1242. children: [
  1243. Align(
  1244. alignment: Alignment.centerLeft,
  1245. child: Text(
  1246. 'Foto',
  1247. style: GoogleFonts.inconsolata(
  1248. fontSize: 16,
  1249. fontWeight: FontWeight.bold,
  1250. ),
  1251. ),
  1252. ),
  1253. ListView.builder(
  1254. shrinkWrap: true,
  1255. itemCount: _ambilFoto.length,
  1256. itemBuilder: (context, i) {
  1257. return Padding(
  1258. padding: const EdgeInsets.only(top: 2),
  1259. child: Row(
  1260. crossAxisAlignment: CrossAxisAlignment.start,
  1261. children: [
  1262. Expanded(
  1263. child:
  1264. Column(
  1265. children:[
  1266. Visibility (
  1267. child: Align(
  1268. alignment: Alignment.centerLeft,
  1269. child:
  1270. InkWell(
  1271. child: Container(
  1272. padding: EdgeInsets.all(5),
  1273. //width: size.width * 0.5,
  1274. decoration: BoxDecoration(
  1275. borderRadius: BorderRadius.circular(5),
  1276. gradient: LinearGradient(
  1277. colors: [
  1278. Colors.redAccent,
  1279. Colors.redAccent
  1280. ],
  1281. ),
  1282. ),
  1283. child: Row(
  1284. mainAxisAlignment: MainAxisAlignment.center,
  1285. children: [
  1286. Text(
  1287. "Ambil Foto\t\t",
  1288. textAlign: TextAlign.center,
  1289. style: TextStyle(
  1290. color: Colors.white,
  1291. //fontSize: 17,
  1292. fontWeight: FontWeight.w500,
  1293. ),
  1294. ),
  1295. const Icon(
  1296. Icons.camera_alt,
  1297. //color: Color(0xFF6B74D6),
  1298. size: 25,
  1299. ),
  1300. ],
  1301. ),
  1302. ),
  1303. onTap: () async {
  1304. final ImagePicker _picker = ImagePicker();
  1305. final XFile? imagePicked = await _picker.pickImage(
  1306. source: ImageSource.camera);
  1307. if (imagePicked != null) {
  1308. _imagePath = File(imagePicked.path);
  1309. logDev.log(_imagePath.toString(), name: "IMAGE PATH");
  1310. List<int> imageBytes = _imagePath!.readAsBytesSync();
  1311. String base64Image = base64Encode(imageBytes);
  1312. //logDev.log(base64Image, name: "String base64");
  1313. setState(() {
  1314. logDev.log(_ambilFoto.length.toString(), name: "ada berapa banyak buttonambil foto");
  1315. _pathFoto[i] = path.basename(_imagePath.toString());
  1316. _base64Foto[i] = base64Image;
  1317. logDev.log(_pathFoto.length.toString(), name: "Banyak path foto");
  1318. logDev.log(_base64Foto.length.toString(), name: "Banyak Base64");
  1319. logDev.log(_pathFoto.toString(), name: "Isi Path FOTO");
  1320. });
  1321. } else if (imagePicked == null) {
  1322. //_imagePath = await getImageFileFromAssets('assets/images/ic_administrator.png') as File?;
  1323. }
  1324. },
  1325. ),
  1326. ),
  1327. ),
  1328. Visibility(
  1329. child: Align(
  1330. alignment: Alignment.centerLeft,
  1331. child:
  1332. FittedBox(
  1333. fit: BoxFit.scaleDown, // Sesuaikan teks agar tidak melebihi lebar container
  1334. child: Text(
  1335. _pathFoto[i]
  1336. /*style: TextStyle(fontSize: size.width),*/
  1337. ),
  1338. ),
  1339. )
  1340. ),
  1341. ]
  1342. )
  1343. ),
  1344. GestureDetector(
  1345. onTap: () {
  1346. setState(() {
  1347. _removeItemFoto(i);
  1348. logDev.log(_pathFoto.length.toString(), name: "Banyak path foto");
  1349. logDev.log(_pathFoto.toString(), name: "Isi Path FOTO");
  1350. });
  1351. },
  1352. child:
  1353. const Icon(
  1354. Icons.delete,
  1355. color: Color(0xFF6B74D6),
  1356. size: 40,
  1357. )
  1358. )
  1359. ],
  1360. ),
  1361. );
  1362. },
  1363. ),
  1364. const SizedBox(
  1365. height: 5,
  1366. ),
  1367. GestureDetector(
  1368. onTap: () {
  1369. setState(() {
  1370. _addFieldFoto();
  1371. });
  1372. },
  1373. child: Center(
  1374. child: Container(
  1375. width: MediaQuery.of(context).size.width,
  1376. padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10),
  1377. decoration: BoxDecoration(
  1378. color: Colors.blueAccent,
  1379. borderRadius: BorderRadius.circular(5),
  1380. ),
  1381. child: Align(
  1382. alignment: Alignment.center,
  1383. child: Text(
  1384. "Tambah Foto+",
  1385. style: GoogleFonts.nunito(
  1386. color: const Color(0xFFF8F8FF),
  1387. ),
  1388. ),
  1389. ),
  1390. ),
  1391. ),
  1392. ),
  1393. ],
  1394. ),
  1395. ),
  1396. InkWell(
  1397. child: Container(
  1398. margin: EdgeInsets.only(left: 10, right: 10, top:15, bottom: 15),
  1399. padding: EdgeInsets.fromLTRB(
  1400. 10, 10, 10, 10),
  1401. width: double.infinity,
  1402. decoration: BoxDecoration(
  1403. borderRadius:
  1404. BorderRadius.circular(5),
  1405. gradient: LinearGradient(colors: [
  1406. Color(0xFF2D4059),
  1407. Color(0xFF2D4059),
  1408. /*Color(0xFF444C60),
  1409. Color(0xFF444C60),*/
  1410. ])),
  1411. child: Text('KIRIM',
  1412. textAlign: TextAlign.center,
  1413. style: TextStyle(
  1414. color: Colors.white,
  1415. fontSize: 17,
  1416. fontWeight: FontWeight.w500)),
  1417. ),
  1418. onTap: () async {
  1419. ProgressDialog loading = ProgressDialog(context);
  1420. loading = ProgressDialog(context,
  1421. type: ProgressDialogType.normal, isDismissible: false, showLogs: true);
  1422. loading.style(
  1423. message: 'Please Wait .....',
  1424. borderRadius: 3,
  1425. backgroundColor: Colors.white,
  1426. progressWidget: CircularProgressIndicator(),
  1427. elevation: 10.0,
  1428. padding: EdgeInsets.all(10),
  1429. insetAnimCurve: Curves.easeInOut,
  1430. progress: 0.0,
  1431. maxProgress: 100.0,
  1432. progressTextStyle: TextStyle(
  1433. color: Colors.black, fontSize: 10.0, fontWeight: FontWeight.w400),
  1434. messageTextStyle: TextStyle(
  1435. color: Colors.black, fontSize: 15.0, fontWeight: FontWeight.w600));
  1436. List<List<dynamic>> tempatKeramaian = [];
  1437. tempatKeramaian = List.generate(_jenisTempat.length, (index) => [_jenisTempat.map((controller) => controller.text).toList()[index], _km.map((controller) => controller.text).toList()[index]]);
  1438. logDev.log(tempatKeramaian.toString(), name:"list tempat keramaian");
  1439. List<List<dynamic>> fotoKeterangan = [];
  1440. fotoKeterangan = List.generate(_base64Foto.length, (index) => [_base64Foto[index], "Keterangan Foto"]);
  1441. logDev.log(fotoKeterangan.toString(), name:"Foto dan Keterangan");
  1442. if (!validateFormSurvey(context)){
  1443. return;
  1444. } else if (validateFormSurvey(context)){
  1445. await loading.show();
  1446. final SharedPreferences prefs = await SharedPreferences.getInstance();
  1447. int? idDetail = prefs.getInt('idDetail');
  1448. int? user_id = prefs.getInt('user_id');
  1449. SendSurvey_Post.connectToAPI(user_id!, idDetail!, nama_desa, nama_kecamatan, nama_kabupaten, nama_provinsi,
  1450. int.parse(isiJumlahPendudukTeksController.text.toString()), titik, isiSignal2TeksController.text.toString(),
  1451. isiSignal3TeksController.text.toString(), isiSignal4TeksController.text.toString(),
  1452. isiCatatanTeksController.text.toString(), tempatKeramaian, fotoKeterangan).then((valueResult) async {
  1453. Map<String, dynamic> object = json.decode(valueResult);
  1454. String status = object['result']['status'].toString();
  1455. logDev.log(status, name: "STATUS!!!!!!!");
  1456. if (status == "success") {
  1457. //String status = object['status'].toString();
  1458. //logDev.log(status, name: "Statusnya");
  1459. await loading.hide();
  1460. Widget okButton = TextButton(
  1461. child: Text("OK"),
  1462. onPressed: () {
  1463. Navigator.of(context, rootNavigator: true).pop();
  1464. Navigator.pushReplacement(context, MaterialPageRoute(builder: (context) => ListSurveyScreen()));
  1465. },
  1466. );
  1467. // set up the AlertDialog
  1468. AlertDialog alert = AlertDialog(
  1469. title: Text("POC Bakti"),
  1470. content: Text("Success Submit"),
  1471. actions: [
  1472. okButton,
  1473. ],
  1474. );
  1475. // show the dialog
  1476. showDialog(
  1477. context: context,
  1478. barrierDismissible: false,
  1479. builder: (
  1480. BuildContext context) {
  1481. return alert;
  1482. },
  1483. );
  1484. } else {
  1485. await loading.hide();
  1486. alertDialogFailedResponse(
  1487. context);
  1488. }
  1489. });
  1490. }
  1491. },
  1492. ),
  1493. ],
  1494. ),
  1495. ),
  1496. ),
  1497. ),
  1498. ],
  1499. ),
  1500. ),
  1501. ),
  1502. ],
  1503. ),
  1504. ],
  1505. )),
  1506. );
  1507. }
  1508. //Validasi Form Survey
  1509. bool validateFormSurvey(BuildContext context) {
  1510. bool result = true;
  1511. if (nama_desa == "" && visibleFormDesa == false) {
  1512. Fluttertoast.showToast(
  1513. msg: "Nama Desa Harus Diisi!",
  1514. toastLength: Toast.LENGTH_SHORT,
  1515. gravity: ToastGravity.CENTER,
  1516. timeInSecForIosWeb: 1,
  1517. textColor: Colors.white,
  1518. fontSize: 16.0);
  1519. result = false;
  1520. } else if (visibleFormDesa == true){
  1521. Fluttertoast.showToast(
  1522. msg: "Mohon Konfirmasi Data Desa Terlebih Dahulu!",
  1523. toastLength: Toast.LENGTH_SHORT,
  1524. gravity: ToastGravity.CENTER,
  1525. timeInSecForIosWeb: 1,
  1526. textColor: Colors.white,
  1527. fontSize: 16.0);
  1528. result = false;
  1529. } else if (nama_kecamatan == "" && visibleFormKecamatan == false) {
  1530. Fluttertoast.showToast(
  1531. msg: "Nama Kecamatan Harus Diisi!",
  1532. toastLength: Toast.LENGTH_SHORT,
  1533. gravity: ToastGravity.CENTER,
  1534. timeInSecForIosWeb: 1,
  1535. textColor: Colors.white,
  1536. fontSize: 16.0);
  1537. result = false;
  1538. } else if (visibleFormKecamatan == true){
  1539. Fluttertoast.showToast(
  1540. msg: "Mohon Konfirmasi Data Kecamatan Terlebih Dahulu!",
  1541. toastLength: Toast.LENGTH_SHORT,
  1542. gravity: ToastGravity.CENTER,
  1543. timeInSecForIosWeb: 1,
  1544. textColor: Colors.white,
  1545. fontSize: 16.0);
  1546. result = false;
  1547. } else if (nama_kabupaten == "" && visibleFormKabupaten == false) {
  1548. Fluttertoast.showToast(
  1549. msg: "Nama Kabupaten Harus Diisi!",
  1550. toastLength: Toast.LENGTH_SHORT,
  1551. gravity: ToastGravity.CENTER,
  1552. timeInSecForIosWeb: 1,
  1553. textColor: Colors.white,
  1554. fontSize: 16.0);
  1555. result = false;
  1556. } else if (visibleFormKabupaten == true){
  1557. Fluttertoast.showToast(
  1558. msg: "Mohon Konfirmasi Data Kabupaten Terlebih Dahulu!",
  1559. toastLength: Toast.LENGTH_SHORT,
  1560. gravity: ToastGravity.CENTER,
  1561. timeInSecForIosWeb: 1,
  1562. textColor: Colors.white,
  1563. fontSize: 16.0);
  1564. result = false;
  1565. } else if (nama_provinsi == "" && visibleFormProvinsi == false) {
  1566. Fluttertoast.showToast(
  1567. msg: "Nama Provinsi Harus Diisi!",
  1568. toastLength: Toast.LENGTH_SHORT,
  1569. gravity: ToastGravity.CENTER,
  1570. timeInSecForIosWeb: 1,
  1571. textColor: Colors.white,
  1572. fontSize: 16.0);
  1573. result = false;
  1574. } else if (visibleFormProvinsi == true){
  1575. Fluttertoast.showToast(
  1576. msg: "Mohon Konfirmasi Data Provinsi Terlebih Dahulu!",
  1577. toastLength: Toast.LENGTH_SHORT,
  1578. gravity: ToastGravity.CENTER,
  1579. timeInSecForIosWeb: 1,
  1580. textColor: Colors.white,
  1581. fontSize: 16.0);
  1582. result = false;
  1583. } else if (isiJumlahPendudukTeksController.text.toString().isEmpty) {
  1584. Fluttertoast.showToast(
  1585. msg: "Jumlah Penduduk Harus Diisi!",
  1586. toastLength: Toast.LENGTH_SHORT,
  1587. gravity: ToastGravity.CENTER,
  1588. timeInSecForIosWeb: 1,
  1589. textColor: Colors.white,
  1590. fontSize: 16.0);
  1591. result = false;
  1592. } else if (isiSignal2TeksController.text.toString().isEmpty) {
  1593. Fluttertoast.showToast(
  1594. msg: "Signal 2G Harus Diisi!",
  1595. toastLength: Toast.LENGTH_SHORT,
  1596. gravity: ToastGravity.CENTER,
  1597. timeInSecForIosWeb: 1,
  1598. textColor: Colors.white,
  1599. fontSize: 16.0);
  1600. result = false;
  1601. } else if (isiSignal3TeksController.text.toString().isEmpty) {
  1602. Fluttertoast.showToast(
  1603. msg: "Signal 3G Harus Diisi!",
  1604. toastLength: Toast.LENGTH_SHORT,
  1605. gravity: ToastGravity.CENTER,
  1606. timeInSecForIosWeb: 1,
  1607. textColor: Colors.white,
  1608. fontSize: 16.0);
  1609. result = false;
  1610. } else if (isiSignal4TeksController.text.toString().isEmpty) {
  1611. Fluttertoast.showToast(
  1612. msg: "Signal 4G Harus Diisi!",
  1613. toastLength: Toast.LENGTH_SHORT,
  1614. gravity: ToastGravity.CENTER,
  1615. timeInSecForIosWeb: 1,
  1616. textColor: Colors.white,
  1617. fontSize: 16.0);
  1618. result = false;
  1619. } else if (_jenisTempat[0].text.toString().isEmpty){
  1620. Fluttertoast.showToast(
  1621. msg: "Tempat Keramaian Harus Diisi!",
  1622. toastLength: Toast.LENGTH_SHORT,
  1623. gravity: ToastGravity.CENTER,
  1624. timeInSecForIosWeb: 1,
  1625. textColor: Colors.white,
  1626. fontSize: 16.0);
  1627. result = false;
  1628. } else if (_km[0].text.toString().isEmpty){
  1629. Fluttertoast.showToast(
  1630. msg: "Tempat Keramaian Harus Diisi!",
  1631. toastLength: Toast.LENGTH_SHORT,
  1632. gravity: ToastGravity.CENTER,
  1633. timeInSecForIosWeb: 1,
  1634. textColor: Colors.white,
  1635. fontSize: 16.0);
  1636. result = false;
  1637. } /*else if (isiCatatanTeksController.text.toString().isEmpty) {
  1638. Fluttertoast.showToast(
  1639. msg: "Catatan Harus Diisi!",
  1640. toastLength: Toast.LENGTH_SHORT,
  1641. gravity: ToastGravity.CENTER,
  1642. timeInSecForIosWeb: 1,
  1643. textColor: Colors.white,
  1644. fontSize: 16.0);
  1645. result = false;
  1646. }*/
  1647. return result;
  1648. }
  1649. }
  1650. alertDialogFailedRetrievedData(BuildContext context){
  1651. Widget okButton = TextButton(
  1652. child: Text("Refresh"),
  1653. onPressed: () {
  1654. Navigator.of(context, rootNavigator: true).pop();
  1655. Navigator.pushReplacement(context, MaterialPageRoute(
  1656. builder: (context) => EditSurveyScreen()));
  1657. },
  1658. );
  1659. Widget noButton = TextButton(
  1660. child: Text("Back"),
  1661. onPressed: () {
  1662. Navigator.of(context, rootNavigator: true).pop();
  1663. Navigator.pop(context);
  1664. },
  1665. );
  1666. // set up the AlertDialog
  1667. AlertDialog alert = AlertDialog(
  1668. title: Text("POC Bakti"),
  1669. content: Text("Failed to Retrieve Data"),
  1670. actions: [
  1671. noButton,
  1672. okButton,
  1673. ],
  1674. );
  1675. // show the dialog
  1676. showDialog(
  1677. context: context,
  1678. barrierDismissible: false,
  1679. builder: (BuildContext context) {
  1680. return alert;
  1681. },
  1682. );
  1683. }
  1684. alertDialogFailedResponse(BuildContext context){
  1685. Widget okButton = TextButton(
  1686. child: Text("Refresh"),
  1687. onPressed: () {
  1688. Navigator.of(context, rootNavigator: true).pop();
  1689. Navigator.pushReplacement(context, MaterialPageRoute(
  1690. builder: (context) => EditSurveyScreen()));
  1691. },
  1692. );
  1693. Widget noButton = TextButton(
  1694. child: Text("Back"),
  1695. onPressed: () {
  1696. Navigator.of(context, rootNavigator: true).pop();
  1697. Navigator.pop(context);
  1698. },
  1699. );
  1700. // set up the AlertDialog
  1701. AlertDialog alert = AlertDialog(
  1702. title: Text("POC Bakti"),
  1703. content: Text("Server Response Error"),
  1704. actions: [
  1705. noButton,
  1706. okButton,
  1707. ],
  1708. );
  1709. // show the dialog
  1710. showDialog(
  1711. context: context,
  1712. barrierDismissible: false,
  1713. builder: (BuildContext context) {
  1714. return alert;
  1715. },
  1716. );
  1717. }