m3_lightmeter/lib/screens/settings/components/widget_list_tile_fractional_stops.dart

47 lines
1.4 KiB
Dart
Raw Normal View History

import 'package:flutter/material.dart';
import 'package:lightmeter/data/models/photography_values/photography_value.dart';
2022-12-16 20:53:26 +00:00
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';
2022-12-16 20:53:26 +00:00
class StopTypeListTile extends StatelessWidget {
const StopTypeListTile({super.key});
@override
Widget build(BuildContext context) {
return ListTile(
2022-12-16 20:53:26 +00:00
leading: const Icon(Icons.straighten),
title: Text(S.of(context).fractionalStops),
2022-12-16 20:53:26 +00:00
trailing: Text(_typeToString(context, context.watch<StopType>())),
onTap: () {
2022-12-16 20:53:26 +00:00
showDialog<StopType>(
context: context,
2022-12-16 20:53:26 +00:00
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);
}
});
},
);
}
2022-12-16 20:53:26 +00:00
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;
}
}
}