Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature - Tambahkan fitur download screenshot di halaman preview screenshot #34

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion assets/translations/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -303,5 +303,12 @@
"description_auto_approval": "New user registration are automatically approved after submitting the registration form.",
"manual_approval": "Manual Approval",
"description_manual_approval": "New user registration are held in a moderation queue and require an super admin to approve them.",
"please_choose_user_registration_workflow": "Please choose user registration workflow"
"please_choose_user_registration_workflow": "Please choose user registration workflow",
"url_screenshot_invalid": "URL screenshot invalid",
"screenshot_name_invalid": "Screenshot name invalid",
"download_directory_invalid": "Download directory invalid",
"something_went_wrong_with_message": "Something went wrong with message {}",
"screenshot_downloaded_successfully": "Screenshot downloaded successfully",
"file_screenshot_doesnt_exists": "File screenshot doesn't exists",
"path_file_screenshot_invalid": "Path file screenshot invalid"
}
42 changes: 42 additions & 0 deletions lib/core/util/widget_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -232,4 +232,46 @@ class WidgetHelper {
}
return false;
}

Future<bool?> showDialogConfirmation(
BuildContext context,
String title,
String content,
List<Widget> actions,
) {
return showDialog<bool?>(
context: context,
builder: (context) {
return AlertDialog(
title: Text(title),
content: Text(content),
actions: actions,
);
},
);
}

Future<void> showDialogMessage(
BuildContext context,
String? title,
String message,
) {
return showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text(title ?? 'info'.tr()),
content: Text(message),
actions: [
TextButton(
onPressed: () {
context.pop();
},
child: Text('dismiss'.tr()),
),
],
);
},
);
}
}
19 changes: 12 additions & 7 deletions lib/feature/presentation/page/home/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1206,18 +1206,19 @@ class _HomePageState extends State<HomePage> with TrayListener, WindowListener {
});
}

void doTakeScreenshot(DateTime? startTime, DateTime? finishTime, {bool isForceStop = false}) async {
Future<void> doTakeScreenshot(DateTime? startTime, DateTime? finishTime, {bool isForceStop = false}) async {
final selectedTaskTemp = selectedTask;
var percentActivity = 0.0;
if (counterActivity > 0 && countTimerInSeconds > 0) {
percentActivity = (counterActivity / countTimerInSeconds) * 100;
}
counterActivity = 0;

if (selectedProject == null || selectedTask == null) {
if (selectedProject == null || selectedTaskTemp == null) {
return;
}

final taskId = selectedTask?.id;
final taskId = selectedTaskTemp.id;

if (startTime == null || finishTime == null) {
return;
Expand Down Expand Up @@ -1281,8 +1282,12 @@ class _HomePageState extends State<HomePage> with TrayListener, WindowListener {
if (listPathStartScreenshots.isNotEmpty) {
// hapus file list path start screenshot karena tidak pakai file tersebut
// jika file screenshot-nya dapat pas di end time
final filtered =
listPathStartScreenshots.where((element) => element != null && element.isNotEmpty).map((e) => e!).toList();
final filtered = listPathStartScreenshots
.where((element) {
return element != null && element.isNotEmpty;
})
.map((e) => e!)
.toList();
for (final element in filtered) {
final file = File(element);
if (file.existsSync()) {
Expand Down Expand Up @@ -1346,14 +1351,14 @@ class _HomePageState extends State<HomePage> with TrayListener, WindowListener {

final trackEntity = Track(
userId: userId,
taskId: taskId!,
taskId: taskId,
startDate: formattedStartDateTime,
finishDate: formattedFinishDateTime,
activity: activity,
files: files,
duration: durationInSeconds,
projectName: selectedProject?.name ?? '',
taskName: selectedTask?.name ?? '',
taskName: selectedTaskTemp.name,
);
final trackEntityId = await trackDao.insertTrack(trackEntity);

Expand Down
Loading