mirror of
https://github.com/block/buzz.git
synced 2026-11-24 10:12:19 +00:00
System Bold Text made single-participant reply labels such as “12 replies” wrap or truncate: the handoff measured normal-weight glyphs, then rendered bold glyphs inside that narrower box. Resolve the inherited text style and platform bold override before measuring, and use that same style for rendering. Addresses the fix-before-merge blocker identified by [Tom's agent on #8987](https://github.com/block/buzz/pull/8987#issuecomment-6611883349), specifically [the Bold Text finding](https://github.com/block/buzz/pull/8987#discussion_r4458491084). Tom classified unloaded-root typing, legacy reply-only paging, and working-state label clipping as acceptable later follow-ups; those remain outside this patch. Validation: - Regression loads the bundled Inter font (the default test font masks weight differences), toggles Bold Text off/on/off, and covers idle/working footers at 1x/2x scale. All four cases failed before the production fix. - Formatting and full analysis passed; 4,252 Flutter tests passed (44 skipped), plus 4 unconfigured-push tests. All 27 crypto tests passed. Mandatory push hooks passed. - Self-review found no blockers in this narrow change. Draft pending app/human verification required by AGENTS.md. To verify: enable system Bold Text, open a channel with a single-participant thread, and confirm “12 replies” remains complete; repeat with enlarged text and toggle Bold Text off. No physical-device validation is claimed. Signed-off-by: kenny lopez <klopez4212@gmail.com> Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz>
156 lines
5.3 KiB
Dart
156 lines
5.3 KiB
Dart
import 'dart:math' as math;
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_hooks/flutter_hooks.dart';
|
|
|
|
import '../../shared/profile/user_profile.dart';
|
|
import '../../shared/theme/theme.dart';
|
|
import 'small_avatar.dart';
|
|
import 'typing_dots.dart';
|
|
|
|
/// Keeps one avatar mounted as its working pill becomes a reply summary.
|
|
class ReplyActivityHandoff extends HookWidget {
|
|
const ReplyActivityHandoff({
|
|
super.key,
|
|
required this.pubkey,
|
|
required this.userCache,
|
|
required this.working,
|
|
required this.label,
|
|
});
|
|
|
|
final String pubkey;
|
|
final Map<String, UserProfile> userCache;
|
|
final bool working;
|
|
final String? label;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final knownAgent = useRef(false);
|
|
if (working) knownAgent.value = true;
|
|
final existingLabel = useRef(false);
|
|
if (working) existingLabel.value = label != null;
|
|
final reducedMotion = MediaQuery.disableAnimationsOf(context);
|
|
final controller = useAnimationController(
|
|
duration: const Duration(milliseconds: 200),
|
|
initialValue: working ? 0 : 1,
|
|
);
|
|
useEffect(() {
|
|
final target = working ? 0.0 : 1.0;
|
|
if (reducedMotion) {
|
|
controller.value = target;
|
|
} else {
|
|
controller.animateTo(target, curve: Curves.easeInOutCubic);
|
|
}
|
|
return null;
|
|
}, [working, reducedMotion]);
|
|
final animated = useAnimation(controller);
|
|
final progress = reducedMotion ? (working ? 0.0 : 1.0) : animated;
|
|
// Match Text's inherited style and platform Bold Text override so the
|
|
// measured box fits the glyphs that are actually rendered.
|
|
var style = DefaultTextStyle.of(context).style.merge(
|
|
context.textTheme.labelMedium?.copyWith(
|
|
color: context.colors.onSurfaceVariant,
|
|
),
|
|
);
|
|
if (MediaQuery.boldTextOf(context)) {
|
|
style = style.merge(const TextStyle(fontWeight: FontWeight.bold));
|
|
}
|
|
return LayoutBuilder(
|
|
builder: (context, constraints) {
|
|
final text = TextPainter(
|
|
text: TextSpan(text: label ?? '', style: style),
|
|
textDirection: Directionality.of(context),
|
|
textScaler: MediaQuery.textScalerOf(context),
|
|
maxLines: 2,
|
|
ellipsis: '…',
|
|
)..layout(maxWidth: math.max(0, constraints.maxWidth - 24));
|
|
final textWidth = text.width;
|
|
final height = math.max(
|
|
constraints.minHeight,
|
|
math.max(28.0, text.height),
|
|
);
|
|
text.dispose();
|
|
// 20px avatar, 4px gap, 19px dots, and 6/8px container insets.
|
|
final pendingWidth = existingLabel.value ? 61 + textWidth : 57.0;
|
|
final width = pendingWidth + (24 + textWidth - pendingWidth) * progress;
|
|
return SizedBox(
|
|
width: width,
|
|
height: height,
|
|
child: Stack(
|
|
clipBehavior: Clip.none,
|
|
children: [
|
|
Positioned(
|
|
left: 0,
|
|
top: (height - 28) / 2,
|
|
height: 28,
|
|
width: 57 + (width - 57) * progress,
|
|
child: DecoratedBox(
|
|
key: const ValueKey('thread-working-container'),
|
|
decoration: BoxDecoration(
|
|
color: context.controlSurface.withValues(
|
|
alpha: 1 - progress,
|
|
),
|
|
borderRadius: BorderRadius.circular(Grid.twelve),
|
|
),
|
|
),
|
|
),
|
|
Positioned(
|
|
left: 6 * (1 - progress),
|
|
top: (height - 20) / 2,
|
|
child: SmallAvatar(
|
|
pubkey: pubkey,
|
|
userCache: userCache,
|
|
agent: knownAgent.value,
|
|
),
|
|
),
|
|
if (progress < 1)
|
|
Positioned(
|
|
left: 30 - 6 * progress,
|
|
top: (height - 5) / 2,
|
|
child: Opacity(
|
|
opacity: 1 - progress,
|
|
child: const TypingDots(
|
|
key: ValueKey('thread-working-dots'),
|
|
dotSize: 5,
|
|
),
|
|
),
|
|
),
|
|
if (label != null)
|
|
Positioned(
|
|
left: existingLabel.value ? 61 - 37 * progress : 24,
|
|
right: 0,
|
|
top: 0,
|
|
bottom: 0,
|
|
child: ClipRect(
|
|
child: OverflowBox(
|
|
alignment: Alignment.centerRight,
|
|
minHeight: 0,
|
|
maxHeight: height,
|
|
minWidth: textWidth,
|
|
maxWidth: textWidth,
|
|
child: Opacity(
|
|
opacity: working || existingLabel.value ? 1 : progress,
|
|
child: Transform.scale(
|
|
scale: working || existingLabel.value
|
|
? 1
|
|
: 0.95 + 0.05 * progress,
|
|
alignment: Alignment.centerRight,
|
|
child: Text(
|
|
label!,
|
|
style: style,
|
|
maxLines: 2,
|
|
overflow: TextOverflow.ellipsis,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|