fix(settings): give every row of a mixed group its own connected surface

In the Material style a Settings group split into connected rows (2dp
gaps, tight inner corners) only when every child was a SettingsItem,
SettingsSwitchItem or ListTile. One custom row, such as a slider or a
segmented choice, dropped the whole group back to a single plain card.
"Volume and transitions" and "Autoplay from your Library" on the
Playback page looked unlike every other section for that reason, and so
did other groups holding a row wrapped in a builder or its own widget
(audio output, headphones, the paired devices of Link, scrobbling
accounts).

A group now decides from its children: several children are rows,
custom ones included, unless a SizedBox or Divider among them shows a
hand-built form, which keeps its card. A single custom child, such as
the equalizer chart, keeps its card too. `connected` became nullable:
true and false still force either layout.

The metadata option sheets keep their previous layout, since their
entries carry their own dividers. The Logs filter drops its divider in
the Material style so its two rows connect like the rest.
This commit is contained in:
zarzet committed 2026-11-19 15:17:43 +07:00
1 parent d07568fef1
commit 384f7eeef0
5 files changed
+81 -26

No files matched your search

+8 -6
View File
@@ -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<LogScreen> {
],
),
),
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,
+8 -1
View File
@@ -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(
+21 -18
View File
@@ -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<Widget> 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<Widget> settingsSectionSlivers({
required String title,
required List<Widget> children,
bool connected = false,
bool? connected,
bool glass = false,
}) => [
SliverToBoxAdapter(child: SettingsSectionHeader(title: title)),
+43
View File
@@ -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 {
+1 -1
View File
@@ -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));
});
}