mirror of
https://gitlab.com/veilid/veilidchat.git
synced 2025-07-24 15:05:22 -04:00
Accessibility update
This commit is contained in:
parent
be8014c97a
commit
3b1cb53b8a
55 changed files with 1089 additions and 807 deletions
|
@ -1,24 +1,13 @@
|
|||
import 'package:awesome_extensions/awesome_extensions.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_form_builder/flutter_form_builder.dart';
|
||||
import 'package:flutter_translate/flutter_translate.dart';
|
||||
|
||||
import '../../settings/settings.dart';
|
||||
import '../../theme/theme.dart';
|
||||
import '../notifications.dart';
|
||||
|
||||
const String formFieldDisplayBetaWarning = 'displayBetaWarning';
|
||||
const String formFieldEnableBadge = 'enableBadge';
|
||||
const String formFieldEnableNotifications = 'enableNotifications';
|
||||
const String formFieldMessageNotificationContent = 'messageNotificationContent';
|
||||
const String formFieldInvitationAcceptMode = 'invitationAcceptMode';
|
||||
const String formFieldInvitationAcceptSound = 'invitationAcceptSound';
|
||||
const String formFieldMessageReceivedMode = 'messageReceivedMode';
|
||||
const String formFieldMessageReceivedSound = 'messageReceivedSound';
|
||||
const String formFieldMessageSentSound = 'messageSentSound';
|
||||
|
||||
Widget buildSettingsPageNotificationPreferences(
|
||||
{required BuildContext context, required void Function() onChanged}) {
|
||||
{required BuildContext context}) {
|
||||
final theme = Theme.of(context);
|
||||
final scale = theme.extension<ScaleScheme>()!;
|
||||
final scaleConfig = theme.extension<ScaleConfig>()!;
|
||||
|
@ -33,7 +22,6 @@ Widget buildSettingsPageNotificationPreferences(
|
|||
final newPrefs = preferencesRepository.value
|
||||
.copyWith(notificationsPreference: newNotificationsPreference);
|
||||
await preferencesRepository.set(newPrefs);
|
||||
onChanged();
|
||||
}
|
||||
|
||||
List<DropdownMenuItem<NotificationMode>> notificationModeItems() {
|
||||
|
@ -54,9 +42,10 @@ Widget buildSettingsPageNotificationPreferences(
|
|||
enabled: x.$2,
|
||||
child: Text(
|
||||
x.$3,
|
||||
style: textTheme.labelSmall,
|
||||
softWrap: false,
|
||||
style: textTheme.labelMedium,
|
||||
textAlign: TextAlign.center,
|
||||
)));
|
||||
).fit(fit: BoxFit.scaleDown)));
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
@ -77,7 +66,8 @@ Widget buildSettingsPageNotificationPreferences(
|
|||
enabled: x.$2,
|
||||
child: Text(
|
||||
x.$3,
|
||||
style: textTheme.labelSmall,
|
||||
softWrap: false,
|
||||
style: textTheme.labelMedium,
|
||||
textAlign: TextAlign.center,
|
||||
)));
|
||||
}
|
||||
|
@ -110,7 +100,8 @@ Widget buildSettingsPageNotificationPreferences(
|
|||
enabled: x.$2,
|
||||
child: Text(
|
||||
x.$3,
|
||||
style: textTheme.labelSmall,
|
||||
softWrap: false,
|
||||
style: textTheme.labelMedium,
|
||||
textAlign: TextAlign.center,
|
||||
)));
|
||||
}
|
||||
|
@ -127,66 +118,45 @@ Widget buildSettingsPageNotificationPreferences(
|
|||
),
|
||||
child: Column(mainAxisSize: MainAxisSize.min, children: [
|
||||
// Display Beta Warning
|
||||
FormBuilderCheckbox(
|
||||
name: formFieldDisplayBetaWarning,
|
||||
title: Text(translate('settings_page.display_beta_warning'),
|
||||
style: textTheme.labelMedium),
|
||||
initialValue: notificationsPreference.displayBetaWarning,
|
||||
StyledCheckbox(
|
||||
label: translate('settings_page.display_beta_warning'),
|
||||
value: notificationsPreference.displayBetaWarning,
|
||||
onChanged: (value) async {
|
||||
if (value == null) {
|
||||
return;
|
||||
}
|
||||
final newNotificationsPreference =
|
||||
notificationsPreference.copyWith(displayBetaWarning: value);
|
||||
|
||||
await updatePreferences(newNotificationsPreference);
|
||||
}),
|
||||
// Enable Badge
|
||||
FormBuilderCheckbox(
|
||||
name: formFieldEnableBadge,
|
||||
title: Text(translate('settings_page.enable_badge'),
|
||||
style: textTheme.labelMedium),
|
||||
initialValue: notificationsPreference.enableBadge,
|
||||
StyledCheckbox(
|
||||
label: translate('settings_page.enable_badge'),
|
||||
value: notificationsPreference.enableBadge,
|
||||
onChanged: (value) async {
|
||||
if (value == null) {
|
||||
return;
|
||||
}
|
||||
final newNotificationsPreference =
|
||||
notificationsPreference.copyWith(enableBadge: value);
|
||||
await updatePreferences(newNotificationsPreference);
|
||||
}),
|
||||
// Enable Notifications
|
||||
FormBuilderCheckbox(
|
||||
name: formFieldEnableNotifications,
|
||||
title: Text(translate('settings_page.enable_notifications'),
|
||||
style: textTheme.labelMedium),
|
||||
initialValue: notificationsPreference.enableNotifications,
|
||||
StyledCheckbox(
|
||||
label: translate('settings_page.enable_notifications'),
|
||||
value: notificationsPreference.enableNotifications,
|
||||
onChanged: (value) async {
|
||||
if (value == null) {
|
||||
return;
|
||||
}
|
||||
final newNotificationsPreference =
|
||||
notificationsPreference.copyWith(enableNotifications: value);
|
||||
await updatePreferences(newNotificationsPreference);
|
||||
}),
|
||||
|
||||
FormBuilderDropdown(
|
||||
name: formFieldMessageNotificationContent,
|
||||
isDense: false,
|
||||
decoration: InputDecoration(
|
||||
labelText: translate('settings_page.message_notification_content')),
|
||||
enabled: notificationsPreference.enableNotifications,
|
||||
initialValue: notificationsPreference.messageNotificationContent,
|
||||
onChanged: (value) async {
|
||||
if (value == null) {
|
||||
return;
|
||||
}
|
||||
final newNotificationsPreference = notificationsPreference.copyWith(
|
||||
messageNotificationContent: value);
|
||||
await updatePreferences(newNotificationsPreference);
|
||||
},
|
||||
StyledDropdown<MessageNotificationContent>(
|
||||
items: messageNotificationContentItems(),
|
||||
).paddingLTRB(0, 4, 0, 4),
|
||||
value: notificationsPreference.messageNotificationContent,
|
||||
decoratorLabel: translate('settings_page.message_notification_content'),
|
||||
onChanged: !notificationsPreference.enableNotifications
|
||||
? null
|
||||
: (value) async {
|
||||
final newNotificationsPreference = notificationsPreference
|
||||
.copyWith(messageNotificationContent: value);
|
||||
await updatePreferences(newNotificationsPreference);
|
||||
},
|
||||
).paddingLTRB(0, 4.scaled(context), 0, 4.scaled(context)),
|
||||
|
||||
// Notifications
|
||||
Table(
|
||||
|
@ -199,95 +169,85 @@ Widget buildSettingsPageNotificationPreferences(
|
|||
color: scale.primaryScale.border,
|
||||
decorationColor: scale.primaryScale.border,
|
||||
decoration: TextDecoration.underline))
|
||||
.paddingAll(8),
|
||||
.paddingAll(8.scaled(context)),
|
||||
Text(translate('settings_page.delivery'),
|
||||
textAlign: TextAlign.center,
|
||||
style: textTheme.titleMedium!.copyWith(
|
||||
color: scale.primaryScale.border,
|
||||
decorationColor: scale.primaryScale.border,
|
||||
decoration: TextDecoration.underline))
|
||||
.paddingAll(8),
|
||||
.paddingAll(8.scaled(context)),
|
||||
Text(translate('settings_page.sound'),
|
||||
textAlign: TextAlign.center,
|
||||
style: textTheme.titleMedium!.copyWith(
|
||||
color: scale.primaryScale.border,
|
||||
decorationColor: scale.primaryScale.border,
|
||||
decoration: TextDecoration.underline))
|
||||
.paddingAll(8),
|
||||
.paddingAll(8.scaled(context)),
|
||||
]),
|
||||
TableRow(children: [
|
||||
// Invitation accepted
|
||||
Text(
|
||||
textAlign: TextAlign.right,
|
||||
translate('settings_page.invitation_accepted'))
|
||||
.paddingAll(8),
|
||||
FormBuilderDropdown(
|
||||
name: formFieldInvitationAcceptMode,
|
||||
isDense: false,
|
||||
enabled: notificationsPreference.enableNotifications,
|
||||
initialValue: notificationsPreference.onInvitationAcceptedMode,
|
||||
onChanged: (value) async {
|
||||
if (value == null) {
|
||||
return;
|
||||
}
|
||||
final newNotificationsPreference = notificationsPreference
|
||||
.copyWith(onInvitationAcceptedMode: value);
|
||||
await updatePreferences(newNotificationsPreference);
|
||||
},
|
||||
.paddingAll(4.scaled(context)),
|
||||
StyledDropdown<NotificationMode>(
|
||||
items: notificationModeItems(),
|
||||
).paddingAll(4),
|
||||
FormBuilderDropdown(
|
||||
name: formFieldInvitationAcceptSound,
|
||||
isDense: false,
|
||||
enabled: notificationsPreference.enableNotifications,
|
||||
initialValue: notificationsPreference.onInvitationAcceptedSound,
|
||||
onChanged: (value) async {
|
||||
if (value == null) {
|
||||
return;
|
||||
}
|
||||
final newNotificationsPreference = notificationsPreference
|
||||
.copyWith(onInvitationAcceptedSound: value);
|
||||
await updatePreferences(newNotificationsPreference);
|
||||
},
|
||||
value: notificationsPreference.onInvitationAcceptedMode,
|
||||
onChanged: !notificationsPreference.enableNotifications
|
||||
? null
|
||||
: (value) async {
|
||||
final newNotificationsPreference =
|
||||
notificationsPreference.copyWith(
|
||||
onInvitationAcceptedMode: value);
|
||||
await updatePreferences(newNotificationsPreference);
|
||||
},
|
||||
).paddingAll(4.scaled(context)),
|
||||
StyledDropdown<SoundEffect>(
|
||||
items: soundEffectItems(),
|
||||
).paddingLTRB(4, 4, 0, 4)
|
||||
value: notificationsPreference.onInvitationAcceptedSound,
|
||||
onChanged: !notificationsPreference.enableNotifications
|
||||
? null
|
||||
: (value) async {
|
||||
final newNotificationsPreference =
|
||||
notificationsPreference.copyWith(
|
||||
onInvitationAcceptedSound: value);
|
||||
await updatePreferences(newNotificationsPreference);
|
||||
},
|
||||
).paddingLTRB(
|
||||
4.scaled(context), 4.scaled(context), 0, 4.scaled(context))
|
||||
]),
|
||||
// Message received
|
||||
TableRow(children: [
|
||||
Text(
|
||||
textAlign: TextAlign.right,
|
||||
translate('settings_page.message_received'))
|
||||
.paddingAll(8),
|
||||
FormBuilderDropdown(
|
||||
name: formFieldMessageReceivedMode,
|
||||
isDense: false,
|
||||
enabled: notificationsPreference.enableNotifications,
|
||||
initialValue: notificationsPreference.onMessageReceivedMode,
|
||||
onChanged: (value) async {
|
||||
if (value == null) {
|
||||
return;
|
||||
}
|
||||
final newNotificationsPreference = notificationsPreference
|
||||
.copyWith(onMessageReceivedMode: value);
|
||||
await updatePreferences(newNotificationsPreference);
|
||||
},
|
||||
.paddingAll(4.scaled(context)),
|
||||
StyledDropdown<NotificationMode>(
|
||||
items: notificationModeItems(),
|
||||
value: notificationsPreference.onMessageReceivedMode,
|
||||
onChanged: !notificationsPreference.enableNotifications
|
||||
? null
|
||||
: (value) async {
|
||||
final newNotificationsPreference =
|
||||
notificationsPreference.copyWith(
|
||||
onMessageReceivedMode: value);
|
||||
await updatePreferences(newNotificationsPreference);
|
||||
},
|
||||
).paddingAll(4),
|
||||
FormBuilderDropdown(
|
||||
name: formFieldMessageReceivedSound,
|
||||
isDense: false,
|
||||
enabled: notificationsPreference.enableNotifications,
|
||||
initialValue: notificationsPreference.onMessageReceivedSound,
|
||||
onChanged: (value) async {
|
||||
if (value == null) {
|
||||
return;
|
||||
}
|
||||
final newNotificationsPreference = notificationsPreference
|
||||
.copyWith(onMessageReceivedSound: value);
|
||||
await updatePreferences(newNotificationsPreference);
|
||||
},
|
||||
StyledDropdown<SoundEffect>(
|
||||
items: soundEffectItems(),
|
||||
).paddingLTRB(4, 4, 0, 4)
|
||||
value: notificationsPreference.onMessageReceivedSound,
|
||||
onChanged: !notificationsPreference.enableNotifications
|
||||
? null
|
||||
: (value) async {
|
||||
final newNotificationsPreference =
|
||||
notificationsPreference.copyWith(
|
||||
onMessageReceivedSound: value);
|
||||
await updatePreferences(newNotificationsPreference);
|
||||
},
|
||||
).paddingLTRB(
|
||||
4.scaled(context), 4.scaled(context), 0, 4.scaled(context))
|
||||
]),
|
||||
|
||||
// Message sent
|
||||
|
@ -295,25 +255,23 @@ Widget buildSettingsPageNotificationPreferences(
|
|||
Text(
|
||||
textAlign: TextAlign.right,
|
||||
translate('settings_page.message_sent'))
|
||||
.paddingAll(8),
|
||||
.paddingAll(4.scaled(context)),
|
||||
const SizedBox.shrink(),
|
||||
FormBuilderDropdown(
|
||||
name: formFieldMessageSentSound,
|
||||
isDense: false,
|
||||
enabled: notificationsPreference.enableNotifications,
|
||||
initialValue: notificationsPreference.onMessageSentSound,
|
||||
onChanged: (value) async {
|
||||
if (value == null) {
|
||||
return;
|
||||
}
|
||||
final newNotificationsPreference = notificationsPreference
|
||||
.copyWith(onMessageSentSound: value);
|
||||
await updatePreferences(newNotificationsPreference);
|
||||
},
|
||||
StyledDropdown<SoundEffect>(
|
||||
items: soundEffectItems(),
|
||||
).paddingLTRB(4, 4, 0, 4)
|
||||
value: notificationsPreference.onMessageSentSound,
|
||||
onChanged: !notificationsPreference.enableNotifications
|
||||
? null
|
||||
: (value) async {
|
||||
final newNotificationsPreference =
|
||||
notificationsPreference.copyWith(
|
||||
onMessageSentSound: value);
|
||||
await updatePreferences(newNotificationsPreference);
|
||||
},
|
||||
).paddingLTRB(
|
||||
4.scaled(context), 4.scaled(context), 0, 4.scaled(context))
|
||||
]),
|
||||
])
|
||||
]).paddingAll(8),
|
||||
]).paddingAll(8.scaled(context)),
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue