m3_lightmeter/lib/screens/settings/components/widget_list_tile_fractional_stops.dart
Vadim 14bac950cf Fixed _models_ and _screens_ folders structure
proper folders for models

unified _screen_ folder filenames
2022-12-18 14:39:02 +03:00

46 lines
1.4 KiB
Dart

import 'package:flutter/material.dart';
import 'package:lightmeter/data/models/photography_values/photography_value.dart';
import 'package:lightmeter/generated/l10n.dart';
import 'package:lightmeter/utils/stop_type_provider.dart';
import 'package:provider/provider.dart';
import 'shared/widget_dialog_picker.dart';
class StopTypeListTile extends StatelessWidget {
const StopTypeListTile({super.key});
@override
Widget build(BuildContext context) {
return ListTile(
leading: const Icon(Icons.straighten),
title: Text(S.of(context).fractionalStops),
trailing: Text(_typeToString(context, context.watch<StopType>())),
onTap: () {
showDialog<StopType>(
context: context,
builder: (_) => DialogPicker<StopType>(
title: S.of(context).showFractionalStops,
selectedValue: context.read<StopType>(),
values: StopType.values,
titleAdapter: _typeToString,
),
).then((value) {
if (value != null) {
StopTypeProvider.of(context).set(value);
}
});
},
);
}
String _typeToString(BuildContext context, StopType stopType) {
switch (stopType) {
case StopType.full:
return S.of(context).none;
case StopType.half:
return S.of(context).halfStops;
case StopType.third:
return S.of(context).thirdStops;
}
}
}