From 7d23e3584a505a25654b94c2c621c44a70497277 Mon Sep 17 00:00:00 2001 From: Vadim Date: Tue, 21 Mar 2023 21:22:14 +0300 Subject: [PATCH] switched to local `Dimens` --- lib/res/dimens.dart | 11 +++- .../widget_container_camera.dart | 3 +- .../widget_container_light_sensor.dart | 1 + .../widget_item_list_exposure_pairs.dart | 1 + .../dialog_picker/widget_picker_dialog.dart | 26 ++++----- .../widget_picker_dialog_animated.dart | 8 +-- .../widget_container_readings.dart | 53 ++++++++++++++----- .../widget_container_equipment_profile.dart | 1 + .../screen_equipment_profile.dart | 1 + .../dialog_filter/widget_dialog_filter.dart | 1 + 10 files changed, 75 insertions(+), 31 deletions(-) diff --git a/lib/res/dimens.dart b/lib/res/dimens.dart index d9e279c..ce931e2 100644 --- a/lib/res/dimens.dart +++ b/lib/res/dimens.dart @@ -31,7 +31,8 @@ class Dimens { // TopBar /// Probably this is a bad practice, but with text size locked, the height is always 212 - static const double readingContainerHeight = 212; + static const double readingContainerSingleValueHeight = 76; + static const double readingContainerDefaultHeight = 212; // `CenteredSlider` static const double cameraSliderTrackHeight = grid4; @@ -47,8 +48,14 @@ class Dimens { paddingL, paddingM, ); - static const EdgeInsets dialogActionsPadding = EdgeInsets.fromLTRB( + static const EdgeInsets dialogIconTitlePadding = EdgeInsets.fromLTRB( paddingL, + 0, + paddingL, + paddingM, + ); + static const EdgeInsets dialogActionsPadding = EdgeInsets.fromLTRB( + paddingM, paddingM, paddingL, paddingL, 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 05877bf..a222f8a 100644 --- a/lib/screens/metering/components/camera_container/widget_container_camera.dart +++ b/lib/screens/metering/components/camera_container/widget_container_camera.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:lightmeter/data/models/exposure_pair.dart'; import 'package:lightmeter/platform_config.dart'; +import 'package:lightmeter/res/dimens.dart'; import 'package:lightmeter/screens/metering/components/camera_container/components/camera_view/widget_camera_view.dart'; import 'package:lightmeter/screens/metering/components/camera_container/models/camera_error_type.dart'; import 'package:lightmeter/screens/metering/components/shared/exposure_pairs_list/widget_list_exposure_pairs.dart'; @@ -44,7 +45,7 @@ class CameraContainer extends StatelessWidget { @override Widget build(BuildContext context) { - final topBarOverflow = Dimens.readingContainerHeight - + final topBarOverflow = Dimens.readingContainerDefaultHeight - ((MediaQuery.of(context).size.width - Dimens.grid8 - 2 * Dimens.paddingM) / 2) / PlatformConfig.cameraPreviewAspectRatio; return Column( 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 de2cc14..60e067d 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 @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:lightmeter/data/models/exposure_pair.dart'; +import 'package:lightmeter/res/dimens.dart'; import 'package:lightmeter/screens/metering/components/shared/exposure_pairs_list/widget_list_exposure_pairs.dart'; import 'package:lightmeter/screens/metering/components/shared/metering_top_bar/widget_top_bar_metering.dart'; import 'package:lightmeter/screens/metering/components/shared/readings_container/widget_container_readings.dart'; diff --git a/lib/screens/metering/components/shared/exposure_pairs_list/components/exposure_pairs_list_item/widget_item_list_exposure_pairs.dart b/lib/screens/metering/components/shared/exposure_pairs_list/components/exposure_pairs_list_item/widget_item_list_exposure_pairs.dart index c7fb384..9514fbe 100644 --- a/lib/screens/metering/components/shared/exposure_pairs_list/components/exposure_pairs_list_item/widget_item_list_exposure_pairs.dart +++ b/lib/screens/metering/components/shared/exposure_pairs_list/components/exposure_pairs_list_item/widget_item_list_exposure_pairs.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:lightmeter/res/dimens.dart'; import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart'; class ExposurePairsListItem extends StatelessWidget { diff --git a/lib/screens/metering/components/shared/readings_container/components/animated_dialog_picker/components/dialog_picker/widget_picker_dialog.dart b/lib/screens/metering/components/shared/readings_container/components/animated_dialog_picker/components/dialog_picker/widget_picker_dialog.dart index 1f758ba..62ba265 100644 --- a/lib/screens/metering/components/shared/readings_container/components/animated_dialog_picker/components/dialog_picker/widget_picker_dialog.dart +++ b/lib/screens/metering/components/shared/readings_container/components/animated_dialog_picker/components/dialog_picker/widget_picker_dialog.dart @@ -1,27 +1,27 @@ import 'package:flutter/material.dart'; import 'package:lightmeter/generated/l10n.dart'; -import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart'; +import 'package:lightmeter/res/dimens.dart'; typedef DialogPickerItemTitleBuilder = Widget Function(BuildContext context, T value); typedef DialogPickerItemTrailingBuilder = Widget? Function(T selected, T value); class DialogPicker extends StatefulWidget { final String title; - final String subtitle; + final String? subtitle; final T initialValue; final List values; final DialogPickerItemTitleBuilder itemTitleBuilder; - final DialogPickerItemTrailingBuilder itemTrailingBuilder; + final DialogPickerItemTrailingBuilder? itemTrailingBuilder; final VoidCallback onCancel; final ValueChanged onSelect; const DialogPicker({ required this.title, - required this.subtitle, + this.subtitle, required this.initialValue, required this.values, required this.itemTitleBuilder, - required this.itemTrailingBuilder, + this.itemTrailingBuilder, required this.onCancel, required this.onSelect, super.key, @@ -56,12 +56,14 @@ class _DialogPickerState extends State> { style: Theme.of(context).textTheme.headlineSmall!, textAlign: TextAlign.center, ), - const SizedBox(height: Dimens.grid16), - Text( - widget.subtitle, - style: Theme.of(context).textTheme.bodyMedium!, - textAlign: TextAlign.center, - ), + if (widget.subtitle != null) ...[ + const SizedBox(height: Dimens.grid16), + Text( + widget.subtitle!, + style: Theme.of(context).textTheme.bodyMedium!, + textAlign: TextAlign.center, + ), + ] ], ), ), @@ -79,7 +81,7 @@ class _DialogPickerState extends State> { style: Theme.of(context).textTheme.bodyLarge!, child: widget.itemTitleBuilder(context, widget.values[index]), ), - secondary: widget.itemTrailingBuilder(_selectedValue, widget.values[index]), + secondary: widget.itemTrailingBuilder?.call(_selectedValue, widget.values[index]), onChanged: (value) { if (value != null) { setState(() { diff --git a/lib/screens/metering/components/shared/readings_container/components/animated_dialog_picker/widget_picker_dialog_animated.dart b/lib/screens/metering/components/shared/readings_container/components/animated_dialog_picker/widget_picker_dialog_animated.dart index 4f4cafb..0bbdabc 100644 --- a/lib/screens/metering/components/shared/readings_container/components/animated_dialog_picker/widget_picker_dialog_animated.dart +++ b/lib/screens/metering/components/shared/readings_container/components/animated_dialog_picker/widget_picker_dialog_animated.dart @@ -6,21 +6,21 @@ import 'components/dialog_picker/widget_picker_dialog.dart'; class AnimatedDialogPicker extends StatelessWidget { final _key = GlobalKey(); final String title; - final String subtitle; + final String? subtitle; final T selectedValue; final List values; final DialogPickerItemTitleBuilder itemTitleBuilder; - final DialogPickerItemTrailingBuilder itemTrailingBuilder; + final DialogPickerItemTrailingBuilder? itemTrailingBuilder; final ValueChanged onChanged; final Widget closedChild; AnimatedDialogPicker({ required this.title, - required this.subtitle, + this.subtitle, required this.selectedValue, required this.values, required this.itemTitleBuilder, - required this.itemTrailingBuilder, + this.itemTrailingBuilder, required this.onChanged, required this.closedChild, super.key, diff --git a/lib/screens/metering/components/shared/readings_container/widget_container_readings.dart b/lib/screens/metering/components/shared/readings_container/widget_container_readings.dart index 37b5915..c6520f4 100644 --- a/lib/screens/metering/components/shared/readings_container/widget_container_readings.dart +++ b/lib/screens/metering/components/shared/readings_container/widget_container_readings.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:lightmeter/data/models/exposure_pair.dart'; import 'package:lightmeter/generated/l10n.dart'; import 'package:lightmeter/providers/equipment_profile_provider.dart'; +import 'package:lightmeter/res/dimens.dart'; import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart'; import 'components/animated_dialog_picker/widget_picker_dialog_animated.dart'; @@ -37,12 +38,11 @@ class ReadingsContainer extends StatelessWidget { return Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - if (true) ...[ - ReadingValueContainer.singleValue( - value: ReadingValue( - label: S.of(context).equipment, - value: EquipmentProfile.of(context)!.name, - ), + if (EquipmentProfile.of(context) != null && EquipmentProfiles.of(context) != null) ...[ + _EquipmentProfilePicker( + selectedValue: EquipmentProfile.of(context)!, + values: EquipmentProfiles.of(context)!, + onChanged: (value) {}, ), const _InnerPadding(), ], @@ -62,7 +62,7 @@ class ReadingsContainer extends StatelessWidget { Row( children: [ Expanded( - child: _IsoValueTile( + child: _IsoValuePicker( selectedValue: iso, values: isoValues, onChanged: onIsoChanged, @@ -70,7 +70,7 @@ class ReadingsContainer extends StatelessWidget { ), const _InnerPadding(), Expanded( - child: _NdValueTile( + child: _NdValuePicker( selectedValue: nd, values: ndValues, onChanged: onNdChanged, @@ -87,12 +87,41 @@ class _InnerPadding extends SizedBox { const _InnerPadding() : super(height: Dimens.grid8, width: Dimens.grid8); } -class _IsoValueTile extends StatelessWidget { +class _EquipmentProfilePicker extends StatelessWidget { + final List values; + final EquipmentProfileData selectedValue; + final ValueChanged onChanged; + + const _EquipmentProfilePicker({ + required this.selectedValue, + required this.values, + required this.onChanged, + }); + + @override + Widget build(BuildContext context) { + return AnimatedDialogPicker( + title: S.of(context).equipmentProfiles, + selectedValue: selectedValue, + values: values, + itemTitleBuilder: (_, value) => Text(value.name), + onChanged: onChanged, + closedChild: ReadingValueContainer.singleValue( + value: ReadingValue( + label: S.of(context).equipmentProfiles, + value: selectedValue.name, + ), + ), + ); + } +} + +class _IsoValuePicker extends StatelessWidget { final List values; final IsoValue selectedValue; final ValueChanged onChanged; - const _IsoValueTile({ + const _IsoValuePicker({ required this.selectedValue, required this.values, required this.onChanged, @@ -121,12 +150,12 @@ class _IsoValueTile extends StatelessWidget { } } -class _NdValueTile extends StatelessWidget { +class _NdValuePicker extends StatelessWidget { final List values; final NdValue selectedValue; final ValueChanged onChanged; - const _NdValueTile({ + const _NdValuePicker({ required this.selectedValue, required this.values, required this.onChanged, diff --git a/lib/screens/settings/components/metering/components/equipment_profiles/components/equipment_profile_screen/components/equipment_profile_container/widget_container_equipment_profile.dart b/lib/screens/settings/components/metering/components/equipment_profiles/components/equipment_profile_screen/components/equipment_profile_container/widget_container_equipment_profile.dart index 63f6542..8a2c24c 100644 --- a/lib/screens/settings/components/metering/components/equipment_profiles/components/equipment_profile_screen/components/equipment_profile_container/widget_container_equipment_profile.dart +++ b/lib/screens/settings/components/metering/components/equipment_profiles/components/equipment_profile_screen/components/equipment_profile_container/widget_container_equipment_profile.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/scheduler.dart'; import 'package:lightmeter/generated/l10n.dart'; +import 'package:lightmeter/res/dimens.dart'; import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart'; import 'components/equipment_list_tiles/widget_list_tiles_equipments.dart'; diff --git a/lib/screens/settings/components/metering/components/equipment_profiles/components/equipment_profile_screen/screen_equipment_profile.dart b/lib/screens/settings/components/metering/components/equipment_profiles/components/equipment_profile_screen/screen_equipment_profile.dart index 4e74d64..4a30a62 100644 --- a/lib/screens/settings/components/metering/components/equipment_profiles/components/equipment_profile_screen/screen_equipment_profile.dart +++ b/lib/screens/settings/components/metering/components/equipment_profiles/components/equipment_profile_screen/screen_equipment_profile.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:lightmeter/generated/l10n.dart'; import 'package:lightmeter/providers/equipment_profile_provider.dart'; +import 'package:lightmeter/res/dimens.dart'; import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart'; import 'components/equipment_profile_container/widget_container_equipment_profile.dart'; diff --git a/lib/screens/settings/components/shared/dialog_filter/widget_dialog_filter.dart b/lib/screens/settings/components/shared/dialog_filter/widget_dialog_filter.dart index d34eaf6..ff828a8 100644 --- a/lib/screens/settings/components/shared/dialog_filter/widget_dialog_filter.dart +++ b/lib/screens/settings/components/shared/dialog_filter/widget_dialog_filter.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:lightmeter/generated/l10n.dart'; +import 'package:lightmeter/res/dimens.dart'; import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart'; class DialogFilter extends StatefulWidget {