From 7abc0efc6c4227000d356d1dc9b72a2ad851aaf4 Mon Sep 17 00:00:00 2001 From: Edouard Marquez Date: Sat, 29 Jul 2023 19:22:16 +0200 Subject: [PATCH] When there is no camera, show the search card in fullscreen (#4354) --- .../smooth_app/lib/pages/scan/scan_page.dart | 41 ++++++++++--------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/packages/smooth_app/lib/pages/scan/scan_page.dart b/packages/smooth_app/lib/pages/scan/scan_page.dart index 89c986e159f..cdf39d377e4 100644 --- a/packages/smooth_app/lib/pages/scan/scan_page.dart +++ b/packages/smooth_app/lib/pages/scan/scan_page.dart @@ -12,6 +12,7 @@ import 'package:smooth_app/generic_lib/design_constants.dart'; import 'package:smooth_app/generic_lib/dialogs/smooth_alert_dialog.dart'; import 'package:smooth_app/generic_lib/widgets/smooth_card.dart'; import 'package:smooth_app/helpers/app_helper.dart'; +import 'package:smooth_app/helpers/camera_helper.dart'; import 'package:smooth_app/helpers/haptic_feedback_helper.dart'; import 'package:smooth_app/helpers/permission_helper.dart'; import 'package:smooth_app/pages/scan/camera_scan_page.dart'; @@ -65,6 +66,7 @@ class _ScanPageState extends State { final AppLocalizations appLocalizations = AppLocalizations.of(context); final TextDirection direction = Directionality.of(context); + final bool hasACamera = CameraHelper.hasACamera; return SmoothScaffold( brightness: @@ -74,26 +76,27 @@ class _ScanPageState extends State { body: SafeArea( child: Column( children: [ - Expanded( - flex: 100 - _carouselHeightPct, - child: Consumer( - builder: ( - BuildContext context, - PermissionListener listener, - _, - ) { - switch (listener.value.status) { - case DevicePermissionStatus.checking: - return EMPTY_WIDGET; - case DevicePermissionStatus.granted: - // TODO(m123): change - return const CameraScannerPage(); - default: - return const _PermissionDeniedCard(); - } - }, + if (hasACamera) + Expanded( + flex: 100 - _carouselHeightPct, + child: Consumer( + builder: ( + BuildContext context, + PermissionListener listener, + _, + ) { + switch (listener.value.status) { + case DevicePermissionStatus.checking: + return EMPTY_WIDGET; + case DevicePermissionStatus.granted: + // TODO(m123): change + return const CameraScannerPage(); + default: + return const _PermissionDeniedCard(); + } + }, + ), ), - ), Expanded( flex: _carouselHeightPct, child: Padding(