mirror of
https://gitlab.com/veilid/veilidchat.git
synced 2025-07-21 05:38:42 -04:00
Accessibility update
This commit is contained in:
parent
be8014c97a
commit
3b1cb53b8a
55 changed files with 1089 additions and 807 deletions
|
@ -32,6 +32,14 @@ class DeveloperPageIntent extends Intent {
|
|||
const DeveloperPageIntent();
|
||||
}
|
||||
|
||||
class DisplayScaleUpIntent extends Intent {
|
||||
const DisplayScaleUpIntent();
|
||||
}
|
||||
|
||||
class DisplayScaleDownIntent extends Intent {
|
||||
const DisplayScaleDownIntent();
|
||||
}
|
||||
|
||||
class KeyboardShortcuts extends StatelessWidget {
|
||||
const KeyboardShortcuts({required this.child, super.key});
|
||||
|
||||
|
@ -57,7 +65,7 @@ class KeyboardShortcuts extends StatelessWidget {
|
|||
});
|
||||
}
|
||||
|
||||
void changeBrightness(BuildContext context) {
|
||||
void _changeBrightness(BuildContext context) {
|
||||
singleFuture(this, () async {
|
||||
final prefs = PreferencesRepository.instance.value;
|
||||
|
||||
|
@ -79,7 +87,7 @@ class KeyboardShortcuts extends StatelessWidget {
|
|||
});
|
||||
}
|
||||
|
||||
void changeColor(BuildContext context) {
|
||||
void _changeColor(BuildContext context) {
|
||||
singleFuture(this, () async {
|
||||
final prefs = PreferencesRepository.instance.value;
|
||||
final oldColor = prefs.themePreference.colorPreference;
|
||||
|
@ -100,6 +108,54 @@ class KeyboardShortcuts extends StatelessWidget {
|
|||
});
|
||||
}
|
||||
|
||||
void _displayScaleUp(BuildContext context) {
|
||||
singleFuture(this, () async {
|
||||
final prefs = PreferencesRepository.instance.value;
|
||||
final oldIndex = displayScaleToIndex(prefs.themePreference.displayScale);
|
||||
if (oldIndex == maxDisplayScaleIndex) {
|
||||
return;
|
||||
}
|
||||
final newIndex = oldIndex + 1;
|
||||
final newDisplayScaleName = indexToDisplayScaleName(newIndex);
|
||||
|
||||
log.info('Changing display scale to $newDisplayScaleName');
|
||||
|
||||
final newPrefs = prefs.copyWith(
|
||||
themePreference: prefs.themePreference
|
||||
.copyWith(displayScale: indexToDisplayScale(newIndex)));
|
||||
await PreferencesRepository.instance.set(newPrefs);
|
||||
|
||||
if (context.mounted) {
|
||||
ThemeSwitcher.of(context)
|
||||
.changeTheme(theme: newPrefs.themePreference.themeData());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void _displayScaleDown(BuildContext context) {
|
||||
singleFuture(this, () async {
|
||||
final prefs = PreferencesRepository.instance.value;
|
||||
final oldIndex = displayScaleToIndex(prefs.themePreference.displayScale);
|
||||
if (oldIndex == 0) {
|
||||
return;
|
||||
}
|
||||
final newIndex = oldIndex - 1;
|
||||
final newDisplayScaleName = indexToDisplayScaleName(newIndex);
|
||||
|
||||
log.info('Changing display scale to $newDisplayScaleName');
|
||||
|
||||
final newPrefs = prefs.copyWith(
|
||||
themePreference: prefs.themePreference
|
||||
.copyWith(displayScale: indexToDisplayScale(newIndex)));
|
||||
await PreferencesRepository.instance.set(newPrefs);
|
||||
|
||||
if (context.mounted) {
|
||||
ThemeSwitcher.of(context)
|
||||
.changeTheme(theme: newPrefs.themePreference.themeData());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void _attachDetach(BuildContext context) {
|
||||
singleFuture(this, () async {
|
||||
if (ProcessorRepository.instance.processorConnectionState.isAttached) {
|
||||
|
@ -125,44 +181,88 @@ class KeyboardShortcuts extends StatelessWidget {
|
|||
@override
|
||||
Widget build(BuildContext context) => ThemeSwitcher(
|
||||
builder: (context) => Shortcuts(
|
||||
shortcuts: const <ShortcutActivator, Intent>{
|
||||
SingleActivator(
|
||||
shortcuts: <ShortcutActivator, Intent>{
|
||||
////////////////////////// Reload Theme
|
||||
const SingleActivator(
|
||||
LogicalKeyboardKey.keyR,
|
||||
control: true,
|
||||
alt: true,
|
||||
): ReloadThemeIntent(),
|
||||
SingleActivator(
|
||||
): const ReloadThemeIntent(),
|
||||
////////////////////////// Switch Brightness
|
||||
const SingleActivator(
|
||||
LogicalKeyboardKey.keyB,
|
||||
control: true,
|
||||
alt: true,
|
||||
): ChangeBrightnessIntent(),
|
||||
SingleActivator(
|
||||
): const ChangeBrightnessIntent(),
|
||||
////////////////////////// Change Color
|
||||
const SingleActivator(
|
||||
LogicalKeyboardKey.keyC,
|
||||
control: true,
|
||||
alt: true,
|
||||
): ChangeColorIntent(),
|
||||
SingleActivator(
|
||||
LogicalKeyboardKey.keyA,
|
||||
control: true,
|
||||
alt: true,
|
||||
): AttachDetachIntent(),
|
||||
SingleActivator(
|
||||
): const ChangeColorIntent(),
|
||||
////////////////////////// Attach/Detach
|
||||
if (kIsDebugMode)
|
||||
const SingleActivator(
|
||||
LogicalKeyboardKey.keyA,
|
||||
control: true,
|
||||
alt: true,
|
||||
): const AttachDetachIntent(),
|
||||
////////////////////////// Show Developer Page
|
||||
const SingleActivator(
|
||||
LogicalKeyboardKey.keyD,
|
||||
control: true,
|
||||
alt: true,
|
||||
): DeveloperPageIntent(),
|
||||
): const DeveloperPageIntent(),
|
||||
////////////////////////// Display Scale Up
|
||||
SingleActivator(
|
||||
LogicalKeyboardKey.equal,
|
||||
meta: isMac || isiOS,
|
||||
control: !(isMac || isiOS),
|
||||
): const DisplayScaleUpIntent(),
|
||||
SingleActivator(
|
||||
LogicalKeyboardKey.equal,
|
||||
shift: true,
|
||||
meta: isMac || isiOS,
|
||||
control: !(isMac || isiOS),
|
||||
): const DisplayScaleUpIntent(),
|
||||
SingleActivator(
|
||||
LogicalKeyboardKey.add,
|
||||
shift: true,
|
||||
meta: isMac || isiOS,
|
||||
control: !(isMac || isiOS),
|
||||
): const DisplayScaleUpIntent(),
|
||||
SingleActivator(
|
||||
LogicalKeyboardKey.numpadAdd,
|
||||
meta: isMac || isiOS,
|
||||
control: !(isMac || isiOS),
|
||||
): const DisplayScaleUpIntent(),
|
||||
////////////////////////// Display Scale Down
|
||||
SingleActivator(
|
||||
LogicalKeyboardKey.minus,
|
||||
meta: isMac || isiOS,
|
||||
control: !(isMac || isiOS),
|
||||
): const DisplayScaleDownIntent(),
|
||||
SingleActivator(
|
||||
LogicalKeyboardKey.numpadSubtract,
|
||||
meta: isMac || isiOS,
|
||||
control: !(isMac || isiOS),
|
||||
): const DisplayScaleDownIntent(),
|
||||
},
|
||||
child: Actions(actions: <Type, Action<Intent>>{
|
||||
ReloadThemeIntent: CallbackAction<ReloadThemeIntent>(
|
||||
onInvoke: (intent) => reloadTheme(context)),
|
||||
ChangeBrightnessIntent: CallbackAction<ChangeBrightnessIntent>(
|
||||
onInvoke: (intent) => changeBrightness(context)),
|
||||
onInvoke: (intent) => _changeBrightness(context)),
|
||||
ChangeColorIntent: CallbackAction<ChangeColorIntent>(
|
||||
onInvoke: (intent) => changeColor(context)),
|
||||
onInvoke: (intent) => _changeColor(context)),
|
||||
AttachDetachIntent: CallbackAction<AttachDetachIntent>(
|
||||
onInvoke: (intent) => _attachDetach(context)),
|
||||
DeveloperPageIntent: CallbackAction<DeveloperPageIntent>(
|
||||
onInvoke: (intent) => _developerPage(context)),
|
||||
DisplayScaleUpIntent: CallbackAction<DisplayScaleUpIntent>(
|
||||
onInvoke: (intent) => _displayScaleUp(context)),
|
||||
DisplayScaleDownIntent: CallbackAction<DisplayScaleDownIntent>(
|
||||
onInvoke: (intent) => _displayScaleDown(context)),
|
||||
}, child: Focus(autofocus: true, child: child))));
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue