This commit is contained in:
Vadim 2023-01-23 20:57:26 +03:00
parent d1d7e23cf9
commit 53c938bb44
6 changed files with 101 additions and 63 deletions

View file

@ -13,10 +13,12 @@
"cancel": "Cancel", "cancel": "Cancel",
"select": "Select", "select": "Select",
"settings": "Settings", "settings": "Settings",
"metering": "Metering",
"fractionalStops": "Fractional stops", "fractionalStops": "Fractional stops",
"showFractionalStops": "Show fractional stops", "showFractionalStops": "Show fractional stops",
"halfStops": "1/2", "halfStops": "1/2",
"thirdStops": "1/3", "thirdStops": "1/3",
"general": "General",
"haptics": "Haptics", "haptics": "Haptics",
"theme": "Theme", "theme": "Theme",
"chooseTheme": "Choose theme", "chooseTheme": "Choose theme",
@ -24,8 +26,9 @@
"themeLight": "Light", "themeLight": "Light",
"themeDark": "Dark", "themeDark": "Dark",
"themeSystemDefault": "System default", "themeSystemDefault": "System default",
"sourceCode": "Source code",
"about": "About", "about": "About",
"sourceCode": "Source code",
"reportIssue": "Report issue",
"version": "Version: {version} ({buildNumber})", "version": "Version: {version} ({buildNumber})",
"@version": { "@version": {
"placeholders": { "placeholders": {

View file

@ -0,0 +1,18 @@
import 'package:flutter/material.dart';
import 'package:lightmeter/generated/l10n.dart';
import 'package:url_launcher/url_launcher.dart';
class ReportIssueListTile extends StatelessWidget {
const ReportIssueListTile({super.key});
@override
Widget build(BuildContext context) {
return ListTile(
leading: const Icon(Icons.bug_report),
title: Text(S.of(context).reportIssue),
onTap: () {
launchUrl(Uri.parse("https://github.com/vodemn/m3_lightmeter/issues"));
},
);
}
}

View file

@ -0,0 +1,46 @@
import 'package:flutter/material.dart';
import 'package:lightmeter/res/dimens.dart';
class SettingsSection extends StatelessWidget {
final String title;
final List<Widget> children;
const SettingsSection({
required this.title,
required this.children,
super.key,
});
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.fromLTRB(
Dimens.paddingM,
0,
Dimens.paddingM,
Dimens.paddingM,
),
child: Material(
borderRadius: BorderRadius.circular(Dimens.borderRadiusL),
color: Theme.of(context).colorScheme.primaryContainer,
child: Padding(
padding: const EdgeInsets.symmetric(vertical: Dimens.paddingM),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Padding(
padding: const EdgeInsets.only(left: Dimens.paddingM),
child: Text(
title,
style: Theme.of(context).textTheme.labelLarge,
),
),
...children,
],
),
),
),
);
}
}

View file

@ -9,6 +9,20 @@ class DynamicColorsListTile extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
if (context.read<DynamicColorsState>() == DynamicColorsState.unavailable) {
return Opacity(
opacity: 0.5,
child: IgnorePointer(
child: SwitchListTile(
secondary: const Icon(Icons.colorize),
title: Text(S.of(context).dynamicColors),
value: false,
enableFeedback: false,
onChanged: (value) {},
),
),
);
}
return SwitchListTile( return SwitchListTile(
secondary: const Icon(Icons.colorize), secondary: const Icon(Icons.colorize),
title: Text(S.of(context).dynamicColors), title: Text(S.of(context).dynamicColors),

View file

@ -13,7 +13,7 @@ class ThemeSettings extends StatelessWidget {
return Column( return Column(
children: [ children: [
const ThemeTypeListTile(), const ThemeTypeListTile(),
if (context.read<DynamicColorsState>() != DynamicColorsState.unavailable) const DynamicColorsListTile(), const DynamicColorsListTile(),
], ],
); );
} }

View file

@ -3,11 +3,13 @@ import 'package:lightmeter/generated/l10n.dart';
import 'package:lightmeter/res/dimens.dart'; import 'package:lightmeter/res/dimens.dart';
import 'components/haptics/provider_list_tile_haptics.dart'; import 'components/haptics/provider_list_tile_haptics.dart';
import 'components/report_issue/widget_list_tile_report_issue.dart';
import 'components/shared/settings_section/widget_settings_section.dart';
import 'components/source_code/widget_list_tile_source_code.dart'; import 'components/source_code/widget_list_tile_source_code.dart';
import 'components/theme/components/widget_list_tile_dynamic_colors.dart';
import 'components/theme/components/widget_list_tile_theme_type.dart';
import 'components/version/widget_list_tile_version.dart'; import 'components/version/widget_list_tile_version.dart';
import 'components/widget_list_tile_fractional_stops.dart'; import 'components/widget_list_tile_fractional_stops.dart';
import 'components/theme/widget_settings_theme.dart';
import 'components/widget_label_version.dart';
class SettingsScreen extends StatelessWidget { class SettingsScreen extends StatelessWidget {
const SettingsScreen({super.key}); const SettingsScreen({super.key});
@ -40,85 +42,40 @@ class SettingsScreen extends StatelessWidget {
), ),
SliverList( SliverList(
delegate: SliverChildListDelegate( delegate: SliverChildListDelegate(
[ <SettingsSection>[
_Section( SettingsSection(
title: S.of(context).theme, title: S.of(context).metering,
children: [ children: [
const StopTypeListTile(), const StopTypeListTile(),
], ],
), ),
_Section( SettingsSection(
title: S.of(context).theme, title: S.of(context).general,
children: [ children: [
const HapticsListTileProvider(), const HapticsListTileProvider(),
], ],
), ),
_Section( SettingsSection(
title: S.of(context).theme, title: S.of(context).theme,
children: [ children: const [
const ThemeSettings(), ThemeTypeListTile(),
DynamicColorsListTile(),
], ],
), ),
_Section( SettingsSection(
title: S.of(context).about, title: S.of(context).about,
children: [ children: const [
const SourceCodeListTile(), SourceCodeListTile(),
const VersionListTile(), ReportIssueListTile(),
VersionListTile(),
], ],
), ),
], ],
), ),
), ),
SliverFillRemaining(
hasScrollBody: false,
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
children: const [VersionLabel()],
),
),
], ],
), ),
), ),
); );
} }
} }
class _Section extends StatelessWidget {
final String title;
final List<Widget> children;
const _Section({required this.title, required this.children});
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.fromLTRB(
Dimens.paddingM,
0,
Dimens.paddingM,
Dimens.paddingM,
),
child: Material(
borderRadius: BorderRadius.circular(Dimens.borderRadiusL),
color: Theme.of(context).colorScheme.primaryContainer,
child: Padding(
padding: const EdgeInsets.symmetric(vertical: Dimens.paddingM),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Padding(
padding: const EdgeInsets.only(left: Dimens.paddingM),
child: Text(
title,
style: Theme.of(context).textTheme.labelLarge,
),
),
...children,
],
),
),
),
);
}
}