mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-11-22 07:20:39 +00:00
Cleanup
This commit is contained in:
parent
9b0cba6ed7
commit
ca8c1f8e4d
5 changed files with 19 additions and 73 deletions
|
@ -2,7 +2,6 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||||
import 'package:lightmeter/data/ev_source/ev_source_type.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/data/permissions_service.dart';
|
||||||
import 'package:lightmeter/screens/settings/settings_screen.dart';
|
import 'package:lightmeter/screens/settings/settings_screen.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
|
@ -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<FractionalStopsDialog> createState() => _FractionalStopsDialogState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _FractionalStopsDialogState extends State<FractionalStopsDialog> {
|
|
||||||
late StopType _selected = widget.selectedType;
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return SimpleDialog(
|
|
||||||
title: Text(S.of(context).showFractionalStops),
|
|
||||||
children: [
|
|
||||||
RadioListTile<StopType>(
|
|
||||||
value: StopType.full,
|
|
||||||
groupValue: _selected,
|
|
||||||
title: Text(S.of(context).none),
|
|
||||||
onChanged: _onChanged,
|
|
||||||
),
|
|
||||||
RadioListTile<StopType>(
|
|
||||||
value: StopType.half,
|
|
||||||
groupValue: _selected,
|
|
||||||
title: Text(S.of(context).halfStops),
|
|
||||||
onChanged: _onChanged,
|
|
||||||
),
|
|
||||||
RadioListTile<StopType>(
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,28 +1,29 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:lightmeter/generated/l10n.dart';
|
|
||||||
import 'package:lightmeter/data/models/photography_value.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:lightmeter/utils/stop_type_provider.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
import 'dialog_fractional_stops.dart';
|
import 'shared/dialog_picker.dart';
|
||||||
|
|
||||||
class FractionalStopsListTile extends StatefulWidget {
|
class StopTypeListTile extends StatelessWidget {
|
||||||
const FractionalStopsListTile({super.key});
|
const StopTypeListTile({super.key});
|
||||||
|
|
||||||
@override
|
|
||||||
State<FractionalStopsListTile> createState() => _FractionalStopsListTileState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _FractionalStopsListTileState extends State<FractionalStopsListTile> {
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return ListTile(
|
return ListTile(
|
||||||
|
leading: const Icon(Icons.straighten),
|
||||||
title: Text(S.of(context).fractionalStops),
|
title: Text(S.of(context).fractionalStops),
|
||||||
trailing: Text(selectedType),
|
trailing: Text(_typeToString(context, context.watch<StopType>())),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
showDialog(
|
showDialog<StopType>(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (_) => FractionalStopsDialog(selectedType: context.read<StopType>()),
|
builder: (_) => DialogPicker<StopType>(
|
||||||
|
title: S.of(context).showFractionalStops,
|
||||||
|
selectedValue: context.read<StopType>(),
|
||||||
|
values: StopType.values,
|
||||||
|
titleAdapter: _typeToString,
|
||||||
|
),
|
||||||
).then((value) {
|
).then((value) {
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
StopTypeProvider.of(context).set(value);
|
StopTypeProvider.of(context).set(value);
|
||||||
|
@ -32,8 +33,8 @@ class _FractionalStopsListTileState extends State<FractionalStopsListTile> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
String get selectedType {
|
String _typeToString(BuildContext context, StopType stopType) {
|
||||||
switch (context.watch<StopType>()) {
|
switch (stopType) {
|
||||||
case StopType.full:
|
case StopType.full:
|
||||||
return S.of(context).none;
|
return S.of(context).none;
|
||||||
case StopType.half:
|
case StopType.half:
|
|
@ -1,9 +1,7 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:lightmeter/data/models/theme_type.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/generated/l10n.dart';
|
||||||
import 'package:lightmeter/res/theme.dart';
|
import 'package:lightmeter/res/theme.dart';
|
||||||
import 'package:lightmeter/utils/stop_type_provider.dart';
|
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
import 'shared/dialog_picker.dart';
|
import 'shared/dialog_picker.dart';
|
||||||
|
|
|
@ -2,9 +2,7 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:lightmeter/generated/l10n.dart';
|
import 'package:lightmeter/generated/l10n.dart';
|
||||||
import 'package:lightmeter/res/dimens.dart';
|
import 'package:lightmeter/res/dimens.dart';
|
||||||
|
|
||||||
import 'components/caffeine_tile.dart';
|
import 'components/fractional_stops_tile.dart';
|
||||||
import 'components/haptics_tile.dart';
|
|
||||||
import 'components/fractional_stops/list_tile_fractional_stops.dart';
|
|
||||||
import 'components/theme_type_tile.dart';
|
import 'components/theme_type_tile.dart';
|
||||||
|
|
||||||
class SettingsScreen extends StatelessWidget {
|
class SettingsScreen extends StatelessWidget {
|
||||||
|
@ -38,9 +36,9 @@ class SettingsScreen extends StatelessWidget {
|
||||||
SliverList(
|
SliverList(
|
||||||
delegate: SliverChildListDelegate(
|
delegate: SliverChildListDelegate(
|
||||||
[
|
[
|
||||||
const FractionalStopsListTile(),
|
const StopTypeListTile(),
|
||||||
const CaffeineListTile(),
|
// const CaffeineListTile(),
|
||||||
const HapticsListTile(),
|
// const HapticsListTile(),
|
||||||
const ThemeTypeListTile(),
|
const ThemeTypeListTile(),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
Loading…
Reference in a new issue