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",
"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": {

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
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(
secondary: const Icon(Icons.colorize),
title: Text(S.of(context).dynamicColors),

View file

@ -13,7 +13,7 @@ class ThemeSettings extends StatelessWidget {
return Column(
children: [
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 '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>[
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<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,
],
),
),
),
);
}
}