mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2025-08-04 20:26:42 +00:00
fixed dialog picker of optional values
This commit is contained in:
parent
6f8231f721
commit
8ef734825d
6 changed files with 25 additions and 18 deletions
|
@ -51,7 +51,7 @@ class LogbookPhotoEditBloc extends Bloc<LogbookPhotoEditEvent, LogbookPhotoEditS
|
|||
_newPhoto = _newPhoto.copyWith(apertureValue: Optional(event.aperture));
|
||||
emit(
|
||||
state.copyWith(
|
||||
aperture: event.aperture,
|
||||
aperture: Optional(event.aperture),
|
||||
canSave: _canSave(),
|
||||
),
|
||||
);
|
||||
|
@ -61,7 +61,7 @@ class LogbookPhotoEditBloc extends Bloc<LogbookPhotoEditEvent, LogbookPhotoEditS
|
|||
_newPhoto = _newPhoto.copyWith(shutterSpeedValue: Optional(event.shutterSpeed));
|
||||
emit(
|
||||
state.copyWith(
|
||||
shutterSpeed: event.shutterSpeed,
|
||||
shutterSpeed: Optional(event.shutterSpeed),
|
||||
canSave: _canSave(),
|
||||
),
|
||||
);
|
||||
|
|
|
@ -8,7 +8,7 @@ class PickerListTile<T extends PhotographyValue> extends StatelessWidget {
|
|||
final String title;
|
||||
final T? selectedValue;
|
||||
final List<T> values;
|
||||
final ValueChanged<T?> onChanged;
|
||||
final ValueChanged<Optional<T>> onChanged;
|
||||
|
||||
const PickerListTile({
|
||||
required this.icon,
|
||||
|
@ -26,14 +26,17 @@ class PickerListTile<T extends PhotographyValue> extends StatelessWidget {
|
|||
title: Text(title),
|
||||
trailing: Text(selectedValue?.toString() ?? S.of(context).notSet),
|
||||
onTap: () {
|
||||
showDialog<T?>(
|
||||
showDialog<Optional<T>>(
|
||||
context: context,
|
||||
builder: (_) => DialogPicker<T?>(
|
||||
builder: (_) => DialogPicker<Optional<T>>(
|
||||
icon: icon,
|
||||
title: title,
|
||||
selectedValue: selectedValue,
|
||||
values: [null, ...values],
|
||||
titleAdapter: (context, value) => value?.toString() ?? S.of(context).notSet,
|
||||
selectedValue: Optional(selectedValue),
|
||||
values: [
|
||||
const Optional(null),
|
||||
...values.toSet().map((e) => Optional(e)),
|
||||
],
|
||||
titleAdapter: (context, value) => value.value?.toString() ?? S.of(context).notSet,
|
||||
),
|
||||
).then((value) {
|
||||
if (value != null) {
|
||||
|
|
|
@ -224,7 +224,7 @@ class _AperturePickerListTile extends StatelessWidget {
|
|||
values: ApertureValue.values,
|
||||
selectedValue: state.aperture,
|
||||
onChanged: (value) {
|
||||
context.read<LogbookPhotoEditBloc>().add(LogbookPhotoApertureChangedEvent(value));
|
||||
context.read<LogbookPhotoEditBloc>().add(LogbookPhotoApertureChangedEvent(value.value));
|
||||
},
|
||||
),
|
||||
);
|
||||
|
@ -244,7 +244,7 @@ class _ShutterSpeedPickerListTile extends StatelessWidget {
|
|||
values: ShutterSpeedValue.values,
|
||||
selectedValue: state.shutterSpeed,
|
||||
onChanged: (value) {
|
||||
context.read<LogbookPhotoEditBloc>().add(LogbookPhotoShutterSpeedChangedEvent(value));
|
||||
context.read<LogbookPhotoEditBloc>().add(LogbookPhotoShutterSpeedChangedEvent(value.value));
|
||||
},
|
||||
),
|
||||
);
|
||||
|
|
|
@ -31,8 +31,8 @@ class LogbookPhotoEditState {
|
|||
|
||||
LogbookPhotoEditState copyWith({
|
||||
String? name,
|
||||
ApertureValue? aperture,
|
||||
ShutterSpeedValue? shutterSpeed,
|
||||
Optional<ApertureValue>? aperture,
|
||||
Optional<ShutterSpeedValue>? shutterSpeed,
|
||||
String? note,
|
||||
bool? canSave,
|
||||
bool? isLoading,
|
||||
|
@ -44,8 +44,8 @@ class LogbookPhotoEditState {
|
|||
ev: ev,
|
||||
iso: iso,
|
||||
nd: nd,
|
||||
aperture: aperture ?? this.aperture,
|
||||
shutterSpeed: shutterSpeed ?? this.shutterSpeed,
|
||||
aperture: aperture != null ? aperture.value : this.aperture,
|
||||
shutterSpeed: shutterSpeed != null ? shutterSpeed.value : this.shutterSpeed,
|
||||
note: note ?? this.note,
|
||||
canSave: canSave ?? this.canSave,
|
||||
isLoading: isLoading ?? this.isLoading,
|
||||
|
|
|
@ -894,11 +894,11 @@ packages:
|
|||
dependency: "direct main"
|
||||
description:
|
||||
path: "."
|
||||
ref: "v2.3.0"
|
||||
resolved-ref: a8c419f21fcda06d76d26cc2416de459f0d51a60
|
||||
ref: "v2.3.1"
|
||||
resolved-ref: "8b39ac1927b791652618509abe0391f844229b93"
|
||||
url: "https://github.com/vodemn/m3_lightmeter_resources"
|
||||
source: git
|
||||
version: "2.3.0+11"
|
||||
version: "2.3.1+12"
|
||||
macros:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
|
@ -37,7 +37,7 @@ dependencies:
|
|||
m3_lightmeter_resources:
|
||||
git:
|
||||
url: "https://github.com/vodemn/m3_lightmeter_resources"
|
||||
ref: v2.3.0
|
||||
ref: v2.3.1
|
||||
map_launcher: 3.2.0
|
||||
material_color_utilities: 0.12.0
|
||||
package_info_plus: 8.1.3
|
||||
|
@ -68,6 +68,10 @@ dev_dependencies:
|
|||
|
||||
dependency_overrides:
|
||||
geolocator_android: 4.6.1
|
||||
m3_lightmeter_resources:
|
||||
git:
|
||||
url: "https://github.com/vodemn/m3_lightmeter_resources"
|
||||
ref: v2.3.1
|
||||
material_color_utilities: 0.11.1
|
||||
|
||||
flutter:
|
||||
|
|
Loading…
Reference in a new issue