import 'package:flutter/cupertino.dart'; import '../../ui/theme/app_theme.dart'; import 'settings_layout.dart'; import 'settings_theme.dart'; /// The Settings page's scrolling column of groups. /// /// It scrolls behind the floating top bar: instead of a top [SafeArea] it pads /// its start by the bar's height (the top media padding), and its end by the /// floating tab bar's (the bottom media padding), so at rest nothing is hidden /// and scrolled groups pass behind the glass pills. The column starts at the /// bar's own side inset, so the groups line up under the title pill, and stops /// at [settingsContentMaxWidth] on a wide window. Cupertino paints the page in /// the grouped background its inset-grouped sections are designed for. class SettingsPageBody extends StatelessWidget { const SettingsPageBody({super.key, required this.children}); final List children; @override Widget build(BuildContext context) { final insets = MediaQuery.paddingOf(context); // The inset-grouped section already pads above its own header. final gap = usesCupertinoControls(context) ? settingsTitleGap : settingsSectionGap; final Widget list = SingleChildScrollView( key: const ValueKey('settings.scroll'), padding: EdgeInsets.fromLTRB( insets.left + settingsPageSidePadding, insets.top + settingsPageTopPadding, insets.right + settingsPageSidePadding, insets.bottom + settingsPageBottomPadding, ), child: Align( alignment: AlignmentDirectional.topStart, child: ConstrainedBox( constraints: const BoxConstraints(maxWidth: settingsContentMaxWidth), child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ for (final (index, child) in children.indexed) ...[ if (index > 0) SizedBox(height: gap), child, ], ], ), ), ), ); if (!usesCupertinoControls(context)) return list; return ColoredBox( color: settingsCupertinoBackground.resolveFrom(context), child: list, ); } } /// The Cupertino Settings page background: the system grouped background, so /// the inset sections' rows read as raised cards in light and dark. const CupertinoDynamicColor settingsCupertinoBackground = AppColors.groupedBackground;