mirror of
https://github.com/block/buzz.git
synced 2026-11-24 18:21:59 +00:00
Duo keeps conversations and Settings details open across closed, book and flat postures. Book mode splits at the fold; flattening restores the sidebar. Native rail controls, full-width navigation backdrops and sheet-local safe areas keep content aligned. Ordinary iPhones remain single-pane in portrait and landscape; tablet and Duo split layouts remain enabled. Includes the recovered preview's matching pane widths, Buzz empty-pane mark, stable Settings chevrons, Bestie pane routing and Duo-only upward New menu attachment. Current main's Activity redesign, Search content fade and unread-navigation button are retained. Menu selection checks sit beside their labels. Shared mobile changes remain in scope: the native iOS status editor, Appearance preview layout, avatar crop preservation, onboarding footer layout, profile/invite sheet geometry and nested conversation navigation. This PR is not exclusively Duo-gated. Nested navigator observers preserve recording cancellation and navigation callbacks; crop resizing preserves the selected image region. iOS 27.1 APIs remain compile-time and runtime gated. Validation on the reconciled source: Flutter analysis, Activity/Home journeys, the full mobile test suite, file-size checks and Swift package tests. The iPhone single-pane fix was also exercised on an iPhone 18 Pro simulator before reconciliation. Fresh hosted CI and physical-device confirmation of the reconciled build are separate and remain pending. --------- Signed-off-by: kenny lopez <klopez4212@gmail.com> Signed-off-by: Tom Brow <tomb@squareup.com> Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Tom Brow <tomb@block.xyz> Co-authored-by: Tom Brow <tomb@squareup.com>
113 lines
3.7 KiB
Dart
113 lines
3.7 KiB
Dart
part of '../pairing_qr_scanner.dart';
|
|
|
|
class _QrScannerCamera extends HookWidget {
|
|
const _QrScannerCamera({required this.controller, required this.onDetect});
|
|
|
|
final MobileScannerController controller;
|
|
final ValueChanged<BarcodeCapture> onDetect;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final cameraState = useState(controller.value);
|
|
useEffect(() {
|
|
var active = true;
|
|
void publish() {
|
|
if (active) cameraState.value = controller.value;
|
|
}
|
|
|
|
void changed() {
|
|
// The scanner can publish initialization state while its child builds.
|
|
if (WidgetsBinding.instance.schedulerPhase ==
|
|
SchedulerPhase.persistentCallbacks) {
|
|
WidgetsBinding.instance.addPostFrameCallback((_) => publish());
|
|
} else {
|
|
publish();
|
|
}
|
|
}
|
|
|
|
controller.addListener(changed);
|
|
return () {
|
|
active = false;
|
|
controller.removeListener(changed);
|
|
};
|
|
}, [controller]);
|
|
final state = cameraState.value;
|
|
final ready = state.isInitialized && state.isRunning;
|
|
final fold = FoldGeometry.of(context);
|
|
final correction = useFuture(
|
|
useMemoized(() async {
|
|
if (defaultTargetPlatform != TargetPlatform.iOS ||
|
|
fold.strip == null ||
|
|
!ready) {
|
|
return 0;
|
|
}
|
|
try {
|
|
return await _qrScannerPlatformChannel.invokeMethod<int>(
|
|
'previewRotationQuarterTurns',
|
|
state.deviceOrientation.name,
|
|
) ??
|
|
0;
|
|
} on PlatformException {
|
|
return 0;
|
|
} on MissingPluginException {
|
|
return 0;
|
|
}
|
|
}, [ready, fold.size, fold.strip?.rect, state.deviceOrientation]),
|
|
preserveState: false,
|
|
);
|
|
return AnimatedOpacity(
|
|
key: const ValueKey('qr-camera-ready-fade'),
|
|
opacity: ready || state.error != null ? 1 : 0,
|
|
duration: MediaQuery.disableAnimationsOf(context) || state.error != null
|
|
? Duration.zero
|
|
: const Duration(milliseconds: 230),
|
|
curve: Curves.easeOut,
|
|
child: RotatedBox(
|
|
key: const ValueKey('qr-camera-orientation'),
|
|
quarterTurns: state.error == null ? correction.data ?? 0 : 0,
|
|
child: MobileScanner(
|
|
controller: controller,
|
|
fit: BoxFit.cover,
|
|
errorBuilder: (context, error) {
|
|
final message = switch (error.errorCode) {
|
|
MobileScannerErrorCode.permissionDenied =>
|
|
'Camera permission is required to scan QR codes.\n\n'
|
|
'Please grant camera access in your device settings.',
|
|
_ =>
|
|
'Could not start camera: '
|
|
"${error.errorDetails?.message ?? 'unknown error'}",
|
|
};
|
|
return ColoredBox(
|
|
color: Colors.black,
|
|
child: Center(
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(Grid.sm),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Icon(
|
|
BuzzIcons.cameraOff,
|
|
size: 48,
|
|
color: Colors.white.withValues(alpha: 0.72),
|
|
),
|
|
const SizedBox(height: Grid.xs),
|
|
Text(
|
|
message,
|
|
textAlign: TextAlign.center,
|
|
style: context.textTheme.bodyMedium?.copyWith(
|
|
color: Colors.white.withValues(alpha: 0.72),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
},
|
|
onDetect: onDetect,
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|