Advertisement
andresual

PersetujuanPage.dart

Mar 9th, 2020
548
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 26.40 KB | None | 0 0
  1. import 'package:MJW_Manajemen/helper/dbHelper.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:loading/loading.dart';
  4. import 'package:pull_to_refresh/pull_to_refresh.dart';
  5. import 'package:loading/indicator/ball_pulse_indicator.dart';
  6. import 'package:shared_preferences/shared_preferences.dart';
  7.  
  8. import 'package:http/http.dart' as http;
  9. import 'dart:async';
  10. import 'dart:convert';
  11.  
  12. class PersetujuanPage extends StatefulWidget {
  13.   @override
  14.   _PersetujuanPageState createState() => _PersetujuanPageState();
  15. }
  16.  
  17. class _PersetujuanPageState extends State<PersetujuanPage> with WidgetsBindingObserver {
  18.   Map data;
  19.   List persetujuandata, jenisDokumenList, statusDokumenList;
  20.   bool loading = true;
  21.   bool updateCounter = true;
  22.   String baseUrl, serverCode, urlPerpanjangan;
  23.   String groupId, _currentDocType1, _currentDocType2, _currentDocStat;
  24.  
  25.   String _currentCabang;
  26.   int _persetujuanJktCount, _persetujuanSbyCount, _persetujuanTestingCount;
  27.  
  28.   TextEditingController updateVlHariController = new TextEditingController();
  29.  
  30.   RefreshController _refreshController = RefreshController(initialRefresh: false);
  31.  
  32.   final dbHelper = DbHelper.instance;
  33.  
  34.   @override
  35.   void initState() {
  36.     WidgetsBinding.instance.addObserver(this);
  37.     super.initState();
  38.     getCredential();
  39.     getServerUrl();
  40.   }
  41.  
  42.   @override
  43.   void dispose() {
  44.     WidgetsBinding.instance.addObserver(this);
  45.     super.dispose();
  46.   }
  47.  
  48.   @override
  49.   void didChangeAppLifecycleState(AppLifecycleState state) {
  50.     if(state == AppLifecycleState.resumed) {
  51.       print('on resume persetujuan: ok');
  52.     } else if(state == AppLifecycleState.paused) {
  53.       print('on paused persetujuan: ok');
  54.     } else if(state == AppLifecycleState.detached) {
  55.       print('on detached persetujuan: ok');
  56.     } else if(state == AppLifecycleState.inactive) {
  57.       print('on inactive persetujuan: ok');
  58.     }
  59.   }
  60.  
  61.   @override
  62.   Widget build(BuildContext context) {
  63.     setState(() {
  64.       _currentDocType1 = _currentDocType1;
  65.       _currentDocType2 = _currentDocType2;
  66.     });
  67.     final body = Container(
  68.       width: MediaQuery.of(context).size.width,
  69.       padding: EdgeInsets.all(8.0),
  70.       decoration: BoxDecoration(
  71.         color: Colors.grey[300]
  72.       ),
  73.       child: (loading) ?
  74.       Center(
  75.         child: Column(
  76.           children: <Widget>[
  77.             Padding(
  78.               padding: EdgeInsets.only(top: MediaQuery.of(context).size.height/2.2),
  79.             ),
  80.             Loading(
  81.               indicator: BallPulseIndicator(), size: 50.0, color: Colors.lightBlue,
  82.             ),
  83.             Text("Memuat Data")
  84.           ]
  85.         )
  86.       ) : /*(persetujuandata == null) ?
  87.       Center(
  88.         child: Column(
  89.           mainAxisAlignment: MainAxisAlignment.center,
  90.           children: <Widget>[
  91.             Text("Tidak ada data untuk disetujui.", style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold))
  92.           ]
  93.         )
  94.       ) :*/
  95.       SmartRefresher(    
  96.         enablePullDown: true,
  97.         enablePullUp: false,
  98.         header: WaterDropHeader(waterDropColor: Colors.lightBlue),
  99.         footer: CustomFooter(
  100.           builder: (BuildContext context, LoadStatus mode){
  101.             Widget body ;
  102.             if(mode==LoadStatus.noMore){
  103.               body = Text("No more Data");
  104.             }
  105.             else if(mode==LoadStatus.loading){
  106.               body = Loading(
  107.                 indicator: BallPulseIndicator(), size: 50.0, color: Colors.lightBlue,
  108.               );
  109.             }
  110.             else if(mode == LoadStatus.failed){
  111.               body = Text("Load Failed!Click retry!");
  112.             }
  113.             else if(mode == LoadStatus.canLoading){
  114.                 body = Text("release to load more");
  115.             }
  116.             else{
  117.               body =  Text("pull up load");
  118.             }
  119.             return Container(
  120.               height: 55.0,
  121.               child: Center(child:body),
  122.             );
  123.           },
  124.         ),
  125.         controller: _refreshController,
  126.         onRefresh: _onRefresh,
  127.         onLoading: _onLoading,
  128.         child: (persetujuandata == null) ?
  129.         Center(
  130.           child: Column(
  131.             mainAxisAlignment: MainAxisAlignment.center,
  132.             children: <Widget>[
  133.               Text("Tidak ada data untuk disetujui.", style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold))
  134.             ]
  135.           )
  136.         ) :
  137.         ListView.builder(
  138.           itemCount: (persetujuandata == null) ? 0 : persetujuandata.length,
  139.           itemBuilder: (BuildContext context, int index) {
  140.             return InkWell(
  141.               onTap: () => goToNewScreen(context,
  142.                             persetujuandata[index]["dokumen_id"],
  143.                             persetujuandata[index]["tanggal"],
  144.                             persetujuandata[index]["dokumen_jenis"],
  145.                             persetujuandata[index]["dokumen_no"],
  146.                             persetujuandata[index]["dokumen_revised"],
  147.                             persetujuandata[index]["stat_dok"]
  148.                           ),
  149.               onLongPress: () => {
  150.                 (persetujuandata[index]["dokumen_jenis"] == 'vonis_loyo') ?                
  151.                   showDialog(
  152.                     context: context,
  153.                     builder: (BuildContext context) {
  154.                       return AlertDialog(
  155.                         title: Text('Perpanjangan Karantina untuk berapa hari ?'),
  156.                         content: TextFormField(
  157.                   controller: updateVlHariController,
  158.                   keyboardType: TextInputType.number,
  159.                   maxLines: 1,
  160.                   autofocus: false,
  161.                   // decoration: InputDecoration(
  162.                   //   contentPadding: EdgeInsets.fromLTRB(10.0, 5.0, 5.0, 10.0),
  163.                   //   border: OutlineInputBorder(borderRadius: BorderRadius.circular(8.0)),
  164.                   //   filled: true,
  165.                   //   fillColor: Colors.grey[300]
  166.                   // ),
  167.                   /*onChanged: (text) {
  168.                     ebmKetAdminControler.text = text;
  169.                   }*/
  170.                 ),
  171.                         actions: <Widget>[
  172.                           FlatButton(
  173.                             child: Text('OK'),
  174.                             onPressed: () {
  175.                               setState(() {
  176.                                   perpanjanganVl(persetujuandata[index]["dokumen_id"], persetujuandata[index]["tanggal"], updateVlHariController.text.toString());
  177.                                   print(persetujuandata[index]["dokumen_id"]);
  178.                                   print(persetujuandata[index]["tanggal"]);
  179.                               });
  180.                               Navigator.of(context).pop();
  181.                             },
  182.                           ),
  183.                         ],
  184.                       );
  185.                     },
  186.                   ) :
  187.                   print("Long press"),
  188.               },
  189.               highlightColor: Colors.white.withAlpha(30),
  190.               splashColor: Colors.white.withAlpha(20),
  191.               child: Card(
  192.                 margin: EdgeInsets.all(3.0),
  193.                 elevation: 3,
  194.                 color: (persetujuandata[index]["dokumen_jenis"] == 'vonis_loyo') ?
  195.                   (int.parse(persetujuandata[index]["tanggal_asal"]) > 3) ? Colors.pink[100] : Colors.white : Colors.white,
  196.                 shape: RoundedRectangleBorder(
  197.                   borderRadius: BorderRadius.circular(7.0)
  198.                 ),
  199.                 child: Padding(
  200.                   padding: EdgeInsets.all(5.0),
  201.                   child: ListTile(
  202.                     title: Row(
  203.                       mainAxisAlignment: MainAxisAlignment.spaceBetween,
  204.                       children: <Widget>[
  205.                         Text("${persetujuandata[index]["title"]}",
  206.                           style: TextStyle(fontSize: 13, fontWeight: FontWeight.bold)
  207.                         ),
  208.                         Row(
  209.                           mainAxisAlignment: MainAxisAlignment.spaceBetween,
  210.                           children: <Widget>[
  211.                             Padding(
  212.                               padding: EdgeInsets.only(right: 5.0),
  213.                               child: Image.asset((persetujuandata[index]["stat_dok"] == "Tunggu") ? 'assets/images/hourglass.png' : (persetujuandata[index]["stat_dok"] == "Tertutup") ? 'assets/images/tick.png' : 'assets/images/cancel.png',
  214.                               height: 10, width: 10,
  215.                               color: (persetujuandata[index]["stat_dok"] == "Tunggu") ? Colors.orange : (persetujuandata[index]["stat_dok"] == "Tertutup") ? Colors.green : Colors.red)
  216.                             ),
  217.                             Text("${persetujuandata[index]["stat_dok"]}",
  218.                             style: TextStyle(fontSize: 10, color: (persetujuandata[index]["stat_dok"] == "Tunggu") ? Colors.orange : (persetujuandata[index]["stat_dok"] == "Tertutup") ? Colors.green : Colors.red))
  219.                           ]
  220.                         )
  221.                       ]
  222.                     ),
  223.                     subtitle: Column(
  224.                       mainAxisAlignment: MainAxisAlignment.spaceBetween,
  225.                       children: <Widget>[
  226.                         Row(
  227.                           mainAxisAlignment: MainAxisAlignment.spaceBetween,
  228.                           children: <Widget>[
  229.                             Text("${persetujuandata[index]["tanggal"]}", style: TextStyle(fontSize: 12)),
  230.                             Text("")
  231.                           ]
  232.                         ),
  233.                         SizedBox(height: 10.0),
  234.                         Row(
  235.                           mainAxisAlignment: MainAxisAlignment.spaceBetween,
  236.                           children: <Widget>[
  237.                             Text("No Dokumen ${persetujuandata[index]["dokumen_no"]}", style: TextStyle(fontSize: 12)),
  238.                             Text((persetujuandata[index]["dokumen_jenis"] == 'izin_karyawan') ?
  239.                               "Karyawan" : "Supplier",
  240.                               style: TextStyle(fontSize: 12)
  241.                             )
  242.                           ]
  243.                         ),
  244.                         Row(
  245.                           mainAxisAlignment: MainAxisAlignment.spaceBetween,
  246.                           children: <Widget>[
  247.                             Text((persetujuandata[index]["dokumen_jenis"] == 'izin_karyawan') ?
  248.                               "" : "Jenis ${persetujuandata[index]["jenis_nama"]}",
  249.                               style: TextStyle(fontSize: 12)
  250.                             ),
  251.                             Text("${persetujuandata[index]["supplier"]}", style: TextStyle(fontSize: 11, fontWeight: FontWeight.bold))
  252.                           ]
  253.                         )
  254.                       ],
  255.                     )
  256.                   )
  257.                 )
  258.               )
  259.             );
  260.           }
  261.         )
  262.       )
  263.     );
  264.  
  265.     return Scaffold(
  266.       backgroundColor: Colors.grey[200],
  267.       appBar: new AppBar(
  268.         title: const Text('Persetujuan'),
  269.         elevation: 3,
  270.       ),
  271.       body: body,
  272.       floatingActionButton: FloatingActionButton(
  273.         onPressed: () => _bottomSheetFilterSearch(context),
  274.         child: Icon(Icons.tune, color: Colors.white),
  275.       ),
  276.     );
  277.   }
  278.  
  279.   //All Function
  280.   Future getServerUrl() async {
  281.     SharedPreferences prefs = await SharedPreferences.getInstance();
  282.     setState(() {
  283.       if (prefs.getString("login_jaringan") == "Lokal"){
  284.         baseUrl = "http://192.168.1.200/";
  285.       } else {
  286.         baseUrl = "http://koffiesoftmjw.ngrok.io/";
  287.       }
  288.  
  289.       if (prefs.getString("login_cabang") == 'MJWJKT'){
  290.         serverCode = "koffie_mjw/index.php?c=c_welcome_chart&m=get_action";
  291.         urlPerpanjangan = "koffie_mjw/index.php?c=c_vonis_loyo&m=update_perpanjangan_karantina";
  292.       } else if(prefs.getString("login_cabang") == 'MJWSBY'){
  293.         serverCode = "koffie_mjw_sby/index.php?c=c_welcome_chart&m=get_action";
  294.         urlPerpanjangan = "koffie_mjw_sby/index.php?c=c_vonis_loyo&m=update_perpanjangan_karantina";
  295.       } else {
  296.         serverCode = "koffie_mjw_testing/index.php?c=c_welcome_chart&m=get_action";
  297.         urlPerpanjangan = "koffie_mjw_testing/index.php?c=c_vonis_loyo&m=update_perpanjangan_karantina";
  298.       }
  299.  
  300.       getData("DOKUMENDAFTAR", "", "", "", "", "", "", "", "", "", "0", "100", groupId);
  301.     });
  302.   }
  303.  
  304.   void getCredential() async {
  305.     SharedPreferences prefs = await SharedPreferences.getInstance();
  306.     setState(() {
  307.       _currentCabang = prefs.getString("login_cabang");
  308.       groupId = prefs.getString("group_id");
  309.     });
  310.    
  311.     if(groupId == "5"){ //ko ahong
  312.       jenisDokumenList = [
  313.         {'jenis':'terima_beli', 'keterangan':'Terima Beli'},
  314.         {'jenis':'kirim_barang', 'keterangan':'Kirim Barang'},
  315.         {'jenis':'izin_karyawan', 'keterangan':'Izin Karyawan'}
  316.       ];
  317.     } else if(groupId == "15"){ //kepala gudang
  318.       jenisDokumenList = [
  319.         {'jenis':'vonis_loyo', 'keterangan':'Vonis Loyo'},
  320.         {'jenis':'mati_kolam', 'keterangan':'Mati Kolam'},
  321.         {'jenis':'izin_karyawan', 'keterangan':'Izin Karyawan'}
  322.       ];
  323.     } else {  //direksi atau administrator
  324.       jenisDokumenList = [
  325.         {'jenis':'harga_beli', 'keterangan':'Harga Beli'},
  326.         {'jenis':'order_beli', 'keterangan':'Order Beli'},
  327.         {'jenis':'nota_beli', 'keterangan':'Nota Beli'},
  328.         {'jenis':'subsidi_beli', 'keterangan':'Subsidi Beli'},
  329.         {'jenis':'personal', 'keterangan':'Supplier / Customer'},
  330.         {'jenis':'register_pkk', 'keterangan':'Register PKK'},
  331.         {'jenis':'mutasi_tabung_oksigen', 'keterangan':'Mutasi Tabung Oksigen'},
  332.         {'jenis':'harga_packing', 'keterangan':'Harga Packing'},
  333.         {'jenis':'sp_material', 'keterangan':'Surat Pesanan Material'},
  334.         {'jenis':'laba_rugi_harian', 'keterangan':'Laba Rugi Harian'},
  335.         {'jenis':'register_cargo_export', 'keterangan':'Ubahan Upi'},
  336.         {'jenis':'izin_karyawan', 'keterangan':'Izin Karyawan'}
  337.       ];
  338.     }
  339.  
  340.     statusDokumenList = ["Tunggu", "Tertutup", "Batal"];
  341.   }
  342.  
  343.   Future getData(String task, String dokumenJenis, String getDocType, String jenisId, String supplierId, String tglAwal, String tglAkhir, String bulan,
  344.                  String tahun, String statusDokumen, String start, String limit, String groupId) async {
  345.     SharedPreferences prefs = await SharedPreferences.getInstance();
  346.     http.Response response = await http.post("$baseUrl$serverCode", body: {
  347.       "task"            : task,
  348.       "dokumen_jenis"   : (dokumenJenis == null) ? "" : dokumenJenis,
  349.       "get_doc_type"    : getDocType,
  350.       "jenis_id"        : jenisId,
  351.       "supplier_id"     : supplierId,
  352.       "tgl_awal"        : tglAwal,
  353.       "tgl_akhir"       : tglAkhir,
  354.       "bulan"           : bulan,
  355.       "tahun"           : tahun,
  356.       "status_dokumen"  : (statusDokumen == null) ? "" : statusDokumen,
  357.       "start"           : start,
  358.       "limit"           : limit,
  359.       "group_id"        : groupId
  360.     });
  361.  
  362.     if (response.statusCode == 200) {
  363.       data = json.decode(response.body);
  364.       print(data.toString());
  365.  
  366.       setState(() {
  367.         persetujuandata = (data["total"] == "0") ? null : data["results"];
  368.  
  369.         if(updateCounter == true){
  370.           if(_currentCabang == 'MJWJKT'){
  371.             Map<String, dynamic> row = {
  372.               DbHelper.columnMenusJktCount : (persetujuandata == null) ? 0 : persetujuandata.length
  373.             };
  374.             dbHelper.updateCount(row, 'Persetujuan');
  375.           } else if(_currentCabang == 'MJWSBY'){
  376.             Map<String, dynamic> row = {
  377.               DbHelper.columnMenusSbyCount : (persetujuandata == null) ? 0 : persetujuandata.length
  378.             };
  379.             dbHelper.updateCount(row, 'Persetujuan');
  380.           } else {
  381.             Map<String, dynamic> row = {
  382.               DbHelper.columnMenusTestCount : (persetujuandata == null) ? 0 : persetujuandata.length
  383.             };
  384.             dbHelper.updateCount(row, 'Persetujuan');
  385.           }
  386.           loading = false;
  387.         } else {
  388.           loading = false;
  389.           updateCounter = true;
  390.         }
  391.       });
  392.  
  393.       /*if(updateCounter == true){
  394.         setState(() {
  395.           persetujuandata = (data["total"] == "0") ? null : data["results"];
  396.  
  397.           if (_currentCabang == 'MJWJKT'){
  398.             _persetujuanJktCount = (persetujuandata == null) ? 0 : persetujuandata.length;
  399.             prefs.setString('persetujuanJktCount', _persetujuanJktCount.toString());
  400.           } else if(_currentCabang == 'MJWSBY'){
  401.             _persetujuanSbyCount = (persetujuandata == null) ? 0 : persetujuandata.length;
  402.             prefs.setString('persetujuanSbyCount', _persetujuanSbyCount.toString());
  403.           } else {
  404.             _persetujuanTestingCount = (persetujuandata == null) ? 0 : persetujuandata.length;
  405.             prefs.setString('persetujuanTestingCount', _persetujuanTestingCount.toString());
  406.             print('new counter: '+_persetujuanTestingCount.toString());
  407.           }
  408.           loading = false;
  409.         });
  410.       } else {
  411.         setState(() {
  412.           persetujuandata = (data["total"] == "0") ? null : data["results"];
  413.           loading = false;
  414.           updateCounter = true;
  415.         });
  416.       } */
  417.     } else {
  418.       return null;
  419.     }    
  420.   }
  421.  
  422.   Future perpanjanganVl(String tbeliId, String tbeliTanggalAsal, String jmlHari) async {
  423.     http.Response response = await http.post("$baseUrl${urlPerpanjangan}", body: {
  424.       "tbeli_id"                : tbeliId,
  425.       "tbeli_tanggal_asal"      : tbeliTanggalAsal,
  426.       "jml_hari"                : jmlHari
  427.     });
  428.  
  429.     if (response.statusCode == 200) {
  430.       print("Update Berhasil");
  431.       print(response);
  432.       setState(() {
  433.         loading = false;
  434.         getData("DOKUMENDAFTAR", "", "", "", "", "", "", "", "", "", "0", "100", groupId);
  435.       });
  436.  
  437.       //Kembali Ke halaman daftar persetujuan
  438.       /*Navigator.of(context).pushReplacementNamed('/EbmListPage',
  439.         arguments: {'tanggal': (selectedDate == null) ? "$ebmTanggal" : "$selectedDate"});*/
  440.  
  441.       // Navigator.of(context).pushNamedAndRemoveUntil(
  442.       //   '/EbmListPage', ModalRoute.withName('/MainPage'),
  443.       //   arguments: {'tanggal': (selectedDate == null) ? "$ebmTanggal" : "$selectedDate"}
  444.       // );
  445.     } else {
  446.       print("$baseUrl${urlPerpanjangan}");
  447.     }
  448.   }
  449.  
  450.   void _onRefresh() async{
  451.     await Future.delayed(Duration(milliseconds: 1000));
  452.     // if failed,use refreshFailed()
  453.     _refreshController.refreshCompleted();
  454.  
  455.     getData("DOKUMENDAFTAR", "", "", "", "", "", "", "", "", "", "0", "100", groupId);
  456.   }
  457.  
  458.   void _onLoading() async{
  459.     // monitor network fetch
  460.     await Future.delayed(Duration(milliseconds: 1000));
  461.     // if failed,use loadFailed(),if no data return,use LoadNodata()
  462.     setState(() {});
  463.  
  464.     _refreshController.loadComplete();
  465.   }
  466.  
  467.   void goToNewScreen(BuildContext context, String docId, String docTanggal, String docType, String docNo, String docRevised, String docStatDok) async {
  468.     SharedPreferences prefs = await SharedPreferences.getInstance();
  469.  
  470.     setState(() {
  471.       prefs.setString('persetujuan_docId', docId);
  472.       prefs.setString('persetujuan_docTanggal', docTanggal);
  473.       prefs.setString('persetujuan_docType', docType);
  474.       prefs.setString('persetujuan_docNo', docNo);
  475.       prefs.setString('persetujuan_docRevised', docRevised);
  476.       prefs.setString('persetujuan_docStatDok', docStatDok);
  477.  
  478.       Navigator.of(context).pushNamed('/PersetujuanDetailPage');
  479.     });
  480.   }
  481.  
  482.   void _bottomSheetFilterSearch(context){
  483.     showModalBottomSheet(
  484.       context: context,
  485.       backgroundColor: Colors.transparent,
  486.       builder: (BuildContext bc){
  487.         return Container(
  488.           decoration: BoxDecoration(
  489.             color: Colors.white,
  490.             borderRadius: new BorderRadius.only(
  491.               topLeft: const Radius.circular(20.0),
  492.               topRight: const Radius.circular(20.0)
  493.             )
  494.           ),
  495.           child: new Wrap(
  496.             children: <Widget>[
  497.               new Column(
  498.                 children: <Widget>[
  499.                   new Divider(height: 20),
  500.                   new InkWell(
  501.                     onTap: () => showDialogListData(context, "Jenis Dokumen"),
  502.                     child: Container(
  503.                       height: 40,
  504.                       width: double.infinity,
  505.                       margin: EdgeInsets.fromLTRB(10, 5, 10, 5),
  506.                       decoration: BoxDecoration(
  507.                         color: Colors.grey[100],
  508.                         borderRadius: new BorderRadius.all(const Radius.circular(20.0)),
  509.                         border: Border.all(color: Colors.grey)
  510.                       ),
  511.                       child: Padding(
  512.                         padding: EdgeInsets.all(10),
  513.                         child: Text((_currentDocType2 == null) ? "Pilih Jenis Dokumen" : _currentDocType2)
  514.                       )
  515.                     )
  516.                   ),
  517.                   new InkWell(
  518.                     onTap: () => showDialogListData(context, "Status Dokumen"),
  519.                     child: Container(
  520.                       height: 40,
  521.                       width: double.infinity,
  522.                       margin: EdgeInsets.fromLTRB(10, 5, 10, 5),
  523.                       decoration: BoxDecoration(
  524.                         color: Colors.grey[100],
  525.                         borderRadius: new BorderRadius.all(const Radius.circular(20.0)),
  526.                         border: Border.all(color: Colors.grey)
  527.                       ),
  528.                       child: Padding(
  529.                         padding: EdgeInsets.all(10),
  530.                         child: Text((_currentDocStat == null) ? "Pilih Status Dokumen" : _currentDocStat)
  531.                       )
  532.                     )
  533.                   ),
  534.                   Divider(height: 20),
  535.                   InkWell(
  536.                     onTap: () => {
  537.                       setState((){
  538.                         loading = true;
  539.                         updateCounter = false;
  540.                       }),
  541.                       Navigator.pop(context),
  542.                       getData("DOKUMENDAFTAR", _currentDocType1, "", "", "", "", "", "", "", _currentDocStat, "0", "100", groupId)
  543.                     },
  544.                     child: Container(
  545.                       margin: EdgeInsets.all(10.0),
  546.                       padding: EdgeInsets.all(10.0),
  547.                       decoration: BoxDecoration(
  548.                         color: Colors.lightBlue,
  549.                         borderRadius: new BorderRadius.all(const Radius.circular(20.0)),
  550.                       ),
  551.                       width: double.infinity,
  552.                       child: Text(
  553.                         "CARI",
  554.                         style: TextStyle(color: Colors.white),
  555.                         textAlign: TextAlign.center
  556.                       ),
  557.                     ),
  558.                   )
  559.                 ],
  560.               ),
  561.             ]
  562.           )
  563.         );
  564.       }
  565.     );
  566.   }
  567.  
  568.   void showDialogListData(BuildContext context, String listData){
  569.     AlertDialog dialog = new AlertDialog(
  570.       shape: RoundedRectangleBorder(
  571.         borderRadius: BorderRadius.circular(10.0),
  572.       ),
  573.       elevation: 0.0,
  574.       backgroundColor: Colors.transparent,
  575.       content: listDataContent(context, listData)
  576.     );
  577.  
  578.     showDialog(context: context, child: dialog);
  579.   }
  580.  
  581.   listDataContent(context, listData) {
  582.     return Container(
  583.       height: 350,
  584.       width: 300,
  585.       decoration: new BoxDecoration(
  586.         color: Colors.blue,
  587.         shape: BoxShape.rectangle,
  588.         borderRadius: BorderRadius.circular(20.0),
  589.         boxShadow: [
  590.           BoxShadow(
  591.             color: Colors.black26,
  592.             blurRadius: 10.0,
  593.             offset: const Offset(0.0, 10.0),
  594.           ),
  595.         ],
  596.       ),
  597.       child: Column(
  598.         children: <Widget>[
  599.           Container(
  600.             padding: EdgeInsets.only(top: 10, bottom: 10),
  601.             child: Text("$listData", style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold)),
  602.           ),
  603.           Container(
  604.             decoration: new BoxDecoration(
  605.               color: Colors.white,
  606.               shape: BoxShape.rectangle,
  607.               borderRadius: BorderRadius.only(
  608.                 bottomLeft: const Radius.circular(20.0),
  609.                 bottomRight: const Radius.circular(20.0)
  610.               )
  611.             ),
  612.             height: 308,
  613.             width: 300,
  614.             padding: EdgeInsets.only(bottom: 10),
  615.             child: ListView.builder(
  616.               shrinkWrap: true,
  617.               itemCount: (listData == 'Jenis Dokumen') ?
  618.                 (jenisDokumenList == null) ? 0 : jenisDokumenList.length :
  619.                 (statusDokumenList == null) ? 0 : statusDokumenList.length,
  620.               itemBuilder: (BuildContext context, int index) {
  621.                 return InkWell(
  622.                   highlightColor: Colors.white.withAlpha(30),
  623.                   splashColor: Colors.white.withAlpha(20),
  624.                   child: Padding(
  625.                     padding: EdgeInsets.all(5),
  626.                     child: Text((listData == 'Jenis Dokumen') ? jenisDokumenList[index]["keterangan"] : statusDokumenList[index]),
  627.                   ),
  628.                   onTap: () =>
  629.                   {                
  630.                     Navigator.pop(context),
  631.                     rebuildView(index, listData)
  632.                   },
  633.                 );
  634.               }
  635.             )
  636.           )
  637.         ],
  638.       )
  639.     );
  640.   }
  641.  
  642.   void rebuildView(int index, String listData){
  643.     (listData == 'Jenis Dokumen') ?
  644.       setState((){
  645.         _currentDocType1 = jenisDokumenList[index]["jenis"];
  646.         _currentDocType2 = jenisDokumenList[index]["keterangan"];
  647.       }) :
  648.       setState((){
  649.         _currentDocStat = statusDokumenList[index];
  650.       });
  651.  
  652.     Navigator.pop(context);
  653.     _bottomSheetFilterSearch(context);
  654.   }
  655.  
  656.   // void showDialogPerpanjangVl(BuildContext context, dataList){
  657.   //   AlertDialog dialog = new AlertDialog(
  658.   //     shape: RoundedRectangleBorder(
  659.   //       borderRadius: BorderRadius.circular(10.0),
  660.   //     ),
  661.   //     elevation: 0.0,
  662.   //     backgroundColor: Colors.transparent,
  663.   //     content: dialogContent(context)
  664.   //   );
  665.  
  666.   //   showDialog(context: context, child: dialog);
  667.   // }
  668.  
  669.   // dialogContent(context, ) {
  670.  
  671.   // }
  672. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement