mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-07-28 23:08:59 +02:00
- SettingsGroup centers itself at 720dp via its incoming constraint (not screen width, so groups inside clamped sheets are never over-inset; unbounded-width contexts guarded); priority scaffold, bespoke hero cards, and donate page get the same inset - all 18+ settings pages clamp from shared widgets - queue list-mode, local/downloaded album track lists, favorite artists, home recent-access, and extension detail sections adopt wideListInset like the screens fixed earlier - track metadata content clamped at 720dp, which also tames the width-derived spectrogram height - announcement dialog capped at 480dp wide; setup wizard and tutorial content at 560dp with a 400dp action button
130 lines
4.1 KiB
Dart
130 lines
4.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:spotiflac_android/l10n/l10n.dart';
|
|
import 'package:spotiflac_android/utils/adaptive_layout.dart';
|
|
import 'package:spotiflac_android/widgets/settings_sliver_app_bar.dart';
|
|
|
|
class PrioritySettingsScaffold extends StatelessWidget {
|
|
final bool hasChanges;
|
|
final String title;
|
|
final String description;
|
|
final String infoText;
|
|
final String? saveLabel;
|
|
final EdgeInsetsGeometry descriptionPadding;
|
|
final List<Widget> slivers;
|
|
final Future<void> Function() onSave;
|
|
final Future<bool> Function(BuildContext context) onConfirmDiscard;
|
|
|
|
const PrioritySettingsScaffold({
|
|
super.key,
|
|
required this.hasChanges,
|
|
required this.title,
|
|
required this.description,
|
|
required this.infoText,
|
|
required this.slivers,
|
|
required this.onSave,
|
|
required this.onConfirmDiscard,
|
|
this.saveLabel,
|
|
this.descriptionPadding = const EdgeInsets.fromLTRB(16, 4, 16, 8),
|
|
});
|
|
|
|
Future<void> _handleBack(BuildContext context) async {
|
|
if (!hasChanges) {
|
|
Navigator.pop(context);
|
|
return;
|
|
}
|
|
final shouldPop = await onConfirmDiscard(context);
|
|
if (shouldPop && context.mounted) {
|
|
Navigator.pop(context);
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final colorScheme = Theme.of(context).colorScheme;
|
|
final wideInset = wideListInset(context);
|
|
|
|
return PopScope(
|
|
canPop: !hasChanges,
|
|
onPopInvokedWithResult: (didPop, result) async {
|
|
if (didPop) return;
|
|
final shouldPop = await onConfirmDiscard(context);
|
|
if (shouldPop && context.mounted) {
|
|
Navigator.pop(context);
|
|
}
|
|
},
|
|
child: Scaffold(
|
|
body: CustomScrollView(
|
|
slivers: [
|
|
SettingsSliverAppBar(
|
|
title: title,
|
|
leading: IconButton(
|
|
tooltip: MaterialLocalizations.of(context).backButtonTooltip,
|
|
icon: const Icon(Icons.arrow_back),
|
|
onPressed: () => _handleBack(context),
|
|
),
|
|
actions: [
|
|
if (hasChanges)
|
|
TextButton(
|
|
onPressed: onSave,
|
|
child: Text(saveLabel ?? context.l10n.dialogSave),
|
|
),
|
|
],
|
|
),
|
|
SliverToBoxAdapter(
|
|
child: Padding(
|
|
padding: descriptionPadding.add(
|
|
EdgeInsets.symmetric(horizontal: wideInset),
|
|
),
|
|
child: Text(
|
|
description,
|
|
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
|
color: colorScheme.onSurfaceVariant,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
...slivers,
|
|
SliverToBoxAdapter(
|
|
child: Padding(
|
|
padding: EdgeInsets.fromLTRB(
|
|
16 + wideInset,
|
|
16,
|
|
16 + wideInset,
|
|
16,
|
|
),
|
|
child: Container(
|
|
padding: const EdgeInsets.all(12),
|
|
decoration: BoxDecoration(
|
|
color: colorScheme.tertiaryContainer.withValues(alpha: 0.3),
|
|
borderRadius: BorderRadius.circular(12),
|
|
),
|
|
child: Row(
|
|
children: [
|
|
Icon(
|
|
Icons.info_outline,
|
|
size: 20,
|
|
color: colorScheme.tertiary,
|
|
),
|
|
const SizedBox(width: 12),
|
|
Expanded(
|
|
child: Text(
|
|
infoText,
|
|
style: Theme.of(context).textTheme.bodySmall
|
|
?.copyWith(
|
|
color: colorScheme.onTertiaryContainer,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
const SliverToBoxAdapter(child: SizedBox(height: 32)),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|