Skip to content
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
3 changes: 2 additions & 1 deletion assets/translations/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -227,5 +227,6 @@
"alias_minutes": "minutes",
"n_minute": "{} minutes",
"choose": "Choose",
"finish_time_must_be_after_start_time": "Finish time must be after start time"
"finish_time_must_be_after_start_time": "Finish time must be after start time",
"play_sound": "Play sound"
}
11 changes: 9 additions & 2 deletions lib/core/util/notification_helper.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'package:dipantau_desktop_client/core/util/enum/global_variable.dart';
import 'package:dipantau_desktop_client/core/util/shared_preferences_manager.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';

Expand All @@ -18,14 +20,19 @@ class NotificationHelper {
}

void showScreenshotTakenNotification() {
final presentSound = sharedPreferencesManager.getBool(
SharedPreferencesManager.keyIsEnableSoundScreenshotNotification,
defaultValue: true,
) ??
true;
localNotification?.show(
DateTime.now().millisecond,
'app_name'.tr(),
'screenshot_taken'.tr(),
const NotificationDetails(
NotificationDetails(
macOS: DarwinNotificationDetails(
presentAlert: true,
presentSound: true,
presentSound: presentSound,
),
),
);
Expand Down
1 change: 1 addition & 0 deletions lib/core/util/shared_preferences_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class SharedPreferencesManager {
static const keyFinishTimeReminderTrack = 'finish_time_reminder_track';
static const keyDayReminderTrack = 'day_reminder_track';
static const keyIntervalReminderTrack = 'interval_reminder_track';
static const keyIsEnableSoundScreenshotNotification = 'is_enable_sound_screenshot_notification';

SharedPreferencesManager();

Expand Down
3 changes: 3 additions & 0 deletions lib/feature/presentation/page/home/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ class _HomePageState extends State<HomePage> with TrayListener, WindowListener {
if (!sharedPreferencesManager.isKeyExists(SharedPreferencesManager.keyIsEnableScreenshotNotification)) {
sharedPreferencesManager.putBool(SharedPreferencesManager.keyIsEnableScreenshotNotification, true);
}
if (!sharedPreferencesManager.isKeyExists(SharedPreferencesManager.keyIsEnableSoundScreenshotNotification)) {
sharedPreferencesManager.putBool(SharedPreferencesManager.keyIsEnableSoundScreenshotNotification, true);
}
initDefaultSelectedProject();
setupWindow();
setupTray();
Expand Down
35 changes: 35 additions & 0 deletions lib/feature/presentation/page/setting/setting_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class _SettingPageState extends State<SettingPage> {
final navigationRailDestinations = <NavigationRailDestination>[];
final sharedPreferencesManager = sl<SharedPreferencesManager>();
final valueNotifierIsEnableScreenshotNotification = ValueNotifier(false);
final valueNotifierIsEnableSoundScreenshotNotification = ValueNotifier(true);
final valueNotifierAppearanceMode = ValueNotifier(AppearanceMode.light);
final valueNotifierLaunchAtStartup = ValueNotifier(true);
final valueNotifierAlwaysOnTop = ValueNotifier(true);
Expand Down Expand Up @@ -258,6 +259,7 @@ class _SettingPageState extends State<SettingPage> {
),
children: [
buildWidgetScreenshotNotification(),
buildWidgetPlaySoundScreenshotNotification(),
const SizedBox(height: 16),
buildWidgetReminderNotTrackNotification(),
const SizedBox(height: 8),
Expand Down Expand Up @@ -686,6 +688,8 @@ class _SettingPageState extends State<SettingPage> {
void prepareData() {
valueNotifierIsEnableScreenshotNotification.value =
sharedPreferencesManager.getBool(SharedPreferencesManager.keyIsEnableScreenshotNotification) ?? false;
valueNotifierIsEnableSoundScreenshotNotification.value =
sharedPreferencesManager.getBool(SharedPreferencesManager.keyIsEnableSoundScreenshotNotification) ?? false;
valueNotifierAlwaysOnTop.value =
sharedPreferencesManager.getBool(SharedPreferencesManager.keyIsAlwaysOnTop, defaultValue: true) ?? true;

Expand Down Expand Up @@ -1072,6 +1076,37 @@ class _SettingPageState extends State<SettingPage> {
);
}

Widget buildWidgetPlaySoundScreenshotNotification() {
return Row(
children: [
SizedBox(
width: 24,
child: ValueListenableBuilder(
valueListenable: valueNotifierIsEnableSoundScreenshotNotification,
builder: (BuildContext context, bool isEnable, _) {
return Checkbox(
value: isEnable,
onChanged: (newValue) {
if (newValue != null) {
valueNotifierIsEnableSoundScreenshotNotification.value = newValue;
sharedPreferencesManager.putBool(
SharedPreferencesManager.keyIsEnableSoundScreenshotNotification,
newValue,
);
}
},
);
},
),
),
const SizedBox(width: 4),
Text(
'play_sound'.tr(),
),
],
);
}

Widget buildWidgetMember() {
return Row(
crossAxisAlignment: CrossAxisAlignment.start,
Expand Down