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

            Line data    Source code
       1              : part of 'foss_menu.dart';
       2              : 
       3              : /// Visual overrides for a [FossMenu]. Every field is optional; a null field
       4              : /// falls back to what the theme resolves. Pass one to a single menu via
       5              : /// `style:` to tweak a one-off, without changing the theme for every other
       6              : /// menu.
       7              : ///
       8              : /// [textStyle] merges over the resolved row style, so setting only a size keeps
       9              : /// the token color.
      10              : ///
      11              : /// A wider panel with tighter corners:
      12              : ///
      13              : /// ```dart
      14              : /// FossMenu(
      15              : ///   items: items,
      16              : ///   style: const FossMenuStyle(minWidth: 220, borderRadius: 6),
      17              : ///   child: const FossButton(child: Text('Open')),
      18              : /// );
      19              : /// ```
      20              : @immutable
      21              : @FossSince('0.1.3')
      22              : class FossMenuStyle {
      23              :   /// Creates a set of menu overrides. All fields default to null (inherit).
      24            1 :   const FossMenuStyle({
      25              :     this.minWidth,
      26              :     this.backgroundColor,
      27              :     this.borderColor,
      28              :     this.borderRadius,
      29              :     this.padding,
      30              :     this.rowRadius,
      31              :     this.highlightColor,
      32              :     this.highlightForeground,
      33              :     this.foreground,
      34              :     this.iconSize,
      35              :     this.textStyle,
      36              :   });
      37              : 
      38              :   /// Smallest panel width in logical pixels. The panel grows past it to fit its
      39              :   /// widest row.
      40              :   final double? minWidth;
      41              : 
      42              :   /// Panel fill color.
      43              :   final Color? backgroundColor;
      44              : 
      45              :   /// Panel border color.
      46              :   final Color? borderColor;
      47              : 
      48              :   /// Uniform corner radius of the panel, in logical pixels.
      49              :   final double? borderRadius;
      50              : 
      51              :   /// Inner padding between the panel border and the rows.
      52              :   final EdgeInsetsGeometry? padding;
      53              : 
      54              :   /// Uniform corner radius of a row's highlight fill, in logical pixels.
      55              :   final double? rowRadius;
      56              : 
      57              :   /// Fill behind the highlighted row.
      58              :   final Color? highlightColor;
      59              : 
      60              :   /// Text and glyph color of the highlighted row.
      61              :   final Color? highlightForeground;
      62              : 
      63              :   /// Text and glyph color of a row at rest.
      64              :   final Color? foreground;
      65              : 
      66              :   /// Glyph size for a row's icon slot, in logical pixels.
      67              :   final double? iconSize;
      68              : 
      69              :   /// Overrides merged over the resolved row text style.
      70              :   final TextStyle? textStyle;
      71              : 
      72              :   /// Returns a copy with every non-null field of [other] laid over this one.
      73              :   /// Used to layer a per-instance override on the theme-resolved defaults.
      74              :   ///
      75              :   /// ```dart
      76              :   /// const base = FossMenuStyle(minWidth: 200, iconSize: 18);
      77              :   /// const override = FossMenuStyle(iconSize: 20);
      78              :   /// base.merge(override); // minWidth 200 kept, iconSize becomes 20
      79              :   /// ```
      80            1 :   FossMenuStyle merge(FossMenuStyle? other) {
      81              :     if (other == null) return this;
      82            1 :     return FossMenuStyle(
      83            2 :       minWidth: other.minWidth ?? minWidth,
      84            2 :       backgroundColor: other.backgroundColor ?? backgroundColor,
      85            2 :       borderColor: other.borderColor ?? borderColor,
      86            2 :       borderRadius: other.borderRadius ?? borderRadius,
      87            2 :       padding: other.padding ?? padding,
      88            2 :       rowRadius: other.rowRadius ?? rowRadius,
      89            2 :       highlightColor: other.highlightColor ?? highlightColor,
      90            2 :       highlightForeground: other.highlightForeground ?? highlightForeground,
      91            2 :       foreground: other.foreground ?? foreground,
      92            2 :       iconSize: other.iconSize ?? iconSize,
      93            1 :       textStyle: other.textStyle == null
      94            1 :           ? textStyle
      95            4 :           : (textStyle?.merge(other.textStyle) ?? other.textStyle),
      96              :     );
      97              :   }
      98              : }
        

Generated by: LCOV version 2.0-1