Skip to content

Commit 60ec6c6

Browse files
authored
Merge pull request #34 from CoderJava/feature/tambahan-fitur-download-screenshot-di-halaman-preview-screenshot
Feature - Tambahkan fitur download screenshot di halaman preview screenshot
2 parents 5cbb9f6 + 6e8e223 commit 60ec6c6

File tree

8 files changed

+376
-108
lines changed

8 files changed

+376
-108
lines changed

assets/translations/en-US.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,5 +303,12 @@
303303
"description_auto_approval": "New user registration are automatically approved after submitting the registration form.",
304304
"manual_approval": "Manual Approval",
305305
"description_manual_approval": "New user registration are held in a moderation queue and require an super admin to approve them.",
306-
"please_choose_user_registration_workflow": "Please choose user registration workflow"
306+
"please_choose_user_registration_workflow": "Please choose user registration workflow",
307+
"url_screenshot_invalid": "URL screenshot invalid",
308+
"screenshot_name_invalid": "Screenshot name invalid",
309+
"download_directory_invalid": "Download directory invalid",
310+
"something_went_wrong_with_message": "Something went wrong with message {}",
311+
"screenshot_downloaded_successfully": "Screenshot downloaded successfully",
312+
"file_screenshot_doesnt_exists": "File screenshot doesn't exists",
313+
"path_file_screenshot_invalid": "Path file screenshot invalid"
307314
}

lib/core/util/widget_helper.dart

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,4 +232,46 @@ class WidgetHelper {
232232
}
233233
return false;
234234
}
235+
236+
Future<bool?> showDialogConfirmation(
237+
BuildContext context,
238+
String title,
239+
String content,
240+
List<Widget> actions,
241+
) {
242+
return showDialog<bool?>(
243+
context: context,
244+
builder: (context) {
245+
return AlertDialog(
246+
title: Text(title),
247+
content: Text(content),
248+
actions: actions,
249+
);
250+
},
251+
);
252+
}
253+
254+
Future<void> showDialogMessage(
255+
BuildContext context,
256+
String? title,
257+
String message,
258+
) {
259+
return showDialog(
260+
context: context,
261+
builder: (context) {
262+
return AlertDialog(
263+
title: Text(title ?? 'info'.tr()),
264+
content: Text(message),
265+
actions: [
266+
TextButton(
267+
onPressed: () {
268+
context.pop();
269+
},
270+
child: Text('dismiss'.tr()),
271+
),
272+
],
273+
);
274+
},
275+
);
276+
}
235277
}

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

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,18 +1206,19 @@ class _HomePageState extends State<HomePage> with TrayListener, WindowListener {
12061206
});
12071207
}
12081208

1209-
void doTakeScreenshot(DateTime? startTime, DateTime? finishTime, {bool isForceStop = false}) async {
1209+
Future<void> doTakeScreenshot(DateTime? startTime, DateTime? finishTime, {bool isForceStop = false}) async {
1210+
final selectedTaskTemp = selectedTask;
12101211
var percentActivity = 0.0;
12111212
if (counterActivity > 0 && countTimerInSeconds > 0) {
12121213
percentActivity = (counterActivity / countTimerInSeconds) * 100;
12131214
}
12141215
counterActivity = 0;
12151216

1216-
if (selectedProject == null || selectedTask == null) {
1217+
if (selectedProject == null || selectedTaskTemp == null) {
12171218
return;
12181219
}
12191220

1220-
final taskId = selectedTask?.id;
1221+
final taskId = selectedTaskTemp.id;
12211222

12221223
if (startTime == null || finishTime == null) {
12231224
return;
@@ -1281,8 +1282,12 @@ class _HomePageState extends State<HomePage> with TrayListener, WindowListener {
12811282
if (listPathStartScreenshots.isNotEmpty) {
12821283
// hapus file list path start screenshot karena tidak pakai file tersebut
12831284
// jika file screenshot-nya dapat pas di end time
1284-
final filtered =
1285-
listPathStartScreenshots.where((element) => element != null && element.isNotEmpty).map((e) => e!).toList();
1285+
final filtered = listPathStartScreenshots
1286+
.where((element) {
1287+
return element != null && element.isNotEmpty;
1288+
})
1289+
.map((e) => e!)
1290+
.toList();
12861291
for (final element in filtered) {
12871292
final file = File(element);
12881293
if (file.existsSync()) {
@@ -1346,14 +1351,14 @@ class _HomePageState extends State<HomePage> with TrayListener, WindowListener {
13461351

13471352
final trackEntity = Track(
13481353
userId: userId,
1349-
taskId: taskId!,
1354+
taskId: taskId,
13501355
startDate: formattedStartDateTime,
13511356
finishDate: formattedFinishDateTime,
13521357
activity: activity,
13531358
files: files,
13541359
duration: durationInSeconds,
13551360
projectName: selectedProject?.name ?? '',
1356-
taskName: selectedTask?.name ?? '',
1361+
taskName: selectedTaskTemp.name,
13571362
);
13581363
final trackEntityId = await trackDao.insertTrack(trackEntity);
13591364

0 commit comments

Comments
 (0)