From d1d7e23cf9657946be43a3864ff0321f5e975dbd Mon Sep 17 00:00:00 2001 From: Vadim <44135514+vodemn@users.noreply.github.com> Date: Mon, 23 Jan 2023 20:36:40 +0300 Subject: [PATCH] added settings sections --- lib/l10n/intl_en.arb | 1 + .../version/widget_list_tile_version.dart | 15 ++++ lib/screens/settings/screen_settings.dart | 70 +++++++++++++++++-- 3 files changed, 82 insertions(+), 4 deletions(-) create mode 100644 lib/screens/settings/components/version/widget_list_tile_version.dart diff --git a/lib/l10n/intl_en.arb b/lib/l10n/intl_en.arb index 9dd7fea..2bd2544 100644 --- a/lib/l10n/intl_en.arb +++ b/lib/l10n/intl_en.arb @@ -25,6 +25,7 @@ "themeDark": "Dark", "themeSystemDefault": "System default", "sourceCode": "Source code", + "about": "About", "version": "Version: {version} ({buildNumber})", "@version": { "placeholders": { diff --git a/lib/screens/settings/components/version/widget_list_tile_version.dart b/lib/screens/settings/components/version/widget_list_tile_version.dart new file mode 100644 index 0000000..5ab1249 --- /dev/null +++ b/lib/screens/settings/components/version/widget_list_tile_version.dart @@ -0,0 +1,15 @@ +import 'package:flutter/material.dart'; +import 'package:lightmeter/generated/l10n.dart'; + + +class VersionListTile extends StatelessWidget { + const VersionListTile({super.key}); + + @override + Widget build(BuildContext context) { + return ListTile( + leading: const Icon(Icons.info_outline), + title: Text(S.of(context).version('', '')), + ); + } +} \ No newline at end of file diff --git a/lib/screens/settings/screen_settings.dart b/lib/screens/settings/screen_settings.dart index 7c29bfd..1968cf3 100644 --- a/lib/screens/settings/screen_settings.dart +++ b/lib/screens/settings/screen_settings.dart @@ -4,6 +4,7 @@ import 'package:lightmeter/res/dimens.dart'; import 'components/haptics/provider_list_tile_haptics.dart'; import 'components/source_code/widget_list_tile_source_code.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'; @@ -40,10 +41,31 @@ class SettingsScreen extends StatelessWidget { SliverList( delegate: SliverChildListDelegate( [ - const StopTypeListTile(), - const HapticsListTileProvider(), - const ThemeSettings(), - const SourceCodeListTile(), + _Section( + title: S.of(context).theme, + children: [ + const StopTypeListTile(), + ], + ), + _Section( + title: S.of(context).theme, + children: [ + const HapticsListTileProvider(), + ], + ), + _Section( + title: S.of(context).theme, + children: [ + const ThemeSettings(), + ], + ), + _Section( + title: S.of(context).about, + children: [ + const SourceCodeListTile(), + const VersionListTile(), + ], + ), ], ), ), @@ -60,3 +82,43 @@ class SettingsScreen extends StatelessWidget { ); } } + +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, + ], + ), + ), + ), + ); + } +}