Sheets rendered at the host's maximum height regardless of content, so a one-item player queue or a two-track picker filled ~75% of a desktop window with empty space. BottomSheetPageScaffold now always lays out Column(mainAxisSize: .min) plus Flexible(child:), and each sheet body shrink-wraps its own scrollable. The scaffold's shrinkWrap flag is gone: its old true branch put the child on an unbounded axis, where an over-tall list overflowed instead of clamping and scrolling. Measured on a 1600x1000 window, the chapter sheet goes from 750px to 118px for one chapter and the two-column track sheet from 750px to 154px for one audio and one subtitle track, both still clamping at the cap. Add SheetSplitColumns for the three side-by-side sheet layouts. A bare VerticalDivider has no intrinsic height, so it inflated those rows to the cap on its own; the rule now paints from a Positioned.fill that cannot size the Stack. IntrinsicHeight is not an option because a Viewport has no intrinsics. Because sheets are bottom-anchored, a content-driven height moves the sheet's top edge and everything above the change point. Three surfaces opt out for that reason and say so at the call site: SubtitleSearchSheet and its language picker keep filling, since both refilter under an autofocused field; FiltersBottomSheet holds the outgoing page's height through its loading transient; and RatingBottomSheet no longer hides MAL/AniList rows asynchronously, which used to slide live rating controls down two rows several hundred ms after open. Wrap the shared StateMessageWidget at the filters sheet boundary rather than editing a widget with 33 filling call sites. The host gains an AnimatedSize keyed per sheet session so nested pushes ease while a replacing show adopts its own height, a 720px absolute height ceiling on desktop windows only, and a min(max(25%, 96px), 60%) drag-dismiss threshold so short sheets neither close on a nudge nor become undismissable. Add videoControls.noAudioDevicesAvailable so the audio output page shows a placeholder instead of a bare header while devices load.
96 lines
2.9 KiB
Dart
96 lines
2.9 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../focus/dpad_navigator.dart';
|
|
import '../focus/key_event_utils.dart';
|
|
import 'bottom_sheet_header.dart';
|
|
|
|
/// Shared page layout for bottom sheets with a stable header and content area.
|
|
///
|
|
/// The content area is a [Flexible], so the page is as tall as [child] wants to
|
|
/// be and no taller, while still being clamped by the sheet's own maximum
|
|
/// height. [child] should therefore shrink-wrap in the vertical axis: use a
|
|
/// `SingleChildScrollView`, or a list with `shrinkWrap: true`. A plain
|
|
/// scrollable sizes itself to the incoming maximum and reintroduces the empty
|
|
/// space this layout exists to avoid.
|
|
///
|
|
/// A child may deliberately fill instead when a content-driven height would
|
|
/// move a control the user is operating — sheets are bottom-anchored, so a
|
|
/// shrinking body drags the top edge and anything above the scroll area with
|
|
/// it. `SubtitleSearchSheet` and its language picker opt out for that
|
|
/// reason; document any other.
|
|
class BottomSheetPageScaffold extends StatelessWidget {
|
|
final String title;
|
|
final Widget child;
|
|
final Widget? leading;
|
|
final Widget? action;
|
|
final VoidCallback? onClose;
|
|
final IconData? icon;
|
|
final Color? iconColor;
|
|
final VoidCallback? onBack;
|
|
final TextStyle? titleStyle;
|
|
final Color? titleColor;
|
|
final bool showHeaderBorder;
|
|
final bool showHeaderDivider;
|
|
final FocusNode? closeFocusNode;
|
|
|
|
const BottomSheetPageScaffold({
|
|
super.key,
|
|
required this.title,
|
|
required this.child,
|
|
this.leading,
|
|
this.action,
|
|
this.onClose,
|
|
this.icon,
|
|
this.iconColor,
|
|
this.onBack,
|
|
this.titleStyle,
|
|
this.titleColor,
|
|
this.showHeaderBorder = true,
|
|
this.showHeaderDivider = false,
|
|
this.closeFocusNode,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
Widget content = Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
BottomSheetHeader(
|
|
title: title,
|
|
leading: leading,
|
|
action: action,
|
|
onClose: onClose,
|
|
icon: icon,
|
|
iconColor: iconColor,
|
|
onBack: onBack,
|
|
titleStyle: titleStyle,
|
|
titleColor: titleColor,
|
|
showBorder: showHeaderBorder,
|
|
closeFocusNode: closeFocusNode,
|
|
),
|
|
if (showHeaderDivider) Divider(color: Theme.of(context).dividerColor, height: 1),
|
|
Flexible(child: child),
|
|
],
|
|
);
|
|
|
|
// Let sub-pages consume Back and return to their parent instead of closing
|
|
// the whole sheet via the overlay host.
|
|
final back = onBack;
|
|
if (back != null) {
|
|
content = Focus(
|
|
canRequestFocus: false,
|
|
skipTraversal: true,
|
|
onKeyEvent: (node, event) {
|
|
if (event.logicalKey.isBackKey) {
|
|
return handleBackKeyAction(event, back);
|
|
}
|
|
return KeyEventResult.ignored;
|
|
},
|
|
child: content,
|
|
);
|
|
}
|
|
|
|
return content;
|
|
}
|
|
}
|