Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'dart:async';
- import 'dart:io';
- import 'package:add_2_calendar/add_2_calendar.dart';
- import 'package:dio/dio.dart';
- import 'package:flutter/material.dart';
- import 'package:flutter_calendar_carousel/classes/event.dart';
- import 'package:flutter_calendar_carousel/classes/event_list.dart';
- import 'package:flutter_local_notifications/flutter_local_notifications.dart';
- import 'package:geolocator/geolocator.dart';
- import 'package:rflutter_alert/rflutter_alert.dart';
- import 'package:rohisapp/endpoint/api.dart';
- import 'package:rohisapp/model/event_model.dart';
- import 'package:rohisapp/notification/firebase_notification_handler.dart';
- import 'package:flutter_calendar_carousel/flutter_calendar_carousel.dart';
- import 'package:intl/intl.dart' show DateFormat;
- import 'package:shared_preferences/shared_preferences.dart';
- import 'package:permission_handler/permission_handler.dart';
- import 'package:device_info/device_info.dart';
- import 'package:html_unescape/html_unescape.dart';
- import 'package:wc_flutter_share/wc_flutter_share.dart';
- class KalenderKegiatan extends StatefulWidget {
- KalenderKegiatan(this.deviceid);
- final String deviceid;
- @override
- _KalenderKegiatanState createState() => _KalenderKegiatanState();
- }
- class _KalenderKegiatanState extends State<KalenderKegiatan>
- with SingleTickerProviderStateMixin {
- FlutterLocalNotificationsPlugin localNotificationsPlugin =
- FlutterLocalNotificationsPlugin();
- initializeNotifications() async {
- var initializeAndroid = AndroidInitializationSettings('ic_launcher');
- var initializeIOS = IOSInitializationSettings();
- var initSettings = InitializationSettings(initializeAndroid, initializeIOS);
- await localNotificationsPlugin.initialize(initSettings);
- var pendingNotificationRequests =
- await localNotificationsPlugin.pendingNotificationRequests();
- print('pendingNotificationRequests ' +
- pendingNotificationRequests.length.toString());
- }
- int jumartikel = 0;
- Timer timer;
- String timeText = '';
- String statusText = '';
- int jam = 0;
- int menit = 0;
- int detik = 0;
- Stopwatch stopwatch = Stopwatch();
- static const delay = Duration(microseconds: 1);
- String m = '';
- String y = '';
- var begin = 0.0;
- Animation<double> heightSize;
- AnimationController controller;
- void updateClock() {
- final duration = Duration(hours: jam, minutes: menit, seconds: detik);
- // if time is up, stop the timer
- if (stopwatch.elapsed.inMilliseconds == duration.inMilliseconds) {
- print('--finished Timer Page--');
- stopwatch.stop();
- stopwatch.reset();
- controller.stop(canceled: false);
- setState(() {
- statusText = 'Finished';
- // buttonText = "Restart";
- });
- return;
- } else {
- statusText = '';
- }
- final millisecondsRemaining =
- duration.inMilliseconds - stopwatch.elapsed.inMilliseconds;
- final hoursRemaining =
- ((millisecondsRemaining / (1000 * 60 * 60)) % 24).toInt();
- final minutesRemaining =
- ((millisecondsRemaining / (1000 * 60)) % 60).toInt();
- final secondsRemaining = ((millisecondsRemaining / 1000) % 60).toInt();
- setState(() {
- timeText = '${hoursRemaining.toString().padLeft(2, '0')}:'
- '${minutesRemaining.toString().padLeft(2, '0')}:'
- '${secondsRemaining.toString().padLeft(2, '0')}';
- });
- if (stopwatch.isRunning) {
- setState(() {});
- } else if (stopwatch.elapsed.inSeconds == 0) {
- setState(() {
- timeText = '${jam.toString().padLeft(2, "0")}:'
- '${menit.toString().padLeft(2, '0')}:'
- '${detik.toString().padLeft(2, '0')}';
- });
- } else {
- setState(() {});
- }
- }
- Position positions;
- double lat;
- double long;
- static double _minHeight = 130, _maxHeight = 290;
- Offset _offset = Offset(0, _minHeight);
- DateTime _currentDate = DateTime.now();
- DateTime _currentDate2 = DateTime.now();
- DateTime _targetDateTime = DateTime.now();
- String _currentMonth = '';
- bool content = false;
- SharedPreferences sharedPreferences;
- bool islogin = false;
- var email = "";
- var userid = "";
- var full_name = "";
- var kota = "";
- var lokasiAdzan = "";
- var tglHijriah = "";
- var tglMasehi = "";
- var deviceid = "";
- String timerString = '';
- bool _isVisible = true;
- String firstHalf;
- String secondHalf;
- bool flag = true;
- static Widget _eventIcon = new Container(
- decoration: new BoxDecoration(
- color: Colors.white,
- borderRadius: BorderRadius.all(Radius.circular(1000)),
- border: Border.all(color: Colors.blue, width: 2.0)),
- child: new Icon(
- Icons.check_circle,
- color: Colors.blue,
- ),
- );
- static Widget _holidayIcon = new Container(
- decoration: new BoxDecoration(
- color: Colors.white,
- borderRadius: BorderRadius.all(Radius.circular(1000)),
- border: Border.all(color: Colors.red, width: 2.0)),
- child: new Icon(
- Icons.home,
- color: Colors.red,
- ),
- );
- EventList<Event> _markedDateMap = EventList<Event>();
- CalendarCarousel _calendarCarouselNoHeader;
- void handleNewDate(date) {
- print("handleNewDate ${date}");
- }
- getDeviceDetails() async {
- String deviceName;
- String deviceVersion;
- String identifier;
- final DeviceInfoPlugin deviceInfoPlugin = new DeviceInfoPlugin();
- try {
- if (Platform.isAndroid) {
- var build = await deviceInfoPlugin.androidInfo;
- deviceName = build.model;
- deviceVersion = build.version.toString();
- identifier = build.androidId; //UUID for Android
- print('identifier ' + identifier);
- } else if (Platform.isIOS) {
- var data = await deviceInfoPlugin.iosInfo;
- deviceName = data.name;
- deviceVersion = data.systemVersion;
- identifier = data.identifierForVendor; //UUID for iOS
- }
- setState(() {
- deviceid = identifier;
- });
- _checkJadwalSholat(deviceid);
- String url = new Api().url;
- var dio = new Dio();
- await dio.post(
- url + "index.php/api/Device_info",
- data: {
- "device_id": identifier,
- "deviceName": deviceName,
- },
- options:
- new Options(contentType: ContentType.parse("application/json")),
- );
- } catch (e) {
- print('Failed to get platform version');
- }
- return [deviceName, deviceVersion, identifier];
- }
- _checkJadwalSholat(identifier) async {
- var now = new DateTime.now();
- var formatter = new DateFormat('MM');
- var dates = formatter.format(now);
- String url = new Api().url;
- Response response;
- var dio = new Dio();
- try {
- // for (int i = 1; i <= 7; i++) {
- response = await dio
- .get(url + "index.php/api/CheckJadwalSholat?device_id=" + identifier);
- final json = response.data;
- if (response.statusCode == 200) {
- // print(json.toString());
- lokasiAdzan = json.toString();
- } else {
- throw Exception('Failed to load');
- }
- } on DioError catch (e) {
- print("GAGAL");
- if (e.response != null) {
- print(e.response.data);
- print(e.response.headers);
- print(e.response.request);
- } else {
- print(e.request);
- print(e.message);
- }
- }
- }
- Widget _boxDate(kategori, dates) {
- print('kategori ' + kategori);
- if (kategori == '0') {
- return new Container(
- width: 50.0,
- height: 50.0,
- padding: EdgeInsets.all(15.0),
- decoration: BoxDecoration(
- color: Colors.green,
- borderRadius: BorderRadius.all(Radius.circular(10.0)),
- boxShadow: <BoxShadow>[
- new BoxShadow(
- color: Colors.black12,
- blurRadius: 10.0,
- offset: new Offset(0.0, 10.0),
- ),
- ],
- ),
- child: Text(dates.toString(),
- style: TextStyle(
- fontSize: 14.0,
- fontWeight: FontWeight.bold,
- )));
- } else if (kategori == '1') {
- return new Container(
- width: 50.0,
- height: 50.0,
- padding: EdgeInsets.all(15.0),
- decoration: BoxDecoration(
- color: Colors.red,
- borderRadius: BorderRadius.all(Radius.circular(10.0)),
- boxShadow: <BoxShadow>[
- new BoxShadow(
- color: Colors.black12,
- blurRadius: 10.0,
- offset: new Offset(0.0, 10.0),
- ),
- ],
- ),
- child: Text(dates.toString(),
- style: TextStyle(
- fontSize: 14.0,
- fontWeight: FontWeight.bold,
- )));
- } else {
- return new Container(
- width: 50.0,
- height: 50.0,
- padding: EdgeInsets.all(15.0),
- decoration: BoxDecoration(
- color: Colors.green,
- borderRadius: BorderRadius.all(Radius.circular(10.0)),
- boxShadow: <BoxShadow>[
- new BoxShadow(
- color: Colors.black12,
- blurRadius: 10.0,
- offset: new Offset(0.0, 10.0),
- ),
- ],
- ),
- child: Text(dates.toString(),
- style: TextStyle(
- fontSize: 14.0,
- fontWeight: FontWeight.bold,
- )));
- }
- }
- Future<void> _scheduleNotifications(id, title, desc, tanggal) async {
- var scheduledNotificationDateTime = tanggal.add(Duration(seconds: 5));
- print('scheduledNotificationDateTime ' +
- scheduledNotificationDateTime.toString());
- var androidPlatformChannelSpecifics = new AndroidNotificationDetails(
- 'your other channel id',
- 'your other channel name',
- 'your other channel description');
- var iOSPlatformChannelSpecifics = IOSNotificationDetails();
- var platformChannelSpecifics = NotificationDetails(
- androidPlatformChannelSpecifics, iOSPlatformChannelSpecifics);
- await localNotificationsPlugin.schedule(id, title, desc,
- scheduledNotificationDateTime, platformChannelSpecifics);
- }
- Widget _shareJadwal(title, date, jam, ustadz, kategori) {
- if (kategori == '0') {
- return Center(
- child: InkWell(
- onTap: () async {
- await WcFlutterShare.share(
- sharePopupTitle: 'Share Jadwal Kajian',
- subject: title,
- text: 'Jadwal Kajian \nTema : ' +
- title +
- '\nTanggal : ' +
- date.toString() +
- '\nJam : ' +
- jam.toString() +
- '\nPengisi :' +
- ustadz,
- mimeType: 'text/plain');
- },
- child: Icon(
- Icons.share,
- color: Colors.black,
- ),
- ));
- } else if (kategori == '0') {
- return Center(
- child: InkWell(
- onTap: () async {
- await WcFlutterShare.share(
- sharePopupTitle: 'Share Jadwal Kajian',
- subject: title,
- text: 'Hari Libur',
- mimeType: 'text/plain');
- },
- child: Icon(
- Icons.share,
- color: Colors.black,
- ),
- ));
- } else {
- return Center(
- child: InkWell(
- onTap: () async {
- await WcFlutterShare.share(
- sharePopupTitle: 'Share Jadwal Kajian',
- subject: title,
- text: 'Jadwal Kajian \nTema : ' +
- title +
- '\nTanggal : ' +
- date.toString() +
- '\nJam : ' +
- jam.toString() +
- '\nPengisi :' +
- ustadz,
- mimeType: 'text/plain');
- },
- child: Icon(
- Icons.share,
- color: Colors.black,
- ),
- ));
- }
- }
- _listEvents(EventModel event) {
- if (event.description_event.length > 30) {
- firstHalf = event.description_event.substring(0, 30);
- secondHalf =
- event.description_event.substring(30, event.description_event.length);
- } else {
- firstHalf = event.description_event;
- secondHalf = "";
- }
- var now = event.date;
- var formatter = new DateFormat('dd');
- var dates = formatter.format(now);
- var end = event.dates;
- var formatterenddate = new DateFormat('yyyy-MM-dd hh:mm:ss');
- var enddate = formatterenddate.format(end);
- var formatter2 = new DateFormat('dd-MM-yyyy');
- var dates2 = formatter2.format(now);
- var dates3 = formatter2.format(end);
- var formatEvent = new DateFormat('yyyy-MM-dd hh:mm:ss');
- var datesEvent = formatEvent.format(now);
- var formatter3 = new DateFormat('hh:mm');
- var jam = formatter3.format(now);
- var lokasi = event.lokasi;
- Events events = Events(
- title: event.title,
- description: jam.toString() + ' - ' + event.description_event,
- location: 'Masjid' + DateTime.now().toString(),
- startDate: DateTime.parse(datesEvent),
- endDate: DateTime.parse(enddate),
- allDay: false,
- );
- return Padding(
- padding: const EdgeInsets.only(top: 8.0),
- child: Align(
- child: Container(
- padding: EdgeInsets.all(15.0),
- decoration: BoxDecoration(
- color: Colors.white,
- borderRadius: BorderRadius.all(Radius.circular(10.0)),
- boxShadow: <BoxShadow>[
- new BoxShadow(
- color: Colors.black12,
- blurRadius: 10.0,
- offset: new Offset(0.0, 10.0),
- ),
- ],
- ),
- child: Column(
- children: <Widget>[
- Row(
- children: <Widget>[
- _boxDate(event.kategori, dates),
- Padding(
- padding: EdgeInsets.only(left: 10.0),
- ),
- Expanded(
- flex: 6,
- child: Column(
- children: <Widget>[
- Row(
- children: <Widget>[
- Text('Tema :' + event.title,
- style: TextStyle(fontSize: 11.0)),
- ],
- ),
- Row(
- children: <Widget>[
- secondHalf.isEmpty
- ? new Text(firstHalf,
- style: TextStyle(fontSize: 11.0))
- : new Column(
- children: <Widget>[
- new Text(
- flag
- ? (firstHalf + "...")
- : (firstHalf + secondHalf),
- style: TextStyle(fontSize: 11.0)),
- new InkWell(
- child: new Row(
- mainAxisAlignment:
- MainAxisAlignment.end,
- children: <Widget>[
- new Text(
- flag
- ? "View Detail"
- : "show less",
- style: new TextStyle(
- color: Colors.blue),
- ),
- ],
- ),
- onTap: () {
- _viewEven(event);
- // setState(() {
- // flag = !flag;
- // });
- },
- ),
- ],
- ),
- // Text(
- // event.description_event,
- // style: TextStyle(fontSize: 11.0),
- // ),
- ],
- ),
- Row(
- children: <Widget>[
- Text(
- 'Pengisi : ' + event.ustadz,
- style: TextStyle(fontSize: 11.0),
- ),
- ],
- ),
- Row(
- children: <Widget>[
- Column(
- children: <Widget>[
- Text('Tanggal : ' + dates2 + ' - ' + dates3,
- style: TextStyle(fontSize: 11.0)),
- ],
- ),
- ],
- ),
- Row(
- children: <Widget>[
- Text(
- 'Jam : ' + jam,
- style: TextStyle(fontSize: 11.0),
- ),
- ],
- ),
- Row(
- children: <Widget>[
- Text(
- 'Lokasi : ' + lokasi,
- style: TextStyle(fontSize: 11.0),
- ),
- ],
- ),
- ],
- )),
- // Expanded(
- // flex: 2,
- // child:
- _shareJadwal(
- event.title, dates2, jam, event.ustadz, event.kategori),
- Padding(
- padding: EdgeInsets.only(left: 10.0),
- ),
- Center(
- child: InkWell(
- onTap: () async {
- print('aaa' + event.dates.toString());
- await _scheduleNotifications(
- int.parse(event.id_event),
- event.title + ' - ' + event.description_event,
- 'tanggal ' + event.date.toString(),
- event.dates);
- },
- child: Icon(
- Icons.notifications,
- color: Colors.black,
- ),
- )),
- Padding(
- padding: EdgeInsets.only(left: 10.0),
- ),
- Center(
- child: InkWell(
- onTap: () async {
- Add2Calendar.addEvent2Cal(events).then((success) {
- print('sukses');
- });
- },
- child: Icon(
- Icons.calendar_today,
- color: Colors.black,
- ),
- )),
- // )
- ],
- ),
- ],
- )),
- ),
- );
- }
- @override
- void initState() {
- new FirebaseNotifications().setUpFirebase();
- super.initState();
- (() async {
- await _event();
- await _hariLibur();
- await getDeviceDetails();
- await fetchEvent();
- sharedPreferences = await SharedPreferences.getInstance();
- setState(() {
- if (sharedPreferences.getBool("isLogin") != null) {
- islogin = sharedPreferences.getBool("isLogin");
- email = sharedPreferences.getString("email");
- full_name = sharedPreferences.getString("full_name");
- userid = sharedPreferences.getString("userid");
- } else {
- full_name = "";
- }
- });
- })();
- // _askPermission();
- }
- @override
- void dispose() {
- controller.dispose();
- stopwatch.stop();
- timer.cancel();
- super.dispose();
- }
- _event() async {
- String url = new Api().url;
- Response res;
- var dio = new Dio();
- try {
- res = await dio.get(url + "index.php/api/Jadwal_kajian");
- final dataEvents = res.data;
- if (res.statusCode == 200) {
- for (int i = 0; i < int.parse(dataEvents[0]['total']); i++) {
- var now = DateTime.parse(dataEvents[i]['date']);
- var end = DateTime.parse(dataEvents[i]['dates']);
- var formatter = new DateFormat('dd/MM/yyyy');
- var dates = formatter.format(now);
- var datesend = formatter.format(end);
- var formatterJam = new DateFormat('HH:mm');
- var jam = formatterJam.format(now);
- var unescape = new HtmlUnescape();
- var text = unescape.convert(dataEvents[i]['ustadz']);
- var kat = unescape.convert(dataEvents[i]['kategori']);
- var description_event =
- unescape.convert(dataEvents[i]['description_event']);
- _markedDateMap.add(
- new DateTime(
- int.parse(dataEvents[i]['eventyear']),
- int.parse(dataEvents[i]['eventmonth']),
- int.parse(dataEvents[i]['eventday'])),
- new Event(
- date: new DateTime(
- int.parse(dataEvents[i]['eventyear']),
- int.parse(dataEvents[i]['eventmonth']),
- int.parse(dataEvents[i]['eventday'])),
- title: dataEvents[i]['title'] +
- '-' +
- dates +
- ' s/d ' +
- datesend +
- '-' +
- jam +
- '-' +
- text +
- '*' +
- kat +
- '*' +
- description_event,
- icon: _eventIcon,
- ),
- );
- }
- } else {
- throw Exception('Failed to load');
- }
- } on DioError catch (e) {
- print("GAGAL");
- if (e.response != null) {
- print(e.response.data);
- print(e.response.headers);
- print(e.response.request);
- } else {
- print(e.request);
- print(e.message);
- }
- }
- }
- _hariLibur() async {
- String url = new Api().url;
- Response res;
- var dio = new Dio();
- try {
- res = await dio.get(url + "index.php/api/Jadwal_kajian/harilibur");
- final dataEvents = res.data;
- if (res.statusCode == 200) {
- for (int i = 0; i < int.parse(dataEvents[0]['total']); i++) {
- var now = DateTime.parse(dataEvents[i]['date']);
- var end = DateTime.parse(dataEvents[i]['dates']);
- var formatter = new DateFormat('dd/MM/yyyy');
- var dates = formatter.format(now);
- var datesend = formatter.format(end);
- var formatterJam = new DateFormat('HH:mm');
- var jam = formatterJam.format(now);
- var unescape = new HtmlUnescape();
- var text = unescape.convert(dataEvents[i]['ustadz']);
- var kat = unescape.convert(dataEvents[i]['kategori']);
- var description_event =
- unescape.convert(dataEvents[i]['description_event']);
- _markedDateMap.add(
- new DateTime(
- int.parse(dataEvents[i]['eventyear']),
- int.parse(dataEvents[i]['eventmonth']),
- int.parse(dataEvents[i]['eventday'])),
- new Event(
- date: new DateTime(
- int.parse(dataEvents[i]['eventyear']),
- int.parse(dataEvents[i]['eventmonth']),
- int.parse(dataEvents[i]['eventday'])),
- title: dataEvents[i]['title'] +
- '-' +
- dates +
- ' s/d ' +
- datesend +
- '-' +
- jam +
- '-' +
- text +
- '*' +
- kat +
- '*' +
- description_event,
- icon: _holidayIcon,
- ),
- );
- }
- } else {
- throw Exception('Failed to load');
- }
- } on DioError catch (e) {
- print("GAGAL");
- if (e.response != null) {
- print(e.response.data);
- print(e.response.headers);
- print(e.response.request);
- } else {
- print(e.request);
- print(e.message);
- }
- }
- }
- _viewEven(EventModel ev) async {
- var titles = "";
- var judul = "";
- var newtgl = "";
- var jam = "";
- var ustadz = "";
- var tgl = "";
- var lokasi = "";
- if (ev.kategori == '1') {
- titles = 'Hari Libur';
- judul = '';
- tgl = '';
- newtgl = ev.date.toString();
- jam = '';
- ustadz = '';
- lokasi = '';
- } else {
- judul = 'Tema : ' + ev.title.toString();
- tgl = ev.date.toString();
- newtgl = 'Tanggal : ' + ev.dates.toString();
- jam = 'Jam : ' + ev.date.toString();
- ustadz = 'Pengisi : ' + ev.ustadz.toString();
- lokasi = 'Lokasi : ' + ev.lokasi.toString();
- titles = 'Detail';
- }
- double c_width = MediaQuery.of(context).size.width * 0.8;
- showDialog(
- context: context,
- builder: (BuildContext context) {
- return AlertDialog(
- title: new Text(titles),
- content: Container(
- width: c_width,
- child: SingleChildScrollView(
- child: Column(
- children: <Widget>[
- new Container(
- padding: const EdgeInsets.all(16.0),
- width: c_width,
- child: new Column(
- children: <Widget>[
- new Text(ev.description_event,
- textAlign: TextAlign.left,
- style: TextStyle(fontSize: 12)),
- ],
- ),
- ),
- new Padding(
- padding: EdgeInsets.only(top: 15.0),
- ),
- DialogButton(
- child: Text(
- "OK",
- style: TextStyle(color: Colors.white, fontSize: 20),
- ),
- onPressed: () {
- Navigator.of(context).pop();
- },
- width: 120,
- )
- ],
- ),
- ),
- ),
- );
- },
- );
- }
- Future<List<EventModel>> fetchEvent() async {
- try {
- String url = new Api().url;
- var notes = List<EventModel>();
- Response response;
- response = await Dio().get(url + "index.php/api/Event");
- final json = response.data;
- if (response.statusCode == 200) {
- notes = (json)
- .map<EventModel>((item) => EventModel.fromJson(item))
- .toList();
- } else {
- throw Exception('Failed to load');
- }
- // print("json " + json.toString());
- return new Future.delayed(new Duration(seconds: 1), () {
- return notes.where((i) => i.id_event != null).toList();
- });
- } catch (e) {
- print('Failed to get platform version');
- }
- }
- // List<EventModelNext> _listFuture = [];
- Future<List<EventModel>> fetchEventNext() async {
- try {
- String url = new Api().url;
- var note = List<EventModel>();
- Response response;
- response = await Dio().get(url +
- "index.php/api/EventNext?month=" +
- m.toString() +
- "&year=" +
- y.toString());
- final json = response.data;
- if (response.statusCode == 200) {
- note = (json)
- .map<EventModel>((item) => EventModel.fromJson(item))
- .toList();
- print('bisa!!!' + note.toString());
- } else {
- throw Exception('Failed to load');
- }
- // print("json " + json.toString());
- return new Future.delayed(new Duration(seconds: 1), () {
- return note.where((i) => i.id_event != null).toList();
- });
- } catch (e) {
- print('Failed to get platform version');
- }
- }
- _listEventsNext(EventModel eventNext) {
- print('eventNext.date - ' + eventNext.date.toString());
- var now = eventNext.date;
- var formatter = new DateFormat('dd');
- var dates = formatter.format(now);
- var end = eventNext.dates;
- var formatterenddate = new DateFormat('yyyy-MM-dd hh:mm:ss');
- var enddate = formatterenddate.format(end);
- var formatter2 = new DateFormat('dd-MM-yyyy');
- var dates2 = formatter2.format(now);
- var dates3 = formatter2.format(end);
- var formatEvent = new DateFormat('yyyy-MM-dd hh:mm:ss');
- var datesEvent = formatEvent.format(now);
- var formatter3 = new DateFormat('hh:mm');
- var jam = formatter3.format(now);
- var lokasi = eventNext.lokasi;
- Events events = Events(
- title: eventNext.title,
- description: jam.toString() + ' - ' + eventNext.description_event,
- location: 'Masjid' + DateTime.now().toString(),
- startDate: DateTime.parse(datesEvent),
- endDate: DateTime.parse(enddate),
- allDay: false,
- );
- return Padding(
- padding: const EdgeInsets.only(top: 8.0),
- child: Align(
- child: Container(
- padding: EdgeInsets.all(15.0),
- decoration: BoxDecoration(
- color: Colors.white,
- borderRadius: BorderRadius.all(Radius.circular(10.0)),
- boxShadow: <BoxShadow>[
- new BoxShadow(
- color: Colors.black12,
- blurRadius: 10.0,
- offset: new Offset(0.0, 10.0),
- ),
- ],
- ),
- child: Column(
- children: <Widget>[
- Row(
- children: <Widget>[
- _boxDate(eventNext.kategori, dates),
- Padding(
- padding: EdgeInsets.only(left: 10.0),
- ),
- Expanded(
- flex: 6,
- child: Column(
- children: <Widget>[
- Row(
- children: <Widget>[
- Text('Tema :' + eventNext.title,
- style: TextStyle(fontSize: 11.0)),
- ],
- ),
- Row(
- children: <Widget>[
- secondHalf.isEmpty
- ? new Text(firstHalf,
- style: TextStyle(fontSize: 11.0))
- : new Column(
- children: <Widget>[
- new Text(
- flag
- ? (firstHalf + "...")
- : (firstHalf + secondHalf),
- style: TextStyle(fontSize: 11.0)),
- new InkWell(
- child: new Row(
- mainAxisAlignment:
- MainAxisAlignment.end,
- children: <Widget>[
- new Text(
- flag
- ? "VIew Detail"
- : "show less",
- style: new TextStyle(
- color: Colors.blue),
- ),
- ],
- ),
- onTap: () {
- _viewEven(eventNext);
- // setState(() {
- // flag = !flag;
- // });
- },
- ),
- ],
- ),
- // Text(
- // event.description_event,
- // style: TextStyle(fontSize: 11.0),
- // ),
- ],
- ),
- Row(
- children: <Widget>[
- Text(
- 'Pengisi : ' + eventNext.ustadz,
- style: TextStyle(fontSize: 11.0),
- ),
- ],
- ),
- Row(
- children: <Widget>[
- Column(
- children: <Widget>[
- Text('Tanggal : ' + dates2 + ' - ' + dates3,
- style: TextStyle(fontSize: 11.0)),
- ],
- ),
- ],
- ),
- Row(
- children: <Widget>[
- Text(
- 'Jam : ' + jam,
- style: TextStyle(fontSize: 11.0),
- ),
- ],
- ),
- Row(
- children: <Widget>[
- Text(
- 'Lokasi : ' + lokasi,
- style: TextStyle(fontSize: 11.0),
- ),
- ],
- ),
- ],
- )),
- // Expanded(
- // flex: 2,
- // child:
- Center(
- child: InkWell(
- onTap: () async {
- await WcFlutterShare.share(
- sharePopupTitle: 'Share Jadwal Kajian',
- subject: eventNext.title,
- text: 'Jadwal Kajian \nTema : ' +
- eventNext.title +
- '\nTanggal : ' +
- dates2.toString() +
- '\nJam : ' +
- jam.toString() +
- '\nPengisi :' +
- eventNext.ustadz,
- mimeType: 'text/plain');
- },
- child: Icon(
- Icons.share,
- color: Colors.black,
- ),
- )),
- Padding(
- padding: EdgeInsets.only(left: 10.0),
- ),
- Center(
- child: InkWell(
- onTap: () async {
- print('aaa' + eventNext.dates.toString());
- await _scheduleNotifications(
- int.parse(eventNext.id_event),
- eventNext.title +
- ' - ' +
- eventNext.description_event,
- 'tanggal ' + eventNext.date.toString(),
- eventNext.dates);
- },
- child: Icon(
- Icons.notifications,
- color: Colors.black,
- ),
- )),
- Padding(
- padding: EdgeInsets.only(left: 10.0),
- ),
- Center(
- child: InkWell(
- onTap: () async {
- Add2Calendar.addEvent2Cal(events).then((success) {
- print('sukses');
- });
- },
- child: Icon(
- Icons.calendar_today,
- color: Colors.black,
- ),
- )),
- // )
- ],
- ),
- ],
- )),
- ),
- );
- }
- Widget _contentKajian() {
- if (_isVisible == true) {
- return Container(
- width: MediaQuery.of(context).size.width,
- // decoration: BoxDecoration(
- // color: Colors.blueGrey[100]),
- height: MediaQuery.of(context).size.height,
- child: new FutureBuilder<List>(
- future: fetchEvent(),
- builder: (context, snapshot) {
- if (snapshot.hasData) {
- return new ListView.builder(
- shrinkWrap: true,
- physics: const NeverScrollableScrollPhysics(),
- itemCount: snapshot.data.length,
- padding: EdgeInsets.only(top: 4.0),
- itemBuilder: (context, index) {
- return _listEvents(snapshot.data[index]);
- },
- );
- }
- return Center(
- child: SizedBox(
- width: 40.0,
- height: 40.0,
- child: const CircularProgressIndicator()),
- );
- }),
- );
- } else if (_isVisible == false) {
- return Container(
- width: MediaQuery.of(context).size.width,
- // decoration: BoxDecoration(
- // color: Colors.blueGrey[100]),
- height: MediaQuery.of(context).size.height,
- child: new FutureBuilder<List>(
- future: fetchEventNext(),
- builder: (context, snapshot) {
- if (snapshot.hasData) {
- return new ListView.builder(
- shrinkWrap: true,
- physics: const NeverScrollableScrollPhysics(),
- itemCount: snapshot.data.length,
- padding: EdgeInsets.only(top: 4.0),
- itemBuilder: (context, index) {
- return _listEventsNext(snapshot.data[index]);
- },
- );
- }
- return Center(
- child: SizedBox(
- width: 40.0,
- height: 40.0,
- child: const CircularProgressIndicator()),
- );
- }),
- );
- } else {
- Container();
- }
- }
- @override
- Widget build(BuildContext context) {
- _calendarCarouselNoHeader = CalendarCarousel<Event>(
- todayBorderColor: Colors.green,
- onDayPressed: (DateTime date, List<Event> events) {
- this.setState(() => _currentDate2 = date);
- // events.forEach((event) => _checkExternal(event.title));
- print(events[0].title);
- },
- weekendTextStyle: TextStyle(
- color: Colors.red,
- ),
- thisMonthDayBorderColor: Colors.grey,
- weekFormat: false,
- markedDatesMap: _markedDateMap,
- height: 310.0,
- selectedDateTime: _currentDate2,
- targetDateTime: _targetDateTime,
- customGridViewPhysics: NeverScrollableScrollPhysics(),
- markedDateShowIcon: true,
- markedDateIconMaxShown: 2,
- markedDateMoreShowTotal:
- false, // null for not showing hidden events indicator
- showHeader: false,
- markedDateIconBuilder: (event) {
- return event.icon;
- },
- todayTextStyle: TextStyle(
- color: Colors.blue,
- ),
- todayButtonColor: Colors.yellow,
- selectedDayTextStyle: TextStyle(
- color: Colors.yellow,
- ),
- minSelectedDate: _currentDate.subtract(Duration(days: 360)),
- maxSelectedDate: _currentDate.add(Duration(days: 360)),
- prevDaysTextStyle: TextStyle(
- fontSize: 16,
- color: Colors.pinkAccent,
- ),
- inactiveDaysTextStyle: TextStyle(
- color: Colors.tealAccent,
- fontSize: 16,
- ),
- onCalendarChanged: (DateTime date) {
- this.setState(() {
- _targetDateTime = date;
- _currentMonth = DateFormat.yMMM().format(_targetDateTime);
- });
- },
- );
- return Scaffold(
- appBar: AppBar(
- backgroundColor: Color.fromRGBO(0, 185, 92, 1),
- title: Center(child: Text("Assalamu'alaikum " + full_name)),
- elevation: 0,
- ),
- body: Stack(
- alignment: Alignment.bottomCenter,
- children: <Widget>[
- new SingleChildScrollView(
- physics: ScrollPhysics(),
- child: Container(
- decoration: BoxDecoration(color: Colors.blueGrey[100]),
- padding: EdgeInsets.only(left: 10.0, right: 10.0, top: 10.0),
- child: Column(
- children: <Widget>[
- Padding(
- padding: EdgeInsets.only(bottom: 20.0),
- ),
- Align(
- child: Padding(
- padding: EdgeInsets.only(left: 10.0, right: 10.0),
- child: Container(
- height: 440.0,
- decoration: BoxDecoration(
- color: Colors.white,
- borderRadius:
- BorderRadius.all(Radius.circular(10.0)),
- boxShadow: <BoxShadow>[
- new BoxShadow(
- color: Colors.black12,
- blurRadius: 10.0,
- offset: new Offset(0.0, 10.0),
- ),
- ],
- ),
- child: Column(
- children: <Widget>[
- Container(
- margin: EdgeInsets.only(
- top: 30.0,
- bottom: 16.0,
- left: 16.0,
- right: 16.0,
- ),
- child: new Row(
- children: <Widget>[
- Expanded(
- child: Text(
- _currentMonth,
- style: TextStyle(
- fontWeight: FontWeight.bold,
- fontSize: 24.0,
- ),
- )),
- FlatButton(
- child: Text('PREV'),
- onPressed: () {
- setState(() {
- _targetDateTime = DateTime(_targetDateTime.year, _targetDateTime.month -1);
- _currentMonth = DateFormat.yMMM().format(_targetDateTime);
- m = DateFormat.M()
- .format(_currentDate2);
- y = DateFormat.y()
- .format(_currentDate2);
- _isVisible = false;
- fetchEventNext();
- });
- },
- ),
- FlatButton(
- child: Text('NEXT'),
- onPressed: () {
- setState(() {
- _targetDateTime = DateTime(_targetDateTime.year, _targetDateTime.month +1);
- _currentMonth = DateFormat.yMMM().format(_targetDateTime);
- m = DateFormat.M()
- .format(_currentDate2);
- y = DateFormat.y()
- .format(_currentDate2);
- _isVisible = false;
- fetchEventNext();
- });
- },
- )
- ],
- ),
- ),
- Container(
- margin:
- EdgeInsets.symmetric(horizontal: 16.0),
- child: _calendarCarouselNoHeader,
- ), //
- ],
- )),
- ),
- ),
- Padding(
- padding: EdgeInsets.only(bottom: 10.0),
- ),
- Padding(
- padding: EdgeInsets.only(bottom: 10.0),
- ),
- Align(
- child: Container(
- padding: EdgeInsets.all(15.0),
- child: Column(
- children: <Widget>[
- Row(
- children: <Widget>[
- Text(
- "Agenda & Kegiatan Bulan Ini",
- textAlign: TextAlign.center,
- style: TextStyle(
- fontSize: 16.0,
- fontWeight: FontWeight.bold,
- color: Colors.black),
- ),
- ],
- ),
- ],
- )),
- ),
- _contentKajian(),
- Padding(
- padding: EdgeInsets.only(bottom: 150.0),
- ),
- ],
- ),
- ),
- ),
- ],
- ));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement