diff --git a/lib/screens/settings/log_screen.dart b/lib/screens/settings/log_screen.dart index b7e9a4dd6..cccc3a01f 100644 --- a/lib/screens/settings/log_screen.dart +++ b/lib/screens/settings/log_screen.dart @@ -11,6 +11,7 @@ import 'package:share_plus/share_plus.dart' show ShareParams, SharePlus; import 'package:mornye/l10n/l10n.dart'; import 'package:mornye/providers/runtime_profile_provider.dart' show mornyeGlassLevelProvider; +import 'package:mornye/theme/mornye_theme.dart'; import 'package:mornye/utils/logger.dart'; import 'package:mornye/widgets/settings_group.dart'; import 'package:mornye/widgets/app_icon.dart'; @@ -468,12 +469,13 @@ class _LogScreenState extends State { ], ), ), - Divider( - height: 1, - indent: 56, - endIndent: 20, - color: colorScheme.outlineVariant.withValues(alpha: 0.3), - ), + if (context.isMornye) + Divider( + height: 1, + indent: 56, + endIndent: 20, + color: colorScheme.outlineVariant.withValues(alpha: 0.3), + ), Padding( padding: const EdgeInsets.symmetric( horizontal: 20, diff --git a/lib/widgets/metadata_editor_fields.dart b/lib/widgets/metadata_editor_fields.dart index 0eb3eab87..d3c97f84f 100644 --- a/lib/widgets/metadata_editor_fields.dart +++ b/lib/widgets/metadata_editor_fields.dart @@ -17,7 +17,14 @@ class MetadataEditorOptions extends StatelessWidget { @override Widget build(BuildContext context) { - if (!context.isMornye) return SettingsGroup(children: children); + if (!context.isMornye) { + // Sheet options carry their own dividers, so only standard rows split. + return SettingsGroup( + connected: + children.isNotEmpty && children.every((child) => child is ListTile), + children: children, + ); + } return Padding( padding: const EdgeInsets.symmetric(horizontal: 20), child: Material( diff --git a/lib/widgets/settings_group.dart b/lib/widgets/settings_group.dart index 5e0fa4219..7c4c35728 100644 --- a/lib/widgets/settings_group.dart +++ b/lib/widgets/settings_group.dart @@ -228,6 +228,20 @@ BorderRadius connectedRowRadius( ); } +/// Whether a group's [children] are rows, each drawn as its own connected +/// surface: several children are, custom ones included, unless a spacer or +/// divider shows a hand-built form. One child alone is when it is a standard +/// row; other single content keeps its card. +bool settingsGroupHasRows(List children) { + bool standard(Widget child) => + child is SettingsItem || child is SettingsSwitchItem || child is ListTile; + return switch (children) { + [] => false, + [final only] => standard(only), + _ => !children.any((child) => child is SizedBox || child is Divider), + }; +} + class _ConnectedRowsScope extends InheritedWidget { const _ConnectedRowsScope({required super.child}); @@ -240,17 +254,16 @@ class SettingsGroup extends StatelessWidget { final EdgeInsetsGeometry? margin; final bool glass; - /// Connects custom [children] that are each one complete row, such as - /// extension rows. Groups of [SettingsItem], [SettingsSwitchItem] and [ListTile] - /// connect without it. - final bool connected; + /// Whether each of [children] is one complete row with its own connected + /// surface. Null decides from the children, see [settingsGroupHasRows]. + final bool? connected; const SettingsGroup({ super.key, required this.children, this.margin, this.glass = false, - this.connected = false, + this.connected, }); @override @@ -298,19 +311,9 @@ class SettingsGroup extends StatelessWidget { } final expressive = materialExpressiveEnabled(context); - // Only groups of standard rows split into connected tiles. Forms and - // custom content keep one card, so spacers never become empty tiles. - final standardRows = - children.isNotEmpty && - (connected || - children.every( - (child) => - child is SettingsItem || - child is SettingsSwitchItem || - child is ListTile, - )); + final rows = connected ?? settingsGroupHasRows(children); // Connected surfaces are static layout, so reduced motion keeps the gaps. - if (!context.isMornye && standardRows) { + if (!context.isMornye && rows) { // Expressive connected list: every row is its own surface separated by // a 2dp gap. The group's ends keep the card radius, inner corners stay // tight, and the gaps replace row dividers. @@ -369,7 +372,7 @@ class SettingsGroup extends StatelessWidget { List settingsSectionSlivers({ required String title, required List children, - bool connected = false, + bool? connected, bool glass = false, }) => [ SliverToBoxAdapter(child: SettingsSectionHeader(title: title)), diff --git a/test/material_expressive_test.dart b/test/material_expressive_test.dart index e9fb27c91..8b9cdcf97 100644 --- a/test/material_expressive_test.dart +++ b/test/material_expressive_test.dart @@ -500,6 +500,49 @@ void main() { expect(tester.takeException(), isNull); }); + testWidgets('custom rows among standard ones keep the group connected', ( + tester, + ) async { + await tester.pumpWidget( + _host( + SettingsGroup( + children: [ + SettingsSwitchItem(title: 'Switch', value: true, onChanged: (_) {}), + const Padding(padding: EdgeInsets.all(16), child: Text('Slider')), + SettingsItem(title: 'Last', onTap: () {}), + ], + ), + ), + ); + await tester.pumpAndSettle(); + final group = find.byType(SettingsGroup); + expect( + find.descendant(of: group, matching: find.byType(M3ECard)), + findsNothing, + ); + // Each row has its own surface, 2dp from the next. + Rect surface(String text) => tester.getRect( + find.ancestor(of: find.text(text), matching: find.byType(Material)).first, + ); + expect(surface('Slider').top, surface('Switch').bottom + 2); + expect(surface('Last').top, surface('Slider').bottom + 2); + expect(tester.takeException(), isNull); + }); + + test('a group decides from its children whether they are rows', () { + const row = SettingsItem(title: 'Row'); + const custom = Padding(padding: EdgeInsets.zero); + expect(settingsGroupHasRows(const []), isFalse); + expect(settingsGroupHasRows(const [row]), isTrue); + // Single content, such as a chart, keeps its card. + expect(settingsGroupHasRows(const [custom]), isFalse); + expect(settingsGroupHasRows(const [row, custom]), isTrue); + expect(settingsGroupHasRows(const [custom, custom]), isTrue); + // A hand-built form. + expect(settingsGroupHasRows(const [custom, SizedBox(), custom]), isFalse); + expect(settingsGroupHasRows(const [row, Divider(), row]), isFalse); + }); + testWidgets('button group squishes neighbours and keeps a plain fallback', ( tester, ) async { diff --git a/test/settings_shared_helpers_test.dart b/test/settings_shared_helpers_test.dart index 8def10073..b90852746 100644 --- a/test/settings_shared_helpers_test.dart +++ b/test/settings_shared_helpers_test.dart @@ -645,6 +645,6 @@ void main() { expect(group.children, same(rows)); final plain = settingsSectionSlivers(title: 'Section', children: const []); final plainGroup = (plain[1] as SliverToBoxAdapter).child! as SettingsGroup; - expect((plainGroup.connected, plainGroup.glass), (false, false)); + expect((plainGroup.connected, plainGroup.glass), (null, false)); }); }