ba198d144a
Keep the audited runs filter, chat colour picker, and Needs you flows as Material bottom sheets on narrow or touch layouts while presenting bounded desktop dialogs on wide layouts. Remove obsolete Cupertino flags and add focused route regressions and notes.
64 lines
2.2 KiB
Dart
64 lines
2.2 KiB
Dart
import 'package:flutter/foundation.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
import '../../../ui/adaptive/app_popups.dart';
|
|
import '../domain/attention_models.dart';
|
|
import 'needs_you_sheet_material.dart';
|
|
|
|
/// Opens the native `Needs you` sheet over the live [entries].
|
|
///
|
|
/// [entries] is the caller's current list: the sheet redraws when it changes, so
|
|
/// dismissing a row updates the open sheet in place, as the browser does. The
|
|
/// dismissal snapshot is captured here, when the route opens; Clear all acts
|
|
/// only on it, so an entry that arrives while the sheet is open is shown but is
|
|
/// never silently cleared.
|
|
///
|
|
/// The surface stays open after Dismiss and Clear all, so several rows can be
|
|
/// dealt with in one visit. Choosing a row closes it; Escape, the barrier and
|
|
/// system back are native route behaviour. Narrow windows use a Material
|
|
/// bottom sheet; wide windows use a bounded Material dialog.
|
|
Future<void> showNeedsYouSheet({
|
|
required BuildContext context,
|
|
required ValueListenable<List<AttentionEntry>> entries,
|
|
required ValueChanged<AttentionEntry> onOpen,
|
|
required ValueChanged<AttentionEntry> onDismiss,
|
|
required ValueChanged<List<AttentionEntry>> onClearAll,
|
|
}) {
|
|
final snapshot = attentionDismissalSnapshot(entries.value);
|
|
if (usesDesktopPopups(context)) {
|
|
return showDialog<void>(
|
|
context: context,
|
|
useRootNavigator: true,
|
|
builder: (dialog) => Dialog(
|
|
clipBehavior: Clip.antiAlias,
|
|
child: ConstrainedBox(
|
|
constraints: BoxConstraints(
|
|
maxWidth: 560,
|
|
maxHeight: MediaQuery.sizeOf(dialog).height * 0.85,
|
|
),
|
|
child: MaterialNeedsYouSheet(
|
|
entries: entries,
|
|
snapshot: snapshot,
|
|
onOpen: onOpen,
|
|
onDismiss: onDismiss,
|
|
onClearAll: onClearAll,
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
return showModalBottomSheet<void>(
|
|
context: context,
|
|
isScrollControlled: true,
|
|
useSafeArea: true,
|
|
showDragHandle: true,
|
|
builder: (_) => MaterialNeedsYouSheet(
|
|
entries: entries,
|
|
snapshot: snapshot,
|
|
onOpen: onOpen,
|
|
onDismiss: onDismiss,
|
|
onClearAll: onClearAll,
|
|
),
|
|
);
|
|
}
|