Files
buzz/mobile/lib/features/channels/compose_bar/suggestions.dart
klopez4212 0bdad8ea96 mobile: simplify verified profiles and prioritize full names (#9051)
Simplifies mobile identity presentation: removes verification checkmarks
from messages, threads, mentions and profiles, plus
issuer/time/disclaimer copy. Profiles show the community-verified full
name as the title and the display name below, with fallback when no full
name exists.

Validation: mobile formatting/analysis, full Flutter suite (4,401
passed, 45 skipped), all 4 unconfigured-push checks, and pre-push hooks
passed. Independent review found no blockers. Device and human visual
checks pending.

<details>
<summary>Before / after snapshots</summary>

Real Flutter profile widget with synthetic data, light/dark themes;
widget previews, not device screenshots. Images are PR attachments only.

| Theme | Before | After |
| --- | --- | --- |
| Light | ![Before,
light](https://github.com/user-attachments/assets/d615c010-7f04-4480-ae5e-e11539abc860)
| ![After,
light](https://github.com/user-attachments/assets/5726e504-349c-4c74-afc5-5557b03061bb)
|
| Dark | ![Before,
dark](https://github.com/user-attachments/assets/29204e7c-840b-41b4-b916-784976e6cbc9)
| ![After,
dark](https://github.com/user-attachments/assets/6c399553-4d95-47e8-9a5d-a2d351598ab3)
|

</details>


<details>
<summary>Inline messages — before / after</summary>

Actual Flutter channel and thread widgets with synthetic verified-user
data; local widget previews, not device screenshots.

| Screen | Before | After |
| --- | --- | --- |
| Channel · light | ![Before: channel,
light](https://github.com/user-attachments/assets/e482b562-5b44-4e48-8a24-ea52e78a8936)
| ![After: channel,
light](https://github.com/user-attachments/assets/2dd3689c-3206-4bc0-84be-0828e0fcca84)
|
| Channel · dark | ![Before: channel,
dark](https://github.com/user-attachments/assets/3c848519-3b96-453f-8751-78c573211f13)
| ![After: channel,
dark](https://github.com/user-attachments/assets/cc781417-e7ef-4988-98b4-b562c075fff6)
|
| Thread · light | ![Before: thread,
light](https://github.com/user-attachments/assets/4117bd8b-de7e-45c7-8e5a-3b25ae600405)
| ![After: thread,
light](https://github.com/user-attachments/assets/b2f8bddb-3023-448b-88fa-a9bc1d3b2ec2)
|
| Thread · dark | ![Before: thread,
dark](https://github.com/user-attachments/assets/4b9fd1fc-0a53-41b0-804c-3f06cd7a2e03)
| ![After: thread,
dark](https://github.com/user-attachments/assets/b407c3c6-c67a-445f-8867-feff60ca5973)
|

</details>

Signed-off-by: kenny lopez <klopez4212@gmail.com>
Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz>
2026-11-04 16:00:52 +00:00

293 lines
9.5 KiB
Dart

part of '../compose_bar.dart';
/// A mention row with its info line: a dense, compact two-line `ListTile`.
const _mentionRowHeight = 59.0;
/// The chooser shows at most three rows, then scrolls.
const _mentionChooserHeight = _mentionRowHeight * 3 + Grid.xxs * 2;
class _MentionSuggestions extends StatelessWidget {
final List<MentionCandidate> suggestions;
/// Shown rows that can no longer be chosen. They stay in place, disabled.
final Set<String> unavailable;
/// The directory search failed: show its error and a retry below the rows.
final bool searchFailed;
/// Hold the full height, rows at the top, so rows that join late fill
/// empty space instead of pushing the shown rows up.
final bool reserveHeight;
/// The directory search is still running: show a thin progress bar on the
/// top edge. It overlays the rows, so it never changes the height.
final bool searching;
final VoidCallback? onRetry;
final Map<String, UserProfile> userCache;
final String? currentPubkey;
final bool isDmChannel;
final void Function(MentionCandidate) onSelect;
const _MentionSuggestions({
required this.suggestions,
this.unavailable = const {},
this.searchFailed = false,
this.reserveHeight = false,
this.searching = false,
this.onRetry,
required this.userCache,
required this.currentPubkey,
required this.isDmChannel,
required this.onSelect,
});
@override
Widget build(BuildContext context) {
return Material(
key: const ValueKey('mention-suggestions-popover'),
type: MaterialType.card,
color: appPopoverColor(context),
surfaceTintColor: Colors.transparent,
elevation: appPopoverElevation,
shadowColor: appPopoverShadowColor(context),
shape: appPopoverShape(context),
clipBehavior: Clip.hardEdge,
child: Stack(
children: [
_rows(context),
if (searching)
const Positioned(
top: 0,
left: 0,
right: 0,
child: LinearProgressIndicator(
key: ValueKey('mention-search-progress'),
minHeight: 2,
backgroundColor: Colors.transparent,
semanticsLabel: 'Searching people',
),
),
],
),
);
}
Widget _rows(BuildContext context) {
return ConstrainedBox(
constraints: BoxConstraints(
minHeight: reserveHeight ? _mentionChooserHeight : 0,
maxHeight: _mentionChooserHeight,
),
child: ListView.separated(
shrinkWrap: true,
padding: const EdgeInsets.symmetric(vertical: Grid.xxs),
itemCount: suggestions.length + (searchFailed ? 1 : 0),
separatorBuilder: (_, _) => const SizedBox.shrink(),
itemBuilder: (context, index) {
if (index == suggestions.length) {
return ListTile(
key: const ValueKey('mention-search-error'),
dense: true,
visualDensity: VisualDensity.compact,
title: Text(
'Could not search community people.',
style: context.textTheme.bodySmall?.copyWith(
color: context.colors.error,
),
),
trailing: TextButton(
onPressed: onRetry == null
? null
: () => _runComposerAction(onRetry!),
child: const Text('Retry'),
),
);
}
final candidate = suggestions[index];
final name = candidate.pickerLabel;
final avatarUrl =
candidate.avatarUrl ?? userCache[candidate.pubkey]?.avatarUrl;
final available = !unavailable.contains(candidate.pubkey);
return ListTile(
enabled: available,
dense: true,
visualDensity: VisualDensity.compact,
leading: AvatarImage(
imageUrl: avatarUrl,
radius: 18,
backgroundColor: context.controlSurface,
fallback: Text(
// Name-derived for named candidates; keyed to the hex
// public key for unnamed ones so the compact-npub label
// doesn't render `N` for everyone.
candidate.initial,
style: context.textTheme.labelMedium?.copyWith(
color: context.colors.onPrimaryContainer,
fontWeight: FontWeight.w600,
),
),
isAgent: candidate.isAgent,
),
title: Row(
children: [
Flexible(
child: Text(
name,
style: context.textTheme.titleSmall,
overflow: TextOverflow.ellipsis,
),
),
],
),
subtitle: _MentionSuggestionInfo.build(
context,
candidate: candidate,
currentPubkey: currentPubkey,
isDmChannel: isDmChannel,
userCache: userCache,
),
onTap: available
? () => _runComposerAction(() => onSelect(candidate))
: null,
);
},
),
);
}
}
/// The secondary info line under a mention suggestion — mirrors desktop's
/// `MentionAutocomplete` subtitle: bot icon + "agent" (or an "admin" badge
/// for human admins), then "managed by …" / "not in channel" (or "not in DM").
abstract final class _MentionSuggestionInfo {
static Widget? build(
BuildContext context, {
required MentionCandidate candidate,
required String? currentPubkey,
required bool isDmChannel,
required Map<String, UserProfile> userCache,
}) {
final ownerLabel = candidate.isAgent
? formatOwnerLabel(candidate.ownerPubkey, currentPubkey, userCache)
: null;
final notInChannel = !candidate.isMember;
final outside = isDmChannel ? 'not in DM' : 'not in channel';
final isAdmin = !candidate.isAgent && candidate.role == 'admin';
final String? detail;
if (ownerLabel != null && notInChannel) {
detail = 'managed by $ownerLabel \u00b7 $outside';
} else if (ownerLabel != null) {
detail = 'managed by $ownerLabel';
} else if (notInChannel) {
detail = outside;
} else {
detail = null;
}
if (!candidate.isAgent && !isAdmin && detail == null) return null;
final style = context.textTheme.labelSmall?.copyWith(
color: context.colors.onSurfaceVariant,
);
return Row(
children: [
if (candidate.isAgent) ...[
Icon(BuzzIcons.bot, size: 12, color: context.colors.onSurfaceVariant),
const SizedBox(width: Grid.half),
Text('agent', style: style),
] else if (isAdmin)
Container(
padding: const EdgeInsets.symmetric(
horizontal: Grid.xxs,
vertical: 1,
),
decoration: BoxDecoration(
color: context.colors.secondaryContainer,
borderRadius: BorderRadius.circular(Radii.sm),
),
child: Text(
'admin',
style: style?.copyWith(
color: context.colors.onSecondaryContainer,
),
),
),
if (detail != null) ...[
if (candidate.isAgent || isAdmin) const SizedBox(width: Grid.xxs),
Flexible(
child: Text(detail, style: style, overflow: TextOverflow.ellipsis),
),
],
],
);
}
}
@visibleForTesting
List<Channel> filterChannels(List<Channel> channels, String? query) {
if (query == null) return const [];
final q = query.toLowerCase();
return channels
.where((c) => c.channelType != 'dm')
.where((c) {
if (q.isEmpty) return true;
return c.name.toLowerCase().contains(q);
})
.take(8)
.toList();
}
class _ChannelSuggestions extends StatelessWidget {
final List<Channel> suggestions;
final void Function(Channel) onSelect;
const _ChannelSuggestions({
required this.suggestions,
required this.onSelect,
});
@override
Widget build(BuildContext context) {
return Material(
key: const ValueKey('channel-suggestions-popover'),
type: MaterialType.card,
color: appPopoverColor(context),
surfaceTintColor: Colors.transparent,
elevation: appPopoverElevation,
shadowColor: appPopoverShadowColor(context),
shape: appPopoverShape(context),
clipBehavior: Clip.hardEdge,
child: ConstrainedBox(
constraints: const BoxConstraints(maxHeight: 240),
child: ListView.separated(
shrinkWrap: true,
padding: const EdgeInsets.symmetric(vertical: Grid.xxs),
itemCount: suggestions.length,
separatorBuilder: (_, _) => const SizedBox.shrink(),
itemBuilder: (context, index) {
final channel = suggestions[index];
return ListTile(
dense: true,
visualDensity: VisualDensity.compact,
horizontalTitleGap: 0,
leading: SizedBox.square(
dimension: 36,
child: Icon(
BuzzIcons.hash,
size: 20,
color: context.colors.onSurfaceVariant,
),
),
title: Text(channel.name, style: context.textTheme.bodyLarge),
onTap: () => _runComposerAction(() => onSelect(channel)),
);
},
),
),
);
}
}