From abd33ed963a42c9dddda6c95ec845eac14cf4c45 Mon Sep 17 00:00:00 2001 From: Vadim <44135514+vodemn@users.noreply.github.com> Date: Mon, 15 Jan 2024 14:27:27 +0100 Subject: [PATCH] integrated EV100 setting to UI --- lib/l10n/intl_en.arb | 1 + lib/l10n/intl_fr.arb | 1 + lib/l10n/intl_ru.arb | 1 + lib/l10n/intl_zh.arb | 1 + .../measure_button/widget_button_measure.dart | 27 ++++++++++++++++--- .../provider_bottom_controls.dart | 3 +++ .../widget_bottom_controls.dart | 3 +++ lib/screens/metering/screen_metering.dart | 1 + .../widget_list_tile_show_ev_100.dart | 19 +++++++++++++ .../widget_settings_section_metering.dart | 2 ++ 10 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 lib/screens/settings/components/metering/components/show_ev_100/widget_list_tile_show_ev_100.dart diff --git a/lib/l10n/intl_en.arb b/lib/l10n/intl_en.arb index 13d5cbd..02dbb3d 100644 --- a/lib/l10n/intl_en.arb +++ b/lib/l10n/intl_en.arb @@ -34,6 +34,7 @@ "calibrationMessageCameraOnly": "The accuracy of the readings measured by this application depends entirely on the rear camera of the device. Therefore, consider testing this application and setting up an EV calibration value that will give you the desired measurement results.", "camera": "Camera", "lightSensor": "Light sensor", + "showEv100": "Show EV\u2081\u2080\u2080", "meteringScreenLayout": "Metering screen layout", "meteringScreenLayoutHint": "Hide elements on the metering screen that you don't need so that they don't waste exposure pairs list space.", "meteringScreenLayoutHintEquipmentProfiles": "Equipment profile picker", diff --git a/lib/l10n/intl_fr.arb b/lib/l10n/intl_fr.arb index 66dc9fb..590976d 100644 --- a/lib/l10n/intl_fr.arb +++ b/lib/l10n/intl_fr.arb @@ -34,6 +34,7 @@ "calibrationMessageCameraOnly": "La précision des lectures mesurées par cette application dépend entièrement de la caméra arrière de l'appareil. Par conséquent, envisagez de tester cette application et de configurer une valeur d'étalonnage EV qui vous donnera les résultats de mesure souhaités.", "camera": "Caméra", "lightSensor": "Capteur de lumière", + "showEv100": "Montrer EV\u2081\u2080\u2080", "meteringScreenLayout": "Disposition de l'écran de mesure", "meteringScreenLayoutHint": "Masquer les éléments sur l'écran de mesure dont vous n'avez pas besoin pour qu'ils ne gaspillent pas de l'espace dans les paires d'exposition.", "meteringScreenLayoutHintEquipmentProfiles": "Sélecteur de profil de l'équipement", diff --git a/lib/l10n/intl_ru.arb b/lib/l10n/intl_ru.arb index 367b707..e7f0743 100644 --- a/lib/l10n/intl_ru.arb +++ b/lib/l10n/intl_ru.arb @@ -34,6 +34,7 @@ "calibrationMessageCameraOnly": "Точность измерений данного приложения полностью зависит от точности камеры вашего устройства. Поэтому рекомендуется самостоятельно подобрать калибровочное значение, которое даст желаемый результат измерений.", "camera": "Камера", "lightSensor": "Датчик освещённости", + "showEv100": "Показывать EV\u2081\u2080\u2080", "meteringScreenLayout": "Элементы главного экрана", "meteringScreenLayoutHint": "Здесь вы можете скрыть некоторые ненужные или неиспользуемые элементы с главного экрана.", "meteringScreenLayoutHintEquipmentProfiles": "Выбор профиля оборудования", diff --git a/lib/l10n/intl_zh.arb b/lib/l10n/intl_zh.arb index 0055685..71fe757 100644 --- a/lib/l10n/intl_zh.arb +++ b/lib/l10n/intl_zh.arb @@ -34,6 +34,7 @@ "calibrationMessageCameraOnly": "此应用程序测量读数的准确s性完全取决于设备的后置摄像头。因此,请考虑测试此应用并手动设置 EV 校准,以获得准确的测量结果。", "camera": "摄像头", "lightSensor": "光传感器", + "showEv100": "显示 EV\u2081\u2080\u2080", "meteringScreenLayout": "布局", "meteringScreenLayoutHint": "隐藏不需要的元素,以免浪费曝光列表空间", "meteringScreenLayoutHintEquipmentProfiles": "设备配置选择", diff --git a/lib/screens/metering/components/bottom_controls/components/measure_button/widget_button_measure.dart b/lib/screens/metering/components/bottom_controls/components/measure_button/widget_button_measure.dart index 99bd2ae..e306dc8 100644 --- a/lib/screens/metering/components/bottom_controls/components/measure_button/widget_button_measure.dart +++ b/lib/screens/metering/components/bottom_controls/components/measure_button/widget_button_measure.dart @@ -1,15 +1,20 @@ import 'package:flutter/material.dart'; import 'package:lightmeter/generated/l10n.dart'; +import 'package:lightmeter/providers/user_preferences_provider.dart'; import 'package:lightmeter/res/dimens.dart'; import 'package:lightmeter/screens/shared/filled_circle/widget_circle_filled.dart'; +const String _subscript100 = '\u2081\u2080\u2080'; + class MeteringMeasureButton extends StatefulWidget { final double? ev; + final double? ev100; final bool isMetering; final VoidCallback onTap; const MeteringMeasureButton({ required this.ev, + required this.ev100, required this.isMetering, required this.onTap, super.key, @@ -61,7 +66,7 @@ class _MeteringMeasureButtonState extends State { color: Theme.of(context).colorScheme.onSurface, size: Dimens.grid72 - Dimens.grid8, child: Center( - child: widget.ev != null ? _EvValueText(ev: widget.ev!) : null, + child: widget.ev != null ? _EvValueText(ev: widget.ev!, ev100: widget.ev100!) : null, ), ), ), @@ -83,16 +88,32 @@ class _MeteringMeasureButtonState extends State { class _EvValueText extends StatelessWidget { final double ev; + final double ev100; - const _EvValueText({required this.ev}); + const _EvValueText({ + required this.ev, + required this.ev100, + }); @override Widget build(BuildContext context) { final theme = Theme.of(context); return Text( - '${ev.toStringAsFixed(1)}\n${S.of(context).ev}', + _text(context), style: theme.textTheme.bodyMedium?.copyWith(color: theme.colorScheme.surface), textAlign: TextAlign.center, ); } + + String _text(BuildContext context) { + final bool showEv100 = UserPreferencesProvider.showEv100Of(context); + final StringBuffer buffer = StringBuffer() + ..writeAll([ + (showEv100 ? ev100 : ev).toStringAsFixed(1), + '\n', + S.of(context).ev, + if (showEv100) _subscript100, + ]); + return buffer.toString(); + } } diff --git a/lib/screens/metering/components/bottom_controls/provider_bottom_controls.dart b/lib/screens/metering/components/bottom_controls/provider_bottom_controls.dart index dd4a9be..f9d6d47 100644 --- a/lib/screens/metering/components/bottom_controls/provider_bottom_controls.dart +++ b/lib/screens/metering/components/bottom_controls/provider_bottom_controls.dart @@ -5,6 +5,7 @@ import 'package:lightmeter/screens/metering/components/bottom_controls/widget_bo class MeteringBottomControlsProvider extends StatelessWidget { final double? ev; + final double? ev100; final bool isMetering; final VoidCallback? onSwitchEvSourceType; final VoidCallback onMeasure; @@ -12,6 +13,7 @@ class MeteringBottomControlsProvider extends StatelessWidget { const MeteringBottomControlsProvider({ required this.ev, + required this.ev100, required this.isMetering, required this.onSwitchEvSourceType, required this.onMeasure, @@ -35,6 +37,7 @@ class MeteringBottomControlsProvider extends StatelessWidget { ), child: MeteringBottomControls( ev: ev, + ev100: ev100, isMetering: isMetering, onSwitchEvSourceType: onSwitchEvSourceType, onMeasure: onMeasure, 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 31ecac4..0eef568 100644 --- a/lib/screens/metering/components/bottom_controls/widget_bottom_controls.dart +++ b/lib/screens/metering/components/bottom_controls/widget_bottom_controls.dart @@ -7,6 +7,7 @@ import 'package:lightmeter/screens/metering/components/bottom_controls/component class MeteringBottomControls extends StatelessWidget { final double? ev; + final double? ev100; final bool isMetering; final VoidCallback? onSwitchEvSourceType; final VoidCallback onMeasure; @@ -14,6 +15,7 @@ class MeteringBottomControls extends StatelessWidget { const MeteringBottomControls({ required this.ev, + required this.ev100, required this.isMetering, required this.onSwitchEvSourceType, required this.onMeasure, @@ -58,6 +60,7 @@ class MeteringBottomControls extends StatelessWidget { const Spacer(), MeteringMeasureButton( ev: ev, + ev100: ev100, isMetering: isMetering, onTap: onMeasure, ), diff --git a/lib/screens/metering/screen_metering.dart b/lib/screens/metering/screen_metering.dart index 380411f..836e6d0 100644 --- a/lib/screens/metering/screen_metering.dart +++ b/lib/screens/metering/screen_metering.dart @@ -40,6 +40,7 @@ class MeteringScreen extends StatelessWidget { BlocBuilder( builder: (context, state) => MeteringBottomControlsProvider( ev: state is MeteringDataState ? state.ev : null, + ev100: state is MeteringDataState ? state.ev100 : null, isMetering: state.isMetering, onSwitchEvSourceType: ServicesProvider.of(context).environment.hasLightSensor ? UserPreferencesProvider.of(context).toggleEvSourceType diff --git a/lib/screens/settings/components/metering/components/show_ev_100/widget_list_tile_show_ev_100.dart b/lib/screens/settings/components/metering/components/show_ev_100/widget_list_tile_show_ev_100.dart new file mode 100644 index 0000000..74e3339 --- /dev/null +++ b/lib/screens/settings/components/metering/components/show_ev_100/widget_list_tile_show_ev_100.dart @@ -0,0 +1,19 @@ +import 'package:flutter/material.dart'; +import 'package:lightmeter/generated/l10n.dart'; +import 'package:lightmeter/providers/user_preferences_provider.dart'; +import 'package:lightmeter/res/dimens.dart'; + +class ShowEv100ListTile extends StatelessWidget { + const ShowEv100ListTile({super.key}); + + @override + Widget build(BuildContext context) { + return SwitchListTile( + secondary: const Icon(Icons.adjust), + title: Text(S.of(context).showEv100), + value: UserPreferencesProvider.showEv100Of(context), + onChanged: (_) => UserPreferencesProvider.of(context).toggleShowEV100(), + contentPadding: const EdgeInsets.symmetric(horizontal: Dimens.paddingM), + ); + } +} diff --git a/lib/screens/settings/components/metering/widget_settings_section_metering.dart b/lib/screens/settings/components/metering/widget_settings_section_metering.dart index 0c6c07d..becf531 100644 --- a/lib/screens/settings/components/metering/widget_settings_section_metering.dart +++ b/lib/screens/settings/components/metering/widget_settings_section_metering.dart @@ -6,6 +6,7 @@ import 'package:lightmeter/screens/settings/components/metering/components/equip import 'package:lightmeter/screens/settings/components/metering/components/films/widget_list_tile_films.dart'; import 'package:lightmeter/screens/settings/components/metering/components/fractional_stops/widget_list_tile_fractional_stops.dart'; import 'package:lightmeter/screens/settings/components/metering/components/metering_screen_layout/widget_list_tile_metering_screen_layout.dart'; +import 'package:lightmeter/screens/settings/components/metering/components/show_ev_100/widget_list_tile_show_ev_100.dart'; import 'package:lightmeter/screens/settings/components/shared/settings_section/widget_settings_section.dart'; class MeteringSettingsSection extends StatelessWidget { @@ -18,6 +19,7 @@ class MeteringSettingsSection extends StatelessWidget { children: const [ StopTypeListTile(), CalibrationListTile(), + ShowEv100ListTile(), MeteringScreenLayoutListTile(), EquipmentProfilesListTile(), FilmsListTile(),