Files
buzz/mobile/lib/features/channels/compose_bar/dock.dart
klopez4212 8cc7e94392 Refine mobile Messages sections, Duo navigation, and chat typography (#9885)
## Summary

- Organize mobile Messages into configurable flat sections. See All
keeps the list and its search position when opening a conversation, and
supports side-by-side browsing on an unfolded Duo.
- Use the same 16-point Messages gutter in booklet and open Duo layouts.
The regular iPhone uses 20 points. Align navigation actions and use
native inline titles on See All.
- Update mobile typography and spacing across chat rows, message
bubbles, drafts, and the composer. Render code proportionally to the
17-point message body.

## Device review

Compare the leading edges of the section headings and channel icons in
Messages on the open Duo and in booklet mode. Open See All and check
that its rows follow the same column.

---------

Signed-off-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz>
Signed-off-by: kenny lopez <klopez4212@gmail.com>
Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz>
2026-11-23 13:14:05 -08:00

259 lines
9.5 KiB
Dart

part of '../compose_bar.dart';
/// Height of the conversation fade behind the composer with the keyboard up.
const _keyboardUpBackdropHeight = 100.0;
class _ComposerDockFrame extends HookWidget {
final Animation<double> expansionAnimation;
final bool forceFullWidth;
final bool hasDraft;
final Widget child;
const _ComposerDockFrame({
required this.expansionAnimation,
required this.forceFullWidth,
required this.hasDraft,
required this.child,
});
@override
Widget build(BuildContext context) {
final reducedMotion = MediaQuery.disableAnimationsOf(context);
final recordingTransition = useAnimationController(
duration: reducedMotion
? Duration.zero
: const Duration(milliseconds: 200),
reverseDuration: reducedMotion
? Duration.zero
: const Duration(milliseconds: 140),
initialValue: forceFullWidth ? 1 : 0,
);
useEffect(() {
if (forceFullWidth) {
recordingTransition.value = math.max(
recordingTransition.value,
expansionAnimation.value.clamp(0.0, 1.0),
);
recordingTransition.forward();
} else {
recordingTransition.reverse();
}
return null;
}, [forceFullWidth, reducedMotion]);
const compactVerticalOffset = Grid.twelve + Grid.quarter;
final visibleBottomGutter = math.max(
Grid.twelve,
MediaQuery.viewPaddingOf(context).bottom +
Grid.xxs -
compactVerticalOffset,
);
final recordingGutterDelta = visibleBottomGutter - Grid.twelve;
final appView = View.of(context);
final restingBackdropHeight = mobileTabFooterBackdropHeight(context);
// The fade gives up one point per point of keyboard travel until it
// reaches its keyboard-up height, so it is continuous while the keyboard
// opens, closes or changes height. Clamping here also means the dock only
// rebuilds while the fade is actually changing.
final fadeTravel = restingBackdropHeight - _keyboardUpBackdropHeight;
double fadeInset(double physicalInset) =>
math.min(physicalInset / appView.devicePixelRatio, fadeTravel);
final keyboardFadeInset = useState(fadeInset(appView.viewInsets.bottom));
useEffect(() {
final observer = _ComposerKeyboardMetricsObserver(
view: appView,
onKeyboardShown: () {},
onKeyboardHidden: () {},
// View insets are physical pixels; the fade is logical.
onKeyboardInsetChanged: (inset) =>
keyboardFadeInset.value = fadeInset(inset),
);
WidgetsBinding.instance.addObserver(observer);
return () {
WidgetsBinding.instance.removeObserver(observer);
observer.dispose();
};
}, [appView, fadeTravel]);
final backdropHeight = restingBackdropHeight - keyboardFadeInset.value;
return Stack(
clipBehavior: Clip.none,
children: [
Positioned(
key: const ValueKey('composer-footer-gradient'),
left: 0,
right: 0,
bottom: 0,
height: backdropHeight,
child: IgnorePointer(
child: MobileTabFooterBackdrop(height: backdropHeight),
),
),
Padding(
padding: EdgeInsets.only(
left: composerHorizontalGutter,
right: composerHorizontalGutter,
bottom: MediaQuery.viewPaddingOf(context).bottom + Grid.xxs,
),
child: Align(
alignment: Alignment.bottomCenter,
child: AnimatedBuilder(
animation: Listenable.merge([
expansionAnimation,
recordingTransition,
]),
child: child,
builder: (context, child) {
final widthProgress = math.max(
expansionAnimation.value.clamp(0.0, 1.0),
recordingTransition.value,
);
final expansionProgress = expansionAnimation.value.clamp(
0.0,
1.0,
);
final compactPositionProgress = 1 - expansionProgress;
return Transform.translate(
key: const ValueKey('composer-position-transition'),
offset: Offset(
0,
compactVerticalOffset * compactPositionProgress,
),
child: Padding(
key: const ValueKey('composer-recording-outer-gutter'),
padding: EdgeInsets.symmetric(
horizontal: forceFullWidth
? recordingGutterDelta * compactPositionProgress
: 0,
),
child: FractionallySizedBox(
key: const ValueKey('composer-width-transition'),
widthFactor: hasDraft
? 1
: collapsedComposerWidthFactor +
(1 - collapsedComposerWidthFactor) *
widthProgress,
child: child,
),
),
);
},
),
),
),
],
);
}
}
class _ComposerOverlayPortal extends StatelessWidget {
final bool suppressed;
final OverlayPortalController controller;
final ValueListenable<_AttachmentSurface> attachmentSurface;
final bool reducedMotion;
final Widget Function(_AttachmentSurface surface) buildOverlayPanel;
final VoidCallback onDismissAttachmentSurface;
final Widget child;
const _ComposerOverlayPortal({
this.suppressed = false,
required this.controller,
required this.attachmentSurface,
required this.reducedMotion,
required this.buildOverlayPanel,
required this.onDismissAttachmentSurface,
required this.child,
});
@override
Widget build(BuildContext context) {
return OverlayPortal.overlayChildLayoutBuilder(
controller: controller,
overlayChildBuilder: (context, layoutInfo) {
if (suppressed) return const SizedBox.shrink();
final composerOrigin = MatrixUtils.transformPoint(
layoutInfo.childPaintTransform,
Offset.zero,
);
return ValueListenableBuilder<_AttachmentSurface>(
valueListenable: attachmentSurface,
builder: (context, surface, _) {
final surfaceDuration = reducedMotion
? Duration.zero
: Duration(
milliseconds:
surface == _AttachmentSurface.camera ||
surface == _AttachmentSurface.photos
? 320
: 250,
);
final expandedSurfaceCoversComposer =
surface == _AttachmentSurface.camera ||
surface == _AttachmentSurface.photos;
final surfaceLeft = expandedSurfaceCoversComposer
? Grid.twelve
: composerOrigin.dx;
final surfaceWidth = expandedSurfaceCoversComposer
? layoutInfo.overlaySize.width - (Grid.twelve * 2)
: layoutInfo.childSize.width;
final overlayAnchorY =
composerOrigin.dy +
(expandedSurfaceCoversComposer
? layoutInfo.childSize.height + Grid.twelve
: 0);
return Stack(
children: [
if (surface != _AttachmentSurface.closed)
Positioned(
left: 0,
top: 0,
right: 0,
height: composerOrigin.dy,
child: ExcludeSemantics(
child: GestureDetector(
key: const ValueKey('attachment-dismiss-barrier'),
behavior: HitTestBehavior.opaque,
onTap: onDismissAttachmentSurface,
),
),
),
AnimatedPositioned(
duration: surfaceDuration,
curve:
surface == _AttachmentSurface.camera ||
surface == _AttachmentSurface.photos
? const Cubic(0.34, 1.25, 0.64, 1)
: const Cubic(0.22, 1, 0.36, 1),
left: surfaceLeft,
bottom: layoutInfo.overlaySize.height - overlayAnchorY,
width: surfaceWidth,
child: ConstrainedBox(
// The suggestions grow upward from the composer, so cap
// them at the space above it. A short view, such as
// landscape with the keyboard up, then keeps the top row
// on screen instead of honoring a reserved height.
constraints: BoxConstraints(
maxHeight: surface == _AttachmentSurface.closed
? math.max(
0,
overlayAnchorY -
MediaQuery.paddingOf(context).top,
)
: double.infinity,
),
child: ClipRect(
child: Padding(
padding: const EdgeInsets.only(bottom: Grid.xxs),
child: buildOverlayPanel(surface),
),
),
),
),
],
);
},
);
},
child: child,
);
}
}