mirror of
https://github.com/block/buzz.git
synced 2026-10-30 22:11:36 +00:00
## Summary - add inline profile photo capture with smooth avatar-to-viewfinder transitions - add close, flip, shutter, retry, and use-photo states with haptics and front-camera mirroring - polish iOS liquid-glass controls and avatar editor motion ### Related issue Follow-up to #6583. ### Testing - just mobile-check - just mobile-test (1,743 tests) - built, installed, and launched on Pixel 10 and iPhone Air --------- Signed-off-by: kenny lopez <klopez4212@gmail.com> Signed-off-by: Code Reviewer <037593536284cf40e221c96c931e9877d4166d54f6bb84e5341a86d7fd5d05a4@buzz.block.builderlab.xyz> Signed-off-by: Perci <5a968df9a7494b4e019b9ecf739e088ba61097b4312124e9a88ae5b42e3f5f3e@buzz.block.builderlab.xyz> Signed-off-by: Max <d8473ee32b973aa31a21a65adddcc4b69cc2a8a4dee8121ecd51926e0cddbc02@buzz.block.builderlab.xyz> Signed-off-by: Wren <5217c5c2f7bfb4333e46d17c98a9255a52dadee18dcd43a43536b95e6776dfa0@buzz.block.builderlab.xyz> Signed-off-by: Meli <5aaa86bce934fc3445fc254aab560a40923f10252f92107e665073dede0e04d3@buzz.block.builderlab.xyz> Signed-off-by: morgmart <98432065+morgmart@users.noreply.github.com> Co-authored-by: Code Reviewer <037593536284cf40e221c96c931e9877d4166d54f6bb84e5341a86d7fd5d05a4@buzz.block.builderlab.xyz> Co-authored-by: Tyler <109685178+tlongwell-block@users.noreply.github.com> Co-authored-by: Perci <5a968df9a7494b4e019b9ecf739e088ba61097b4312124e9a88ae5b42e3f5f3e@buzz.block.builderlab.xyz> Co-authored-by: Max <d8473ee32b973aa31a21a65adddcc4b69cc2a8a4dee8121ecd51926e0cddbc02@buzz.block.builderlab.xyz> Co-authored-by: Wren <5217c5c2f7bfb4333e46d17c98a9255a52dadee18dcd43a43536b95e6776dfa0@buzz.block.builderlab.xyz> Co-authored-by: Meli <5aaa86bce934fc3445fc254aab560a40923f10252f92107e665073dede0e04d3@buzz.block.builderlab.xyz> Co-authored-by: morgmart <98432065+morgmart@users.noreply.github.com> Co-authored-by: Claude <noreply@anthropic.com>
72 lines
2.1 KiB
Dart
72 lines
2.1 KiB
Dart
import 'dart:async';
|
|
|
|
/// Serializes camera teardown so replacement sessions never overlap.
|
|
///
|
|
/// A native disposal failure is intentionally contained: callers can proceed
|
|
/// with the next camera session after the failed release has settled.
|
|
class CameraDisposalBarrier {
|
|
Future<void> _pending = Future<void>.value();
|
|
|
|
/// Reserves camera ownership while a controller is initializing.
|
|
CameraDisposalReservation reserve() {
|
|
final reservation = CameraDisposalReservation._(_pending);
|
|
_pending = reservation._settled;
|
|
return reservation;
|
|
}
|
|
|
|
/// Completes after earlier and [dispose] callbacks have settled.
|
|
///
|
|
/// Exceptions from [dispose] are handled so they cannot prevent a later
|
|
/// replacement session from acquiring the camera.
|
|
Future<void> release(Future<void> Function() dispose) {
|
|
final previous = _pending;
|
|
final release = () async {
|
|
await previous;
|
|
try {
|
|
await dispose();
|
|
} catch (_) {
|
|
// A failed native release must not permanently block camera recovery.
|
|
}
|
|
}();
|
|
_pending = release;
|
|
return release;
|
|
}
|
|
|
|
/// Completes once all scheduled teardown work has settled.
|
|
Future<void> get settled => _pending;
|
|
}
|
|
|
|
/// Owns one in-flight camera initialization in a [CameraDisposalBarrier].
|
|
class CameraDisposalReservation {
|
|
CameraDisposalReservation._(this._previous) {
|
|
_settled = () async {
|
|
await _previous;
|
|
await _completion.future;
|
|
}();
|
|
}
|
|
|
|
final Future<void> _previous;
|
|
final _completion = Completer<void>();
|
|
late final Future<void> _settled;
|
|
|
|
/// Waits for older camera teardown before this candidate initializes.
|
|
Future<void> get ready => _previous;
|
|
|
|
/// Releases this reservation after a successful initialization.
|
|
void complete() {
|
|
if (!_completion.isCompleted) _completion.complete();
|
|
}
|
|
|
|
/// Disposes a failed or cancelled candidate before allowing replacement.
|
|
Future<void> dispose(Future<void> Function() release) async {
|
|
await _previous;
|
|
try {
|
|
await release();
|
|
} catch (_) {
|
|
// A failed native release must not permanently block camera recovery.
|
|
} finally {
|
|
complete();
|
|
}
|
|
}
|
|
}
|