forked from Nexus/nexus
parent
f80ceb0736
commit
3b7a4c0cd4
1 changed files with 469 additions and 1 deletions
|
|
@ -43,6 +43,7 @@ import "package:nexus/widgets/settings/block_user_field.dart";
|
|||
import "package:nexus/widgets/settings/dialog_list_tile.dart";
|
||||
import "package:nexus/widgets/settings/enable_image_packs_sheet.dart";
|
||||
import "package:nexus/widgets/settings/keyword_field.dart";
|
||||
import "package:nexus/widgets/settings/persona_sheet.dart";
|
||||
import "package:nexus/widgets/users/user_bottom_sheet.dart";
|
||||
import "package:nexus/widgets/encryption/reset_encryption_sheet.dart";
|
||||
|
||||
|
|
@ -51,6 +52,9 @@ class SettingsSectionsController
|
|||
@override
|
||||
Future<IMap<String, IList<SettingsCategory>>> build() async {
|
||||
final settings = await ref.watch(SettingsController.provider.future);
|
||||
final personas = ref.watch(
|
||||
AccountDataController.provider.select((data) => data.perMessageProfiles),
|
||||
);
|
||||
// Not awaited, so a slow homeserver doesn't hold up the rest of settings
|
||||
final accountManagement = ref
|
||||
.watch(AccountManagementController.provider)
|
||||
|
|
@ -443,6 +447,99 @@ class SettingsSectionsController
|
|||
),
|
||||
]),
|
||||
),
|
||||
.new(
|
||||
title: "Personas",
|
||||
icon: Icons.groups,
|
||||
settings: .new([
|
||||
.new(
|
||||
title: "Enable Personas",
|
||||
description: "Send messages as other names and avatars, chosen per room from the composer.",
|
||||
icon: Icons.groups,
|
||||
builder: (title, description, icon) => SwitchListTile(
|
||||
title: Text(title),
|
||||
subtitle: Text(description),
|
||||
secondary: Icon(icon),
|
||||
value: settings.personas,
|
||||
onChanged: (value) => ref
|
||||
.read(SettingsController.provider.notifier)
|
||||
.set(settings.copyWith(personas: value))
|
||||
.onError(showError),
|
||||
),
|
||||
),
|
||||
if (settings.personas) ...[
|
||||
if (personas.profiles.isNotEmpty)
|
||||
.new(
|
||||
title: "Default Persona",
|
||||
description: "Who you send as in rooms you haven't chosen a persona for.",
|
||||
icon: Icons.person_pin,
|
||||
builder: (title, description, icon) =>
|
||||
DialogListTile<String>(
|
||||
icon: Icon(icon),
|
||||
title: title,
|
||||
subtitle: Text(description),
|
||||
value: personas.defaultProfileId ?? "",
|
||||
options: [
|
||||
"",
|
||||
...personas.profiles.map((profile) => profile.id),
|
||||
],
|
||||
getName: (id) => switch (personas.byId(id)) {
|
||||
final profile? => profile.displayName ?? id,
|
||||
null => "Yourself",
|
||||
},
|
||||
onChanged: (id) => accountData
|
||||
.setPerMessageProfiles(
|
||||
personas.copyWith(
|
||||
defaultProfileId: id.isEmpty ? null : id,
|
||||
),
|
||||
)
|
||||
.onError(showError),
|
||||
),
|
||||
),
|
||||
header(
|
||||
"Personas",
|
||||
"The names and avatars you can send messages as.",
|
||||
Icons.groups,
|
||||
),
|
||||
...personas.profiles.map(
|
||||
(persona) => Setting(
|
||||
title: persona.displayName ?? persona.id,
|
||||
description: "A persona.",
|
||||
icon: Icons.person,
|
||||
builder: (title, _, _) => Builder(
|
||||
builder: (context) => ListTile(
|
||||
leading: AvatarOrHash(persona.avatarUrl, title),
|
||||
title: Text(title),
|
||||
subtitle: switch (persona.triggers.firstOrNull) {
|
||||
final trigger? => Text(
|
||||
"Trigger: ${trigger.prefix}text${trigger.suffix}",
|
||||
),
|
||||
null => null,
|
||||
},
|
||||
trailing: Icon(Icons.chevron_right),
|
||||
onTap: () => context.showAdaptiveSheet(
|
||||
(_) => PersonaSheet(persona: persona),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
.new(
|
||||
title: "Add Persona",
|
||||
description: "Create a name and avatar to send messages as.",
|
||||
icon: Icons.add,
|
||||
builder: (title, _, icon) => Builder(
|
||||
builder: (context) => ListTile(
|
||||
leading: Icon(icon),
|
||||
title: Text(title),
|
||||
onTap: () => context.showAdaptiveSheet(
|
||||
(_) => const PersonaSheet(),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
]),
|
||||
),
|
||||
.new(
|
||||
title: "Image Packs",
|
||||
icon: Icons.emoji_emotions,
|
||||
|
|
|
|||
Loading…
Reference in a new issue