diff --git a/lib/l10n/intl_en.arb b/lib/l10n/intl_en.arb index 2bd2544..7cb99f0 100644 --- a/lib/l10n/intl_en.arb +++ b/lib/l10n/intl_en.arb @@ -13,10 +13,12 @@ "cancel": "Cancel", "select": "Select", "settings": "Settings", + "metering": "Metering", "fractionalStops": "Fractional stops", "showFractionalStops": "Show fractional stops", "halfStops": "1/2", "thirdStops": "1/3", + "general": "General", "haptics": "Haptics", "theme": "Theme", "chooseTheme": "Choose theme", @@ -24,8 +26,9 @@ "themeLight": "Light", "themeDark": "Dark", "themeSystemDefault": "System default", - "sourceCode": "Source code", "about": "About", + "sourceCode": "Source code", + "reportIssue": "Report issue", "version": "Version: {version} ({buildNumber})", "@version": { "placeholders": { diff --git a/lib/screens/settings/components/report_issue/widget_list_tile_report_issue.dart b/lib/screens/settings/components/report_issue/widget_list_tile_report_issue.dart new file mode 100644 index 0000000..6d3215c --- /dev/null +++ b/lib/screens/settings/components/report_issue/widget_list_tile_report_issue.dart @@ -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")); + }, + ); + } +} diff --git a/lib/screens/settings/components/shared/settings_section/widget_settings_section.dart b/lib/screens/settings/components/shared/settings_section/widget_settings_section.dart new file mode 100644 index 0000000..e940973 --- /dev/null +++ b/lib/screens/settings/components/shared/settings_section/widget_settings_section.dart @@ -0,0 +1,46 @@ +import 'package:flutter/material.dart'; +import 'package:lightmeter/res/dimens.dart'; + +class SettingsSection extends StatelessWidget { + final String title; + final List 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, + ], + ), + ), + ), + ); + } +} diff --git a/lib/screens/settings/components/theme/components/widget_list_tile_dynamic_colors.dart b/lib/screens/settings/components/theme/components/widget_list_tile_dynamic_colors.dart index d5cb9b1..876bc79 100644 --- a/lib/screens/settings/components/theme/components/widget_list_tile_dynamic_colors.dart +++ b/lib/screens/settings/components/theme/components/widget_list_tile_dynamic_colors.dart @@ -9,6 +9,20 @@ class DynamicColorsListTile extends StatelessWidget { @override Widget build(BuildContext context) { + if (context.read() == 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( secondary: const Icon(Icons.colorize), title: Text(S.of(context).dynamicColors), diff --git a/lib/screens/settings/components/theme/widget_settings_theme.dart b/lib/screens/settings/components/theme/widget_settings_theme.dart index ed7cfa9..5d72ca3 100644 --- a/lib/screens/settings/components/theme/widget_settings_theme.dart +++ b/lib/screens/settings/components/theme/widget_settings_theme.dart @@ -13,7 +13,7 @@ class ThemeSettings extends StatelessWidget { return Column( children: [ const ThemeTypeListTile(), - if (context.read() != DynamicColorsState.unavailable) const DynamicColorsListTile(), + const DynamicColorsListTile(), ], ); } diff --git a/lib/screens/settings/screen_settings.dart b/lib/screens/settings/screen_settings.dart index 1968cf3..9a7797a 100644 --- a/lib/screens/settings/screen_settings.dart +++ b/lib/screens/settings/screen_settings.dart @@ -3,11 +3,13 @@ import 'package:lightmeter/generated/l10n.dart'; import 'package:lightmeter/res/dimens.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/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/widget_list_tile_fractional_stops.dart'; -import 'components/theme/widget_settings_theme.dart'; -import 'components/widget_label_version.dart'; class SettingsScreen extends StatelessWidget { const SettingsScreen({super.key}); @@ -40,85 +42,40 @@ class SettingsScreen extends StatelessWidget { ), SliverList( delegate: SliverChildListDelegate( - [ - _Section( - title: S.of(context).theme, + [ + SettingsSection( + title: S.of(context).metering, children: [ const StopTypeListTile(), ], ), - _Section( - title: S.of(context).theme, + SettingsSection( + title: S.of(context).general, children: [ const HapticsListTileProvider(), ], ), - _Section( + SettingsSection( title: S.of(context).theme, - children: [ - const ThemeSettings(), + children: const [ + ThemeTypeListTile(), + DynamicColorsListTile(), ], ), - _Section( + SettingsSection( title: S.of(context).about, - children: [ - const SourceCodeListTile(), - const VersionListTile(), + children: const [ + SourceCodeListTile(), + ReportIssueListTile(), + VersionListTile(), ], ), ], ), ), - SliverFillRemaining( - hasScrollBody: false, - child: Column( - mainAxisAlignment: MainAxisAlignment.end, - children: const [VersionLabel()], - ), - ), ], ), ), ); } } - -class _Section extends StatelessWidget { - final String title; - final List 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, - ], - ), - ), - ), - ); - } -}