Advertisement
febu19

Untitled

Dec 3rd, 2019
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 83.55 KB | None | 0 0
  1. import 'dart:async';
  2. import 'dart:io';
  3.  
  4. import 'package:cached_network_image/cached_network_image.dart';
  5. import 'package:dio/dio.dart';
  6. import 'package:flutter/material.dart';
  7. import 'package:flutter_calendar_carousel/classes/event.dart';
  8. import 'package:flutter_calendar_carousel/classes/event_list.dart';
  9. import 'package:geolocator/geolocator.dart';
  10. import 'package:rflutter_alert/rflutter_alert.dart';
  11. import 'package:rohisapp/endpoint/api.dart';
  12. import 'package:rohisapp/model/amalanModel.dart';
  13. import 'package:rohisapp/model/artikel.dart';
  14. import 'package:rohisapp/model/event_model.dart';
  15. import 'package:rohisapp/model/youtube_model.dart';
  16. import 'package:rohisapp/notification/firebase_notification_handler.dart';
  17. import 'package:rohisapp/page/amalan_harian.dart';
  18. import 'package:rohisapp/page/arahKiblat.dart';
  19. import 'package:rohisapp/page/artikel.dart';
  20. import 'package:rohisapp/page/artikel_detail.dart';
  21. import 'package:flutter_calendar_carousel/flutter_calendar_carousel.dart';
  22. import 'package:intl/intl.dart' show DateFormat, toBeginningOfSentenceCase;
  23. import 'package:flutter_calendar/flutter_calendar.dart';
  24. import 'package:rohisapp/page/dzkirdoa.dart';
  25. import 'package:rohisapp/page/jadwal_shalat.dart';
  26. import 'package:rohisapp/page/jadwal_sholat.dart';
  27. import 'package:rohisapp/page/kalender.dart';
  28. import 'package:rohisapp/page/kalender_kegiatan.dart';
  29. import 'package:rohisapp/page/kiblat.dart';
  30. import 'package:rohisapp/page/login.dart';
  31. import 'package:rohisapp/page/notif.dart';
  32. import 'package:rohisapp/page/notifikasi.dart';
  33. import 'package:rohisapp/page/pengaturan.dart';
  34. import 'package:rohisapp/page/quran.dart';
  35. import 'package:rohisapp/page/screen/quran_list.dart';
  36. import 'package:rohisapp/page/video_kajian.dart';
  37. import 'package:rohisapp/page/video_kajian_detail.dart';
  38. import 'package:shared_preferences/shared_preferences.dart';
  39. import 'package:permission_handler/permission_handler.dart';
  40. import 'package:android_intent/android_intent.dart';
  41. import 'package:device_info/device_info.dart';
  42. import 'package:geocoder/geocoder.dart';
  43. import 'package:flutter/material.dart';
  44. import 'package:flutter/services.dart';
  45. import 'dart:math' as math;
  46. import 'package:html_unescape/html_unescape.dart';
  47. import 'package:sliding_up_panel/sliding_up_panel.dart';
  48. import 'package:pull_to_refresh/pull_to_refresh.dart';
  49. import 'kiblatcompass.dart';
  50.  
  51. class HomePanel extends StatefulWidget {
  52.   @override
  53.   _HomePanelState createState() => _HomePanelState();
  54. }
  55.  
  56. class _HomePanelState extends State<HomePanel>
  57.     with SingleTickerProviderStateMixin {
  58.   Future<List<AmalanModel>> _listFutureAmalan;
  59.   Future<List<ArtikelModel>> _listFutureArtikel;
  60.   Future<List<YoutubeModel>> _listFutureYoutube;
  61.   final RefreshController _refreshController = RefreshController();
  62.   double _panelHeightOpen = 300.0;
  63.   double _panelHeightClosed = 100.0;
  64.   int jumartikel = 0;
  65.   Timer timer;
  66.   String timeText = '';
  67.   String statusText = '';
  68.   int jam = 0;
  69.   int menit = 0;
  70.   int detik = 0;
  71.   Stopwatch stopwatch = Stopwatch();
  72.   static const delay = Duration(microseconds: 1);
  73.  
  74.   var begin = 0.0;
  75.   Animation<double> heightSize;
  76.   AnimationController controller;
  77.   void updateClock() {
  78.     final duration = Duration(hours: jam, minutes: menit, seconds: detik);
  79.  
  80.     // if time is up, stop the timer
  81.     if (stopwatch.elapsed.inMilliseconds == duration.inMilliseconds) {
  82.       print('--finished Timer Page--');
  83.       stopwatch.stop();
  84.       stopwatch.reset();
  85.       controller.stop(canceled: false);
  86.       setState(() {
  87.         statusText = 'Finished';
  88.         // buttonText = "Restart";
  89.       });
  90.       return;
  91.     } else {
  92.       statusText = '';
  93.     }
  94.  
  95.     final millisecondsRemaining =
  96.         duration.inMilliseconds - stopwatch.elapsed.inMilliseconds;
  97.     final hoursRemaining =
  98.         ((millisecondsRemaining / (1000 * 60 * 60)) % 24).toInt();
  99.     final minutesRemaining =
  100.         ((millisecondsRemaining / (1000 * 60)) % 60).toInt();
  101.     final secondsRemaining = ((millisecondsRemaining / 1000) % 60).toInt();
  102.  
  103.     setState(() {
  104.       timeText = '${hoursRemaining.toString().padLeft(2, '0')}:'
  105.           '${minutesRemaining.toString().padLeft(2, '0')}:'
  106.           '${secondsRemaining.toString().padLeft(2, '0')}';
  107.     });
  108.  
  109.     if (stopwatch.isRunning) {
  110.       setState(() {});
  111.     } else if (stopwatch.elapsed.inSeconds == 0) {
  112.       setState(() {
  113.         timeText = '${jam.toString().padLeft(2, "0")}:'
  114.             '${menit.toString().padLeft(2, '0')}:'
  115.             '${detik.toString().padLeft(2, '0')}';
  116.       });
  117.     } else {
  118.       setState(() {});
  119.     }
  120.   }
  121.  
  122.   Position positions;
  123.   double lat;
  124.   double long;
  125.   PermissionStatus _statusPermission;
  126.   static double _minHeight = 130, _maxHeight = 290;
  127.   Offset _offset = Offset(0, _minHeight);
  128.   bool _isOpen = false;
  129.   DateTime _currentDate = DateTime.now();
  130.   DateTime _currentDate2 = DateTime.now();
  131.   DateTime _targetDateTime = DateTime.now();
  132.   String _currentMonth = '';
  133.   bool content = false;
  134.   SharedPreferences sharedPreferences;
  135.   bool islogin = false;
  136.   var email = "";
  137.   var userid = "";
  138.   var full_name = "";
  139.   var waktu_sholat = "";
  140.   var jam_sholat = "";
  141.   var kota = "";
  142.   var lokasiAdzan = "";
  143.   var tglHijriah = "";
  144.   var tglMasehi = "";
  145.   var deviceid = "";
  146.   var lokasi_adzan = "";
  147.   String timerString = '';
  148.  
  149.   static Widget _eventIcon = new Container(
  150.     decoration: new BoxDecoration(
  151.         color: Colors.white,
  152.         borderRadius: BorderRadius.all(Radius.circular(1000)),
  153.         border: Border.all(color: Colors.blue, width: 2.0)),
  154.     child: new Icon(
  155.       Icons.check_circle,
  156.       color: Colors.blue,
  157.     ),
  158.   );
  159.  
  160.   static Widget _holidayIcon = new Container(
  161.     decoration: new BoxDecoration(
  162.         color: Colors.white,
  163.         borderRadius: BorderRadius.all(Radius.circular(1000)),
  164.         border: Border.all(color: Colors.red, width: 2.0)),
  165.     child: new Icon(
  166.       Icons.home,
  167.       color: Colors.red,
  168.     ),
  169.   );
  170.  
  171.   EventList<Event> _markedDateMap = EventList<Event>();
  172.   List<EventModel> _listEvent = [];
  173.  
  174.   CalendarCarousel _calendarCarousel, _calendarCarouselNoHeader;
  175.  
  176.   void handleNewDate(date) {
  177.     print("handleNewDate ${date}");
  178.   }
  179.  
  180.   getDeviceDetails() async {
  181.     String deviceName;
  182.     String deviceVersion;
  183.     String identifier;
  184.     final DeviceInfoPlugin deviceInfoPlugin = new DeviceInfoPlugin();
  185.     try {
  186.       if (Platform.isAndroid) {
  187.         var build = await deviceInfoPlugin.androidInfo;
  188.         deviceName = build.model;
  189.         deviceVersion = build.version.toString();
  190.         identifier = build.androidId; //UUID for Android
  191.         print('identifier ' + identifier);
  192.       } else if (Platform.isIOS) {
  193.         var data = await deviceInfoPlugin.iosInfo;
  194.         deviceName = data.name;
  195.         deviceVersion = data.systemVersion;
  196.         identifier = data.identifierForVendor; //UUID for iOS
  197.       }
  198.       setState(() {
  199.         deviceid = identifier;
  200.       });
  201.       _checkJadwalSholat(deviceid);
  202.       String url = new Api().url;
  203.       var dio = new Dio();
  204.       await dio.post(
  205.         url + "index.php/api/Device_info",
  206.         data: {
  207.           "device_id": identifier,
  208.           "deviceName": deviceName,
  209.         },
  210.         options:
  211.             new Options(contentType: ContentType.parse("application/json")),
  212.       );
  213.     } catch (e) {
  214.       print('Failed to get platform version');
  215.     }
  216.  
  217.     return [deviceName, deviceVersion, identifier];
  218.   }
  219.  
  220.   _checkJadwalSholat(identifier) async {
  221.     var now = new DateTime.now();
  222.     var formatter = new DateFormat('MM');
  223.     var dates = formatter.format(now);
  224.  
  225.     String url = new Api().url;
  226.     Response response;
  227.     var dio = new Dio();
  228.     try {
  229.       // for (int i = 1; i <= 7; i++) {
  230.       response = await dio
  231.           .get(url + "index.php/api/CheckJadwalSholat?device_id=" + identifier);
  232.       final json = response.data;
  233.       if (response.statusCode == 200) {
  234.         // print(json.toString());
  235.         lokasiAdzan = json.toString();
  236.         getWaktuSholat(lokasiAdzan);
  237.         getJadwalSholat(lokasiAdzan);
  238.       } else {
  239.         throw Exception('Failed to load');
  240.       }
  241.     } on DioError catch (e) {
  242.       print("GAGAL");
  243.  
  244.       if (e.response != null) {
  245.         print(e.response.data);
  246.         print(e.response.headers);
  247.         print(e.response.request);
  248.       } else {
  249.         print(e.request);
  250.         print(e.message);
  251.       }
  252.     }
  253.   }
  254.  
  255.  
  256.  
  257.   @override
  258.   void initState() {
  259.     new FirebaseNotifications().setUpFirebase();
  260.     // requestLocationPermission(context);
  261.     // getWaktuSholat();
  262.  
  263.     super.initState();
  264.     (() async {
  265.       await _event();
  266.       await _hariLibur();
  267.       await getDeviceDetails();
  268.       // await getJadwalSholat();
  269.       sharedPreferences = await SharedPreferences.getInstance();
  270.       setState(() {
  271.         if (sharedPreferences.getBool("isLogin") != null) {
  272.           islogin = sharedPreferences.getBool("isLogin");
  273.           email = sharedPreferences.getString("email");
  274.           full_name = sharedPreferences.getString("full_name");
  275.           userid = sharedPreferences.getString("userid");
  276.         } else {
  277.           full_name = "";
  278.         }
  279.       });
  280.      
  281.        _listFutureAmalan = fetchAmalanBelumDikerjakan();
  282.   _listFutureArtikel = fetchArtikel();
  283.    _listFutureYoutube = fetchVideo();
  284.     })();
  285.     // _askPermission();
  286.   }
  287.  
  288.   @override
  289.   void dispose() {
  290.     controller.dispose();
  291.     stopwatch.stop();
  292.     timer.cancel();
  293.  
  294.     super.dispose();
  295.   }
  296.  
  297.   getJadwalSholat(lokasi) async {
  298.     String url = new Api().url;
  299.     Response response;
  300.     response = await Dio()
  301.         .get(url + "index.php/api/JadwalSholatByKota?kota=" + lokasi);
  302.   }
  303.  
  304.   void getWaktuSholat(lokasi) async {
  305.     String url = new Api().url;
  306.  
  307.     Response response;
  308.     response = await Dio().get(url + "index.php/api/NextPrayer?kota=" + lokasi);
  309.     final json = response.data;
  310.     print('json ' + json.toString());
  311.     setState(() {
  312.       waktu_sholat = json["waktu_sholat"].toString();
  313.       jam_sholat = json["jam"].toString();
  314.       tglHijriah = json["hijr"].toString();
  315.       tglMasehi = json["tanggal"];
  316.       detik = int.parse(json["detik"]);
  317.       jam = int.parse(json["jams"]);
  318.       menit = int.parse(json["menit"]);
  319.  
  320.       print('tglMasehi ' + tglMasehi);
  321.     });
  322.   }
  323.  
  324.   // void requestLocationPermission(BuildContext context) async {
  325.   //   try {
  326.   //     Position currentPosition = await Geolocator()
  327.   //         .getCurrentPosition(desiredAccuracy: LocationAccuracy.best);
  328.   //     if (this.mounted) {
  329.   //       final coordinates = new Coordinates(
  330.   //           currentPosition.latitude, currentPosition.longitude);
  331.   //       var addresses =
  332.   //           await Geocoder.local.findAddressesFromCoordinates(coordinates);
  333.   //       List<Address> first = addresses;
  334.  
  335.   //       setState(() {
  336.   //         lat = currentPosition.latitude;
  337.   //         long = currentPosition.longitude;
  338.   //         kota = first[0].subAdminArea;
  339.   //         print("position " + currentPosition.toString());
  340.   //       });
  341.   //       getWaktuSholat(currentPosition.latitude, currentPosition.longitude);
  342.   //     }
  343.   //   } on PlatformException catch (e) {
  344.   //     print("!!!!" + e.toString());
  345.   //   } catch (e) {
  346.   //     print("!!GEOLOC ERROR " + e.toString());
  347.   //   }
  348.   // }
  349.  
  350.   // void _askPermission() {
  351.   //   PermissionHandler().requestPermissions(
  352.   //       [PermissionGroup.locationWhenInUse]).then(_onStatusRequested);
  353.   // }
  354.  
  355.   // void _onStatusRequested(Map<PermissionGroup, PermissionStatus> statuses) {
  356.   //   final status = statuses[PermissionGroup.locationWhenInUse];
  357.   //   if (status != PermissionStatus.granted) {
  358.   //     new Alert(
  359.   //       context: context,
  360.   //       type: AlertType.warning,
  361.   //       title: "Aktifkan Lokasi ?",
  362.   //       desc: "Untuk Mengakses Fitur ini Anda Harus mengaktifkan Lokasi Anda",
  363.   //       buttons: [
  364.   //         DialogButton(
  365.   //           child: Text(
  366.   //             "TIDAK",
  367.   //             style: TextStyle(color: Colors.white, fontSize: 20),
  368.   //           ),
  369.   //           onPressed: () {
  370.   //             Navigator.of(context).push(new MaterialPageRoute(builder: (_) {
  371.   //               return new Home();
  372.   //             }));
  373.   //           },
  374.   //           color: Colors.blue,
  375.   //         ),
  376.   //         DialogButton(
  377.   //           child: Text(
  378.   //             "YA",
  379.   //             style: TextStyle(color: Colors.white, fontSize: 20),
  380.   //           ),
  381.   //           onPressed: () async {
  382.   //             openLocationSetting();
  383.   //             Navigator.of(context).pop();
  384.   //           },
  385.   //           color: Colors.blue,
  386.   //         )
  387.   //       ],
  388.   //     ).show();
  389.   //   }
  390.   // }
  391.  
  392.   void openLocationSetting() async {
  393.     final AndroidIntent intent = new AndroidIntent(
  394.       action: 'android.settings.LOCATION_SOURCE_SETTINGS',
  395.     );
  396.     await intent.launch();
  397.   }
  398.  
  399.   Widget _content() {
  400.     if (content == true) {
  401.       return Text(
  402.           "Pertama, banyak membaca tasbih.\n\nKedua, membaca Al Ikhlash, Al Falaq dan An Nas (3x) (HR. Abu Dawud 5082 dan Tirmidzi 3575, dihasankan Albani)\n\n Ketiga, ketika pagi membaca (1x):\n\nأَصْبَحْنَا وَأَصْبَحَ الْمُلْكُ لِلَّهِ، وَالْحَمْدُ لِلَّهِ، لاَ إِلَـهَ إِلاَّ اللهُ وَحْدَهُ لاَ شَرِيْكَ لَهُ، لَهُ الْمُلْكُ وَلَهُ الْحَمْدُ وَهُوَ عَلَى كُلِّ شَيْءٍ قَدِيْرُ. رَبِّ أَسْأَلُكَ خَيْرَ مَا فِيْ هَذَا الْيَوْمِ وَخَيْرَ مَا بَعْدَهُ، وَأَعُوْذُ بِكَ مِنْ شَرِّ مَا فِيْ هَذَا الْيَوْمِ وَشَرِّ مَا بَعْدَهُ، رَبِّ أَعُوْذُ بِكَ مِنَ الْكَسَلِ وَسُوْءِ الْكِبَرِ، رَبِّ أَعُوْذُ بِكَ مِنْ عَذَابٍ فِي النَّارِ وَعَذَابٍ فِي الْقَبْرِ \n\nKeempat, ketika pagi membaca (1x):\n\n اَللَّهُمَّ بِكَ أَصْبَحْنَا، وَبِكَ أَمْسَيْنَا، وَبِكَ نَحْيَا، وَبِكَ نَمُوْتُ وَإِلَيْكَ النُّشُوْرُ \n\nKelima, membaca sayyidul istighfar (1x):\n\nاَللَّهُمَّ أَنْتَ رَبِّيْ لاَ إِلَـهَ إِلاَّ أَنْتَ، خَلَقْتَنِيْ وَأَنَا عَبْدُكَ، وَأَنَا عَلَى عَهْدِكَ وَوَعْدِكَ مَا اسْتَطَعْتُ، أَعُوْذُ بِكَ مِنْ شَرِّ مَا صَنَعْتُ، أَبُوْءُ لَكَ بِنِعْمَتِكَ عَلَيَّ، وَأَبُوْءُ بِذَنْبِيْ فَاغْفِرْ لِيْ فَإِنَّهُ لاَ يَغْفِرُ الذُّنُوْبَ إِلاَّ أَنْتَ. \n\nKeenam, membaca (3x):\n\nرَضِيْتُ بِاللهِ رَبًّا، وَبِاْلإِسْلاَمِ دِيْنًا، وَبِمُحَمَّدٍ صَلَّى اللهُ عَلَيْهِ وَسَلَّمَ نَبِيًّ \n\nKetujuh, membaca (1x):\n\nيَا حَيُّ يَا قَيُّوْمُ بِرَحْمَتِكَ أَسْتَغِيْثُ، أَصْلِحْ لِيْ شَأْنِيْ كُلَّهُ وَلاَ تَكِلْنِيْ إِلَى نَفْسِيْ طَرْفَةَ عَيْنٍ وَبِمُحَمَّدٍ صَلَّى اللهُ عَلَيْهِ وَسَلَّمَ نَبِيًّا");
  403.     } else {
  404.       return Container();
  405.     }
  406.   }
  407.  
  408.   Future<List<AmalanModel>> fetchAmalanBelumDikerjakan() async {
  409.     String url = new Api().url;
  410.     var dio = new Dio();
  411.     try {
  412.       var notes = List<AmalanModel>();
  413.  
  414.       Response response;
  415.       response = await dio.get(
  416.           url + "index.php/api/AmalanBelumDikerjakan?id_device=" + deviceid);
  417.       final json = response.data;
  418.       if (response.statusCode == 200) {
  419.         notes = (json)
  420.             .map<AmalanModel>((item) => AmalanModel.fromJson(item))
  421.             .toList();
  422.       } else {
  423.         throw Exception('Failed to load');
  424.       }
  425.       return new Future.delayed(new Duration(seconds: 1), () {
  426.         return notes.where((i) => i.id_amalan_harian != null).toList();
  427.       });
  428.     } catch (e) {
  429.       print('Failed to get platform version');
  430.     }
  431.   }
  432.  
  433.   _amalkan(idamal) async {
  434.     var now = new DateTime.now();
  435.     var formatter = new DateFormat('yyyy-MM-dd');
  436.     var dates = formatter.format(now);
  437.     String url = new Api().url;
  438.     var dio = new Dio();
  439.     print("idamal " + idamal.toString());
  440.     try {
  441.       await dio.post(
  442.         url + "index.php/api/Amalan",
  443.         data: {
  444.           "id_amalan_harian": idamal,
  445.           "id_device": deviceid,
  446.           "tanggal": dates,
  447.           "diamalkan": "1",
  448.           "created_by": "user",
  449.         },
  450.         options:
  451.             new Options(contentType: ContentType.parse("application/json")),
  452.       );
  453.       print("SUKSES");
  454.       new Alert(
  455.         context: context,
  456.         type: AlertType.success,
  457.         title: "Sukses",
  458.         desc: "Data Disimpan",
  459.         buttons: [
  460.           DialogButton(
  461.             child: Text(
  462.               "OK",
  463.               style: TextStyle(color: Colors.white, fontSize: 20),
  464.             ),
  465.             onPressed: () {
  466.               Navigator.of(context)
  467.                   .pushReplacement(new MaterialPageRoute(builder: (_) {
  468.                 return new HomePanel();
  469.               }));
  470.             },
  471.             width: 120,
  472.           )
  473.         ],
  474.       ).show();
  475.     } on DioError catch (e) {
  476.       print("GAGAL");
  477.       new Alert(
  478.         context: context,
  479.         type: AlertType.warning,
  480.         title: "Gagal",
  481.         desc: "Data Gagal Disimpan",
  482.         buttons: [
  483.           DialogButton(
  484.             child: Text(
  485.               "OK",
  486.               style: TextStyle(color: Colors.white, fontSize: 20),
  487.             ),
  488.             onPressed: () {
  489.               Navigator.of(context).pop();
  490.             },
  491.             width: 120,
  492.           )
  493.         ],
  494.       ).show();
  495.  
  496.       if (e.response != null) {
  497.         print(e.response.data);
  498.         print(e.response.headers);
  499.         print(e.response.request);
  500.       } else {
  501.         print(e.request);
  502.         print(e.message);
  503.       }
  504.     }
  505.   }
  506.  
  507.   _event() async {
  508.     String url = new Api().url;
  509.     Response res;
  510.     var dio = new Dio();
  511.     try {
  512.       res = await dio.get(url + "index.php/api/Jadwal_kajian");
  513.  
  514.       final dataEvents = res.data;
  515.       if (res.statusCode == 200) {
  516.         for (int i = 0; i < int.parse(dataEvents[0]['total']); i++) {
  517.           var now = DateTime.parse(dataEvents[i]['date']);
  518.           var end = DateTime.parse(dataEvents[i]['dates']);
  519.           var formatter = new DateFormat('dd/MM/yyyy');
  520.           var dates = formatter.format(now);
  521.           var datesend = formatter.format(end);
  522.           var formatterJam = new DateFormat('HH:mm');
  523.           var jam = formatterJam.format(now);
  524.           var unescape = new HtmlUnescape();
  525.           var text = unescape.convert(dataEvents[i]['ustadz']);
  526.           var kat = unescape.convert(dataEvents[i]['kategori']);
  527.           var lokasi = unescape.convert(dataEvents[i]['lokasi']);
  528.           _markedDateMap.add(
  529.             new DateTime(
  530.                 int.parse(dataEvents[i]['eventyear']),
  531.                 int.parse(dataEvents[i]['eventmonth']),
  532.                 int.parse(dataEvents[i]['eventday'])),
  533.             new Event(
  534.               date: new DateTime(
  535.                   int.parse(dataEvents[i]['eventyear']),
  536.                   int.parse(dataEvents[i]['eventmonth']),
  537.                   int.parse(dataEvents[i]['eventday'])),
  538.               title: dataEvents[i]['title'] +
  539.                   '-' +
  540.                   dates +
  541.                   ' s/d ' +
  542.                   datesend +
  543.                   '-' +
  544.                   jam +
  545.                   '-' +
  546.                   text +
  547.                   '*' +
  548.                   kat,
  549.               desc: text + '-' + lokasi,
  550.               icon: _eventIcon,
  551.             ),
  552.           );
  553.         }
  554.       } else {
  555.         throw Exception('Failed to load');
  556.       }
  557.     } on DioError catch (e) {
  558.       print("GAGAL");
  559.  
  560.       if (e.response != null) {
  561.         print(e.response.data);
  562.         print(e.response.headers);
  563.         print(e.response.request);
  564.       } else {
  565.         print(e.request);
  566.         print(e.message);
  567.       }
  568.     }
  569.   }
  570.  
  571.   _hariLibur() async {
  572.     String url = new Api().url;
  573.     Response res;
  574.     var dio = new Dio();
  575.     try {
  576.       res = await dio.get(url + "index.php/api/Jadwal_kajian/harilibur");
  577.  
  578.       final dataEvents = res.data;
  579.       if (res.statusCode == 200) {
  580.         for (int i = 0; i < int.parse(dataEvents[0]['total']); i++) {
  581.           var now = DateTime.parse(dataEvents[i]['date']);
  582.           var end = DateTime.parse(dataEvents[i]['dates']);
  583.           var formatter = new DateFormat('dd/MM/yyyy');
  584.           var dates = formatter.format(now);
  585.           var datesend = formatter.format(end);
  586.           var formatterJam = new DateFormat('HH:mm');
  587.           var jam = formatterJam.format(now);
  588.           var unescape = new HtmlUnescape();
  589.           var text = unescape.convert(dataEvents[i]['ustadz']);
  590.           var kat = unescape.convert(dataEvents[i]['kategori']);
  591.           var lokasi = unescape.convert(dataEvents[i]['lokasi']);
  592.           var description_event =
  593.               unescape.convert(dataEvents[i]['description_event']);
  594.  
  595.           _markedDateMap.add(
  596.             new DateTime(
  597.                 int.parse(dataEvents[i]['eventyear']),
  598.                 int.parse(dataEvents[i]['eventmonth']),
  599.                 int.parse(dataEvents[i]['eventday'])),
  600.             new Event(
  601.               date: new DateTime(
  602.                   int.parse(dataEvents[i]['eventyear']),
  603.                   int.parse(dataEvents[i]['eventmonth']),
  604.                   int.parse(dataEvents[i]['eventday'])),
  605.               title: dataEvents[i]['title'] +
  606.                   '-' +
  607.                   dates +
  608.                   ' s/d ' +
  609.                   datesend +
  610.                   '-' +
  611.                   jam +
  612.                   '-' +
  613.                   text +
  614.                   '*' +
  615.                   kat,
  616.               desc: text + '-' + lokasi,
  617.               icon: _holidayIcon,
  618.             ),
  619.           );
  620.         }
  621.       } else {
  622.         throw Exception('Failed to load');
  623.       }
  624.     } on DioError catch (e) {
  625.       print("GAGAL");
  626.  
  627.       if (e.response != null) {
  628.         print(e.response.data);
  629.         print(e.response.headers);
  630.         print(e.response.request);
  631.       } else {
  632.         print(e.request);
  633.         print(e.message);
  634.       }
  635.     }
  636.   }
  637.  
  638.   _viewEven(title, desc) async {
  639.     var kajian = title.toString().split('-');
  640.     var deskripsi = desc.toString().split('-');
  641.     var kategori = title.toString().split('*');
  642.     var titles = "";
  643.     var judul = "";
  644.     var newtgl = "";
  645.     var jam = "";
  646.     var ustadz = "";
  647.     var tgl = "";
  648.     var lokasi = '';
  649.     if (kategori[1] == '1') {
  650.       titles = 'Hari Libur';
  651.       judul = '';
  652.       tgl = '';
  653.       newtgl = kajian[0].toString();
  654.       jam = '';
  655.       ustadz = '';
  656.       lokasi = '';
  657.     } else {
  658.       judul = 'Tema : ' + kajian[0].toString();
  659.       tgl = kajian[1].toString();
  660.       newtgl = 'Tanggal : ' + tgl.replaceAll('s/d', '-');
  661.       jam = 'Jam : ' + kajian[2].toString();
  662.       ustadz = 'Pengisi : ' + deskripsi[0].toString();
  663.       lokasi = 'Lokasi : ' + deskripsi[1].toString();
  664.       titles = 'Jadwal Kajian';
  665.     }
  666.     showDialog(
  667.       context: context,
  668.       builder: (BuildContext context) {
  669.         return AlertDialog(
  670.           title: new Text(titles),
  671.           content: Container(
  672.             width: MediaQuery.of(context).size.width,
  673.             child: SingleChildScrollView(
  674.               child: Column(
  675.                 children: <Widget>[
  676.                   new Row(
  677.                     children: <Widget>[
  678.                       Text(
  679.                         newtgl,
  680.                         style: TextStyle(fontSize: 12),
  681.                       ),
  682.                     ],
  683.                   ),
  684.                   new Padding(
  685.                     padding: EdgeInsets.only(top: 5.0),
  686.                   ),
  687.                   new Row(
  688.                     children: <Widget>[
  689.                       Text(
  690.                         jam,
  691.                         style: TextStyle(fontSize: 12),
  692.                       ),
  693.                     ],
  694.                   ),
  695.                   new Padding(
  696.                     padding: EdgeInsets.only(top: 5.0),
  697.                   ),
  698.                   new Row(
  699.                     children: <Widget>[
  700.                       Text(judul, style: TextStyle(fontSize: 12)),
  701.                     ],
  702.                   ),
  703.                   new Padding(
  704.                     padding: EdgeInsets.only(top: 5.0),
  705.                   ),
  706.                   new Row(
  707.                     children: <Widget>[
  708.                       Text(ustadz, style: TextStyle(fontSize: 12)),
  709.                     ],
  710.                   ),
  711.                   new Padding(
  712.                     padding: EdgeInsets.only(top: 5.0),
  713.                   ),
  714.                   new Row(
  715.                     children: <Widget>[
  716.                       Text(lokasi, style: TextStyle(fontSize: 12)),
  717.                     ],
  718.                   ),
  719.                   new Padding(
  720.                     padding: EdgeInsets.only(top: 15.0),
  721.                   ),
  722.                   DialogButton(
  723.                     child: Text(
  724.                       "OK",
  725.                       style: TextStyle(color: Colors.white, fontSize: 20),
  726.                     ),
  727.                     onPressed: () {
  728.                       Navigator.of(context).pop();
  729.                     },
  730.                     width: 120,
  731.                   )
  732.                 ],
  733.               ),
  734.             ),
  735.           ),
  736.         );
  737.       },
  738.     );
  739.   }
  740.  
  741.   @override
  742.   Widget build(BuildContext context) {
  743.     _calendarCarouselNoHeader = CalendarCarousel<Event>(
  744.       todayBorderColor: Colors.green,
  745.       onDayPressed: (DateTime date, List<Event> events) {
  746.         this.setState(() => _currentDate2 = date);
  747.         for (var item in events) {
  748.           _viewEven(item.title, item.desc);
  749.         }
  750.         // events.forEach((event) => _checkExternal(event.title));
  751.         print(events[0].title);
  752.       },
  753.       weekendTextStyle: TextStyle(
  754.         color: Colors.red,
  755.       ),
  756.       thisMonthDayBorderColor: Colors.grey,
  757.       weekFormat: false,
  758.       markedDatesMap: _markedDateMap,
  759.       height: 310.0,
  760.       selectedDateTime: _currentDate2,
  761.         targetDateTime: _targetDateTime,
  762.       customGridViewPhysics: NeverScrollableScrollPhysics(),
  763.       markedDateShowIcon: true,
  764.       markedDateIconMaxShown: 2,
  765.       markedDateMoreShowTotal:
  766.           false, // null for not showing hidden events indicator
  767.       showHeader: false,
  768.       markedDateIconBuilder: (event) {
  769.         return event.icon;
  770.       },
  771.       todayTextStyle: TextStyle(
  772.         color: Colors.blue,
  773.       ),
  774.       todayButtonColor: Colors.yellow,
  775.       selectedDayTextStyle: TextStyle(
  776.         color: Colors.yellow,
  777.       ),
  778.       minSelectedDate: _currentDate.subtract(Duration(days: 360)),
  779.       maxSelectedDate: _currentDate.add(Duration(days: 360)),
  780.       prevDaysTextStyle: TextStyle(
  781.         fontSize: 16,
  782.         color: Colors.pinkAccent,
  783.       ),
  784.       inactiveDaysTextStyle: TextStyle(
  785.         color: Colors.tealAccent,
  786.         fontSize: 16,
  787.       ),
  788.       onCalendarChanged: (DateTime date) {
  789.         this.setState(() {
  790.           _targetDateTime = date;
  791.           _currentMonth = DateFormat.yMMM().format(_targetDateTime);
  792.         });
  793.       },
  794.     );
  795.     return Scaffold(
  796.         appBar: AppBar(
  797.           backgroundColor: Color.fromRGBO(0, 185, 92, 1),
  798.           title: Center(child: Text("Assalamu'alaikum " + full_name)),
  799.           elevation: 0,
  800.         ),
  801.         body: Stack(
  802.             alignment: Alignment.topCenter,
  803.             children: <Widget>[
  804.               SlidingUpPanel(
  805.                 margin: const EdgeInsets.only(left: 10.0, right: 10.0),
  806.                 maxHeight: _panelHeightOpen,
  807.                 minHeight: _panelHeightClosed,
  808.                 parallaxEnabled: true,
  809.                 parallaxOffset: .5,
  810.                 body: _body(),
  811.                 panel: _panel(),
  812.                 borderRadius: BorderRadius.only(
  813.                     topLeft: Radius.circular(18.0),
  814.                     topRight: Radius.circular(18.0)),
  815.                 onPanelSlide: (double pos) => setState(() {}),
  816.               ),
  817.             ],
  818.          
  819.         ));
  820.   }
  821.  
  822.   Widget _panel() {
  823.     return Column(
  824.       children: <Widget>[
  825.         Container(
  826.           padding: EdgeInsets.only(left: 15.0),
  827.           child: Row(
  828.             children: <Widget>[
  829.               Flexible(
  830.                   flex: 2,
  831.                   child: Column(
  832.                     children: <Widget>[
  833.                       Row(
  834.                         children: <Widget>[
  835.                           Text("",
  836.                               style: TextStyle(
  837.                                   fontSize: 12.0,
  838.                                   fontWeight: FontWeight.normal,
  839.                                   color: Colors.black)),
  840.                         ],
  841.                       ),
  842.                     ],
  843.                   )),
  844.               Padding(padding: EdgeInsets.only(left: 10.0)),
  845.               Flexible(
  846.                   flex: 2,
  847.                   child: Column(
  848.                     children: <Widget>[
  849.                       Row(
  850.                         children: <Widget>[
  851.                           Text(" ",
  852.                               style: TextStyle(
  853.                                   fontSize: 12.0,
  854.                                   fontWeight: FontWeight.normal,
  855.                                   color: Colors.black)),
  856.                         ],
  857.                       ),
  858.                     ],
  859.                   )),
  860.               Padding(padding: EdgeInsets.only(left: 10.0)),
  861.               Flexible(
  862.                   flex: 2,
  863.                   child: Column(
  864.                     children: <Widget>[
  865.                       InkWell(
  866.                         onTap: () {
  867.                           _handleClick();
  868.                           // setState(() {
  869.                           //   _isOpen = true;
  870.                           // });
  871.                         },
  872.                         child: Row(
  873.                           children: <Widget>[
  874.                             Material(
  875.                               color: Colors.black,
  876.                               child: Container(
  877.                                 width: 53.0,
  878.                                 height: 5.0,
  879.                               ), // Container
  880.                             )
  881.                           ],
  882.                         ),
  883.                       ),
  884.                     ],
  885.                   )),
  886.               Padding(padding: EdgeInsets.only(left: 10.0)),
  887.               Flexible(
  888.                   flex: 2,
  889.                   child: Column(
  890.                     children: <Widget>[
  891.                       Row(
  892.                         children: <Widget>[
  893.                           Text("",
  894.                               style: TextStyle(
  895.                                   fontSize: 12.0,
  896.                                   fontWeight: FontWeight.normal,
  897.                                   color: Colors.black)),
  898.                         ],
  899.                       ),
  900.                     ],
  901.                   )),
  902.               Padding(padding: EdgeInsets.only(left: 10.0)),
  903.               Flexible(
  904.                   flex: 2,
  905.                   child: Column(
  906.                     children: <Widget>[
  907.                       Row(
  908.                         children: <Widget>[
  909.                           Text("",
  910.                               style: TextStyle(
  911.                                   fontSize: 12.0,
  912.                                   fontWeight: FontWeight.normal,
  913.                                   color: Colors.black)),
  914.                         ],
  915.                       ),
  916.                     ],
  917.                   )),
  918.             ],
  919.           ),
  920.         ),
  921.         Container(
  922.           padding: EdgeInsets.only(left: 15.0),
  923.           child: Row(
  924.             children: <Widget>[
  925.               Flexible(
  926.                   flex: 2,
  927.                   child: Column(
  928.                     children: <Widget>[
  929.                       Row(
  930.                         children: <Widget>[
  931.                           InkWell(
  932.                             onTap: () {
  933.                               Navigator.of(context).push(new MaterialPageRoute(
  934.                                 builder: (BuildContext context) =>
  935.                                     new DzkirDoa(0),
  936.                               ));
  937.                             },
  938.                             child: Image.asset(
  939.                               'img/doadzikir.png',
  940.                               height: 50.0,
  941.                             ),
  942.                           ),
  943.                         ],
  944.                       ),
  945.                       Row(
  946.                         children: <Widget>[
  947.                           Text("Dzikir & Doa",
  948.                               style: TextStyle(
  949.                                   fontSize: 12.0,
  950.                                   fontWeight: FontWeight.normal,
  951.                                   color: Colors.black)),
  952.                         ],
  953.                       ),
  954.                       Row(
  955.                         children: <Widget>[
  956.                           Text("",
  957.                               style: TextStyle(
  958.                                   fontSize: 12.0,
  959.                                   fontWeight: FontWeight.normal,
  960.                                   color: Colors.black)),
  961.                         ],
  962.                       ),
  963.                     ],
  964.                   )),
  965.               Padding(padding: EdgeInsets.only(left: 10.0)),
  966.               Flexible(
  967.                   flex: 2,
  968.                   child: Column(
  969.                     children: <Widget>[
  970.                       Row(
  971.                         children: <Widget>[
  972.                           InkWell(
  973.                             onTap: () {
  974.                               Navigator.of(context).push(new MaterialPageRoute(
  975.                                 builder: (BuildContext context) =>
  976.                                     new KalenderKegiatan(deviceid),
  977.                               ));
  978.                             },
  979.                             child: Image.asset(
  980.                               'assets/icons/icon-kalender-hijriah/drawable-hdpi/Group 154.png',
  981.                               height: 50.0,
  982.                             ),
  983.                           ),
  984.                         ],
  985.                       ),
  986.                       Row(
  987.                         children: <Widget>[
  988.                           Text(" Kalender",
  989.                               style: TextStyle(
  990.                                   fontSize: 12.0,
  991.                                   fontWeight: FontWeight.normal,
  992.                                   color: Colors.black)),
  993.                         ],
  994.                       ),
  995.                       Row(
  996.                         children: <Widget>[
  997.                           Text(" Kegiatan",
  998.                               style: TextStyle(
  999.                                   fontSize: 12.0,
  1000.                                   fontWeight: FontWeight.normal,
  1001.                                   color: Colors.black)),
  1002.                         ],
  1003.                       ),
  1004.                     ],
  1005.                   )),
  1006.               Padding(padding: EdgeInsets.only(left: 10.0)),
  1007.               Flexible(
  1008.                   flex: 2,
  1009.                   child: Column(
  1010.                     children: <Widget>[
  1011.                       Row(
  1012.                         children: <Widget>[
  1013.                           InkWell(
  1014.                             onTap: () {
  1015.                               Navigator.of(context).push(new MaterialPageRoute(
  1016.                                 builder: (BuildContext context) =>
  1017.                                     new KiblatCompass(),
  1018.                               ));
  1019.                             },
  1020.                             child: Image.asset(
  1021.                               'assets/icons/icon-kiblat/drawable-hdpi/Group 155.png',
  1022.                               height: 50.0,
  1023.                             ),
  1024.                           ),
  1025.                         ],
  1026.                       ),
  1027.                       Row(
  1028.                         children: <Widget>[
  1029.                           Text("   Kiblat",
  1030.                               style: TextStyle(
  1031.                                   fontSize: 12.0,
  1032.                                   fontWeight: FontWeight.normal,
  1033.                                   color: Colors.black)),
  1034.                         ],
  1035.                       ),
  1036.                       Row(
  1037.                         children: <Widget>[
  1038.                           Text("",
  1039.                               style: TextStyle(
  1040.                                   fontSize: 12.0,
  1041.                                   fontWeight: FontWeight.normal,
  1042.                                   color: Colors.black)),
  1043.                         ],
  1044.                       ),
  1045.                     ],
  1046.                   )),
  1047.               Padding(padding: EdgeInsets.only(left: 10.0)),
  1048.               Flexible(
  1049.                   flex: 2,
  1050.                   child: Column(
  1051.                     children: <Widget>[
  1052.                       Row(
  1053.                         children: <Widget>[
  1054.                           InkWell(
  1055.                             onTap: () {
  1056.                               Navigator.of(context).push(new MaterialPageRoute(
  1057.                                 builder: (BuildContext context) =>
  1058.                                     new AmalanHarian(deviceid),
  1059.                               ));
  1060.                             },
  1061.                             child: Image.asset(
  1062.                               'assets/icons/icon-amalan-harian/drawable-hdpi/Group 156.png',
  1063.                               height: 50.0,
  1064.                             ),
  1065.                           ),
  1066.                         ],
  1067.                       ),
  1068.                       Row(
  1069.                         children: <Widget>[
  1070.                           Text(" Amalan",
  1071.                               style: TextStyle(
  1072.                                   fontSize: 12.0,
  1073.                                   fontWeight: FontWeight.normal,
  1074.                                   color: Colors.black)),
  1075.                         ],
  1076.                       ),
  1077.                       Row(
  1078.                         children: <Widget>[
  1079.                           Text("  Harian",
  1080.                               style: TextStyle(
  1081.                                   fontSize: 12.0,
  1082.                                   fontWeight: FontWeight.normal,
  1083.                                   color: Colors.black)),
  1084.                         ],
  1085.                       ),
  1086.                     ],
  1087.                   )),
  1088.             ],
  1089.           ),
  1090.         ),
  1091.         Padding(padding: EdgeInsets.only(top: 15.0)),
  1092.         _iconLain(),
  1093.         _iconLain2(),
  1094.       ],
  1095.     );
  1096.   }
  1097.  
  1098.   Widget _body() {
  1099.     return SmartRefresher(
  1100.         controller: _refreshController,
  1101.        enablePullDown: true,
  1102.         enablePullUp: true,
  1103.         header: WaterDropHeader(),
  1104.         onRefresh: () async {
  1105.           await _event();
  1106.       await _hariLibur();
  1107.       await getDeviceDetails();
  1108.        _listFutureAmalan = fetchAmalanBelumDikerjakan();
  1109.   _listFutureArtikel = fetchArtikel();
  1110.    _listFutureYoutube = fetchVideo();
  1111.           await Future.delayed(Duration(seconds: 1));
  1112.           _refreshController.refreshCompleted();
  1113.         },
  1114.         onLoading: () async{
  1115.           await Future.delayed(Duration(milliseconds: 1000));
  1116.           print("AAAA");
  1117.           _refreshController.loadComplete();
  1118.         },
  1119.                   child:  new SingleChildScrollView(
  1120.         child: Container(
  1121.           decoration: BoxDecoration(color: Colors.blueGrey[100]),
  1122.           padding: EdgeInsets.only(bottom: 100.0),
  1123.           child: Column(
  1124.             children: <Widget>[
  1125.               Align(
  1126.                 alignment: Alignment.topLeft,
  1127.                 child: Column(
  1128.                   children: <Widget>[
  1129.                     Container(
  1130.                       padding: EdgeInsets.only(left: 10.0, right: 10.0),
  1131.                       height: 180.0,
  1132.                       decoration: new BoxDecoration(
  1133.                         color: Color.fromRGBO(0, 185, 92, 1),
  1134.                         borderRadius: new BorderRadius.vertical(
  1135.                             bottom: new Radius.elliptical(
  1136.                                 MediaQuery.of(context).size.width, 100.0)),
  1137.                       ),
  1138.                       alignment: Alignment.center, // where to position the child
  1139.                       child: Container(
  1140.                         // padding: EdgeInsets.all(15.0),
  1141.  
  1142.                         // color: Colors.blue,
  1143.                         decoration: BoxDecoration(
  1144.                           borderRadius: new BorderRadius.circular(35.0),
  1145.                           image: DecorationImage(
  1146.                             image: AssetImage("assets/img/moskee.jpg"),
  1147.                             fit: BoxFit.cover,
  1148.                           ),
  1149.                         ),
  1150.                         child: Column(
  1151.                           crossAxisAlignment: CrossAxisAlignment.start,
  1152.                           children: <Widget>[
  1153.                             Row(
  1154.                               children: <Widget>[
  1155.                                 Flexible(
  1156.                                     flex: 1,
  1157.                                     child: Column(
  1158.                                       crossAxisAlignment: CrossAxisAlignment.end,
  1159.                                       children: <Widget>[
  1160.                                         Padding(
  1161.                                           padding: EdgeInsets.only(
  1162.                                               left: 40.0, top: 20.0),
  1163.                                         ),
  1164.                                         Icon(
  1165.                                           Icons.timer,
  1166.                                           color: Colors.white,
  1167.                                         ),
  1168.                                         Padding(
  1169.                                           padding: EdgeInsets.only(bottom: 5.0),
  1170.                                         ),
  1171.                                       ],
  1172.                                     )),
  1173.                                 Padding(
  1174.                                   padding: EdgeInsets.only(left: 10.0),
  1175.                                 ),
  1176.                                 Flexible(
  1177.                                     flex: 6,
  1178.                                     child: Column(
  1179.                                       crossAxisAlignment: CrossAxisAlignment.end,
  1180.                                       children: <Widget>[
  1181.                                         Padding(
  1182.                                           padding: EdgeInsets.only(
  1183.                                               left: 20.0, top: 10.0),
  1184.                                         ),
  1185.                                         Row(
  1186.                                           children: <Widget>[
  1187.                                             Text(
  1188.                                               waktu_sholat,
  1189.                                               style: TextStyle(
  1190.                                                   fontSize: 11.0,
  1191.                                                   fontWeight: FontWeight.normal,
  1192.                                                   color: Colors.white),
  1193.                                             ),
  1194.                                           ],
  1195.                                         ),
  1196.                                         Padding(
  1197.                                           padding: EdgeInsets.only(bottom: 5.0),
  1198.                                         ),
  1199.                                         Row(
  1200.                                           children: <Widget>[
  1201.                                             Text(
  1202.                                               tglMasehi,
  1203.                                               style: TextStyle(
  1204.                                                   fontSize: 11.0,
  1205.                                                   fontWeight: FontWeight.normal,
  1206.                                                   color: Colors.white),
  1207.                                             ),
  1208.                                           ],
  1209.                                         ),
  1210.                                         Padding(
  1211.                                           padding: EdgeInsets.only(bottom: 5.0),
  1212.                                         ),
  1213.                                         Row(
  1214.                                           children: <Widget>[
  1215.                                             Text(
  1216.                                               tglHijriah,
  1217.                                               style: TextStyle(
  1218.                                                 fontSize: 11.0,
  1219.                                                 fontWeight: FontWeight.normal,
  1220.                                                 color: Colors.white,
  1221.                                               ),
  1222.                                             ),
  1223.                                           ],
  1224.                                         ),
  1225.                                       ],
  1226.                                     )),
  1227.                                 Padding(
  1228.                                   padding: EdgeInsets.only(left: 10.0),
  1229.                                 ),
  1230.                                 Flexible(
  1231.                                     flex: 3,
  1232.                                     child: Column(
  1233.                                       crossAxisAlignment: CrossAxisAlignment.end,
  1234.                                       children: <Widget>[
  1235.                                         Padding(
  1236.                                           padding: EdgeInsets.only(left: 20.0),
  1237.                                         ),
  1238.                                         Row(
  1239.                                           children: <Widget>[
  1240.                                             Text(
  1241.                                               "Next Prayer",
  1242.                                               style: TextStyle(
  1243.                                                   fontSize: 11.0,
  1244.                                                   fontWeight: FontWeight.normal,
  1245.                                                   color: Colors.white),
  1246.                                             ),
  1247.                                           ],
  1248.                                         ),
  1249.                                         Padding(
  1250.                                           padding: EdgeInsets.only(bottom: 5.0),
  1251.                                         ),
  1252.                                         Row(
  1253.                                           children: <Widget>[
  1254.                                             Text(
  1255.                                               toBeginningOfSentenceCase(
  1256.                                                   lokasiAdzan),
  1257.                                               style: TextStyle(
  1258.                                                   fontSize: 11.0,
  1259.                                                   fontWeight: FontWeight.normal,
  1260.                                                   color: Colors.white),
  1261.                                             ),
  1262.                                           ],
  1263.                                         ),
  1264.                                       ],
  1265.                                     ))
  1266.                               ],
  1267.                             ),
  1268.                             Padding(
  1269.                               padding: EdgeInsets.only(bottom: 10.0),
  1270.                             ),
  1271.                             Row(
  1272.                               children: <Widget>[
  1273.                                 Column(
  1274.                                   crossAxisAlignment: CrossAxisAlignment.end,
  1275.                                   children: <Widget>[
  1276.                                     Padding(
  1277.                                       padding: EdgeInsets.only(left: 210.0),
  1278.                                     ),
  1279.                                     Row(
  1280.                                       children: <Widget>[
  1281.                                         Text(
  1282.                                           jam_sholat,
  1283.                                           textAlign: TextAlign.center,
  1284.                                           style: TextStyle(
  1285.                                               fontSize: 36.0,
  1286.                                               fontWeight: FontWeight.normal,
  1287.                                               color: Colors.white),
  1288.                                         ),
  1289.                                       ],
  1290.                                     ),
  1291.                                   ],
  1292.                                 ),
  1293.                               ],
  1294.                             ),
  1295.                             Padding(
  1296.                               padding: EdgeInsets.only(bottom: 5.0),
  1297.                             ),
  1298.                             Row(
  1299.                               children: <Widget>[
  1300.                                 Column(
  1301.                                   crossAxisAlignment: CrossAxisAlignment.end,
  1302.                                   children: <Widget>[
  1303.                                     Padding(
  1304.                                       padding: EdgeInsets.only(left: 195.0),
  1305.                                     ),
  1306.                                     Row(
  1307.                                       children: <Widget>[
  1308.                                         Text(
  1309.                                           // '(- ' + timeText + ')',
  1310.                                           '',
  1311.                                           textAlign: TextAlign.center,
  1312.                                           style: TextStyle(
  1313.                                               fontSize: 16.0,
  1314.                                               fontWeight: FontWeight.normal,
  1315.                                               color: Colors.white),
  1316.                                         ),
  1317.                                       ],
  1318.                                     ),
  1319.                                   ],
  1320.                                 ),
  1321.                               ],
  1322.                             ),
  1323.                             Padding(
  1324.                               padding: EdgeInsets.only(bottom: 10.0),
  1325.                             ),
  1326.                             Row(
  1327.                               children: <Widget>[
  1328.                                 Column(
  1329.                                   crossAxisAlignment: CrossAxisAlignment.end,
  1330.                                   children: <Widget>[
  1331.                                     Padding(
  1332.                                       padding: EdgeInsets.only(left: 310.0),
  1333.                                     ),
  1334.                                     InkWell(
  1335.                                       onTap: () {
  1336.                                         Navigator.of(context)
  1337.                                             .push(new MaterialPageRoute(
  1338.                                           builder: (BuildContext context) =>
  1339.                                               new JadwalShalat(
  1340.                                                   deviceid, lokasiAdzan),
  1341.                                         ));
  1342.                                       },
  1343.                                       child: Row(
  1344.                                         children: <Widget>[
  1345.                                           Text(
  1346.                                             "View All",
  1347.                                             textAlign: TextAlign.center,
  1348.                                             style: TextStyle(
  1349.                                                 fontSize: 16.0,
  1350.                                                 fontWeight: FontWeight.normal,
  1351.                                                 color: Colors.white),
  1352.                                           ),
  1353.                                           Icon(
  1354.                                             Icons.arrow_right,
  1355.                                             color: Colors.white,
  1356.                                           ),
  1357.                                         ],
  1358.                                       ),
  1359.                                     ),
  1360.                                   ],
  1361.                                 ),
  1362.                               ],
  1363.                             ),
  1364.                           ],
  1365.                         ),
  1366.                       ),
  1367.                     ),
  1368.                   ],
  1369.                 ),
  1370.               ),
  1371.               Padding(
  1372.                 padding: EdgeInsets.only(bottom: 20.0),
  1373.               ),
  1374.               Align(
  1375.                 child: Padding(
  1376.                   padding: EdgeInsets.only(left: 10.0, right: 10.0),
  1377.                   child: Container(
  1378.                       height: 440.0,
  1379.                       decoration: BoxDecoration(
  1380.                         color: Colors.white,
  1381.                         borderRadius: BorderRadius.all(Radius.circular(10.0)),
  1382.                         boxShadow: <BoxShadow>[
  1383.                           new BoxShadow(
  1384.                             color: Colors.black12,
  1385.                             blurRadius: 10.0,
  1386.                             offset: new Offset(0.0, 10.0),
  1387.                           ),
  1388.                         ],
  1389.                       ),
  1390.                       child: Column(
  1391.                         children: <Widget>[
  1392.                           Container(
  1393.                             margin: EdgeInsets.only(
  1394.                               top: 30.0,
  1395.                               bottom: 16.0,
  1396.                               left: 16.0,
  1397.                               right: 16.0,
  1398.                             ),
  1399.                             child: new Row(
  1400.                               children: <Widget>[
  1401.                                 Expanded(
  1402.                                     child: Text(
  1403.                                   _currentMonth,
  1404.                                   style: TextStyle(
  1405.                                     fontWeight: FontWeight.bold,
  1406.                                     fontSize: 24.0,
  1407.                                   ),
  1408.                                 )),
  1409.                                 FlatButton(
  1410.                                   child: Text('PREV'),
  1411.                                   onPressed: () {
  1412.                                     setState(() {
  1413.                                       _currentDate2 = _currentDate2
  1414.                                           .subtract(Duration(days: 30));
  1415.                                       _currentMonth =
  1416.                                           DateFormat.yMMM().format(_currentDate2);
  1417.                                     });
  1418.                                   },
  1419.                                 ),
  1420.                                 FlatButton(
  1421.                                   child: Text('NEXT'),
  1422.                                   onPressed: () {
  1423.                                     setState(() {
  1424.                                       _currentDate2 =
  1425.                                           _currentDate2.add(Duration(days: 30));
  1426.                                       _currentMonth =
  1427.                                           DateFormat.yMMM().format(_currentDate2);
  1428.                                     });
  1429.                                   },
  1430.                                 )
  1431.                               ],
  1432.                             ),
  1433.                           ),
  1434.                           Container(
  1435.                             margin: EdgeInsets.symmetric(horizontal: 16.0),
  1436.                             child: _calendarCarouselNoHeader,
  1437.                           ), //
  1438.                         ],
  1439.                       )),
  1440.                 ),
  1441.               ),
  1442.               Padding(
  1443.                 padding: EdgeInsets.only(bottom: 10.0),
  1444.               ),
  1445.               Align(
  1446.                 child: Padding(
  1447.                   padding: const EdgeInsets.only(left: 10.0, right: 10.0),
  1448.                   child: Container(
  1449.                       padding: EdgeInsets.all(15.0),
  1450.                       decoration: BoxDecoration(
  1451.                         color: Colors.white,
  1452.                         borderRadius: BorderRadius.all(Radius.circular(10.0)),
  1453.                         boxShadow: <BoxShadow>[
  1454.                           new BoxShadow(
  1455.                             color: Colors.black12,
  1456.                             blurRadius: 10.0,
  1457.                             offset: new Offset(0.0, 10.0),
  1458.                           ),
  1459.                         ],
  1460.                       ),
  1461.                       child: Column(
  1462.                         children: <Widget>[
  1463.                           Row(
  1464.                             children: <Widget>[
  1465.                               Text(
  1466.                                 "Dzikir & Doa",
  1467.                                 textAlign: TextAlign.center,
  1468.                                 style: TextStyle(
  1469.                                     fontSize: 16.0,
  1470.                                     fontWeight: FontWeight.bold,
  1471.                                     color: Colors.black),
  1472.                               ),
  1473.                             ],
  1474.                           ),
  1475.                           Padding(
  1476.                             padding: EdgeInsets.only(bottom: 10.0),
  1477.                           ),
  1478.                           Container(
  1479.                             width: MediaQuery.of(context).size.width,
  1480.                             // decoration: BoxDecoration(
  1481.                             //     color: Colors.blueGrey[100]),
  1482.                             height: 120.0,
  1483.                             child: new FutureBuilder<List>(
  1484.                                 future: _listFutureAmalan,
  1485.                                 builder: (context, snapshot) {
  1486.                                   if (snapshot.hasData) {
  1487.                                     return new ListView.builder(
  1488.                                       itemCount: snapshot.data.length,
  1489.                                       padding: EdgeInsets.only(top: 4.0),
  1490.                                       itemBuilder: (context, index) {
  1491.                                         return _listAmalan(snapshot.data[index]);
  1492.                                       },
  1493.                                     );
  1494.                                   }
  1495.                                   return Center(
  1496.                                     child: SizedBox(
  1497.                                         width: 40.0,
  1498.                                         height: 40.0,
  1499.                                         child: const CircularProgressIndicator()),
  1500.                                   );
  1501.                                 }),
  1502.                           ),
  1503.                         ],
  1504.                       )),
  1505.                 ),
  1506.               ),
  1507.               Padding(
  1508.                 padding: EdgeInsets.only(bottom: 10.0),
  1509.               ),
  1510.               Align(
  1511.                 child: Padding(
  1512.                   padding: const EdgeInsets.only(left: 10.0, right: 10.0),
  1513.                   child: Column(
  1514.                     children: <Widget>[
  1515.                       Container(
  1516.                         padding: EdgeInsets.all(15.0),
  1517.                         decoration: BoxDecoration(
  1518.                           color: Colors.white,
  1519.                           borderRadius: BorderRadius.all(Radius.circular(10.0)),
  1520.                           boxShadow: <BoxShadow>[
  1521.                             new BoxShadow(
  1522.                               color: Colors.black12,
  1523.                               blurRadius: 10.0,
  1524.                               offset: new Offset(0.0, 10.0),
  1525.                             ),
  1526.                           ],
  1527.                         ),
  1528.                         child: Column(
  1529.                           children: <Widget>[
  1530.                             Row(
  1531.                               children: <Widget>[
  1532.                                 Text(
  1533.                                   "Artikel Hari Ini",
  1534.                                   textAlign: TextAlign.center,
  1535.                                   style: TextStyle(
  1536.                                       fontSize: 16.0,
  1537.                                       fontWeight: FontWeight.bold,
  1538.                                       color: Colors.black),
  1539.                                 ),
  1540.                               ],
  1541.                             ),
  1542.                             Padding(
  1543.                               padding: EdgeInsets.only(bottom: 10.0),
  1544.                             ),
  1545.                             SizedBox(
  1546.                               height: 250.0,
  1547.                               child: new FutureBuilder<List>(
  1548.                                   future: _listFutureArtikel,
  1549.                                   builder: (context, snapshot) {
  1550.                                     if (snapshot.hasData) {
  1551.                                       return new ListView.builder(
  1552.                                         itemCount: snapshot.data.length,
  1553.                                         padding: EdgeInsets.only(top: 12.0),
  1554.                                         physics: new ClampingScrollPhysics(),
  1555.                                         scrollDirection: Axis.horizontal,
  1556.                                         itemBuilder: (context, index) {
  1557.                                           return _listArtikel(
  1558.                                               snapshot.data[index]);
  1559.                                         },
  1560.                                       );
  1561.                                     }
  1562.                                     return Center(
  1563.                                       child: SizedBox(
  1564.                                           width: 40.0,
  1565.                                           height: 40.0,
  1566.                                           child:
  1567.                                               const CircularProgressIndicator()),
  1568.                                     );
  1569.                                   }),
  1570.                             ),
  1571.                           ],
  1572.                         ),
  1573.                       ),
  1574.                       Padding(
  1575.                         padding: EdgeInsets.only(bottom: 10.0),
  1576.                       ),
  1577.                     ],
  1578.                   ),
  1579.                 ),
  1580.               ),
  1581.               Align(
  1582.                 child: Padding(
  1583.                   padding: const EdgeInsets.only(left: 10.0, right: 10.0),
  1584.                   child: Column(
  1585.                     children: <Widget>[
  1586.                       Container(
  1587.                         padding: EdgeInsets.all(15.0),
  1588.                         decoration: BoxDecoration(
  1589.                           color: Colors.white,
  1590.                           borderRadius: BorderRadius.all(Radius.circular(10.0)),
  1591.                           boxShadow: <BoxShadow>[
  1592.                             new BoxShadow(
  1593.                               color: Colors.black12,
  1594.                               blurRadius: 10.0,
  1595.                               offset: new Offset(0.0, 10.0),
  1596.                             ),
  1597.                           ],
  1598.                         ),
  1599.                         child: Column(
  1600.                           children: <Widget>[
  1601.                             Row(
  1602.                               children: <Widget>[
  1603.                                 Text(
  1604.                                   "Video Kajian Hari Ini",
  1605.                                   textAlign: TextAlign.center,
  1606.                                   style: TextStyle(
  1607.                                       fontSize: 16.0,
  1608.                                       fontWeight: FontWeight.bold,
  1609.                                       color: Colors.black),
  1610.                                 ),
  1611.                               ],
  1612.                             ),
  1613.                             Padding(
  1614.                               padding: EdgeInsets.only(bottom: 10.0),
  1615.                             ),
  1616.                             Container(
  1617.                               child: new FutureBuilder<List>(
  1618.                                   future: _listFutureYoutube,
  1619.                                   builder: (context, snapshot) {
  1620.                                     if (snapshot.hasData) {
  1621.                                       if (snapshot.data.length > 0) {
  1622.                                         return new GridView.builder(
  1623.                                           itemCount: 2,
  1624.                                           gridDelegate:
  1625.                                               SliverGridDelegateWithFixedCrossAxisCount(
  1626.                                                   crossAxisSpacing: 10.0,
  1627.                                                   mainAxisSpacing: 20.0,
  1628.                                                   crossAxisCount: 2,
  1629.                                                   childAspectRatio: 16 / 20),
  1630.                                           shrinkWrap: true,
  1631.                                           itemBuilder:
  1632.                                               (BuildContext context, int index) {
  1633.                                             return _listItem(
  1634.                                                 snapshot.data[index]);
  1635.                                           },
  1636.                                         );
  1637.                                       } else {
  1638.                                         return Container();
  1639.                                       }
  1640.                                     }
  1641.                                     return Center(
  1642.                                       child: SizedBox(
  1643.                                           width: 40.0,
  1644.                                           height: 40.0,
  1645.                                           child:
  1646.                                               const CircularProgressIndicator()),
  1647.                                     );
  1648.                                   }),
  1649.                             ),
  1650.                           ],
  1651.                         ),
  1652.                       ),
  1653.                       Padding(
  1654.                         padding: EdgeInsets.only(bottom: 10.0),
  1655.                       ),
  1656.                     ],
  1657.                   ),
  1658.                 ),
  1659.               ),
  1660.               Padding(
  1661.                 padding: EdgeInsets.only(bottom: 150.0),
  1662.               ),
  1663.             ],
  1664.           ),
  1665.         ),
  1666.       ),
  1667.     );
  1668.   }
  1669.  
  1670.   void _handleClick() {
  1671.     _isOpen = !_isOpen;
  1672.     Timer.periodic(Duration(milliseconds: 5), (timer) {
  1673.       if (_isOpen) {
  1674.         double value = _offset.dy +
  1675.             10; // we increment the height of the Container by 10 every 5ms
  1676.         _offset = Offset(0, value);
  1677.         if (_offset.dy > _maxHeight) {
  1678.           _offset =
  1679.               Offset(0, _maxHeight); // makes sure it does't go above maxHeight
  1680.           timer.cancel();
  1681.         }
  1682.       } else {
  1683.         double value = _offset.dy - 10; // we decrement the height by 10 here
  1684.         _offset = Offset(0, value);
  1685.         if (_offset.dy < _minHeight) {
  1686.           _offset = Offset(
  1687.               0, _minHeight); // makes sure it doesn't go beyond minHeight
  1688.           timer.cancel();
  1689.         }
  1690.       }
  1691.       setState(() {});
  1692.     });
  1693.   }
  1694.  
  1695.   Widget _iconLain() {
  1696.     // if (_isOpen == true) {
  1697.     //   if (_offset.dy > 200) {
  1698.     return Container(
  1699.       padding: EdgeInsets.only(left: 15.0),
  1700.       child: Row(
  1701.         children: <Widget>[
  1702.           Flexible(
  1703.               flex: 2,
  1704.               child: Column(
  1705.                 children: <Widget>[
  1706.                   Row(
  1707.                     children: <Widget>[
  1708.                       InkWell(
  1709.                         onTap: () {
  1710.                           Navigator.of(context).push(new MaterialPageRoute(
  1711.                             builder: (BuildContext context) => new Artikel(),
  1712.                           ));
  1713.                         },
  1714.                         child: Image.asset(
  1715.                           'assets/icons/icon-artikel/drawable-hdpi/Group 157.png',
  1716.                           height: 50.0,
  1717.                         ),
  1718.                       ),
  1719.                     ],
  1720.                   ),
  1721.                   Row(
  1722.                     children: <Widget>[
  1723.                       Text("  Artikel",
  1724.                           style: TextStyle(
  1725.                               fontSize: 12.0,
  1726.                               fontWeight: FontWeight.normal,
  1727.                               color: Colors.black)),
  1728.                     ],
  1729.                   ),
  1730.                   Row(
  1731.                     children: <Widget>[
  1732.                       Text("",
  1733.                           style: TextStyle(
  1734.                               fontSize: 12.0,
  1735.                               fontWeight: FontWeight.normal,
  1736.                               color: Colors.black)),
  1737.                     ],
  1738.                   ),
  1739.                 ],
  1740.               )),
  1741.           Padding(padding: EdgeInsets.only(left: 10.0)),
  1742.           Flexible(
  1743.               flex: 2,
  1744.               child: Column(
  1745.                 children: <Widget>[
  1746.                   Row(
  1747.                     children: <Widget>[
  1748.                       InkWell(
  1749.                         onTap: () {
  1750.                           Navigator.of(context).push(new MaterialPageRoute(
  1751.                             builder: (BuildContext context) =>
  1752.                                 new VideoKajian(),
  1753.                           ));
  1754.                         },
  1755.                         child: Image.asset(
  1756.                           'assets/icons/icon-video/drawable-hdpi/Group 158.png',
  1757.                           height: 50.0,
  1758.                         ),
  1759.                       ),
  1760.                     ],
  1761.                   ),
  1762.                   Row(
  1763.                     children: <Widget>[
  1764.                       Text("   Video",
  1765.                           style: TextStyle(
  1766.                               fontSize: 12.0,
  1767.                               fontWeight: FontWeight.normal,
  1768.                               color: Colors.black)),
  1769.                     ],
  1770.                   ),
  1771.                   Row(
  1772.                     children: <Widget>[
  1773.                       Text("   Kajian",
  1774.                           style: TextStyle(
  1775.                               fontSize: 12.0,
  1776.                               fontWeight: FontWeight.normal,
  1777.                               color: Colors.black)),
  1778.                     ],
  1779.                   ),
  1780.                 ],
  1781.               )),
  1782.           Padding(padding: EdgeInsets.only(left: 10.0)),
  1783.           Flexible(
  1784.               flex: 2,
  1785.               child: Column(
  1786.                 children: <Widget>[
  1787.                   Row(
  1788.                     children: <Widget>[
  1789.                       InkWell(
  1790.                         onTap: () {
  1791.                           Navigator.of(context).push(new MaterialPageRoute(
  1792.                             builder: (BuildContext context) =>
  1793.                                 new JadwalShalat(deviceid, lokasiAdzan),
  1794.                             // new Notif(),
  1795.                           ));
  1796.                         },
  1797.                         child: Image.asset(
  1798.                           'assets/icons/icon-jadwal-shalat/drawable-hdpi/Group 159.png',
  1799.                           height: 50.0,
  1800.                         ),
  1801.                       ),
  1802.                     ],
  1803.                   ),
  1804.                   Row(
  1805.                     children: <Widget>[
  1806.                       Text("  Jadwal",
  1807.                           style: TextStyle(
  1808.                               fontSize: 12.0,
  1809.                               fontWeight: FontWeight.normal,
  1810.                               color: Colors.black)),
  1811.                     ],
  1812.                   ),
  1813.                   Row(
  1814.                     children: <Widget>[
  1815.                       Text("  Sholat",
  1816.                           style: TextStyle(
  1817.                               fontSize: 12.0,
  1818.                               fontWeight: FontWeight.normal,
  1819.                               color: Colors.black)),
  1820.                     ],
  1821.                   ),
  1822.                 ],
  1823.               )),
  1824.           Padding(padding: EdgeInsets.only(left: 10.0)),
  1825.           Flexible(
  1826.               flex: 2,
  1827.               child: Column(
  1828.                 children: <Widget>[
  1829.                   Row(
  1830.                     children: <Widget>[
  1831.                       InkWell(
  1832.                         onTap: () {
  1833.                           Navigator.of(context).push(new MaterialPageRoute(
  1834.                             builder: (BuildContext context) => new Pengaturan(),
  1835.                           ));
  1836.                         },
  1837.                         child: Image.asset(
  1838.                           'assets/icons/icon-pengaturan/drawable-hdpi/Group 160.png',
  1839.                           height: 50.0,
  1840.                         ),
  1841.                       ),
  1842.                     ],
  1843.                   ),
  1844.                   Row(
  1845.                     children: <Widget>[
  1846.                       Text("Pengaturan",
  1847.                           style: TextStyle(
  1848.                               fontSize: 12.0,
  1849.                               fontWeight: FontWeight.normal,
  1850.                               color: Colors.black)),
  1851.                     ],
  1852.                   ),
  1853.                   Row(
  1854.                     children: <Widget>[
  1855.                       Text(" ",
  1856.                           style: TextStyle(
  1857.                               fontSize: 12.0,
  1858.                               fontWeight: FontWeight.normal,
  1859.                               color: Colors.black)),
  1860.                     ],
  1861.                   ),
  1862.                 ],
  1863.               )),
  1864.         ],
  1865.       ),
  1866.     );
  1867.     //   } else {
  1868.     //     return Container();
  1869.     //   }
  1870.     // } else {
  1871.     //   return Container();
  1872.     // }
  1873.   }
  1874.  
  1875.   Widget _iconLain2() {
  1876.     // if (_isOpen == true) {
  1877.     //   if (_offset.dy > 200) {
  1878.     return Container(
  1879.       padding: EdgeInsets.only(left: 15.0),
  1880.       child: Row(
  1881.         children: <Widget>[
  1882.           Flexible(
  1883.               flex: 2,
  1884.               child: Column(
  1885.                 children: <Widget>[
  1886.                   Row(
  1887.                     children: <Widget>[
  1888.                       InkWell(
  1889.                         onTap: () {
  1890.                           Navigator.of(context).push(new MaterialPageRoute(
  1891.                             builder: (BuildContext context) => new QuranList(),
  1892.                           ));
  1893.                         },
  1894.                         child: Image.asset(
  1895.                           'assets/icons/icon-artikel/drawable-hdpi/Group 157.png',
  1896.                           height: 50.0,
  1897.                         ),
  1898.                       ),
  1899.                     ],
  1900.                   ),
  1901.                   Row(
  1902.                     children: <Widget>[
  1903.                       Text("  Al-Quran",
  1904.                           style: TextStyle(
  1905.                               fontSize: 12.0,
  1906.                               fontWeight: FontWeight.normal,
  1907.                               color: Colors.black)),
  1908.                     ],
  1909.                   ),
  1910.                   Row(
  1911.                     children: <Widget>[
  1912.                       Text("",
  1913.                           style: TextStyle(
  1914.                               fontSize: 12.0,
  1915.                               fontWeight: FontWeight.normal,
  1916.                               color: Colors.black)),
  1917.                     ],
  1918.                   ),
  1919.                 ],
  1920.               )),
  1921.         ],
  1922.       ),
  1923.     );
  1924.     //   } else {
  1925.     //     return Container();
  1926.     //   }
  1927.     // } else {
  1928.     //   return Container();
  1929.     // }
  1930.   }
  1931.  
  1932.   _listAmalan(AmalanModel amalan) {
  1933.     return Padding(
  1934.       padding: const EdgeInsets.only(top: 8.0),
  1935.       child: new Row(
  1936.         children: <Widget>[
  1937.           Expanded(
  1938.             flex: 2,
  1939.             child: InkWell(
  1940.               onTap: () {
  1941.                 if (content == false) {
  1942.                   setState(() {
  1943.                     content = true;
  1944.                   });
  1945.                 } else {
  1946.                   setState(() {
  1947.                     content = false;
  1948.                   });
  1949.                 }
  1950.               },
  1951.               child: Image.asset(
  1952.                 "img/doadzikir.png",
  1953.                 height: 50.0,
  1954.               ),
  1955.             ),
  1956.           ),
  1957.           Expanded(
  1958.               flex: 6,
  1959.               child: InkWell(
  1960.                   onTap: () {
  1961.                     if (content == false) {
  1962.                       setState(() {
  1963.                         content = true;
  1964.                       });
  1965.                     } else {
  1966.                       setState(() {
  1967.                         content = false;
  1968.                       });
  1969.                     }
  1970.                   },
  1971.                   child: Text(amalan.title))),
  1972.           // Expanded(
  1973.           //   flex: 2,
  1974.           //   child:
  1975.           InkWell(
  1976.             onTap: () {
  1977.               _amalkan(amalan.id_amalan_harian);
  1978.             },
  1979.             child: new ClipOval(
  1980.               child: Container(
  1981.                 color: Colors.blueGrey[100],
  1982.                 height: 35.0, // height of the button
  1983.                 width: 35.0, // width of the button
  1984.                 child: Center(
  1985.                     child: Icon(
  1986.                   Icons.check,
  1987.                   color: Colors.white,
  1988.                 )),
  1989.               ),
  1990.             ),
  1991.           ),
  1992.         ],
  1993.       ),
  1994.     );
  1995.   }
  1996.  
  1997.   Widget _listItem(YoutubeModel yt) {
  1998.     return Column(
  1999.       children: <Widget>[
  2000.         CachedNetworkImage(
  2001.           imageUrl: yt.thumb,
  2002.           placeholder: (context, url) => CircularProgressIndicator(),
  2003.           errorWidget: (context, url, error) => Icon(Icons.error),
  2004.         ),
  2005.         Padding(
  2006.           padding: EdgeInsets.only(top: 5.0),
  2007.         ),
  2008.         Text(
  2009.           yt.title,
  2010.           // textAlign: TextAlign.center,
  2011.           style: TextStyle(
  2012.               fontSize: 12.0,
  2013.               fontWeight: FontWeight.normal,
  2014.               color: Colors.black),
  2015.         ),
  2016.         Padding(
  2017.           padding: EdgeInsets.only(top: 5.0),
  2018.         ),
  2019.         InkWell(
  2020.           onTap: () {
  2021.             Navigator.of(context).push(new MaterialPageRoute(
  2022.               builder: (BuildContext context) => new VideoKajianDetail(
  2023.                 youtube: yt,
  2024.               ),
  2025.             ));
  2026.           },
  2027.           child: Align(
  2028.             alignment: Alignment.topRight,
  2029.             child: Container(
  2030.               decoration: BoxDecoration(
  2031.                 color: Color.fromRGBO(0, 185, 92, 1),
  2032.                 borderRadius: BorderRadius.all(Radius.circular(10.0)),
  2033.                 boxShadow: <BoxShadow>[
  2034.                   new BoxShadow(
  2035.                     color: Colors.black12,
  2036.                     blurRadius: 10.0,
  2037.                     offset: new Offset(0.0, 10.0),
  2038.                   ),
  2039.                 ],
  2040.               ),
  2041.               // color: Color.fromRGBO(
  2042.               //     0, 185, 92, 1),
  2043.               height: 25.0, // height of the button
  2044.               width: 55.0, // width of the button
  2045.               child: Center(
  2046.                   child: Text("Tonton",
  2047.                       style: TextStyle(
  2048.                           fontSize: 12.0,
  2049.                           fontWeight: FontWeight.normal,
  2050.                           color: Colors.white))),
  2051.             ),
  2052.           ),
  2053.         ),
  2054.       ],
  2055.     );
  2056.   }
  2057.  
  2058.   Future<List<YoutubeModel>> fetchVideo() async {
  2059.     String url = new Api().url;
  2060.     print(url + "index.php/api/Youtube/date");
  2061.     var notes = List<YoutubeModel>();
  2062.  
  2063.     Response response;
  2064.     response = await Dio().get(url + "index.php/api/Youtube/date");
  2065.     final json = response.data;
  2066.     if (response.statusCode == 200) {
  2067.       notes = (json)
  2068.           .map<YoutubeModel>((item) => YoutubeModel.fromJson(item))
  2069.           .toList();
  2070.     } else {
  2071.       throw Exception('Failed to load');
  2072.     }
  2073.     // print("json " + json.toString());
  2074.     return new Future.delayed(new Duration(seconds: 1), () {
  2075.       return notes.toList();
  2076.     });
  2077.   }
  2078.  
  2079.   Widget _listArtikel(ArtikelModel a) {
  2080.     return Container(
  2081.       margin: EdgeInsets.only(right: 16.0),
  2082.       child: Column(
  2083.         children: <Widget>[
  2084.           CachedNetworkImage(
  2085.             imageUrl: "http://103.4.52.200/upload/" + a.imageThumbFile,
  2086.             placeholder: (context, url) => CircularProgressIndicator(),
  2087.             errorWidget: (context, url, error) => Icon(Icons.error),
  2088.             width: 200.0,
  2089.             height: 160.0,
  2090.           ),
  2091.           // Image.network(
  2092.           //   "http://103.4.52.200/upload/" + a.imageThumbFile,
  2093.           //   width: 200.0,
  2094.           //   height: 160.0,
  2095.           // ),
  2096.           Padding(
  2097.             padding: EdgeInsets.only(top: 5.0),
  2098.           ),
  2099.           Text(
  2100.             a.title,
  2101.             // textAlign: TextAlign.center,
  2102.             style: TextStyle(
  2103.                 fontSize: 12.0,
  2104.                 fontWeight: FontWeight.normal,
  2105.                 color: Colors.black),
  2106.           ),
  2107.           Padding(
  2108.             padding: EdgeInsets.only(top: 5.0),
  2109.           ),
  2110.           InkWell(
  2111.             onTap: () {
  2112.               Navigator.of(context).push(new MaterialPageRoute(builder: (_) {
  2113.                 return new ArtikelDetail(a);
  2114.               }));
  2115.             },
  2116.             child: Align(
  2117.               alignment: Alignment.topRight,
  2118.               child: Container(
  2119.                 decoration: BoxDecoration(
  2120.                   color: Color.fromRGBO(0, 185, 92, 1),
  2121.                   borderRadius: BorderRadius.all(Radius.circular(10.0)),
  2122.                   boxShadow: <BoxShadow>[
  2123.                     new BoxShadow(
  2124.                       color: Colors.black12,
  2125.                       blurRadius: 10.0,
  2126.                       // offset: new Offset(0.0, 10.0),
  2127.                     ),
  2128.                   ],
  2129.                 ),
  2130.                 // color: Color.fromRGBO(
  2131.                 //     0, 185, 92, 1),
  2132.                 height: 25.0, // height of the button
  2133.                 width: 55.0, // width of the button
  2134.                 child: Center(
  2135.                     child: Text("Baca",
  2136.                         style: TextStyle(
  2137.                             fontSize: 12.0,
  2138.                             fontWeight: FontWeight.normal,
  2139.                             color: Colors.white))),
  2140.               ),
  2141.             ),
  2142.           ),
  2143.         ],
  2144.       ),
  2145.     );
  2146.   }
  2147.  
  2148.   Future<List<ArtikelModel>> fetchArtikel() async {
  2149.     String url = new Api().url;
  2150.     var dio = new Dio();
  2151.     var notes = List<ArtikelModel>();
  2152.     try {
  2153.       Response response;
  2154.       response = await dio.get(url + "index.php/api/Artikel/date");
  2155.       final json = response.data;
  2156.       if (response.statusCode == 200) {
  2157.         notes = (json)
  2158.             .map<ArtikelModel>((item) => ArtikelModel.fromJson(item))
  2159.             .toList();
  2160.       } else {
  2161.         throw Exception('Failed to load');
  2162.       }
  2163.       // print("json " + json.toString());
  2164.       return new Future.delayed(new Duration(seconds: 1), () {
  2165.         setState(() {
  2166.           jumartikel = notes
  2167.               .where((i) => i.statusDeleted == "n")
  2168.               .where((i) => i.statusActive == "y")
  2169.               .length;
  2170.         });
  2171.         return notes
  2172.             .where((i) => i.statusDeleted == "n")
  2173.             .where((i) => i.statusActive == "y")
  2174.             .toList();
  2175.       });
  2176.     } on DioError catch (e) {
  2177.       print("GAGAL");
  2178.  
  2179.       if (e.response != null) {
  2180.         print(e.response.data);
  2181.         print(e.response.headers);
  2182.         print(e.response.request);
  2183.       } else {
  2184.         print(e.request);
  2185.         print(e.message);
  2186.       }
  2187.     }
  2188.   }
  2189. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement