Files
pipelines/app/lib/features/attention/ui/needs_you_sheet.dart
T

58 lines
2.0 KiB
Dart

import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import '../../../ui/adaptive/host.dart';
import '../domain/attention_models.dart';
import 'needs_you_sheet_cupertino.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 sheet 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. The caller supplies the native host
/// explicitly when it already knows it; otherwise the ambient app host decides.
Future<void> showNeedsYouSheet({
required BuildContext context,
required ValueListenable<List<AttentionEntry>> entries,
required ValueChanged<AttentionEntry> onOpen,
required ValueChanged<AttentionEntry> onDismiss,
required ValueChanged<List<AttentionEntry>> onClearAll,
bool? cupertino,
}) {
final snapshot = attentionDismissalSnapshot(entries.value);
final native = cupertino ?? usesCupertinoHost(context);
if (native) {
return showCupertinoModalPopup<void>(
context: context,
builder: (_) => CupertinoNeedsYouSheet(
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,
),
);
}