diff --git a/lib/application.dart b/lib/application.dart index 077d48c..fd75a59 100644 --- a/lib/application.dart +++ b/lib/application.dart @@ -2,7 +2,6 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:lightmeter/data/ev_source/ev_source_type.dart'; -import 'package:lightmeter/data/models/theme_type.dart'; import 'package:lightmeter/data/permissions_service.dart'; import 'package:lightmeter/screens/settings/settings_screen.dart'; import 'package:provider/provider.dart'; diff --git a/lib/screens/settings/components/fractional_stops/dialog_fractional_stops.dart b/lib/screens/settings/components/fractional_stops/dialog_fractional_stops.dart deleted file mode 100644 index 2c4514b..0000000 --- a/lib/screens/settings/components/fractional_stops/dialog_fractional_stops.dart +++ /dev/null @@ -1,50 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:lightmeter/generated/l10n.dart'; -import 'package:lightmeter/data/models/photography_value.dart'; - -class FractionalStopsDialog extends StatefulWidget { - final StopType selectedType; - - const FractionalStopsDialog({required this.selectedType, super.key}); - - @override - State createState() => _FractionalStopsDialogState(); -} - -class _FractionalStopsDialogState extends State { - late StopType _selected = widget.selectedType; - - @override - Widget build(BuildContext context) { - return SimpleDialog( - title: Text(S.of(context).showFractionalStops), - children: [ - RadioListTile( - value: StopType.full, - groupValue: _selected, - title: Text(S.of(context).none), - onChanged: _onChanged, - ), - RadioListTile( - value: StopType.half, - groupValue: _selected, - title: Text(S.of(context).halfStops), - onChanged: _onChanged, - ), - RadioListTile( - value: StopType.third, - groupValue: _selected, - title: Text(S.of(context).thirdStops), - onChanged: _onChanged, - ), - ], - ); - } - - void _onChanged(StopType? value) { - setState(() { - _selected = value!; - }); - Navigator.of(context).pop(_selected); - } -} diff --git a/lib/screens/settings/components/fractional_stops/list_tile_fractional_stops.dart b/lib/screens/settings/components/fractional_stops_tile.dart similarity index 56% rename from lib/screens/settings/components/fractional_stops/list_tile_fractional_stops.dart rename to lib/screens/settings/components/fractional_stops_tile.dart index 5f75f0c..1c6ed74 100644 --- a/lib/screens/settings/components/fractional_stops/list_tile_fractional_stops.dart +++ b/lib/screens/settings/components/fractional_stops_tile.dart @@ -1,28 +1,29 @@ import 'package:flutter/material.dart'; -import 'package:lightmeter/generated/l10n.dart'; import 'package:lightmeter/data/models/photography_value.dart'; +import 'package:lightmeter/generated/l10n.dart'; import 'package:lightmeter/utils/stop_type_provider.dart'; import 'package:provider/provider.dart'; -import 'dialog_fractional_stops.dart'; +import 'shared/dialog_picker.dart'; -class FractionalStopsListTile extends StatefulWidget { - const FractionalStopsListTile({super.key}); +class StopTypeListTile extends StatelessWidget { + const StopTypeListTile({super.key}); - @override - State createState() => _FractionalStopsListTileState(); -} - -class _FractionalStopsListTileState extends State { @override Widget build(BuildContext context) { return ListTile( + leading: const Icon(Icons.straighten), title: Text(S.of(context).fractionalStops), - trailing: Text(selectedType), + trailing: Text(_typeToString(context, context.watch())), onTap: () { - showDialog( + showDialog( context: context, - builder: (_) => FractionalStopsDialog(selectedType: context.read()), + builder: (_) => DialogPicker( + title: S.of(context).showFractionalStops, + selectedValue: context.read(), + values: StopType.values, + titleAdapter: _typeToString, + ), ).then((value) { if (value != null) { StopTypeProvider.of(context).set(value); @@ -32,8 +33,8 @@ class _FractionalStopsListTileState extends State { ); } - String get selectedType { - switch (context.watch()) { + String _typeToString(BuildContext context, StopType stopType) { + switch (stopType) { case StopType.full: return S.of(context).none; case StopType.half: diff --git a/lib/screens/settings/components/theme_type_tile.dart b/lib/screens/settings/components/theme_type_tile.dart index bec8afb..94ba115 100644 --- a/lib/screens/settings/components/theme_type_tile.dart +++ b/lib/screens/settings/components/theme_type_tile.dart @@ -1,9 +1,7 @@ import 'package:flutter/material.dart'; import 'package:lightmeter/data/models/theme_type.dart'; -import 'package:lightmeter/data/shared_prefs_service.dart'; import 'package:lightmeter/generated/l10n.dart'; import 'package:lightmeter/res/theme.dart'; -import 'package:lightmeter/utils/stop_type_provider.dart'; import 'package:provider/provider.dart'; import 'shared/dialog_picker.dart'; diff --git a/lib/screens/settings/settings_screen.dart b/lib/screens/settings/settings_screen.dart index b028f06..715a0e5 100644 --- a/lib/screens/settings/settings_screen.dart +++ b/lib/screens/settings/settings_screen.dart @@ -2,9 +2,7 @@ import 'package:flutter/material.dart'; import 'package:lightmeter/generated/l10n.dart'; import 'package:lightmeter/res/dimens.dart'; -import 'components/caffeine_tile.dart'; -import 'components/haptics_tile.dart'; -import 'components/fractional_stops/list_tile_fractional_stops.dart'; +import 'components/fractional_stops_tile.dart'; import 'components/theme_type_tile.dart'; class SettingsScreen extends StatelessWidget { @@ -38,9 +36,9 @@ class SettingsScreen extends StatelessWidget { SliverList( delegate: SliverChildListDelegate( [ - const FractionalStopsListTile(), - const CaffeineListTile(), - const HapticsListTile(), + const StopTypeListTile(), + // const CaffeineListTile(), + // const HapticsListTile(), const ThemeTypeListTile(), ], ),