From b644f11db4113341684bd406808b6e0b6c962ad8 Mon Sep 17 00:00:00 2001 From: CoderJava Date: Fri, 6 Oct 2023 22:19:28 +0700 Subject: [PATCH 1/4] feat: Update podfile.lock --- macos/Podfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/macos/Podfile.lock b/macos/Podfile.lock index b6968ce..484b54c 100644 --- a/macos/Podfile.lock +++ b/macos/Podfile.lock @@ -90,6 +90,6 @@ SPEC CHECKSUMS: tray_manager: 9064e219c56d75c476e46b9a21182087930baf90 window_manager: 3a1844359a6295ab1e47659b1a777e36773cd6e8 -PODFILE CHECKSUM: 7b8886a4ad89b3a2f7a16642e81ab6bed5c5d3ac +PODFILE CHECKSUM: 8d40c19d3cbdb380d870685c3a564c989f1efa52 COCOAPODS: 1.13.0 From 89e1078c342e2209463e84f56172f87a4a918878 Mon Sep 17 00:00:00 2001 From: CoderJava Date: Fri, 6 Oct 2023 22:19:55 +0700 Subject: [PATCH 2/4] feat: Reset timer di tray manager setelah user logout --- lib/feature/presentation/page/setting/setting_page.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/feature/presentation/page/setting/setting_page.dart b/lib/feature/presentation/page/setting/setting_page.dart index 9c23be5..71501d7 100644 --- a/lib/feature/presentation/page/setting/setting_page.dart +++ b/lib/feature/presentation/page/setting/setting_page.dart @@ -1032,6 +1032,7 @@ class _SettingPageState extends State { if (isLogout != null && mounted) { await helper.setLogout(); if (mounted) { + trayManager.setTitle('--:--:--'); context.goNamed(SplashPage.routeName); } } From eb10fd98848512053540a029fc422b7d3e811cb3 Mon Sep 17 00:00:00 2001 From: CoderJava Date: Fri, 6 Oct 2023 22:20:55 +0700 Subject: [PATCH 3/4] feat: Tampilkan dialog peringatan jika si user logout dalam kondisi timer-nya sedang jalan Cegah si user agar tidak bisa logout jika kondisi timer-nya sedang jalan. --- .../presentation/page/home/home_page.dart | 32 +++++++++---------- .../page/setting/setting_page.dart | 20 ++++++++++++ 2 files changed, 36 insertions(+), 16 deletions(-) diff --git a/lib/feature/presentation/page/home/home_page.dart b/lib/feature/presentation/page/home/home_page.dart index 89170e6..ba87022 100644 --- a/lib/feature/presentation/page/home/home_page.dart +++ b/lib/feature/presentation/page/home/home_page.dart @@ -45,6 +45,7 @@ import 'package:tray_manager/tray_manager.dart'; import 'package:window_manager/window_manager.dart'; var countTimeReminderTrackInSeconds = 0; +var isGlobalTimerStart = false; class HomePage extends StatefulWidget { static const routePath = '/home'; @@ -83,7 +84,6 @@ class _HomePageState extends State with TrayListener, WindowListener { var isWindowVisible = true; var userId = ''; var email = ''; - var isTimerStart = false; var isTimerStartTemp = false; TrackUserLiteResponse? trackUserLite; ItemProjectResponse? selectedProject; @@ -147,7 +147,7 @@ class _HomePageState extends State with TrayListener, WindowListener { now.day, ); timerDate = Timer.periodic(const Duration(seconds: 1), (_) { - if (!isTimerStart) { + if (!isGlobalTimerStart) { // reminder track var isShowReminderTrack = false; final now = DateTime.now(); @@ -533,7 +533,7 @@ class _HomePageState extends State with TrayListener, WindowListener { final firstTask = filteredTask.first; startTime = DateTime.now(); selectedTask = firstTask; - isTimerStart = true; + isGlobalTimerStart = true; setTrayContextMenu(); valueNotifierTaskTracked.value = firstTask.trackedInSeconds; resetCountTimer(); @@ -666,7 +666,7 @@ class _HomePageState extends State with TrayListener, WindowListener { } startTime = DateTime.now(); selectedTask = itemTask; - isTimerStart = true; + isGlobalTimerStart = true; setTrayContextMenu(); valueNotifierTaskTracked.value = itemTask.trackedInSeconds; resetCountTimer(); @@ -733,7 +733,7 @@ class _HomePageState extends State with TrayListener, WindowListener { } void stopTimerFromButton(TrackTask itemTask) { - isTimerStart = false; + isGlobalTimerStart = false; setTrayContextMenu(); itemTask.trackedInSeconds = valueNotifierTaskTracked.value; stopTimer(); @@ -747,7 +747,7 @@ class _HomePageState extends State with TrayListener, WindowListener { borderRadius: BorderRadius.circular(8), child: InkWell( borderRadius: BorderRadius.circular(8), - onTap: isTimerStart || isTimerStartTemp + onTap: isGlobalTimerStart || isTimerStartTemp ? null : () async { final selectedProjectTemp = await showModalBottomSheet( @@ -806,7 +806,7 @@ class _HomePageState extends State with TrayListener, WindowListener { height: 8, decoration: BoxDecoration( shape: BoxShape.circle, - color: isTimerStart || isTimerStartTemp ? Colors.green : Colors.grey, + color: isGlobalTimerStart || isTimerStartTemp ? Colors.green : Colors.grey, ), ), const SizedBox(width: 4), @@ -822,7 +822,7 @@ class _HomePageState extends State with TrayListener, WindowListener { ), ), const SizedBox(width: 16), - isTimerStart || isTimerStartTemp + isGlobalTimerStart || isTimerStartTemp ? Container() : const Icon( Icons.keyboard_arrow_down, @@ -995,7 +995,7 @@ class _HomePageState extends State with TrayListener, WindowListener { void setTrayContextMenu() { final items = []; if (listTrackTask.isNotEmpty) { - if (!isTimerStart) { + if (!isGlobalTimerStart) { items.add( MenuItem( key: keyTrayStartWorking, @@ -1096,7 +1096,7 @@ class _HomePageState extends State with TrayListener, WindowListener { final task = listTrackTask.first; startTime = DateTime.now(); selectedTask = task; - isTimerStart = true; + isGlobalTimerStart = true; setTrayContextMenu(); valueNotifierTaskTracked.value = task.trackedInSeconds; resetCountTimer(); @@ -1107,7 +1107,7 @@ class _HomePageState extends State with TrayListener, WindowListener { final task = filteredTask.first; startTime = DateTime.now(); selectedTask = task; - isTimerStart = true; + isGlobalTimerStart = true; setTrayContextMenu(); valueNotifierTaskTracked.value = task.trackedInSeconds; resetCountTimer(); @@ -1117,7 +1117,7 @@ class _HomePageState extends State with TrayListener, WindowListener { } void stopTimerFromSystemTray() { - isTimerStart = false; + isGlobalTimerStart = false; setTrayContextMenu(); selectedTask?.trackedInSeconds = valueNotifierTaskTracked.value; stopTimer(); @@ -1158,8 +1158,8 @@ class _HomePageState extends State with TrayListener, WindowListener { isHaveActivity = true; } else if (strEvent == 'screen_is_locked') { // auto stop timer dan ambil screenshot-nya - if (isTimerStart) { - isTimerStart = false; + if (isGlobalTimerStart) { + isGlobalTimerStart = false; setTrayContextMenu(); stopTimer(); finishTime = DateTime.now(); @@ -1271,7 +1271,7 @@ class _HomePageState extends State with TrayListener, WindowListener { // stop timer-nya jika permission screen recording-nya tidak diallow-kan atau // gagal ambil screenshot-nya di end time stopTimer(); - isTimerStart = false; + isGlobalTimerStart = false; setTrayContextMenu(); selectedTask = null; setState(() {}); @@ -1294,7 +1294,7 @@ class _HomePageState extends State with TrayListener, WindowListener { // stop timer-nya jika isForceStop bernilai true listPathScreenshots.clear(); stopTimer(); - isTimerStart = false; + isGlobalTimerStart = false; setTrayContextMenu(); selectedTask = null; setState(() {}); diff --git a/lib/feature/presentation/page/setting/setting_page.dart b/lib/feature/presentation/page/setting/setting_page.dart index 71501d7..185a2ab 100644 --- a/lib/feature/presentation/page/setting/setting_page.dart +++ b/lib/feature/presentation/page/setting/setting_page.dart @@ -27,6 +27,7 @@ import 'package:flutter/scheduler.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:go_router/go_router.dart'; import 'package:launch_at_startup/launch_at_startup.dart'; +import 'package:tray_manager/tray_manager.dart'; import 'package:window_manager/window_manager.dart'; class SettingPage extends StatefulWidget { @@ -1002,6 +1003,25 @@ class _SettingPageState extends State { } Future doLogout() async { + if (isGlobalTimerStart) { + showDialog( + context: context, + builder: (context) { + return AlertDialog( + title: Text('warning'.tr()), + content: Text('please_stop_the_timer_if_you_want_to_logout'.tr()), + actions: [ + TextButton( + onPressed: () => context.pop(), + child: Text('dismiss'.tr()), + ), + ], + ); + }, + ); + return; + } + final isLogout = await showDialog( context: context, builder: (context) { From 2bb29c3d37d4de02b60ed3f77881d037d600eae1 Mon Sep 17 00:00:00 2001 From: CoderJava Date: Fri, 6 Oct 2023 22:21:11 +0700 Subject: [PATCH 4/4] feat: Update localization bahasa English --- assets/translations/en-US.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/assets/translations/en-US.json b/assets/translations/en-US.json index a794d2c..d69e192 100644 --- a/assets/translations/en-US.json +++ b/assets/translations/en-US.json @@ -293,5 +293,6 @@ "please_set_finish_date": "Please set finish date", "finish_date_time_must_be_after_of_start_date_time": "The finish date time must be after the start date time", "reason": "Reason", - "why_are_you_adding_manual_track": "e.g. Forgot to start timer" + "why_are_you_adding_manual_track": "e.g. Forgot to start timer", + "please_stop_the_timer_if_you_want_to_logout": "Please stop the timer if you want to logout." } \ No newline at end of file