From 9436a5909473cacc85c40c1aaeaf21fd7e8698f9 Mon Sep 17 00:00:00 2001 From: Vadim <44135514+vodemn@users.noreply.github.com> Date: Sun, 5 Feb 2023 16:56:04 +0300 Subject: [PATCH] Added camera and exposurepairs list placeholders --- lib/l10n/intl_en.arb | 1 + lib/providers/theme_provider.dart | 12 ++++--- .../widget_bottom_controls.dart | 4 +-- .../widget_placeholder_camera_view.dart | 14 ++++++++ .../widget_container_camera.dart | 13 ++++---- .../widget_container_light_sensor.dart | 2 +- .../widget_list_exposure_pairs_empty.dart | 32 +++++++++++++++++++ .../widget_list_exposure_pairs.dart | 4 +++ 8 files changed, 67 insertions(+), 15 deletions(-) create mode 100644 lib/screens/metering/components/camera_container/components/camera_view_placeholder/widget_placeholder_camera_view.dart create mode 100644 lib/screens/metering/components/shared/exposure_pairs_list/components/empty_exposure_pairs_list/widget_list_exposure_pairs_empty.dart diff --git a/lib/l10n/intl_en.arb b/lib/l10n/intl_en.arb index 7046d31..c984bce 100644 --- a/lib/l10n/intl_en.arb +++ b/lib/l10n/intl_en.arb @@ -17,6 +17,7 @@ "filmSpeed": "Film speed", "nd": "ND", "ndFilterFactor": "Neutral density filter factor", + "noExposurePairs": "There are no exposure pairs for the selected settings.", "none": "None", "cancel": "Cancel", "select": "Select", diff --git a/lib/providers/theme_provider.dart b/lib/providers/theme_provider.dart index 840d4fa..70d008d 100644 --- a/lib/providers/theme_provider.dart +++ b/lib/providers/theme_provider.dart @@ -224,16 +224,18 @@ class _ThemeDataProvider extends StatelessWidget { return ColorScheme( brightness: brightness, + background: Color(scheme.background), + error: Color(scheme.error), + errorContainer: Color(scheme.errorContainer), + onBackground: Color(scheme.onBackground), + onError: Color(scheme.onError), + onErrorContainer: Color(scheme.onErrorContainer), primary: Color(scheme.primary), onPrimary: Color(scheme.onPrimary), primaryContainer: Color(scheme.primaryContainer), onPrimaryContainer: Color(scheme.onPrimaryContainer), secondary: Color(scheme.secondary), onSecondary: Color(scheme.onSecondary), - error: Color(scheme.error), - onError: Color(scheme.onError), - background: Color(scheme.background), - onBackground: Color(scheme.onBackground), surface: Color.alphaBlend( Color(scheme.primary).withOpacity(0.05), Color(scheme.background), @@ -244,6 +246,8 @@ class _ThemeDataProvider extends StatelessWidget { Color(scheme.background), ), onSurfaceVariant: Color(scheme.onSurfaceVariant), + outline: Color(scheme.outline), + outlineVariant: Color(scheme.outlineVariant), ); } } diff --git a/lib/screens/metering/components/bottom_controls/widget_bottom_controls.dart b/lib/screens/metering/components/bottom_controls/widget_bottom_controls.dart index 9f3f0a2..a8001d8 100644 --- a/lib/screens/metering/components/bottom_controls/widget_bottom_controls.dart +++ b/lib/screens/metering/components/bottom_controls/widget_bottom_controls.dart @@ -46,9 +46,7 @@ class MeteringBottomControls extends StatelessWidget { ) else const Spacer(), - MeteringMeasureButton( - onTap: onMeasure, - ), + MeteringMeasureButton(onTap: onMeasure), Expanded( child: Center( child: IconButton( diff --git a/lib/screens/metering/components/camera_container/components/camera_view_placeholder/widget_placeholder_camera_view.dart b/lib/screens/metering/components/camera_container/components/camera_view_placeholder/widget_placeholder_camera_view.dart new file mode 100644 index 0000000..5b73922 --- /dev/null +++ b/lib/screens/metering/components/camera_container/components/camera_view_placeholder/widget_placeholder_camera_view.dart @@ -0,0 +1,14 @@ +import 'package:flutter/material.dart'; +import 'package:lightmeter/res/dimens.dart'; + +class CameraViewPlaceholder extends StatelessWidget { + const CameraViewPlaceholder({super.key}); + + @override + Widget build(BuildContext context) { + return Card( + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(Dimens.borderRadiusM)), + child: const Center(child: Icon(Icons.no_photography)), + ); + } +} diff --git a/lib/screens/metering/components/camera_container/widget_container_camera.dart b/lib/screens/metering/components/camera_container/widget_container_camera.dart index 5d46616..d73765f 100644 --- a/lib/screens/metering/components/camera_container/widget_container_camera.dart +++ b/lib/screens/metering/components/camera_container/widget_container_camera.dart @@ -12,6 +12,7 @@ import 'package:lightmeter/screens/metering/components/shared/readings_container import 'bloc_container_camera.dart'; import 'components/camera_controls/widget_camera_controls.dart'; +import 'components/camera_view_placeholder/widget_placeholder_camera_view.dart'; import 'event_container_camera.dart'; import 'state_container_camera.dart'; @@ -76,13 +77,11 @@ class _CameraViewBuilder extends StatelessWidget { Widget build(BuildContext context) { return AspectRatio( aspectRatio: PlatformConfig.cameraPreviewAspectRatio, - child: Center( - child: BlocBuilder( - buildWhen: (previous, current) => current is CameraInitializedState, - builder: (context, state) => state is CameraInitializedState - ? CameraView(controller: state.controller) - : const ColoredBox(color: Colors.black), - ), + child: BlocBuilder( + buildWhen: (previous, current) => current is CameraInitializedState, + builder: (context, state) => state is CameraInitializedState + ? Center(child: CameraView(controller: state.controller)) + : const CameraViewPlaceholder(), ), ); } diff --git a/lib/screens/metering/components/light_sensor_container/widget_container_light_sensor.dart b/lib/screens/metering/components/light_sensor_container/widget_container_light_sensor.dart index 1bec2da..e8019d0 100644 --- a/lib/screens/metering/components/light_sensor_container/widget_container_light_sensor.dart +++ b/lib/screens/metering/components/light_sensor_container/widget_container_light_sensor.dart @@ -44,7 +44,7 @@ class LightSensorContainer extends StatelessWidget { Expanded( child: Padding( padding: const EdgeInsets.symmetric(horizontal: Dimens.paddingM), - child: ExposurePairsList(exposurePairs), + child: Center(child: ExposurePairsList(exposurePairs)), ), ), ], diff --git a/lib/screens/metering/components/shared/exposure_pairs_list/components/empty_exposure_pairs_list/widget_list_exposure_pairs_empty.dart b/lib/screens/metering/components/shared/exposure_pairs_list/components/empty_exposure_pairs_list/widget_list_exposure_pairs_empty.dart new file mode 100644 index 0000000..ea6728f --- /dev/null +++ b/lib/screens/metering/components/shared/exposure_pairs_list/components/empty_exposure_pairs_list/widget_list_exposure_pairs_empty.dart @@ -0,0 +1,32 @@ +import 'package:flutter/material.dart'; +import 'package:lightmeter/generated/l10n.dart'; +import 'package:lightmeter/res/dimens.dart'; + +class EmptyExposurePairsList extends StatelessWidget { + const EmptyExposurePairsList({super.key}); + + @override + Widget build(BuildContext context) { + return ConstrainedBox( + constraints: BoxConstraints(maxWidth: MediaQuery.of(context).size.width / 2), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Icon( + Icons.not_interested, + color: Theme.of(context).colorScheme.onBackground, + ), + const SizedBox(height: Dimens.grid8), + Text( + S.of(context).noExposurePairs, + style: Theme.of(context) + .textTheme + .bodyMedium + ?.copyWith(color: Theme.of(context).colorScheme.onBackground), + textAlign: TextAlign.center, + ), + ], + ), + ); + } +} diff --git a/lib/screens/metering/components/shared/exposure_pairs_list/widget_list_exposure_pairs.dart b/lib/screens/metering/components/shared/exposure_pairs_list/widget_list_exposure_pairs.dart index df758af..11c0f9e 100644 --- a/lib/screens/metering/components/shared/exposure_pairs_list/widget_list_exposure_pairs.dart +++ b/lib/screens/metering/components/shared/exposure_pairs_list/widget_list_exposure_pairs.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:lightmeter/data/models/exposure_pair.dart'; import 'package:lightmeter/res/dimens.dart'; +import 'components/empty_exposure_pairs_list/widget_list_exposure_pairs_empty.dart'; import 'components/exposure_pairs_list_item/widget_item_list_exposure_pairs.dart'; class ExposurePairsList extends StatelessWidget { @@ -11,6 +12,9 @@ class ExposurePairsList extends StatelessWidget { @override Widget build(BuildContext context) { + if (exposurePairs.isEmpty) { + return const EmptyExposurePairsList(); + } return Stack( alignment: Alignment.center, children: [