Skip to content

Commit 7c165c3

Browse files
klopez4212Terp
andauthored
Smooth profile avatar editor transitions (#8640)
Smooths profile avatar editing with concurrent 200 ms entry/return transitions, fixed-size circle movement between tabs, and a crossfade to the dotted placeholder on cancel. New empty avatars open on Emoji, ready to save. Review fixes: keep the suggested emoji separate from the Image fallback, and preserve native editor transparency across appearance changes. Regression journeys cover empty Image previews, retained Emoji selection, and light/dark updates. Validation: focused Flutter journeys pass; restoring the old baseline fails both fresh-editor regressions. At `bffb83f5e`: full Flutter suite and push checks passed; all 107 native tests passed on the iOS simulator. Prior iPhone visual approval covers the transition work; these review fixes still need a device check. Follow-up to #8628. --------- Signed-off-by: kenny lopez <[email protected]> Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz>
1 parent 6e332f4 commit 7c165c3

7 files changed

Lines changed: 451 additions & 102 deletions

File tree

‎mobile/ios/Runner/NativeProfileSetup.swift‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ final class NativeProfileSetupCoordinator: NSObject, UIAdaptivePresentationContr
4040
let controller = self.navigation?.viewControllers.first as? NativeProfileSetupController else { result(nil); return }
4141
self.navigation?.overrideUserInterfaceStyle = args["dark"] as? Bool == true ? .dark : .light
4242
controller.updateAppearance(args)
43-
self.avatarController?.view.backgroundColor = controller.view.backgroundColor
4443
self.updateEditorAppearance(controller)
4544
result(nil); return
4645
}
@@ -136,6 +135,7 @@ final class NativeProfileSetupCoordinator: NSObject, UIAdaptivePresentationContr
136135
return
137136
}
138137
if call.method == "controls", let state = call.arguments as? [String: Any] {
138+
guard !finishing else { result(nil); return }
139139
self.editorCanDone = state["canDone"] as? Bool ?? false
140140
self.editorBusy = state["busy"] as? Bool ?? false
141141
let fullScreen = state["fullScreen"] as? Bool == true
@@ -152,6 +152,11 @@ final class NativeProfileSetupCoordinator: NSObject, UIAdaptivePresentationContr
152152
let draft = call.arguments as? [String: Any]
153153
func returnToProfile() {
154154
controller.navigationItem.setRightBarButton(nil, animated: false)
155+
// Restore the native chrome alongside Flutter's exit. The transparent
156+
// editor reveals it during the animation; the final handoff must not
157+
// restart it or allow another navigation action mid-transition.
158+
controller.view.isUserInteractionEnabled = false
159+
controller.navigationItem.leftBarButtonItem?.isEnabled = false
155160
controller.setEditorVisible(false)
156161
let frame = controller.editorFrame
157162
let rect = controller.avatarFrame(in: controller.view).offsetBy(dx: -frame.minX, dy: -frame.minY)
@@ -180,7 +185,8 @@ final class NativeProfileSetupCoordinator: NSObject, UIAdaptivePresentationContr
180185
let editor = FlutterViewController(engine: engine, nibName: nil, bundle: nil)
181186
avatarController = editor
182187
engine.registrar(forPlugin: "BuzzIosNavigationBar")?.register(IosNavigationBarFactory(messenger: messenger, parent: editor), withId: "buzz/ios_navigation_bar")
183-
editor.view.backgroundColor = controller.view.backgroundColor
188+
editor.isViewOpaque = false
189+
editor.view.backgroundColor = .clear
184190
controller.addChild(editor)
185191
editor.view.frame = editorFrame
186192
editor.view.autoresizingMask = [.flexibleWidth, .flexibleHeight]
@@ -229,6 +235,8 @@ final class NativeProfileSetupCoordinator: NSObject, UIAdaptivePresentationContr
229235
if let enabled = previousInteractivePopEnabled { navigation?.interactivePopGestureRecognizer?.isEnabled = enabled }
230236
previousInteractivePopEnabled = nil
231237
disabledSheetPans.forEach { $0.isEnabled = true }; disabledSheetPans.removeAll()
238+
controller?.view.isUserInteractionEnabled = true
239+
controller?.navigationItem.leftBarButtonItem?.isEnabled = true
232240
controller?.setEditorVisible(false)
233241
controller?.setAvatarHidden(false)
234242
controller?.avatarReady()
@@ -422,6 +430,7 @@ private final class NativeProfileSetupController: UIViewController, UITextFieldD
422430
return CGRect(x: 0, y: top, width: view.bounds.width, height: max(0, view.safeAreaLayoutGuide.layoutFrame.maxY - top))
423431
}
424432
func setEditorVisible(_ visible: Bool) {
433+
guard editingAvatar != visible else { return }
425434
editingAvatar = visible
426435
heading.accessibilityElementsHidden = visible
427436
explanationRow.accessibilityElementsHidden = visible

‎mobile/ios/RunnerTests/ProfileSetupRecoveryTests.swift‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,16 @@ final class ProfileSetupRecoveryTests: XCTestCase {
131131
XCTAssertEqual(profile.navigationItem.rightBarButtonItem?.title, "Done")
132132
XCTAssertFalse(profile.navigationItem.rightBarButtonItem?.isEnabled ?? true)
133133
XCTAssertTrue(profile.navigationItem.leftBarButtonItem?.isEnabled ?? false)
134-
XCTAssertTrue(profile.children.contains { $0 is FlutterViewController })
134+
let editor = profile.children.compactMap { $0 as? FlutterViewController }.first
135+
XCTAssertEqual(editor?.isViewOpaque, false, "Native chrome must remain visible through the exiting editor")
136+
XCTAssertEqual(editor?.view.backgroundColor, UIColor.clear)
137+
for dark in [false, true] {
138+
messenger.invoke("appearance", arguments: ["session": 81, "dark": dark,
139+
"pageBackgroundArgb": dark ? 0xFF000000 : 0xFFFFFFFF])
140+
XCTAssertEqual(editor?.isViewOpaque, false)
141+
XCTAssertEqual(editor?.view.backgroundColor, UIColor.clear)
142+
XCTAssertEqual(nav.overrideUserInterfaceStyle, dark ? .dark : .light)
143+
}
135144
XCTAssertFalse(pan.isEnabled)
136145
XCTAssertFalse(nav.interactivePopGestureRecognizer?.isEnabled ?? true)
137146
XCTAssertTrue(nav.isModalInPresentation)

‎mobile/lib/features/profile/animated_avatar_capture.dart‎

Lines changed: 98 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ class AnimatedAvatarCapture extends HookConsumerWidget {
4848
this.disposalBarrier,
4949
this.previewKey,
5050
this.previewSize,
51+
this.controlsTransitionProgress = 1,
52+
this.previewOffset = 0,
5153
});
5254

5355
/// Identifies the visible avatar for the native sheet transition.
@@ -56,6 +58,12 @@ class AnimatedAvatarCapture extends HookConsumerWidget {
5658
/// Fixed visible preview diameter when hosted in profile setup.
5759
final double? previewSize;
5860

61+
/// Entrance progress for the controls, independent of the fixed-size preview.
62+
final double controlsTransitionProgress;
63+
64+
/// Moves the capture circle independently of its controls during tab changes.
65+
final double previewOffset;
66+
5967
/// The vertical space available to the capture surface.
6068
final double height;
6169

@@ -590,90 +598,108 @@ class AnimatedAvatarCapture extends HookConsumerWidget {
590598
Widget captureContent() => Column(
591599
mainAxisSize: MainAxisSize.min,
592600
children: [
593-
SizedBox.square(
594-
key: const ValueKey('animated-avatar-capture-preview'),
595-
dimension: capturePreviewSize,
596-
child: Stack(
597-
key: previewKey,
598-
fit: StackFit.expand,
599-
children: [
600-
Padding(
601-
padding: previewSize == null
602-
? const EdgeInsets.all(4)
603-
: EdgeInsets.zero,
604-
child: ClipOval(
605-
child: ColoredBox(
606-
color: Colors.black,
607-
child: isPreparingFrames.value
608-
? Center(
609-
child: BuzzLoadingIndicator(
610-
size: 44,
611-
color: context.colors.onSurface,
612-
semanticLabel: 'Preparing animated avatar',
601+
Transform.translate(
602+
offset: Offset(0, previewOffset),
603+
child: SizedBox.square(
604+
key: const ValueKey('animated-avatar-capture-preview'),
605+
dimension: capturePreviewSize,
606+
child: Stack(
607+
key: previewKey,
608+
fit: StackFit.expand,
609+
children: [
610+
Padding(
611+
padding: previewSize == null
612+
? const EdgeInsets.all(4)
613+
: EdgeInsets.zero,
614+
child: ClipOval(
615+
child: ColoredBox(
616+
color: Colors.black,
617+
child: isPreparingFrames.value
618+
? Center(
619+
child: BuzzLoadingIndicator(
620+
size: 44,
621+
color: context.colors.onSurface,
622+
semanticLabel: 'Preparing animated avatar',
623+
),
624+
)
625+
: active != null
626+
? _AspectCorrectCameraPreview(controller: active)
627+
: Center(
628+
child: isInitializing.value
629+
? const BuzzLoadingIndicator(
630+
color: Colors.white,
631+
semanticLabel: 'Starting camera',
632+
)
633+
: const Icon(
634+
BuzzIcons.cameraOff,
635+
color: Colors.white,
636+
size: 32,
637+
),
613638
),
614-
)
615-
: active != null
616-
? _AspectCorrectCameraPreview(controller: active)
617-
: Center(
618-
child: isInitializing.value
619-
? const BuzzLoadingIndicator(
620-
color: Colors.white,
621-
semanticLabel: 'Starting camera',
622-
)
623-
: const Icon(
624-
BuzzIcons.cameraOff,
625-
color: Colors.white,
626-
size: 32,
627-
),
628-
),
639+
),
629640
),
630641
),
631-
),
632-
if (isRecording.value)
633-
Padding(
634-
// A progress stroke is centred on its circular path. Inset
635-
// it so the outer half is not clipped by the preview stack.
636-
padding: const EdgeInsets.all(2),
637-
child: CircularProgressIndicator(
638-
key: const ValueKey('animated-avatar-recording-ring'),
639-
value: progress.value,
640-
strokeWidth: 4,
641-
strokeCap: StrokeCap.round,
642-
color: context.colors.onSurface,
643-
backgroundColor: context.colors.outlineVariant,
642+
if (isRecording.value)
643+
Padding(
644+
// A progress stroke is centred on its circular path. Inset
645+
// it so the outer half is not clipped by the preview stack.
646+
padding: const EdgeInsets.all(2),
647+
child: CircularProgressIndicator(
648+
key: const ValueKey('animated-avatar-recording-ring'),
649+
value: progress.value,
650+
strokeWidth: 4,
651+
strokeCap: StrokeCap.round,
652+
color: context.colors.onSurface,
653+
backgroundColor: context.colors.outlineVariant,
654+
),
644655
),
645-
),
646-
],
656+
],
657+
),
647658
),
648659
),
649-
const SizedBox(height: Grid.xs),
650-
Text(
651-
isRecording.value
652-
? 'Recording…'
653-
: isPreparingFrames.value
654-
? 'Cutting you out of the background…'
655-
: 'Line up your shot.',
656-
textAlign: TextAlign.center,
657-
style: context.textTheme.bodyMedium?.copyWith(
658-
color: context.colors.onSurfaceVariant,
660+
Transform.translate(
661+
key: const ValueKey('animated-avatar-controls-transition'),
662+
offset: Offset(0, 16 * (1 - controlsTransitionProgress)),
663+
child: Opacity(
664+
opacity: controlsTransitionProgress,
665+
child: Column(
666+
mainAxisSize: MainAxisSize.min,
667+
children: [
668+
const SizedBox(height: Grid.xs),
669+
Text(
670+
isRecording.value
671+
? 'Recording…'
672+
: isPreparingFrames.value
673+
? 'Cutting you out of the background…'
674+
: 'Line up your shot.',
675+
textAlign: TextAlign.center,
676+
style: context.textTheme.bodyMedium?.copyWith(
677+
color: context.colors.onSurfaceVariant,
678+
),
679+
),
680+
if (error.value != null) _ErrorText(error.value!),
681+
SizedBox(height: recordGap),
682+
_AnimatedRecordButton(
683+
busy: isRecording.value || isPreparingFrames.value,
684+
onPressed: active == null
685+
? null
686+
: () {
687+
unawaited(HapticFeedback.mediumImpact());
688+
unawaited(record());
689+
},
690+
),
691+
],
692+
),
659693
),
660694
),
661-
if (error.value != null) _ErrorText(error.value!),
662-
SizedBox(height: recordGap),
663-
_AnimatedRecordButton(
664-
busy: isRecording.value || isPreparingFrames.value,
665-
onPressed: active == null
666-
? null
667-
: () {
668-
unawaited(HapticFeedback.mediumImpact());
669-
unawaited(record());
670-
},
671-
),
672695
],
673696
);
674697
return SizedBox(
675698
height: height,
676-
child: SingleChildScrollView(child: captureContent()),
699+
child: SingleChildScrollView(
700+
clipBehavior: Clip.none,
701+
child: captureContent(),
702+
),
677703
);
678704
}
679705
}

0 commit comments

Comments
 (0)