Advertisement
febu19

Untitled

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