switched to local Dimens

This commit is contained in:
Vadim 2023-03-21 21:22:14 +03:00
parent 18210caf7d
commit 7d23e3584a
10 changed files with 75 additions and 31 deletions

View file

@ -31,7 +31,8 @@ class Dimens {
// TopBar // TopBar
/// Probably this is a bad practice, but with text size locked, the height is always 212 /// 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` // `CenteredSlider`
static const double cameraSliderTrackHeight = grid4; static const double cameraSliderTrackHeight = grid4;
@ -47,8 +48,14 @@ class Dimens {
paddingL, paddingL,
paddingM, paddingM,
); );
static const EdgeInsets dialogActionsPadding = EdgeInsets.fromLTRB( static const EdgeInsets dialogIconTitlePadding = EdgeInsets.fromLTRB(
paddingL, paddingL,
0,
paddingL,
paddingM,
);
static const EdgeInsets dialogActionsPadding = EdgeInsets.fromLTRB(
paddingM,
paddingM, paddingM,
paddingL, paddingL,
paddingL, paddingL,

View file

@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:lightmeter/data/models/exposure_pair.dart'; import 'package:lightmeter/data/models/exposure_pair.dart';
import 'package:lightmeter/platform_config.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/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/camera_container/models/camera_error_type.dart';
import 'package:lightmeter/screens/metering/components/shared/exposure_pairs_list/widget_list_exposure_pairs.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 @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final topBarOverflow = Dimens.readingContainerHeight - final topBarOverflow = Dimens.readingContainerDefaultHeight -
((MediaQuery.of(context).size.width - Dimens.grid8 - 2 * Dimens.paddingM) / 2) / ((MediaQuery.of(context).size.width - Dimens.grid8 - 2 * Dimens.paddingM) / 2) /
PlatformConfig.cameraPreviewAspectRatio; PlatformConfig.cameraPreviewAspectRatio;
return Column( return Column(

View file

@ -1,5 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:lightmeter/data/models/exposure_pair.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/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/metering_top_bar/widget_top_bar_metering.dart';
import 'package:lightmeter/screens/metering/components/shared/readings_container/widget_container_readings.dart'; import 'package:lightmeter/screens/metering/components/shared/readings_container/widget_container_readings.dart';

View file

@ -1,4 +1,5 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:lightmeter/res/dimens.dart';
import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart'; import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart';
class ExposurePairsListItem<T extends PhotographyStopValue> extends StatelessWidget { class ExposurePairsListItem<T extends PhotographyStopValue> extends StatelessWidget {

View file

@ -1,27 +1,27 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:lightmeter/generated/l10n.dart'; import 'package:lightmeter/generated/l10n.dart';
import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart'; import 'package:lightmeter/res/dimens.dart';
typedef DialogPickerItemTitleBuilder<T> = Widget Function(BuildContext context, T value); typedef DialogPickerItemTitleBuilder<T> = Widget Function(BuildContext context, T value);
typedef DialogPickerItemTrailingBuilder<T> = Widget? Function(T selected, T value); typedef DialogPickerItemTrailingBuilder<T> = Widget? Function(T selected, T value);
class DialogPicker<T> extends StatefulWidget { class DialogPicker<T> extends StatefulWidget {
final String title; final String title;
final String subtitle; final String? subtitle;
final T initialValue; final T initialValue;
final List<T> values; final List<T> values;
final DialogPickerItemTitleBuilder<T> itemTitleBuilder; final DialogPickerItemTitleBuilder<T> itemTitleBuilder;
final DialogPickerItemTrailingBuilder<T> itemTrailingBuilder; final DialogPickerItemTrailingBuilder<T>? itemTrailingBuilder;
final VoidCallback onCancel; final VoidCallback onCancel;
final ValueChanged onSelect; final ValueChanged onSelect;
const DialogPicker({ const DialogPicker({
required this.title, required this.title,
required this.subtitle, this.subtitle,
required this.initialValue, required this.initialValue,
required this.values, required this.values,
required this.itemTitleBuilder, required this.itemTitleBuilder,
required this.itemTrailingBuilder, this.itemTrailingBuilder,
required this.onCancel, required this.onCancel,
required this.onSelect, required this.onSelect,
super.key, super.key,
@ -56,12 +56,14 @@ class _DialogPickerState<T> extends State<DialogPicker<T>> {
style: Theme.of(context).textTheme.headlineSmall!, style: Theme.of(context).textTheme.headlineSmall!,
textAlign: TextAlign.center, textAlign: TextAlign.center,
), ),
if (widget.subtitle != null) ...[
const SizedBox(height: Dimens.grid16), const SizedBox(height: Dimens.grid16),
Text( Text(
widget.subtitle, widget.subtitle!,
style: Theme.of(context).textTheme.bodyMedium!, style: Theme.of(context).textTheme.bodyMedium!,
textAlign: TextAlign.center, textAlign: TextAlign.center,
), ),
]
], ],
), ),
), ),
@ -79,7 +81,7 @@ class _DialogPickerState<T> extends State<DialogPicker<T>> {
style: Theme.of(context).textTheme.bodyLarge!, style: Theme.of(context).textTheme.bodyLarge!,
child: widget.itemTitleBuilder(context, widget.values[index]), child: widget.itemTitleBuilder(context, widget.values[index]),
), ),
secondary: widget.itemTrailingBuilder(_selectedValue, widget.values[index]), secondary: widget.itemTrailingBuilder?.call(_selectedValue, widget.values[index]),
onChanged: (value) { onChanged: (value) {
if (value != null) { if (value != null) {
setState(() { setState(() {

View file

@ -6,21 +6,21 @@ import 'components/dialog_picker/widget_picker_dialog.dart';
class AnimatedDialogPicker<T> extends StatelessWidget { class AnimatedDialogPicker<T> extends StatelessWidget {
final _key = GlobalKey<AnimatedDialogState>(); final _key = GlobalKey<AnimatedDialogState>();
final String title; final String title;
final String subtitle; final String? subtitle;
final T selectedValue; final T selectedValue;
final List<T> values; final List<T> values;
final DialogPickerItemTitleBuilder<T> itemTitleBuilder; final DialogPickerItemTitleBuilder<T> itemTitleBuilder;
final DialogPickerItemTrailingBuilder<T> itemTrailingBuilder; final DialogPickerItemTrailingBuilder<T>? itemTrailingBuilder;
final ValueChanged<T> onChanged; final ValueChanged<T> onChanged;
final Widget closedChild; final Widget closedChild;
AnimatedDialogPicker({ AnimatedDialogPicker({
required this.title, required this.title,
required this.subtitle, this.subtitle,
required this.selectedValue, required this.selectedValue,
required this.values, required this.values,
required this.itemTitleBuilder, required this.itemTitleBuilder,
required this.itemTrailingBuilder, this.itemTrailingBuilder,
required this.onChanged, required this.onChanged,
required this.closedChild, required this.closedChild,
super.key, super.key,

View file

@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:lightmeter/data/models/exposure_pair.dart'; import 'package:lightmeter/data/models/exposure_pair.dart';
import 'package:lightmeter/generated/l10n.dart'; import 'package:lightmeter/generated/l10n.dart';
import 'package:lightmeter/providers/equipment_profile_provider.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 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart';
import 'components/animated_dialog_picker/widget_picker_dialog_animated.dart'; import 'components/animated_dialog_picker/widget_picker_dialog_animated.dart';
@ -37,12 +38,11 @@ class ReadingsContainer extends StatelessWidget {
return Column( return Column(
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
children: [ children: [
if (true) ...[ if (EquipmentProfile.of(context) != null && EquipmentProfiles.of(context) != null) ...[
ReadingValueContainer.singleValue( _EquipmentProfilePicker(
value: ReadingValue( selectedValue: EquipmentProfile.of(context)!,
label: S.of(context).equipment, values: EquipmentProfiles.of(context)!,
value: EquipmentProfile.of(context)!.name, onChanged: (value) {},
),
), ),
const _InnerPadding(), const _InnerPadding(),
], ],
@ -62,7 +62,7 @@ class ReadingsContainer extends StatelessWidget {
Row( Row(
children: [ children: [
Expanded( Expanded(
child: _IsoValueTile( child: _IsoValuePicker(
selectedValue: iso, selectedValue: iso,
values: isoValues, values: isoValues,
onChanged: onIsoChanged, onChanged: onIsoChanged,
@ -70,7 +70,7 @@ class ReadingsContainer extends StatelessWidget {
), ),
const _InnerPadding(), const _InnerPadding(),
Expanded( Expanded(
child: _NdValueTile( child: _NdValuePicker(
selectedValue: nd, selectedValue: nd,
values: ndValues, values: ndValues,
onChanged: onNdChanged, onChanged: onNdChanged,
@ -87,12 +87,41 @@ class _InnerPadding extends SizedBox {
const _InnerPadding() : super(height: Dimens.grid8, width: Dimens.grid8); const _InnerPadding() : super(height: Dimens.grid8, width: Dimens.grid8);
} }
class _IsoValueTile extends StatelessWidget { class _EquipmentProfilePicker extends StatelessWidget {
final List<EquipmentProfileData> values;
final EquipmentProfileData selectedValue;
final ValueChanged<EquipmentProfileData> onChanged;
const _EquipmentProfilePicker({
required this.selectedValue,
required this.values,
required this.onChanged,
});
@override
Widget build(BuildContext context) {
return AnimatedDialogPicker<EquipmentProfileData>(
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<IsoValue> values; final List<IsoValue> values;
final IsoValue selectedValue; final IsoValue selectedValue;
final ValueChanged<IsoValue> onChanged; final ValueChanged<IsoValue> onChanged;
const _IsoValueTile({ const _IsoValuePicker({
required this.selectedValue, required this.selectedValue,
required this.values, required this.values,
required this.onChanged, required this.onChanged,
@ -121,12 +150,12 @@ class _IsoValueTile extends StatelessWidget {
} }
} }
class _NdValueTile extends StatelessWidget { class _NdValuePicker extends StatelessWidget {
final List<NdValue> values; final List<NdValue> values;
final NdValue selectedValue; final NdValue selectedValue;
final ValueChanged<NdValue> onChanged; final ValueChanged<NdValue> onChanged;
const _NdValueTile({ const _NdValuePicker({
required this.selectedValue, required this.selectedValue,
required this.values, required this.values,
required this.onChanged, required this.onChanged,

View file

@ -1,6 +1,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart'; import 'package:flutter/scheduler.dart';
import 'package:lightmeter/generated/l10n.dart'; import 'package:lightmeter/generated/l10n.dart';
import 'package:lightmeter/res/dimens.dart';
import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart'; import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart';
import 'components/equipment_list_tiles/widget_list_tiles_equipments.dart'; import 'components/equipment_list_tiles/widget_list_tiles_equipments.dart';

View file

@ -1,6 +1,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:lightmeter/generated/l10n.dart'; import 'package:lightmeter/generated/l10n.dart';
import 'package:lightmeter/providers/equipment_profile_provider.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 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart';
import 'components/equipment_profile_container/widget_container_equipment_profile.dart'; import 'components/equipment_profile_container/widget_container_equipment_profile.dart';

View file

@ -1,5 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:lightmeter/generated/l10n.dart'; import 'package:lightmeter/generated/l10n.dart';
import 'package:lightmeter/res/dimens.dart';
import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart'; import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart';
class DialogFilter<T extends PhotographyValue> extends StatefulWidget { class DialogFilter<T extends PhotographyValue> extends StatefulWidget {