m3_lightmeter/lib/screens/settings/components/shared/dialog_picker/widget_dialog_picker.dart
Vadim cc9f162933
ML-107 Films filter (#118)
* added stub `FilmsProvider`

* moved dialogs to the shared folder

* typo

* separated `EquipmentSettingsSection`

* copy

* `IAPBuilder` -> `IAPListTile`

* moved `Film` to resources repo

* fixed films selection

* untied iso and selected film

* removed film from exposure pairs building

* indicate push/pull

* copy

* Update .gitignore

* fixed extreme exposure pairs reciprocity display

* sync with iap changes

* sync iap stub with iap changes

* added reciprocity description

* added workspace file

* Update .gitignore
2023-09-14 16:59:16 +02:00

67 lines
1.8 KiB
Dart

import 'package:flutter/material.dart';
import 'package:lightmeter/generated/l10n.dart';
import 'package:lightmeter/res/dimens.dart';
class DialogPicker<T> extends StatefulWidget {
final IconData icon;
final String title;
final T selectedValue;
final List<T> values;
final String Function(BuildContext context, T value) titleAdapter;
const DialogPicker({
required this.icon,
required this.title,
required this.selectedValue,
required this.values,
required this.titleAdapter,
super.key,
});
@override
State<DialogPicker<T>> createState() => _DialogPickerState<T>();
}
class _DialogPickerState<T> extends State<DialogPicker<T>> {
late T _selected = widget.selectedValue;
@override
Widget build(BuildContext context) {
return AlertDialog(
icon: Icon(widget.icon),
titlePadding: Dimens.dialogIconTitlePadding,
title: Text(widget.title),
contentPadding: EdgeInsets.zero,
content: Column(
mainAxisSize: MainAxisSize.min,
children: widget.values
.map(
(e) => RadioListTile(
value: e,
groupValue: _selected,
title: Text(widget.titleAdapter(context, e)),
onChanged: (T? value) {
if (value != null) {
setState(() {
_selected = value;
});
}
},
),
)
.toList(),
),
actionsPadding: Dimens.dialogActionsPadding,
actions: [
TextButton(
onPressed: Navigator.of(context).pop,
child: Text(S.of(context).cancel),
),
TextButton(
onPressed: () => Navigator.of(context).pop(_selected),
child: Text(S.of(context).select),
),
],
);
}
}