LCOV - code coverage report
Current view: top level - theme/radii - foss_radii.dart Coverage Total Hit
Test: fossui coverage Lines: 100.0 % 9 9
Test Date: 2026-11-29 09:15:47 Functions: - 0 0

            Line data    Source code
       1              : import 'dart:math' as math;
       2              : 
       3              : // ThemeExtension has no home outside material.dart on the supported SDKs.
       4              : // ignore: deprecated_member_use
       5              : import 'package:flutter/material.dart' show ThemeExtension;
       6              : import 'package:fossui/src/theme/lerp_encoders.dart';
       7              : import 'package:theme_tailor_annotation/theme_tailor_annotation.dart';
       8              : 
       9              : part 'foss_radii.tailor.dart';
      10              : 
      11              : /// Corner radii in logical pixels. [standard] is the default scale; [full] is a
      12              : /// pill sentinel, clamped to half the height at the use site.
      13              : ///
      14              : /// ```dart
      15              : /// const r = FossRadii.standard;
      16              : /// final corners = BorderRadius.circular(r.lg); // 10 px
      17              : /// final pill = BorderRadius.circular(FossRadii.full);
      18              : /// ```
      19              : @TailorMixin(themeGetter: ThemeGetter.none, encoders: [DoubleLerpEncoder()])
      20              : class FossRadii extends ThemeExtension<FossRadii> with _$FossRadiiTailorMixin {
      21              :   /// Creates a radius scale. Prefer [standard] unless retheming.
      22            5 :   const FossRadii({
      23              :     required this.sm,
      24              :     required this.md,
      25              :     required this.lg,
      26              :     required this.xl,
      27              :     required this.xl2,
      28              :   });
      29              : 
      30              :   /// Derives the full scale from a single [base] (the `lg` step). Steps offset
      31              :   /// from it (sm -4, md -2, lg +0, xl +4, xl2 +6), each clamped at 0, so
      32              :   /// `fromBase(10)` reproduces [standard].
      33              :   ///
      34              :   /// ```dart
      35              :   /// final r = FossRadii.fromBase(22); // rounder corners across the app
      36              :   /// ```
      37            1 :   factory FossRadii.fromBase(double base) {
      38            3 :     double step(double delta) => math.max(0, base + delta);
      39            1 :     return FossRadii(
      40            1 :       sm: step(-4),
      41            1 :       md: step(-2),
      42            1 :       lg: step(0),
      43            1 :       xl: step(4),
      44            1 :       xl2: step(6),
      45              :     );
      46              :   }
      47              : 
      48              :   /// Small corners (6 px): small controls and inline marks.
      49              :   @override
      50              :   final double sm;
      51              : 
      52              :   /// Medium corners (8 px): buttons, inputs.
      53              :   @override
      54              :   final double md;
      55              : 
      56              :   /// Large corners (10 px): cards.
      57              :   @override
      58              :   final double lg;
      59              : 
      60              :   /// Extra-large corners (14 px): sheets and large surfaces.
      61              :   @override
      62              :   final double xl;
      63              : 
      64              :   /// Double extra-large corners (16 px).
      65              :   @override
      66              :   final double xl2;
      67              : 
      68              :   /// Pill sentinel; clamp to half the height at the use site.
      69              :   static const full = 9999.0;
      70              : 
      71              :   /// The default radius scale.
      72              :   static const standard = FossRadii(sm: 6, md: 8, lg: 10, xl: 14, xl2: 16);
      73              : }
        

Generated by: LCOV version 2.0-1