Skip to content

Commit

Permalink
👽 Done kot
Browse files Browse the repository at this point in the history
  • Loading branch information
iqfareez committed Sep 20, 2020
1 parent 8738873 commit fc57adb
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 21 deletions.
12 changes: 12 additions & 0 deletions lib/utils/DateAndTime.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import 'package:intl/intl.dart';

class DateAndTime {
static String toAmPmReadable(int unix) {
var format12 = DateFormat('h:mm a');
var date =
new DateTime.fromMillisecondsSinceEpoch(unix * 1000, isUtc: true);
date = date.add(Duration(hours: 8)); //phone already formatted like this
var formattedTime = format12.format(date);
return (formattedTime);
}
}
47 changes: 27 additions & 20 deletions lib/views/GetPrayerTime.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:get_storage/get_storage.dart';
import 'package:intl/date_symbol_data_local.dart';
import 'package:intl/intl.dart';
import 'package:waktusolatmalaysia/CONSTANTS.dart';
import 'package:waktusolatmalaysia/blocs/azan_times_today_bloc.dart';
import 'package:waktusolatmalaysia/blocs/waktusolatapp_bloc.dart';
import 'package:waktusolatmalaysia/models/azanproapi.dart';
import 'package:waktusolatmalaysia/models/waktusolatappapi.dart';
import 'package:waktusolatmalaysia/utils/DateAndTime.dart';
import 'package:waktusolatmalaysia/utils/cachedPrayerData.dart';
import 'package:waktusolatmalaysia/utils/sizeconfig.dart';

Expand All @@ -23,12 +22,12 @@ class GetPrayerTime extends StatefulWidget {
class _GetPrayerTimeState extends State<GetPrayerTime> {
WaktusolatappBloc _timeBloc;

String timeFormat = "&format=12-hour";
// String timeFormat = "&format=12-hour";

@override
void initState() {
super.initState();
initializeDateFormatting('en_US', null);
// initializeDateFormatting('en_US', null);
_timeBloc = WaktusolatappBloc(location, null);
}

Expand Down Expand Up @@ -76,23 +75,31 @@ class PrayTimeList extends StatelessWidget {
// final AzanPro prayerTime;
final WaktuSolatApp prayerTime;

const PrayTimeList({Key key, this.prayerTime}) : super(key: key);
PrayTimeList({Key key, this.prayerTime}) : super(key: key);

@override
Widget build(BuildContext context) {
String subuhTime = prayerTime.data.prayTimes[1].subuh.toString();
String zohorTime = prayerTime.data.prayTimes[1].zohor.toString();
String asarTime = prayerTime.data.prayTimes[1].asar.toString();
String maghribTime = prayerTime.data.prayTimes[1].maghrib.toString();
String isyaTime = prayerTime.data.prayTimes[1].isyak.toString();
int day = int.parse(DateFormat('d').format(DateTime.now())); //example: 21

// String subuhTime = prayerTime.success.toString();
//since array start at 0, the date should be minus 1

// CachedPrayerTimeData.subuhTime = subuhTime;
// CachedPrayerTimeData.zohorTime = zohorTime;
// CachedPrayerTimeData.asarTime = asarTime;
// CachedPrayerTimeData.maghribTime = maghribTime;
// CachedPrayerTimeData.isyaTime = isyaTime;
@override
Widget build(BuildContext context) {
int arrayDay = day - 1;
String subuhTime =
DateAndTime.toAmPmReadable(prayerTime.data.prayTimes[arrayDay].subuh);
String zohorTime =
DateAndTime.toAmPmReadable(prayerTime.data.prayTimes[arrayDay].zohor);
String asarTime =
DateAndTime.toAmPmReadable(prayerTime.data.prayTimes[arrayDay].asar);
String maghribTime =
DateAndTime.toAmPmReadable(prayerTime.data.prayTimes[arrayDay].maghrib);
String isyaTime =
DateAndTime.toAmPmReadable(prayerTime.data.prayTimes[arrayDay].isyak);

CachedPrayerTimeData.subuhTime = subuhTime;
CachedPrayerTimeData.zohorTime = zohorTime;
CachedPrayerTimeData.asarTime = asarTime;
CachedPrayerTimeData.maghribTime = maghribTime;
CachedPrayerTimeData.isyaTime = isyaTime;

return Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
Expand All @@ -105,7 +112,7 @@ class PrayTimeList extends StatelessWidget {
solatCard(zohorTime, 'Zohor'),
solatCard(asarTime, 'Asr'),
solatCard(maghribTime, 'Maghrib'),
solatCard(isyaTime, 'Isyak'),
solatCard(isyaTime, 'Isya\''),

// RaisedButton(
// child: Text('DEBUG BUTTON'),
Expand Down
2 changes: 1 addition & 1 deletion lib/views/bottomAppBar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class MyBottomAppBar extends StatelessWidget {
copyAndShare.updateMessage();
Clipboard.setData(
new ClipboardData(text: copyAndShare.getMessage()));
Fluttertoast.showToast(msg: 'Copied');
Fluttertoast.showToast(msg: 'Timetable copied');
})
],
),
Expand Down

0 comments on commit fc57adb

Please sign in to comment.