@@ -493,6 +493,13 @@ class _HomePageState extends State<HomePage> with TrayListener, WindowListener {
493493
494494 return InkWell (
495495 onTap: () async {
496+ final isPermissionScreenRecordingGranted =
497+ await platformChannelHelper.checkPermissionScreenRecording ();
498+ if (mounted && isPermissionScreenRecordingGranted != null && ! isPermissionScreenRecordingGranted) {
499+ widgetHelper.showDialogPermissionScreenRecording (context);
500+ return ;
501+ }
502+
496503 if (selectedTask != itemTask) {
497504 if (selectedTask != null ) {
498505 selectedTask! .trackedInSeconds = valueNotifierTotalTracked.value;
@@ -956,7 +963,19 @@ class _HomePageState extends State<HomePage> with TrayListener, WindowListener {
956963 final activity = percentActivity.round ();
957964
958965 final listPathScreenshots = await platformChannelHelper.doTakeScreenshot ();
959- if (listPathScreenshots.isEmpty) {
966+ final isPermissionScreenRecordingGranted =
967+ await platformChannelHelper.checkPermissionScreenRecording ();
968+ if (isPermissionScreenRecordingGranted != null && ! isPermissionScreenRecordingGranted) {
969+ debugPrint ('screen recording not granted' );
970+ notificationHelper.showPermissionScreenRecordingIssuedNotification ();
971+ valueNotifierTotalTracked.value -= durationInSeconds;
972+ valueNotifierTaskTracked.value -= durationInSeconds;
973+ isTimerStart = false ;
974+ stopTimer ();
975+ selectedTask = null ;
976+ setState (() {});
977+ return ;
978+ } else if (listPathScreenshots.isEmpty) {
960979 debugPrint ('list path screenshots is empty' );
961980 valueNotifierTotalTracked.value -= durationInSeconds;
962981 valueNotifierTaskTracked.value -= durationInSeconds;
@@ -1077,17 +1096,17 @@ class _HomePageState extends State<HomePage> with TrayListener, WindowListener {
10771096
10781097 void checkAssetAudio () async {
10791098 // Copy file audio dari aset ke /Library/Sounds [macOS]
1080- final bytes = await rootBundle.load ('assets/audio/hasta_la_vista.aiff' );
1099+ final bytesHastaLaVista = await rootBundle.load ('assets/audio/hasta_la_vista.aiff' );
10811100 final libraryDirectory = await getLibraryDirectory ();
10821101 final directory = Directory ('${libraryDirectory .path }/sounds' );
10831102 final pathDirectory = directory.path;
1084- final buffer = bytes .buffer;
1103+ final bufferHastaLaVista = bytesHastaLaVista .buffer;
10851104 final fileAudioReminderNotTrack = File ('$pathDirectory /hasta_la_vista.aiff' );
10861105 if (! fileAudioReminderNotTrack.existsSync ()) {
10871106 fileAudioReminderNotTrack.writeAsBytes (
1088- buffer .asUint8List (
1089- bytes .offsetInBytes,
1090- buffer .lengthInBytes,
1107+ bufferHastaLaVista .asUint8List (
1108+ bytesHastaLaVista .offsetInBytes,
1109+ bufferHastaLaVista .lengthInBytes,
10911110 ),
10921111 );
10931112 }
0 commit comments