mirror of
https://gitlab.com/veilid/veilidchat.git
synced 2025-07-21 13:48:43 -04:00
new chat widget
This commit is contained in:
parent
063eeb8d12
commit
1a9cca0667
44 changed files with 1904 additions and 981 deletions
|
@ -16,6 +16,14 @@ class ReloadThemeIntent extends Intent {
|
|||
const ReloadThemeIntent();
|
||||
}
|
||||
|
||||
class ChangeBrightnessIntent extends Intent {
|
||||
const ChangeBrightnessIntent();
|
||||
}
|
||||
|
||||
class ChangeColorIntent extends Intent {
|
||||
const ChangeColorIntent();
|
||||
}
|
||||
|
||||
class AttachDetachIntent extends Intent {
|
||||
const AttachDetachIntent();
|
||||
}
|
||||
|
@ -49,6 +57,49 @@ class KeyboardShortcuts extends StatelessWidget {
|
|||
});
|
||||
}
|
||||
|
||||
void changeBrightness(BuildContext context) {
|
||||
singleFuture(this, () async {
|
||||
final prefs = PreferencesRepository.instance.value;
|
||||
|
||||
final oldBrightness = prefs.themePreference.brightnessPreference;
|
||||
final newBrightness = BrightnessPreference.values[
|
||||
(oldBrightness.index + 1) % BrightnessPreference.values.length];
|
||||
|
||||
log.info('Changing brightness to $newBrightness');
|
||||
|
||||
final newPrefs = prefs.copyWith(
|
||||
themePreference: prefs.themePreference
|
||||
.copyWith(brightnessPreference: newBrightness));
|
||||
await PreferencesRepository.instance.set(newPrefs);
|
||||
|
||||
if (context.mounted) {
|
||||
ThemeSwitcher.of(context)
|
||||
.changeTheme(theme: newPrefs.themePreference.themeData());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void changeColor(BuildContext context) {
|
||||
singleFuture(this, () async {
|
||||
final prefs = PreferencesRepository.instance.value;
|
||||
final oldColor = prefs.themePreference.colorPreference;
|
||||
final newColor = ColorPreference
|
||||
.values[(oldColor.index + 1) % ColorPreference.values.length];
|
||||
|
||||
log.info('Changing color to $newColor');
|
||||
|
||||
final newPrefs = prefs.copyWith(
|
||||
themePreference:
|
||||
prefs.themePreference.copyWith(colorPreference: newColor));
|
||||
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) {
|
||||
|
@ -75,17 +126,34 @@ class KeyboardShortcuts extends StatelessWidget {
|
|||
Widget build(BuildContext context) => ThemeSwitcher(
|
||||
builder: (context) => Shortcuts(
|
||||
shortcuts: <LogicalKeySet, Intent>{
|
||||
LogicalKeySet(LogicalKeyboardKey.alt, LogicalKeyboardKey.keyR):
|
||||
const ReloadThemeIntent(),
|
||||
LogicalKeySet(LogicalKeyboardKey.alt, LogicalKeyboardKey.keyD):
|
||||
const AttachDetachIntent(),
|
||||
LogicalKeySet(
|
||||
LogicalKeyboardKey.alt, LogicalKeyboardKey.backquote):
|
||||
const DeveloperPageIntent(),
|
||||
LogicalKeyboardKey.alt,
|
||||
LogicalKeyboardKey.control,
|
||||
LogicalKeyboardKey.keyR): const ReloadThemeIntent(),
|
||||
LogicalKeySet(
|
||||
LogicalKeyboardKey.alt,
|
||||
LogicalKeyboardKey.control,
|
||||
LogicalKeyboardKey.keyB): const ChangeBrightnessIntent(),
|
||||
LogicalKeySet(
|
||||
LogicalKeyboardKey.alt,
|
||||
LogicalKeyboardKey.control,
|
||||
LogicalKeyboardKey.keyC): const ChangeColorIntent(),
|
||||
LogicalKeySet(
|
||||
LogicalKeyboardKey.alt,
|
||||
LogicalKeyboardKey.control,
|
||||
LogicalKeyboardKey.keyD): const AttachDetachIntent(),
|
||||
LogicalKeySet(
|
||||
LogicalKeyboardKey.alt,
|
||||
LogicalKeyboardKey.control,
|
||||
LogicalKeyboardKey.backquote): const DeveloperPageIntent(),
|
||||
},
|
||||
child: Actions(actions: <Type, Action<Intent>>{
|
||||
ReloadThemeIntent: CallbackAction<ReloadThemeIntent>(
|
||||
onInvoke: (intent) => reloadTheme(context)),
|
||||
ChangeBrightnessIntent: CallbackAction<ChangeBrightnessIntent>(
|
||||
onInvoke: (intent) => changeBrightness(context)),
|
||||
ChangeColorIntent: CallbackAction<ChangeColorIntent>(
|
||||
onInvoke: (intent) => changeColor(context)),
|
||||
AttachDetachIntent: CallbackAction<AttachDetachIntent>(
|
||||
onInvoke: (intent) => _attachDetach(context)),
|
||||
DeveloperPageIntent: CallbackAction<DeveloperPageIntent>(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue