Skip to content

Commit b29e99a

Browse files
committed
Buat fitur reminder not track
By default, reminder-nya akan tampil per 10 menit jika si user lupa jalankan timer-nya. Untuk saat ini belum ada pengaturannya.
1 parent a287cb6 commit b29e99a

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

lib/core/util/notification_helper.dart

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,19 @@ class NotificationHelper {
3030
),
3131
);
3232
}
33+
34+
void showReminderNotTrackNotification() {
35+
localNotification?.show(
36+
DateTime.now().millisecond,
37+
'app_name'.tr(),
38+
'reminder_not_tracking_time'.tr(),
39+
const NotificationDetails(
40+
macOS: DarwinNotificationDetails(
41+
presentAlert: true,
42+
presentSound: true,
43+
sound: 'hasta_la_vista.aiff',
44+
),
45+
),
46+
);
47+
}
3348
}

lib/feature/presentation/page/home/home_page.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ class _HomePageState extends State<HomePage> with TrayListener, WindowListener {
6565
final notificationHelper = sl<NotificationHelper>();
6666
final intervalScreenshot = 60 * 5; // 300 detik (5 menit)
6767
final listTrackLocal = <Track>[];
68+
final intervalReminderNotTrack = 60 * 10; // 600 detik (10 menit)
6869

6970
var isWindowVisible = true;
7071
var userId = '';
@@ -75,6 +76,7 @@ class _HomePageState extends State<HomePage> with TrayListener, WindowListener {
7576
TrackTask? selectedTask;
7677
Timer? timeTrack, timerCronTrack, timerDate;
7778
var countTimerInSeconds = 0;
79+
var countTimerReminderNotTrack = 0;
7880
var isHaveActivity = false;
7981
var counterActivity = 0;
8082
DateTime? startTime;
@@ -124,6 +126,14 @@ class _HomePageState extends State<HomePage> with TrayListener, WindowListener {
124126
now.day,
125127
);
126128
timerDate = Timer.periodic(const Duration(seconds: 1), (_) {
129+
if (!isTimerStart) {
130+
countTimerReminderNotTrack += 1;
131+
if (countTimerReminderNotTrack == intervalReminderNotTrack) {
132+
countTimerReminderNotTrack = 0;
133+
notificationHelper.showReminderNotTrackNotification();
134+
}
135+
}
136+
127137
final now = DateTime.now();
128138
final dateTimeNow = DateTime(
129139
now.year,
@@ -1016,13 +1026,15 @@ class _HomePageState extends State<HomePage> with TrayListener, WindowListener {
10161026
}
10171027

10181028
void startTimer() {
1029+
countTimerReminderNotTrack = 0;
10191030
stopTimer();
10201031
timeTrack = Timer.periodic(const Duration(seconds: 1), (_) {
10211032
increaseTimerTray();
10221033
});
10231034
}
10241035

10251036
void stopTimer() {
1037+
countTimerReminderNotTrack = 0;
10261038
if (timeTrack != null && timeTrack!.isActive) {
10271039
timeTrack!.cancel();
10281040
}

0 commit comments

Comments
 (0)