Files
buzz/mobile/lib/features/channels/compose_bar/dock.dart
klopez4212 d647c9fd98 Refine iOS composer and transcribe recordings into drafts (#9574)
Refine the iOS composer with 40-point glass controls, native attachment
menus, persistent emoji access, and selected-text formatting. The mic
now transcribes recordings on device into an editable, unsent draft;
Dictation has no five-minute recording cap or timer label, and its
waveform fills the space between the controls. Voice note remains
available in attachments with its five-minute cap. Unsupported devices
fail before recording, and audio is retained until the draft is durably
saved. Stopped dictation remains recoverable across editor teardown;
failed retention and cleanup can be retried. Recovered transcripts are
inserted only once across navigation or restart, preserving live exact
mention bindings.

Preserve selection handles over glass with animated avatars. Reduce the
conversation fade to 100 points above the keyboard and transition
continuously to 180 as the keyboard closes, without a first-frame jump
when opening; Home is unchanged.

Validation: 5,117 mobile tests and 27 crypto tests pass; analysis
passes. Prior native suite on iPhone 16/iOS 26.5: 119 pass, one
pre-existing expected failure, zero unexpected failures. Physical Air
preview approved; simulator selection/dragging and attachment flows
exercised. Fixed the native navigation test's timing race and a
community-cache cleanup test that checked a parent directory before its
asynchronous removal completed. Repository-wide `just ci` previously
stopped in unchanged `buzz-test-client` load-generator tests; new-head
hosted checks are pending.

Snapshots: production composer in an iPhone Air simulator fixture with
fictional conversation text; Photos snapshot retained from the
attachment preview.

| Composer | Attachments | Photos |
| --- | --- | --- |
| ![Keyboard-up
composer](https://github.com/user-attachments/assets/b7c8f0a4-25f8-4ca2-b8ae-11e18655e64a)
| ![Native attachment
menu](https://github.com/user-attachments/assets/5eaf5259-8e04-4da7-93f5-1b2eccab3c3c)
|
![Photos](https://github.com/user-attachments/assets/a6216b7d-5eaf-482c-b587-6052825b88fc)
|

---------

Signed-off-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz>
Signed-off-by: Tom Brow <tomb@squareup.com>
Signed-off-by: Princess Donut <b238ea756dee4d98afa5883fc7f1de61eeabe65bf700e3a5a5a80db5e42e2c2b@buzz.block.builderlab.xyz>
Signed-off-by: Tom Brow <tomb@block.xyz>
Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz>
Co-authored-by: Tom Brow <tomb@block.xyz>
Co-authored-by: Tom Brow <tomb@squareup.com>
Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@buzz.block.builderlab.xyz>
Co-authored-by: Princess Donut <b238ea756dee4d98afa5883fc7f1de61eeabe65bf700e3a5a5a80db5e42e2c2b@buzz.block.builderlab.xyz>
2026-11-20 16:35:20 +00:00

255 lines
9.4 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 Widget child;
const _ComposerDockFrame({
required this.expansionAnimation,
required this.forceFullWidth,
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:
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,
);
}
}