mirror of
https://gitlab.com/veilid/veilidchat.git
synced 2025-07-20 21:28:41 -04:00
big identity refactor
This commit is contained in:
parent
bae58d5f5c
commit
ddc02f6771
46 changed files with 2143 additions and 1300 deletions
35
lib/app.dart
35
lib/app.dart
|
@ -1,4 +1,5 @@
|
|||
import 'package:animated_theme_switcher/animated_theme_switcher.dart';
|
||||
import 'package:async_tools/async_tools.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
@ -7,6 +8,7 @@ import 'package:flutter_localizations/flutter_localizations.dart';
|
|||
import 'package:flutter_translate/flutter_translate.dart';
|
||||
import 'package:form_builder_validators/form_builder_validators.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:veilid_support/veilid_support.dart';
|
||||
|
||||
import 'account_manager/account_manager.dart';
|
||||
import 'init.dart';
|
||||
|
@ -22,6 +24,10 @@ class ReloadThemeIntent extends Intent {
|
|||
const ReloadThemeIntent();
|
||||
}
|
||||
|
||||
class AttachDetachThemeIntent extends Intent {
|
||||
const AttachDetachThemeIntent();
|
||||
}
|
||||
|
||||
class VeilidChatApp extends StatelessWidget {
|
||||
const VeilidChatApp({
|
||||
required this.initialThemeData,
|
||||
|
@ -37,6 +43,29 @@ class VeilidChatApp extends StatelessWidget {
|
|||
final theme =
|
||||
PreferencesRepository.instance.value.themePreferences.themeData();
|
||||
ThemeSwitcher.of(context).changeTheme(theme: theme);
|
||||
|
||||
// Hack to reload translations
|
||||
final localizationDelegate = LocalizedApp.of(context).delegate;
|
||||
singleFuture(this, () async {
|
||||
await LocalizationDelegate.create(
|
||||
fallbackLocale: localizationDelegate.fallbackLocale.toString(),
|
||||
supportedLocales: localizationDelegate.supportedLocales
|
||||
.map((x) => x.toString())
|
||||
.toList());
|
||||
});
|
||||
}
|
||||
|
||||
void _attachDetachTheme(BuildContext context) {
|
||||
singleFuture(this, () async {
|
||||
if (ProcessorRepository.instance.processorConnectionState.isAttached) {
|
||||
log.info('Detaching');
|
||||
await Veilid.instance.detach();
|
||||
} else if (ProcessorRepository
|
||||
.instance.processorConnectionState.isDetached) {
|
||||
log.info('Attaching');
|
||||
await Veilid.instance.attach();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Widget _buildShortcuts(
|
||||
|
@ -48,10 +77,16 @@ class VeilidChatApp extends StatelessWidget {
|
|||
LogicalKeySet(
|
||||
LogicalKeyboardKey.alt, LogicalKeyboardKey.keyR):
|
||||
const ReloadThemeIntent(),
|
||||
LogicalKeySet(
|
||||
LogicalKeyboardKey.alt, LogicalKeyboardKey.keyD):
|
||||
const AttachDetachThemeIntent(),
|
||||
},
|
||||
child: Actions(actions: <Type, Action<Intent>>{
|
||||
ReloadThemeIntent: CallbackAction<ReloadThemeIntent>(
|
||||
onInvoke: (intent) => _reloadTheme(context)),
|
||||
AttachDetachThemeIntent:
|
||||
CallbackAction<AttachDetachThemeIntent>(
|
||||
onInvoke: (intent) => _attachDetachTheme(context)),
|
||||
}, child: Focus(autofocus: true, child: builder(context)))));
|
||||
|
||||
@override
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue