Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions lib/features/boards/views/boards_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import 'package:prism_plurality/shared/widgets/prism_segmented_control.dart';
import 'package:prism_plurality/shared/widgets/prism_spinner.dart';
import 'package:prism_plurality/shared/widgets/prism_top_bar.dart';
import 'package:prism_plurality/shared/widgets/prism_top_bar_action.dart';
import 'package:prism_plurality/shared/widgets/prism_scaled_height.dart';

// ---------------------------------------------------------------------------
// SharedPreferences key — persists the last viewed sub-tab index.
Expand Down Expand Up @@ -183,16 +184,23 @@ class _BoardsScreenState extends ConsumerState<BoardsScreen> {
// Top bar
// ---------------------------------------------------------------------------

class _BoardsTopBar extends StatelessWidget implements PreferredSizeWidget {
class _BoardsTopBar extends StatelessWidget
implements PreferredSizeWidget, PrismScaledHeight {
const _BoardsTopBar({required this.onComposeTap});

final VoidCallback onComposeTap;

@override
Size get preferredSize => const Size.fromHeight(kToolbarHeight);
Size get preferredSize => const Size.fromHeight(PrismTokens.topBarHeight);

@override
Widget build(BuildContext context) {
double preferredHeightFor(BuildContext context, {double? availableWidth}) {
return _buildBar(
context,
).preferredHeightFor(context, availableWidth: availableWidth);
}

PrismTopBar _buildBar(BuildContext context) {
return PrismTopBar(
title: context.l10n.boardsScreenTitle,
leading: const _BoardsMemberFilterButton(),
Expand All @@ -206,6 +214,9 @@ class _BoardsTopBar extends StatelessWidget implements PreferredSizeWidget {
],
);
}

@override
Widget build(BuildContext context) => _buildBar(context);
}

// ---------------------------------------------------------------------------
Expand Down
17 changes: 14 additions & 3 deletions lib/features/boards/views/member_board_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import 'package:prism_plurality/features/boards/widgets/board_actor_selector.dar
import 'package:prism_plurality/features/members/providers/members_providers.dart';
import 'package:prism_plurality/shared/extensions/app_localizations_extension.dart';
import 'package:prism_plurality/shared/theme/app_icons.dart';
import 'package:prism_plurality/shared/theme/prism_tokens.dart';
import 'package:prism_plurality/shared/widgets/clamped_body.dart';
import 'package:prism_plurality/shared/widgets/adaptive_detail_surface.dart';
import 'package:prism_plurality/shared/widgets/empty_state.dart';
Expand All @@ -21,6 +22,7 @@ import 'package:prism_plurality/shared/widgets/prism_page_scaffold.dart';
import 'package:prism_plurality/shared/widgets/prism_spinner.dart';
import 'package:prism_plurality/shared/widgets/prism_top_bar.dart';
import 'package:prism_plurality/shared/widgets/prism_top_bar_action.dart';
import 'package:prism_plurality/shared/widgets/prism_scaled_height.dart';

/// Full paginated list of public board posts by or about a given member.
///
Expand Down Expand Up @@ -71,7 +73,7 @@ void _openMemberBoardPost(BuildContext context, String postId) {
// ---------------------------------------------------------------------------

class _MemberBoardTopBar extends StatelessWidget
implements PreferredSizeWidget {
implements PreferredSizeWidget, PrismScaledHeight {
const _MemberBoardTopBar({
required this.member,
required this.memberName,
Expand All @@ -83,10 +85,19 @@ class _MemberBoardTopBar extends StatelessWidget
final VoidCallback onComposeTap;

@override
Size get preferredSize => const Size.fromHeight(kToolbarHeight);
Size get preferredSize => const Size.fromHeight(PrismTokens.topBarHeight);

@override
Widget build(BuildContext context) {
double preferredHeightFor(BuildContext context, {double? availableWidth}) {
return _buildBar(
context,
).preferredHeightFor(context, availableWidth: availableWidth);
}

@override
Widget build(BuildContext context) => _buildBar(context);

PrismTopBar _buildBar(BuildContext context) {
final l10n = context.l10n;

final leadingAvatar = member != null
Expand Down
18 changes: 12 additions & 6 deletions lib/features/boards/widgets/board_message_section.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,20 @@ class BoardMessageSection extends ConsumerWidget {
color: theme.colorScheme.primary,
),
const SizedBox(width: 8),
Text(
l10n.memberSectionBoardMessages,
style: theme.textTheme.labelLarge?.copyWith(
color: theme.colorScheme.primary,
fontWeight: FontWeight.w600,
// The title takes the leftover width and wraps; while it kept its
// intrinsic width behind a Spacer it pushed the actor selector and
// the compose action off the card (measured 80 / 127px over at
// 3.375x). Selector identity, actions and keys are unchanged.
Expanded(
child: Text(
l10n.memberSectionBoardMessages,
style: theme.textTheme.labelLarge?.copyWith(
color: theme.colorScheme.primary,
fontWeight: FontWeight.w600,
),
),
),
const Spacer(),
const SizedBox(width: 8),
const BoardActorSelector(),
PrismInlineIconButton(
icon: AppIcons.add,
Expand Down
200 changes: 168 additions & 32 deletions lib/features/boards/widgets/post_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,13 @@ import 'package:prism_plurality/shared/widgets/prism_markdown_text.dart';
import 'package:prism_plurality/shared/widgets/member_avatar.dart';
import 'package:prism_plurality/shared/widgets/prism_dialog.dart';
import 'package:prism_plurality/shared/widgets/prism_list_row.dart';
import 'package:prism_plurality/shared/widgets/prism_scaled_height.dart';
import 'package:prism_plurality/shared/widgets/prism_surface.dart';

/// The same visibility word is rendered by the pill and measured by its header.
String _audienceLabel(String audience) =>
audience == 'public' ? 'public' : 'private';

// ---------------------------------------------------------------------------
// Inline markdown stripper — for accessibility labels only.
// ---------------------------------------------------------------------------
Expand Down Expand Up @@ -272,43 +277,101 @@ class _PostTileContent extends ConsumerWidget {
),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 10),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
child: _PostHeaderParticipants(
author: author,
target: target,
post: post,
authorColor: authorColor,
theme: theme,
l10n: l10n,
prefer: prefer,
),
),
const SizedBox(width: 8),
if (showAudiencePill) ...[
_AudiencePill(audience: post.audience, theme: theme),
const SizedBox(width: 8),
],
Text(
_formatTimestamp(post.writtenAt, context),
// Measured fit, not a container that reflows on its own: the metadata
// keeps today's inline position beside the participant strip whenever it
// fits next to the strip's non-shrinkable pieces, and a long user name
// keeps ellipsising on that one line. Only metadata that genuinely cannot
// fit - the 3.375x case that overflowed by 90px - takes its own line, and
// it then wraps internally rather than overflowing the card.
child: LayoutBuilder(
builder: (context, constraints) {
final timestampLabel = _formatTimestamp(
post.writtenAt,
context,
);
final hasMenu = hasActions && isDesktopOrWeb;
final fitsInline =
_headerMetaWidth(
context,
theme: theme,
timestamp: timestampLabel,
audience: post.audience,
showAudiencePill: showAudiencePill,
hasMenu: hasMenu,
) +
8 +
_headerStripFixedWidth(
context,
theme: theme,
hasTargetAvatar: post.targetMemberId != null,
) <=
constraints.maxWidth;

final participants = _PostHeaderParticipants(
author: author,
target: target,
post: post,
authorColor: authorColor,
theme: theme,
l10n: l10n,
prefer: prefer,
);
final timestamp = Text(
timestampLabel,
style: theme.textTheme.labelMedium?.copyWith(
color: theme.colorScheme.onSurfaceVariant.withValues(
alpha: 0.7,
),
fontSize: 11,
),
),
if (hasActions && isDesktopOrWeb) ...[
const SizedBox(width: 4),
_InlineMenuButton(
post: post,
viewerMember: viewerMember,
buildActions: _buildActions,
),
],
],
);
final pill = showAudiencePill
? _AudiencePill(audience: post.audience, theme: theme)
: null;
final menu = hasMenu
? _InlineMenuButton(
post: post,
viewerMember: viewerMember,
buildActions: _buildActions,
)
: null;

if (fitsInline) {
// Unchanged default geometry: names ellipsise, metadata inline.
return Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(child: participants),
const SizedBox(width: 8),
if (pill != null) ...[pill, const SizedBox(width: 8)],
timestamp,
if (menu != null) ...[const SizedBox(width: 4), menu],
],
);
}

return Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(child: participants),
if (menu != null) ...[const SizedBox(width: 4), menu],
],
),
const SizedBox(height: 4),
Wrap(
alignment: WrapAlignment.end,
crossAxisAlignment: WrapCrossAlignment.center,
spacing: 8,
runSpacing: 2,
children: [?pill, timestamp],
),
],
);
},
),
),
),
Expand Down Expand Up @@ -406,6 +469,79 @@ class _PostTileContent extends ConsumerWidget {
return card;
}

/// Width of one line of [text] as the header paints it.
///
/// [style] is the style handed to `Text`; [prismTextStyleForMeasurement] applies the
/// ambient [DefaultTextStyle] merge and the bold-text flag exactly as `Text` does, and
/// the painter gets the inherited locale and height behaviour, so the measured line and
/// the painted line resolve the same face.
double _headerLineWidth(BuildContext context, String text, TextStyle? style) {
final painter = TextPainter(
text: TextSpan(
text: text,
style: prismTextStyleForMeasurement(context, style),
),
textDirection: Directionality.of(context),
textScaler: MediaQuery.textScalerOf(context),
textHeightBehavior: prismTextHeightBehaviorFor(context),
locale: Localizations.maybeLocaleOf(context),
maxLines: 1,
)..layout();
final width = painter.width;
painter.dispose();
return width;
}

/// Width the header metadata needs side by side, from the strings and styles it
/// actually renders: the visibility word in the pill (+ its 16dp padding and the
/// 8dp gap before it), the formatted timestamp, and the desktop menu when present.
double _headerMetaWidth(
BuildContext context, {
required ThemeData theme,
required String timestamp,
required String audience,
required bool showAudiencePill,
required bool hasMenu,
}) {
var width = _headerLineWidth(
context,
timestamp,
theme.textTheme.labelMedium?.copyWith(fontSize: 11),
);
if (showAudiencePill) {
width +=
8 +
16 +
_headerLineWidth(
context,
_audienceLabel(audience),
theme.textTheme.labelSmall?.copyWith(
fontWeight: FontWeight.w600,
fontSize: 10,
),
);
}
if (hasMenu) width += 4 + 26; // 4dp gap + the 18dp icon in its 4dp padding.
return width;
}

/// Width the participant strip cannot give away: the author avatar and its gap, the
/// gaps around the "to" connector, the connector itself, and the target avatar when
/// the post has one. Both names are flexible and ellipsise, so they count as zero -
/// a long name must never force the metadata off the line on its own.
double _headerStripFixedWidth(
BuildContext context, {
required ThemeData theme,
required bool hasTargetAvatar,
}) {
final to = _headerLineWidth(
context,
'to',
theme.textTheme.labelMedium?.copyWith(fontSize: 12),
);
return 22 + 6 + 8 + to + 8 + (hasTargetAvatar ? 22 + 6 : 0);
}

String _formatTimestamp(DateTime dt, BuildContext context) {
final diff = DateTime.now().difference(dt);
if (diff.inSeconds < 60) return 'just now';
Expand Down Expand Up @@ -550,7 +686,7 @@ class _AudiencePill extends StatelessWidget {
borderRadius: BorderRadius.circular(PrismShapes.of(context).radius(8)),
),
child: Text(
isPublic ? 'public' : 'private',
_audienceLabel(audience),
style: theme.textTheme.labelSmall?.copyWith(
color: color,
fontWeight: FontWeight.w600,
Expand Down
Loading
Loading