forked from Nexus/nexus
tweak PMP support
This commit is contained in:
parent
3b7a4c0cd4
commit
4800123044
9 changed files with 69 additions and 61 deletions
4
.vscode/settings.json
vendored
4
.vscode/settings.json
vendored
|
|
@ -15,6 +15,8 @@
|
||||||
"underride",
|
"underride",
|
||||||
"unifiedpush",
|
"unifiedpush",
|
||||||
"unredact",
|
"unredact",
|
||||||
"webpush"
|
"webpush",
|
||||||
|
"subprofile",
|
||||||
|
"subprofiles"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,7 +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/dialog_list_tile.dart";
|
||||||
import "package:nexus/widgets/settings/enable_image_packs_sheet.dart";
|
import "package:nexus/widgets/settings/enable_image_packs_sheet.dart";
|
||||||
import "package:nexus/widgets/settings/keyword_field.dart";
|
import "package:nexus/widgets/settings/keyword_field.dart";
|
||||||
import "package:nexus/widgets/settings/persona_sheet.dart";
|
import "package:nexus/widgets/settings/subprofile_sheet.dart";
|
||||||
import "package:nexus/widgets/users/user_bottom_sheet.dart";
|
import "package:nexus/widgets/users/user_bottom_sheet.dart";
|
||||||
import "package:nexus/widgets/encryption/reset_encryption_sheet.dart";
|
import "package:nexus/widgets/encryption/reset_encryption_sheet.dart";
|
||||||
|
|
||||||
|
|
@ -52,7 +52,7 @@ class SettingsSectionsController
|
||||||
@override
|
@override
|
||||||
Future<IMap<String, IList<SettingsCategory>>> build() async {
|
Future<IMap<String, IList<SettingsCategory>>> build() async {
|
||||||
final settings = await ref.watch(SettingsController.provider.future);
|
final settings = await ref.watch(SettingsController.provider.future);
|
||||||
final personas = ref.watch(
|
final subprofiles = ref.watch(
|
||||||
AccountDataController.provider.select((data) => data.perMessageProfiles),
|
AccountDataController.provider.select((data) => data.perMessageProfiles),
|
||||||
);
|
);
|
||||||
// Not awaited, so a slow homeserver doesn't hold up the rest of settings
|
// Not awaited, so a slow homeserver doesn't hold up the rest of settings
|
||||||
|
|
@ -448,47 +448,49 @@ class SettingsSectionsController
|
||||||
]),
|
]),
|
||||||
),
|
),
|
||||||
.new(
|
.new(
|
||||||
title: "Personas",
|
title: "Subprofiles",
|
||||||
icon: Icons.groups,
|
icon: Icons.groups,
|
||||||
settings: .new([
|
settings: .new([
|
||||||
.new(
|
.new(
|
||||||
title: "Enable Personas",
|
title: "Enable Subprofiles",
|
||||||
description: "Send messages as other names and avatars, chosen per room from the composer.",
|
description: "Send messages as other names and avatars, chosen per room from the composer.",
|
||||||
icon: Icons.groups,
|
icon: Icons.groups,
|
||||||
builder: (title, description, icon) => SwitchListTile(
|
builder: (title, description, icon) => SwitchListTile(
|
||||||
title: Text(title),
|
title: Text(title),
|
||||||
subtitle: Text(description),
|
subtitle: Text(description),
|
||||||
secondary: Icon(icon),
|
secondary: Icon(icon),
|
||||||
value: settings.personas,
|
value: settings.subprofiles,
|
||||||
onChanged: (value) => ref
|
onChanged: (value) => ref
|
||||||
.read(SettingsController.provider.notifier)
|
.read(SettingsController.provider.notifier)
|
||||||
.set(settings.copyWith(personas: value))
|
.set(settings.copyWith(subprofiles: value))
|
||||||
.onError(showError),
|
.onError(showError),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (settings.personas) ...[
|
if (settings.subprofiles) ...[
|
||||||
if (personas.profiles.isNotEmpty)
|
if (subprofiles.profiles.isNotEmpty)
|
||||||
.new(
|
.new(
|
||||||
title: "Default Persona",
|
title: "Default Subprofile",
|
||||||
description: "Who you send as in rooms you haven't chosen a persona for.",
|
description: "Who you send as in rooms you haven't chosen a subprofile for.",
|
||||||
icon: Icons.person_pin,
|
icon: Icons.person_pin,
|
||||||
builder: (title, description, icon) =>
|
builder: (title, description, icon) =>
|
||||||
DialogListTile<String>(
|
DialogListTile<String>(
|
||||||
icon: Icon(icon),
|
icon: Icon(icon),
|
||||||
title: title,
|
title: title,
|
||||||
subtitle: Text(description),
|
subtitle: Text(description),
|
||||||
value: personas.defaultProfileId ?? "",
|
value: subprofiles.defaultProfileId ?? "",
|
||||||
options: [
|
options: [
|
||||||
"",
|
"",
|
||||||
...personas.profiles.map((profile) => profile.id),
|
...subprofiles.profiles.map(
|
||||||
|
(profile) => profile.id,
|
||||||
|
),
|
||||||
],
|
],
|
||||||
getName: (id) => switch (personas.byId(id)) {
|
getName: (id) => switch (subprofiles.byId(id)) {
|
||||||
final profile? => profile.displayName ?? id,
|
final profile? => profile.displayName ?? id,
|
||||||
null => "Yourself",
|
null => "Account Profile",
|
||||||
},
|
},
|
||||||
onChanged: (id) => accountData
|
onChanged: (id) => accountData
|
||||||
.setPerMessageProfiles(
|
.setPerMessageProfiles(
|
||||||
personas.copyWith(
|
subprofiles.copyWith(
|
||||||
defaultProfileId: id.isEmpty ? null : id,
|
defaultProfileId: id.isEmpty ? null : id,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
@ -496,20 +498,20 @@ class SettingsSectionsController
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
header(
|
header(
|
||||||
"Personas",
|
"Subprofiles",
|
||||||
"The names and avatars you can send messages as.",
|
"The names and avatars you can send messages as.",
|
||||||
Icons.groups,
|
Icons.groups,
|
||||||
),
|
),
|
||||||
...personas.profiles.map(
|
...subprofiles.profiles.map(
|
||||||
(persona) => Setting(
|
(subprofile) => Setting(
|
||||||
title: persona.displayName ?? persona.id,
|
title: subprofile.displayName ?? subprofile.id,
|
||||||
description: "A persona.",
|
description: "A subprofile.",
|
||||||
icon: Icons.person,
|
icon: Icons.person,
|
||||||
builder: (title, _, _) => Builder(
|
builder: (title, _, _) => Builder(
|
||||||
builder: (context) => ListTile(
|
builder: (context) => ListTile(
|
||||||
leading: AvatarOrHash(persona.avatarUrl, title),
|
leading: AvatarOrHash(subprofile.avatarUrl, title),
|
||||||
title: Text(title),
|
title: Text(title),
|
||||||
subtitle: switch (persona.triggers.firstOrNull) {
|
subtitle: switch (subprofile.triggers.firstOrNull) {
|
||||||
final trigger? => Text(
|
final trigger? => Text(
|
||||||
"Trigger: ${trigger.prefix}text${trigger.suffix}",
|
"Trigger: ${trigger.prefix}text${trigger.suffix}",
|
||||||
),
|
),
|
||||||
|
|
@ -517,14 +519,14 @@ class SettingsSectionsController
|
||||||
},
|
},
|
||||||
trailing: Icon(Icons.chevron_right),
|
trailing: Icon(Icons.chevron_right),
|
||||||
onTap: () => context.showAdaptiveSheet(
|
onTap: () => context.showAdaptiveSheet(
|
||||||
(_) => PersonaSheet(persona: persona),
|
(_) => SubprofileSheet(subprofile: subprofile),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
.new(
|
.new(
|
||||||
title: "Add Persona",
|
title: "Add Subprofile",
|
||||||
description: "Create a name and avatar to send messages as.",
|
description: "Create a name and avatar to send messages as.",
|
||||||
icon: Icons.add,
|
icon: Icons.add,
|
||||||
builder: (title, _, icon) => Builder(
|
builder: (title, _, icon) => Builder(
|
||||||
|
|
@ -532,7 +534,7 @@ class SettingsSectionsController
|
||||||
leading: Icon(icon),
|
leading: Icon(icon),
|
||||||
title: Text(title),
|
title: Text(title),
|
||||||
onTap: () => context.showAdaptiveSheet(
|
onTap: () => context.showAdaptiveSheet(
|
||||||
(_) => const PersonaSheet(),
|
(_) => const SubprofileSheet(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -7,14 +7,15 @@ import "package:nexus/controllers/rooms.dart";
|
||||||
import "package:nexus/models/account_data.dart";
|
import "package:nexus/models/account_data.dart";
|
||||||
import "package:nexus/models/per_message_profiles.dart";
|
import "package:nexus/models/per_message_profiles.dart";
|
||||||
|
|
||||||
typedef RoomPersonas = ({
|
typedef RoomSubprofiles = ({
|
||||||
IList<StoredProfile> profiles,
|
IList<StoredProfile> profiles,
|
||||||
StoredProfile? current,
|
StoredProfile? current,
|
||||||
});
|
});
|
||||||
|
|
||||||
class PersonasController(final String roomId) extends Notifier<RoomPersonas> {
|
class SubprofilesController(final String roomId)
|
||||||
|
extends Notifier<RoomSubprofiles> {
|
||||||
@override
|
@override
|
||||||
RoomPersonas build() {
|
RoomSubprofiles build() {
|
||||||
final global = ref.watch(
|
final global = ref.watch(
|
||||||
AccountDataController.provider.select((data) => data.perMessageProfiles),
|
AccountDataController.provider.select((data) => data.perMessageProfiles),
|
||||||
);
|
);
|
||||||
|
|
@ -52,5 +53,7 @@ class PersonasController(final String roomId) extends Notifier<RoomPersonas> {
|
||||||
}
|
}
|
||||||
|
|
||||||
static final provider = NotifierProvider.autoDispose
|
static final provider = NotifierProvider.autoDispose
|
||||||
.family<PersonasController, RoomPersonas, String>(PersonasController.new);
|
.family<SubprofilesController, RoomSubprofiles, String>(
|
||||||
|
SubprofilesController.new,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -23,7 +23,7 @@ class const Settings({
|
||||||
final RoomOrder roomOrder = .unreadFirst,
|
final RoomOrder roomOrder = .unreadFirst,
|
||||||
final NameColor nameColor = .powerLevel,
|
final NameColor nameColor = .powerLevel,
|
||||||
final ShowAndSend typingIndicators = .showAndSend,
|
final ShowAndSend typingIndicators = .showAndSend,
|
||||||
final bool personas = false,
|
final bool subprofiles = false,
|
||||||
|
|
||||||
/// When not sending, read receipts are still sent privately, so that the
|
/// When not sending, read receipts are still sent privately, so that the
|
||||||
/// user's other devices know what has been read.
|
/// user's other devices know what has been read.
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import "dart:io";
|
||||||
import "package:fast_immutable_collections/fast_immutable_collections.dart";
|
import "package:fast_immutable_collections/fast_immutable_collections.dart";
|
||||||
import "package:collection/collection.dart";
|
import "package:collection/collection.dart";
|
||||||
import "package:material_adaptive_sheets/material_adaptive_sheets.dart";
|
import "package:material_adaptive_sheets/material_adaptive_sheets.dart";
|
||||||
import "package:nexus/widgets/composer/persona_button.dart";
|
import "package:nexus/widgets/composer/subprofile_button.dart";
|
||||||
import "package:nexus/controllers/bot_argument_suggestions.dart";
|
import "package:nexus/controllers/bot_argument_suggestions.dart";
|
||||||
import "package:nexus/controllers/bot_command_draft.dart";
|
import "package:nexus/controllers/bot_command_draft.dart";
|
||||||
import "package:nexus/controllers/bot_commands.dart";
|
import "package:nexus/controllers/bot_commands.dart";
|
||||||
|
|
@ -566,7 +566,7 @@ class const Composer(
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
? [
|
? [
|
||||||
PersonaButton(roomId),
|
SubprofileButton(roomId),
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: hasReplacement
|
onPressed: hasReplacement
|
||||||
? null
|
? null
|
||||||
|
|
|
||||||
|
|
@ -2,23 +2,23 @@ import "package:flutter_riverpod/flutter_riverpod.dart";
|
||||||
import "package:material_adaptive_sheets/material_adaptive_sheets.dart";
|
import "package:material_adaptive_sheets/material_adaptive_sheets.dart";
|
||||||
import "package:material_ui/material_ui.dart";
|
import "package:material_ui/material_ui.dart";
|
||||||
import "package:nexus/controllers/account_data.dart";
|
import "package:nexus/controllers/account_data.dart";
|
||||||
import "package:nexus/controllers/personas.dart";
|
import "package:nexus/controllers/subprofiles.dart";
|
||||||
import "package:nexus/controllers/settings.dart";
|
import "package:nexus/controllers/settings.dart";
|
||||||
import "package:nexus/main.dart";
|
import "package:nexus/main.dart";
|
||||||
import "package:nexus/widgets/avatars/avatar_or_hash.dart";
|
import "package:nexus/widgets/avatars/avatar_or_hash.dart";
|
||||||
|
|
||||||
/// Chooses the persona messages are sent as in [roomId], if personas are on.
|
/// Chooses the subprofile messages are sent as in [roomId], if subprofiles are on.
|
||||||
class const PersonaButton(final String roomId, {super.key})
|
class const SubprofileButton(final String roomId, {super.key})
|
||||||
extends ConsumerWidget {
|
extends ConsumerWidget {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
final enabled = ref.watch(
|
final enabled = ref.watch(
|
||||||
SettingsController.provider.select(
|
SettingsController.provider.select(
|
||||||
(settings) => settings.value?.personas ?? false,
|
(settings) => settings.value?.subprofiles ?? false,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
final (:profiles, :current) = ref.watch(
|
final (:profiles, :current) = ref.watch(
|
||||||
PersonasController.provider(roomId),
|
SubprofilesController.provider(roomId),
|
||||||
);
|
);
|
||||||
if (!enabled || profiles.isEmpty) return const SizedBox.shrink();
|
if (!enabled || profiles.isEmpty) return const SizedBox.shrink();
|
||||||
|
|
||||||
|
|
@ -47,7 +47,7 @@ class const PersonaButton(final String roomId, {super.key})
|
||||||
return AdaptiveMenuButton<void>(
|
return AdaptiveMenuButton<void>(
|
||||||
tooltip: switch (current) {
|
tooltip: switch (current) {
|
||||||
final current? => "Sending as ${current.displayName ?? current.id}",
|
final current? => "Sending as ${current.displayName ?? current.id}",
|
||||||
null => "Choose persona",
|
null => "Choose subprofile",
|
||||||
},
|
},
|
||||||
icon: switch (current) {
|
icon: switch (current) {
|
||||||
final current? => AvatarOrHash(
|
final current? => AvatarOrHash(
|
||||||
|
|
@ -57,7 +57,7 @@ class const PersonaButton(final String roomId, {super.key})
|
||||||
null => Icon(Icons.person),
|
null => Icon(Icons.person),
|
||||||
},
|
},
|
||||||
itemBuilder: (_) => [
|
itemBuilder: (_) => [
|
||||||
item(id: "", leading: Icon(Icons.person), title: "Yourself"),
|
item(id: "", leading: Icon(Icons.person), title: "Account Profile"),
|
||||||
...profiles.map(
|
...profiles.map(
|
||||||
(profile) => item(
|
(profile) => item(
|
||||||
id: profile.id,
|
id: profile.id,
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import "package:material_ui/material_ui.dart";
|
import "package:material_ui/material_ui.dart";
|
||||||
import "package:flutter_riverpod/flutter_riverpod.dart";
|
import "package:flutter_riverpod/flutter_riverpod.dart";
|
||||||
import "package:nexus/controllers/author.dart";
|
import "package:nexus/controllers/author.dart";
|
||||||
|
import "package:nexus/controllers/user.dart";
|
||||||
import "package:nexus/helpers/extensions/get_localpart.dart";
|
import "package:nexus/helpers/extensions/get_localpart.dart";
|
||||||
import "package:nexus/helpers/extensions/show_user_popover.dart";
|
import "package:nexus/helpers/extensions/show_user_popover.dart";
|
||||||
import "package:nexus/helpers/extensions/displayname_color.dart";
|
import "package:nexus/helpers/extensions/displayname_color.dart";
|
||||||
|
|
@ -34,7 +35,7 @@ class const MessageDisplayname(
|
||||||
),
|
),
|
||||||
if (event.pmp != null)
|
if (event.pmp != null)
|
||||||
Text(
|
Text(
|
||||||
"(via ${event.sender})",
|
"(${ref.watch(UserController.provider(.new(roomId: event.roomId, userId: event.sender))).value?.displayName ?? event.sender.localpart})",
|
||||||
style: Theme.of(context).textTheme.labelSmall
|
style: Theme.of(context).textTheme.labelSmall
|
||||||
?.copyWith(color: color, fontWeight: .bold),
|
?.copyWith(color: color, fontWeight: .bold),
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
|
|
|
||||||
|
|
@ -9,16 +9,18 @@ import "package:nexus/models/per_message_profiles.dart";
|
||||||
import "package:nexus/widgets/avatars/avatar_or_hash.dart";
|
import "package:nexus/widgets/avatars/avatar_or_hash.dart";
|
||||||
import "package:nexus/widgets/avatars/editable_avatar.dart";
|
import "package:nexus/widgets/avatars/editable_avatar.dart";
|
||||||
|
|
||||||
class const PersonaSheet({final StoredProfile? persona, super.key})
|
class const SubprofileSheet({final StoredProfile? subprofile, super.key})
|
||||||
extends HookConsumerWidget {
|
extends HookConsumerWidget {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
final saving = Saving.use();
|
final saving = Saving.use();
|
||||||
final trigger = persona?.triggers.firstOrNull;
|
final trigger = subprofile?.triggers.firstOrNull;
|
||||||
final nameController = useTextEditingController(text: persona?.displayName);
|
final nameController = useTextEditingController(
|
||||||
|
text: subprofile?.displayName,
|
||||||
|
);
|
||||||
final prefixController = useTextEditingController(text: trigger?.prefix);
|
final prefixController = useTextEditingController(text: trigger?.prefix);
|
||||||
final suffixController = useTextEditingController(text: trigger?.suffix);
|
final suffixController = useTextEditingController(text: trigger?.suffix);
|
||||||
final avatar = useState(persona?.avatarUrl);
|
final avatar = useState(subprofile?.avatarUrl);
|
||||||
final name = useValueListenable(nameController).text.trim();
|
final name = useValueListenable(nameController).text.trim();
|
||||||
|
|
||||||
final accountData = ref.read(AccountDataController.provider.notifier);
|
final accountData = ref.read(AccountDataController.provider.notifier);
|
||||||
|
|
@ -35,24 +37,24 @@ class const PersonaSheet({final StoredProfile? persona, super.key})
|
||||||
final suffix = suffixController.text;
|
final suffix = suffixController.text;
|
||||||
final edited = StoredProfile(
|
final edited = StoredProfile(
|
||||||
id:
|
id:
|
||||||
persona?.id ??
|
subprofile?.id ??
|
||||||
DateTime.now().microsecondsSinceEpoch.toRadixString(36),
|
DateTime.now().microsecondsSinceEpoch.toRadixString(36),
|
||||||
displayName: name,
|
displayName: name,
|
||||||
avatarUrl: avatar.value,
|
avatarUrl: avatar.value,
|
||||||
triggers: .new([
|
triggers: .new([
|
||||||
if (prefix.isNotEmpty || suffix.isNotEmpty)
|
if (prefix.isNotEmpty || suffix.isNotEmpty)
|
||||||
(trigger ?? const .new()).copyWith(prefix: prefix, suffix: suffix),
|
(trigger ?? const .new()).copyWith(prefix: prefix, suffix: suffix),
|
||||||
...?persona?.triggers.skip(1),
|
...?subprofile?.triggers.skip(1),
|
||||||
]),
|
]),
|
||||||
);
|
);
|
||||||
final profiles = current();
|
final profiles = current();
|
||||||
|
|
||||||
return update(
|
return update(
|
||||||
profiles.copyWith(
|
profiles.copyWith(
|
||||||
profiles: persona == null
|
profiles: subprofile == null
|
||||||
? profiles.profiles.add(edited)
|
? profiles.profiles.add(edited)
|
||||||
: profiles.profiles.replaceFirstWhere(
|
: profiles.profiles.replaceFirstWhere(
|
||||||
(profile) => profile.id == persona!.id,
|
(profile) => profile.id == subprofile!.id,
|
||||||
(_) => edited,
|
(_) => edited,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
@ -64,9 +66,9 @@ class const PersonaSheet({final StoredProfile? persona, super.key})
|
||||||
return update(
|
return update(
|
||||||
profiles.copyWith(
|
profiles.copyWith(
|
||||||
profiles: profiles.profiles.removeWhere(
|
profiles: profiles.profiles.removeWhere(
|
||||||
(profile) => profile.id == persona!.id,
|
(profile) => profile.id == subprofile!.id,
|
||||||
),
|
),
|
||||||
defaultProfileId: profiles.defaultProfileId == persona!.id
|
defaultProfileId: profiles.defaultProfileId == subprofile!.id
|
||||||
? null
|
? null
|
||||||
: profiles.defaultProfileId,
|
: profiles.defaultProfileId,
|
||||||
),
|
),
|
||||||
|
|
@ -74,9 +76,9 @@ class const PersonaSheet({final StoredProfile? persona, super.key})
|
||||||
}
|
}
|
||||||
|
|
||||||
return SheetLayout(
|
return SheetLayout(
|
||||||
title: Text(persona == null ? "Add Persona" : "Edit Persona"),
|
title: Text(subprofile == null ? "Add Subprofile" : "Edit Subprofile"),
|
||||||
actions: [
|
actions: [
|
||||||
if (persona != null)
|
if (subprofile != null)
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: saving.active ? null : delete,
|
onPressed: saving.active ? null : delete,
|
||||||
style: TextButton.styleFrom(
|
style: TextButton.styleFrom(
|
||||||
|
|
@ -98,19 +100,19 @@ class const PersonaSheet({final StoredProfile? persona, super.key})
|
||||||
onChanged: (url) async => avatar.value = url,
|
onChanged: (url) async => avatar.value = url,
|
||||||
child: AvatarOrHash(
|
child: AvatarOrHash(
|
||||||
avatar.value,
|
avatar.value,
|
||||||
name.isEmpty ? "Persona" : name,
|
name.isEmpty ? "Subprofile" : name,
|
||||||
dimension: 120,
|
dimension: 120,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
TextField(
|
TextField(
|
||||||
controller: nameController,
|
controller: nameController,
|
||||||
autofocus: persona == null,
|
autofocus: subprofile == null,
|
||||||
textCapitalization: .words,
|
textCapitalization: .words,
|
||||||
decoration: const .new(labelText: "Display name"),
|
decoration: const .new(labelText: "Display name"),
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
"Optionally, messages that start with the prefix *and* end with the suffix are sent as this persona, without them. Leave one empty to only need the other. Both are case-sensitive.",
|
"Optionally, messages that start with the prefix *and* end with the suffix are sent as this subprofile, without them. Leave one empty to only need the other. Both are case-sensitive.",
|
||||||
),
|
),
|
||||||
Row(
|
Row(
|
||||||
spacing: 8,
|
spacing: 8,
|
||||||
|
|
@ -3,15 +3,12 @@ import "package:flutter_riverpod/flutter_riverpod.dart";
|
||||||
import "package:material_ui/material_ui.dart";
|
import "package:material_ui/material_ui.dart";
|
||||||
import "package:material_adaptive_sheets/material_adaptive_sheets.dart";
|
import "package:material_adaptive_sheets/material_adaptive_sheets.dart";
|
||||||
import "package:nexus/controllers/author.dart";
|
import "package:nexus/controllers/author.dart";
|
||||||
|
import "package:nexus/controllers/user.dart";
|
||||||
import "package:nexus/helpers/extensions/displayname_color.dart";
|
import "package:nexus/helpers/extensions/displayname_color.dart";
|
||||||
import "package:nexus/helpers/extensions/get_localpart.dart";
|
import "package:nexus/helpers/extensions/get_localpart.dart";
|
||||||
import "package:nexus/helpers/extensions/show_user_popover.dart";
|
import "package:nexus/helpers/extensions/show_user_popover.dart";
|
||||||
import "package:nexus/models/event.dart";
|
import "package:nexus/models/event.dart";
|
||||||
|
|
||||||
/// A user's [name] in text, opening their popover when tapped. Unlike a widget
|
|
||||||
/// in text, it wraps and ellipsizes with the rest of it.
|
|
||||||
|
|
||||||
// Can't be const, since it sets the recognizer's onTapUp
|
|
||||||
// ignore: prefer_const_constructors_in_immutables
|
// ignore: prefer_const_constructors_in_immutables
|
||||||
class UserSpan(
|
class UserSpan(
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
|
|
@ -59,7 +56,8 @@ class UserSpan(
|
||||||
children: [
|
children: [
|
||||||
if (event.pmp != null)
|
if (event.pmp != null)
|
||||||
TextSpan(
|
TextSpan(
|
||||||
text: " (via ${event.sender})",
|
text:
|
||||||
|
"(${ref.watch(UserController.provider(.new(roomId: event.roomId, userId: event.sender))).value?.displayName ?? event.sender.localpart})",
|
||||||
recognizer: recognizer,
|
recognizer: recognizer,
|
||||||
style: Theme.of(context).textTheme.labelSmall
|
style: Theme.of(context).textTheme.labelSmall
|
||||||
?.copyWith(color: color, fontWeight: .bold),
|
?.copyWith(color: color, fontWeight: .bold),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue