added subprofile search

This commit is contained in:
Henry Hiles 2026-11-29 14:16:20 -05:00
commit d5f04122eb
Signed by: Henry-Hiles
SSH key fingerprint: SHA256:VKQUdS31Q90KvX7EkKMHMBpUspcmItAh86a+v7PGiIs

View file

@ -2,12 +2,11 @@ import "package:flutter_hooks/flutter_hooks.dart";
import "package:hooks_riverpod/hooks_riverpod.dart";
import "package:material_adaptive_sheets/material_adaptive_sheets.dart";
import "package:material_ui/material_ui.dart";
import "package:nexus/controllers/account_data.dart";
import "package:nexus/controllers/subprofiles.dart";
import "package:nexus/controllers/settings.dart";
import "package:nexus/main.dart";
import "package:nexus/models/room_subprofiles.dart";
import "package:nexus/widgets/avatars/avatar_or_hash.dart";
import "package:nexus/widgets/composer/subprofile_picker.dart";
/// Chooses the subprofile messages are sent as in [roomId], if subprofiles are
/// on. It shows the one the text in [controller] would trigger, if any.
@ -32,29 +31,7 @@ class const SubprofileButton(
if (!enabled || profiles.isEmpty) return const SizedBox.shrink();
final shown = triggered ?? current;
Future<void> choose(String profileId) => ref
.read(AccountDataController.provider.notifier)
.setRoomProfile(roomId, profileId)
.onError(showError);
PopupMenuItem<void> item({
required String id,
required Widget leading,
required String title,
}) {
final selected = (current?.id ?? "") == id;
return PopupMenuItem(
onTap: () => choose(id),
child: ListTile(
selected: selected,
leading: leading,
title: Text(title),
trailing: selected ? Icon(Icons.check) : null,
),
);
}
return AdaptiveMenuButton<void>(
return IconButton(
tooltip: switch ((triggered, current)) {
(final triggered?, _) =>
"Sending this message as ${triggered.displayName ?? triggered.id}",
@ -69,19 +46,8 @@ class const SubprofileButton(
),
null => Icon(Icons.person),
},
itemBuilder: (_) => [
item(id: "", leading: Icon(Icons.person), title: "Account Profile"),
...profiles.map(
(profile) => item(
id: profile.id,
leading: AvatarOrHash(
profile.avatarUrl,
profile.displayName ?? profile.id,
),
title: profile.displayName ?? profile.id,
),
),
],
onPressed: () =>
context.showAdaptivePopover((_) => SubprofilePicker(roomId)),
);
}
}