Skip to content

Commit

Permalink
Merge pull request #25 from ryanaidilp/4.3.1
Browse files Browse the repository at this point in the history
bug fixes, improvements, and code styling 4.3.1
  • Loading branch information
ryanaidilp committed Jan 28, 2021
2 parents 2eaf11c + 3591e82 commit 9f4b3d1
Show file tree
Hide file tree
Showing 60 changed files with 2,597 additions and 1,978 deletions.
1 change: 1 addition & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include: package:lint/analysis_options.yaml
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ android {
applicationId "com.banuacoders.siap"
minSdkVersion 24
targetSdkVersion 30
versionCode 40
versionName '4.3.0'
versionCode 41
versionName '4.3.1'
}

signingConfigs {
Expand Down
23 changes: 11 additions & 12 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,17 @@ Future<void> main() async {
Intl.defaultLocale = 'id_ID';
OneSignal.shared.setLogLevel(OSLogLevel.verbose, OSLogLevel.none);
OneSignal.shared.setLocationShared(true);
OneSignal.shared.init(FlutterConfig.get("ONE_SIGNAL_APP_ID"), iOSSettings: {
OSiOSSettings.autoPrompt: false,
OSiOSSettings.inAppLaunchUrl: false
});
OneSignal.shared.init(FlutterConfig.get("ONE_SIGNAL_APP_ID").toString(),
iOSSettings: {
OSiOSSettings.autoPrompt: false,
OSiOSSettings.inAppLaunchUrl: false
});
OneSignal.shared
.setInFocusDisplayType(OSNotificationDisplayType.notification);

var initializedSettingsAndroid =
const initializedSettingsAndroid =
AndroidInitializationSettings('ic_stat_onesignal_default');
var initializationSettings =
const initializationSettings =
InitializationSettings(android: initializedSettingsAndroid);
await flutterLocalNotificationsPlugin.initialize(initializationSettings);

Expand Down Expand Up @@ -71,27 +72,25 @@ class _MyAppState extends State<MyApp> {

Future<void> scheduleAlarm(
DateTime scheduledNotificationDateTime, String body) async {
var androidPlatformChannelSpecifics = AndroidNotificationDetails(
final androidPlatformChannelSpecifics = AndroidNotificationDetails(
'alarm_id', 'alarm_id', 'Channel alarm',
icon: 'ic_stat_onesignal_default',
enableVibration: true,
enableLights: true,
playSound: true,
priority: Priority.high,
importance: Importance.max,
vibrationPattern: Int64List.fromList([0, 1000, 5000, 2000]));

tz.initializeTimeZones();
tz.setLocalLocation(tz.getLocation('Asia/Makassar'));

var scheduleTime = tz.TZDateTime.from(
final scheduleTime = tz.TZDateTime.from(
scheduledNotificationDateTime, tz.getLocation('Asia/Makassar'));

var platformChannelSpecifics =
final platformChannelSpecifics =
NotificationDetails(android: androidPlatformChannelSpecifics);

await flutterLocalNotificationsPlugin.zonedSchedule(
Random().nextInt(pow(2, 31)),
Random().nextInt(int.parse(pow(2, 31).toString())),
'Pengingat',
body,
scheduleTime,
Expand Down
22 changes: 12 additions & 10 deletions lib/models/absent_permission.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,18 @@ class AbsentPermission {

factory AbsentPermission.fromJson(Map<String, dynamic> json) {
return AbsentPermission(
id: json[ABSENT_PERMISSION_ID_FIELD] as int,
title: json[ABSENT_PERMISSION_TITLE_FIELD] as String,
description: json[ABSENT_PERMISSION_DESCRIPTION_FIELD] as String,
isApproved: json[ABSENT_PERMISSION_IS_APPROVED_FIELD] as bool,
photo: json[ABSENT_PERMISSION_PHOTO_FIELD] as String,
approvalStatus: json[APPROVAL_STATUS_FIELD] as String,
dueDate: DateTime.parse(json[ABSENT_PERMISSION_DUE_DATE_FIELD]),
startDate: DateTime.parse(json[ABSENT_PERMISSION_START_DATE_FIELD]),
user: json[ABSENT_PERMISSION_USER_FIELD] != null
? User.fromJson(json[ABSENT_PERMISSION_USER_FIELD])
id: json[absentPermissionIdField] as int,
title: json[absentPermissionTitleField] as String,
description: json[absentPermissionDescriptionField] as String,
isApproved: json[absentPermissionIsApprovedField] as bool,
photo: json[absentPermissionPhotoField] as String,
approvalStatus: json[approvalStatusField] as String,
dueDate: DateTime.parse(json[absentPermissionDueDateField].toString()),
startDate:
DateTime.parse(json[absentPermissionStartDateField].toString()),
user: json[absentPermissionUserField] != null
? User.fromJson(
json[absentPermissionUserField] as Map<String, dynamic>)
: null);
}
}
24 changes: 12 additions & 12 deletions lib/models/employee.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,18 @@ class Employee {

factory Employee.fromJson(Map<String, dynamic> json) {
return Employee(
nip: json[USER_NIP_FIELD] as String,
name: json[USER_NAME_FIELD] as String,
phone: json[USER_PHONE_FIELD] as String,
gender: json[USER_GENDER_FIELD] as String,
department: json[USER_DEPARTMENT_FIELD] as String,
rank: json[USER_RANK_FIELD] as String,
group: json[USER_GROUP_FIELD] as String,
status: json[USER_STATUS_FIELD] as String,
position: json[USER_POSITION_FIELD] as String,
presences: json[USER_PRESENCES_FIELD] != null
? (json[USER_PRESENCES_FIELD] as List<dynamic>)
.map((json) => Presence.fromJson(json))
nip: json[userNipField] as String,
name: json[userNameField] as String,
phone: json[userPhoneField] as String,
gender: json[userGenderField] as String,
department: json[userDepartmentField] as String,
rank: json[userRankField] as String,
group: json[userGroupField] as String,
status: json[userStatusField] as String,
position: json[userPositionField] as String,
presences: json[userPresencesField] != null
? (json[userPresencesField] as List<dynamic>)
.map((json) => Presence.fromJson(json as Map<String, dynamic>))
.toList()
: null);
}
Expand Down
6 changes: 3 additions & 3 deletions lib/models/holiday.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Holiday {
factory Holiday.fromJson(Map<String, dynamic> json) => Holiday(
date: json == null
? DateTime.now()
: DateTime.parse(json[HOLIDAY_DATE_FIELD].toString()),
name: json[HOLIDAY_NAME_FIELD] as String,
description: json[HOLIDAY_DESCRIPTION_FIELD] as String);
: DateTime.parse(json[holidayDateField].toString()),
name: json[holidayNameField] as String,
description: json[holidayDescriptionField] as String);
}
6 changes: 3 additions & 3 deletions lib/models/location.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ class Location {

factory Location.fromJson(Map<String, dynamic> json) {
return Location(
latitude: double.parse(json[LOCATION_LATITUDE_FIELD].toString()),
longitude: double.parse(json[LOCATION_LONGITUDE_FIELD].toString()),
address: json[LOCATION_ADDRESS_FIELD] as String);
latitude: double.parse(json[locationLatitudeField].toString()),
longitude: double.parse(json[locationLongitudeField].toString()),
address: json[locationAddressField] as String);
}
}
10 changes: 5 additions & 5 deletions lib/models/notification.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ class UserNotification {

factory UserNotification.fromJson(Map<String, dynamic> json) {
return UserNotification(
id: json[NOTIFICATION_ID_FIELD] as String,
notifiableId: json[NOTIFICATION_NOTIFIABLE_ID_FIELD] as int,
notifiableType: json[NOTIFICATION_NOTIFIABLE_TYPE_FIELD] as String,
data: json[JSON_DATA_FIELD] as Map<String, dynamic>,
isRead: json[NOTIFICATION_IS_READ_FIELD] as bool);
id: json[notificationIdField] as String,
notifiableId: json[notificationNotifiableIdField] as int,
notifiableType: json[notificationNotifiableTypeField] as String,
data: json[jsonDataField] as Map<String, dynamic>,
isRead: json[notificationIsReadField] as bool);
}
}
20 changes: 10 additions & 10 deletions lib/models/outstation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ class Outstation {

factory Outstation.fromJson(Map<String, dynamic> json) {
return Outstation(
id: json[OUTSTATION_ID_FIELD] as int,
title: json[OUTSTATION_TITLE_FIELD] as String,
description: json[OUTSTATION_DESCRIPTION_FIELD] as String,
isApproved: json[OUTSTATION_IS_APPROVED_FIELD] as bool,
photo: json[OUTSTATION_PHOTO_FIELD] as String,
approvalStatus: json[APPROVAL_STATUS_FIELD] as String,
dueDate: DateTime.parse(json[OUTSTATION_DUE_DATE_FIELD]),
startDate: DateTime.parse(json[OUTSTATION_START_DATE_FIELD]),
user: json[OUTSTATION_USER_FIELD] != null
? User.fromJson(json[OUTSTATION_USER_FIELD])
id: json[outstationIdField] as int,
title: json[outstationTitleField] as String,
description: json[outstationDescriptionField] as String,
isApproved: json[outstationIsApprovedField] as bool,
photo: json[outstationPhotoField] as String,
approvalStatus: json[approvalStatusField] as String,
dueDate: DateTime.parse(json[outstationDueDateField].toString()),
startDate: DateTime.parse(json[outstationStartDateField].toString()),
user: json[outstationUserField] != null
? User.fromJson(json[outstationUserField] as Map<String, dynamic>)
: null);
}
}
22 changes: 11 additions & 11 deletions lib/models/paid_leave.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ class PaidLeave {
final User user;

factory PaidLeave.fromJson(Map<String, dynamic> json) => PaidLeave(
id: json[PAID_LEAVE_ID_FIELD] as int,
title: json[PAID_LEAVE_TITLE_FIELD] as String,
category: json[PAID_LEAVE_CATEGORY_FIELD] as String,
description: json[PAID_LEAVE_DESCRIPTION_FIELD] as String,
isApproved: json[PAID_LEAVE_IS_APPROVED_FIELD] as bool,
approvalStatus: json[APPROVAL_STATUS_FIELD] as String,
startDate: DateTime.parse(json[PAID_LEAVE_START_DATE_FIELD]),
dueDate: DateTime.parse(json[PAID_LEAVE_DUE_DATE_FIELD]),
photo: json[PAID_LEAVE_PHOTO_FIELD] as String,
user: json[PAID_LEAVE_USER_FIELD] != null
? User.fromJson(json[PAID_LEAVE_USER_FIELD])
id: json[paidLeaveIdField] as int,
title: json[paidLeaveTitleField] as String,
category: json[paidLeaveCategoryField] as String,
description: json[paidLeaveDescriptionField] as String,
isApproved: json[paidLeaveIsApprovedField] as bool,
approvalStatus: json[approvalStatusField] as String,
startDate: DateTime.parse(json[paidLeaveStartDateField].toString()),
dueDate: DateTime.parse(json[paidLeaveDueDateField].toString()),
photo: json[paidLeavePhotoField] as String,
user: json[paidLeaveUserField] != null
? User.fromJson(json[paidLeaveUserField] as Map<String, dynamic>)
: null);
}
18 changes: 9 additions & 9 deletions lib/models/presence.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ class Presence {

factory Presence.fromJson(Map<String, dynamic> json) {
return Presence(
id: json[USER_ID_FIELD] as int,
date: DateTime.parse(json[PRESENCE_DATE_FIELD].toString()),
codeType: json[PRESENCE_CODE_TYPE_FIELD] as String,
status: json[PRESENCE_STATUS_FIELD] as String,
attendTime: json[PRESENCE_ATTEND_TIME_FIELD] as String,
id: json[userIdField] as int,
date: DateTime.parse(json[presenceDateField].toString()),
codeType: json[presenceCodeTypeField] as String,
status: json[presenceStatusField] as String,
attendTime: json[presenceAttendTimeField] as String,
location: Location.fromJson(
json[PRESENCE_LOCATION_FIELD] as Map<String, dynamic>),
photo: json[PRESENCE_PHOTO_FIELD] as String,
startTime: DateTime.parse(json[PRESENCE_START_TIME_FIELD].toString()),
endTime: DateTime.parse(json[PRESENCE_END_TIME_FIELD].toString()),
json[presenceLocationField] as Map<String, dynamic>),
photo: json[presencePhotoField] as String,
startTime: DateTime.parse(json[presenceStartTimeField].toString()),
endTime: DateTime.parse(json[presenceEndTimeField].toString()),
);
}
}
16 changes: 9 additions & 7 deletions lib/models/report/absent_report.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ class AbsentReport {
final int totalWorkDay;

factory AbsentReport.fromJson(Map<String, dynamic> json) => AbsentReport(
daily: (json[ABSENT_REPORT_DAILY_FIELD] as List<dynamic>)
.map((item) => Daily.fromJson(item))
daily: (json[absentReportDailyField] as List<dynamic>)
.map((item) => Daily.fromJson(item as Map<String, dynamic>))
.toList(),
monthly: Monthly.fromJson(json[ABSENT_REPORT_MONTHLY_FIELD]),
yearly: Yearly.fromJson(json[ABSENT_REPORT_YEARLY_FIELD]),
holidays: (json[ABSENT_REPORT_HOLIDAYS_FIELD] as List<dynamic>)
.map((item) => Holiday.fromJson(item))
monthly: Monthly.fromJson(
json[absentReportMonthlyField] as Map<String, dynamic>),
yearly: Yearly.fromJson(
json[absentReportYearlyField] as Map<String, dynamic>),
holidays: (json[absentReportHolidaysField] as List<dynamic>)
.map((item) => Holiday.fromJson(item as Map<String, dynamic>))
.toList(),
totalWorkDay: json[REPORT_TOTAL_WORK_DAY_FIELD] as int);
totalWorkDay: json[reportTotalWorkDayField] as int);
}
34 changes: 18 additions & 16 deletions lib/models/report/daily.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ class Daily {
final List<DailyData> attendances;

factory Daily.fromJson(Map<String, dynamic> json) {
List<dynamic> _presences = json[DAILY_PRESENCES_FIELD] as List<dynamic>;
final List<dynamic> _presences = json[dailyPresencesField] as List<dynamic>;

return Daily(
date: DateTime.parse(json[DAILY_DATE_FIELD].toString()),
date: DateTime.parse(json[dailyDateField].toString()),
attendancePercentage:
double.parse(json[REPORT_ATTENDANCE_PERCENTAGE_FIELD].toString()),
attendances: _presences.map((json) => DailyData.fromJson(json)).toList(),
double.parse(json[reportAttendancePercentageFieldField].toString()),
attendances: _presences
.map((json) => DailyData.fromJson(json as Map<String, dynamic>))
.toList(),
);
}
}
Expand All @@ -36,19 +38,19 @@ class DailyData {
final String photo;

factory DailyData.fromJson(Map<String, dynamic> json) => DailyData(
attendTime: json[DAILY_DATA_ATTEND_TIME_FIELD],
attendType: json[DAILY_DATA_ATTEND_TYPE_FIELD],
attendStatus: json[DAILY_DATA_ATTEND_STATUS_FIELD],
startTime: DateTime.parse(json[PRESENCE_START_TIME_FIELD]),
address: json[LOCATION_ADDRESS_FIELD] as String,
photo: json[PRESENCE_PHOTO_FIELD] as String);
attendTime: json[dailyDataAttendTimeField].toString(),
attendType: json[dailyDataAttendTypeField].toString(),
attendStatus: json[dailyDataAttendStatusField].toString(),
startTime: DateTime.parse(json[presenceStartTimeField].toString()),
address: json[locationAddressField] as String,
photo: json[presencePhotoField] as String);

Map<String, dynamic> toMap() => <String, dynamic>{
DAILY_DATA_ATTEND_TYPE_FIELD: this.attendType,
DAILY_DATA_ATTEND_TIME_FIELD: this.attendTime,
DAILY_DATA_ATTEND_STATUS_FIELD: this.attendStatus,
PRESENCE_START_TIME_FIELD: this.startTime.toString(),
LOCATION_ADDRESS_FIELD: this.address,
PRESENCE_PHOTO_FIELD: this.photo
dailyDataAttendTypeField: attendType,
dailyDataAttendTimeField: attendTime,
dailyDataAttendStatusField: attendStatus,
presenceStartTimeField: startTime.toString(),
locationAddressField: address,
presencePhotoField: photo
};
}
12 changes: 6 additions & 6 deletions lib/models/report/monthly.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ class Monthly {

factory Monthly.fromJson(Map<String, dynamic> json) => Monthly(
attendancePercentage:
double.parse(json[REPORT_ATTENDANCE_PERCENTAGE_FIELD].toString()),
lateCount: json[REPORT_LATE_COUNT_FIELD] as int,
leaveEarlyCount: json[REPORT_LEAVE_EARLY_COUNT_FIELD] as int,
notMorningParadeCount: json[REPORT_NOT_MORNING_PARADE_COUNT_FIELD] as int,
earlyLunchBreakCount: json[REPORT_EARLY_LUNCH_BREAK_COUNT_FIELD] as int,
double.parse(json[reportAttendancePercentageFieldField].toString()),
lateCount: json[reportLateCountField] as int,
leaveEarlyCount: json[reportLeaveEarlyFieldCountField] as int,
notMorningParadeCount: json[reportNotMorningParadeCountField] as int,
earlyLunchBreakCount: json[reportEarlyLunchBreakCountField] as int,
notComeAfterLunchBreakCount:
json[REPORT_NOT_COME_AFTER_LUNCH_BREAK_COUNT_FIELD] as int);
json[reportNotComeAfterLunchBreakCountField] as int);
}
30 changes: 14 additions & 16 deletions lib/models/report/yearly.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,24 @@ class Yearly {

factory Yearly.fromJson(Map<String, dynamic> json) {
return Yearly(
lateCount: json[REPORT_LATE_COUNT_FIELD],
lateCount: json[reportLateCountField] as int,
attendancePercentage:
double.parse(json[REPORT_ATTENDANCE_PERCENTAGE_FIELD].toString()),
absent: json[YEARLY_ABSENT_FIELD] as Map<String, dynamic>,
double.parse(json[reportAttendancePercentageFieldField].toString()),
absent: json[yearlyAbsentField] as Map<String, dynamic>,
absentPermission:
json[YEARLY_ABSENT_PERMISSION_FIELD] as Map<String, dynamic>,
outstation: json[YEARLY_OUTSTATION_FIELD] as Map<String, dynamic>,
leaveEarlyCount: json[REPORT_LEAVE_EARLY_COUNT_FIELD] as int,
notMorningParadeCount:
json[REPORT_NOT_MORNING_PARADE_COUNT_FIELD] as int,
earlyLunchBreakCount: json[REPORT_EARLY_LUNCH_BREAK_COUNT_FIELD] as int,
json[yearlyAbsentPermissionField] as Map<String, dynamic>,
outstation: json[yearlyOutstationField] as Map<String, dynamic>,
leaveEarlyCount: json[reportLeaveEarlyFieldCountField] as int,
notMorningParadeCount: json[reportNotMorningParadeCountField] as int,
earlyLunchBreakCount: json[reportEarlyLunchBreakCountField] as int,
notComeAfterLunchBreakCount:
json[REPORT_NOT_COME_AFTER_LUNCH_BREAK_COUNT_FIELD] as int,
annualLeave: json[REPORT_ANNUAL_LEAVE_FIELD] as Map<String, dynamic>,
json[reportNotComeAfterLunchBreakCountField] as int,
annualLeave: json[reportAnnualLeaveField] as Map<String, dynamic>,
importantReasonLeave:
json[REPORT_IMPORTANT_REASON_LEAVE_FIELD] as Map<String, dynamic>,
sickLeave: json[REPORT_SICK_LEAVE_FIELD] as Map<String, dynamic>,
maternityLeave:
json[REPORT_MATERNITY_LEAVE_FIELD] as Map<String, dynamic>,
json[reportImportantReasonLeaveField] as Map<String, dynamic>,
sickLeave: json[reportSickLeaveField] as Map<String, dynamic>,
maternityLeave: json[reportMaternityLeaveField] as Map<String, dynamic>,
outOfLiabilityLeave:
json[REPORT_OUT_OF_LIABILITY_LEAVE_FIELD] as Map<String, dynamic>);
json[reportOutOfLiabilityLeaveField] as Map<String, dynamic>);
}
}
Loading

0 comments on commit 9f4b3d1

Please sign in to comment.