LCOV - code coverage report
Current view: top level - components/dialog - foss_dialog_show.dart Coverage Total Hit
Test: fossui coverage Lines: 100.0 % 10 10
Test Date: 2026-11-29 09:15:47 Functions: - 0 0

            Line data    Source code
       1              : part of 'foss_dialog.dart';
       2              : 
       3              : /// Opens a modal dialog and resolves to the value passed to `Navigator.pop`.
       4              : ///
       5              : /// Defaults to a bottom sheet ([FossDialogPresentation.bottomSheet]) that
       6              : /// slides up from the bottom edge; pass [FossDialogPresentation.centered] for a
       7              : /// centered card. The scrim, focus trap, and focus restoration come from the
       8              : /// framework; the active theme is captured and re-provided in the route. Set
       9              : /// [barrierDismissible] to false to require an explicit action.
      10              : ///
      11              : /// ```dart
      12              : /// final ok = await showFossDialog<bool>(
      13              : ///   context: context,
      14              : ///   builder: (context) => FossDialog(
      15              : ///     title: const Text('Delete project'),
      16              : ///     description: const Text('This cannot be undone.'),
      17              : ///     actions: [
      18              : ///       FossButton(
      19              : ///         variant: FossButtonVariant.ghost,
      20              : ///         onPressed: () => Navigator.pop(context, false),
      21              : ///         child: const Text('Cancel'),
      22              : ///       ),
      23              : ///       FossButton(
      24              : ///         onPressed: () => Navigator.pop(context, true),
      25              : ///         child: const Text('Delete'),
      26              : ///       ),
      27              : ///     ],
      28              : ///   ),
      29              : /// );
      30              : /// ```
      31            4 : Future<T?> showFossDialog<T>({
      32              :   required BuildContext context,
      33              :   required WidgetBuilder builder,
      34              :   FossDialogPresentation presentation = FossDialogPresentation.bottomSheet,
      35              :   bool barrierDismissible = true,
      36              :   String? barrierLabel,
      37              :   bool useRootNavigator = true,
      38            4 : }) => _showDialogRoute<T>(
      39              :   context: context,
      40              :   builder: builder,
      41              :   presentation: presentation,
      42              :   barrierDismissible: barrierDismissible,
      43              :   barrierLabel: barrierLabel,
      44              :   useRootNavigator: useRootNavigator,
      45              : );
      46              : 
      47              : /// Opens a non-dismissible alert dialog and resolves to the value passed to
      48              : /// `Navigator.pop`.
      49              : ///
      50              : /// Unlike a plain dialog, the scrim does not dismiss it: the user must pick an
      51              : /// action. System back pops the route with a null result, the cancel path.
      52              : ///
      53              : /// ```dart
      54              : /// final confirmed = await showFossAlertDialog<bool>(
      55              : ///   context: context,
      56              : ///   builder: (context) => FossAlertDialog(
      57              : ///     title: const Text('Delete account'),
      58              : ///     description: const Text('This is permanent.'),
      59              : ///     actions: [
      60              : ///       FossButton(
      61              : ///         variant: FossButtonVariant.ghost,
      62              : ///         onPressed: () => Navigator.pop(context, false),
      63              : ///         child: const Text('Cancel'),
      64              : ///       ),
      65              : ///       FossButton(
      66              : ///         variant: FossButtonVariant.destructive,
      67              : ///         onPressed: () => Navigator.pop(context, true),
      68              : ///         child: const Text('Delete'),
      69              : ///       ),
      70              : ///     ],
      71              : ///   ),
      72              : /// );
      73              : /// ```
      74            1 : Future<T?> showFossAlertDialog<T>({
      75              :   required BuildContext context,
      76              :   required WidgetBuilder builder,
      77              :   FossDialogPresentation presentation = FossDialogPresentation.bottomSheet,
      78              :   String? barrierLabel,
      79              :   bool useRootNavigator = true,
      80            1 : }) => _showDialogRoute<T>(
      81              :   context: context,
      82              :   builder: builder,
      83              :   presentation: presentation,
      84              :   barrierDismissible: false,
      85              :   barrierLabel: barrierLabel,
      86              :   useRootNavigator: useRootNavigator,
      87              : );
      88              : 
      89              : /// Opens [builder] as a modal dialog route: the shared body behind
      90              : /// [showFossDialog] and [showFossAlertDialog]. A bottom sheet slides up on the
      91              : /// drawer motion; a centered card rides the default fade and scale. The
      92              : /// presentation is set on the route once and read back by the surface through
      93              : /// [_DialogPresentationScope].
      94            5 : Future<T?> _showDialogRoute<T>({
      95              :   required BuildContext context,
      96              :   required WidgetBuilder builder,
      97              :   required FossDialogPresentation presentation,
      98              :   required bool barrierDismissible,
      99              :   required String? barrierLabel,
     100              :   required bool useRootNavigator,
     101              : }) {
     102            5 :   final sheet = presentation == FossDialogPresentation.bottomSheet;
     103            5 :   return showFossModal<T>(
     104              :     context: context,
     105              :     barrierDismissible: barrierDismissible,
     106              :     barrierLabel: barrierLabel,
     107              :     useRootNavigator: useRootNavigator,
     108           15 :     transitionDuration: sheet ? context.fossTheme.motion.drawer : null,
     109              :     transitionBuilder: sheet ? bottomSheetTransition : null,
     110           10 :     builder: (context) => _DialogPresentationScope(
     111              :       presentation: presentation,
     112            5 :       child: Builder(builder: builder),
     113              :     ),
     114              :   );
     115              : }
        

Generated by: LCOV version 2.0-1