diff --git a/lib/src/attributes/border/border_util.dart b/lib/src/attributes/border/border_util.dart index 0b37e37f7..a86ce6861 100644 --- a/lib/src/attributes/border/border_util.dart +++ b/lib/src/attributes/border/border_util.dart @@ -37,12 +37,14 @@ class BorderSideUtility BorderStyle? style, double? strokeAlign, }) { - return builder(BorderSideDto( - color: color, - strokeAlign: strokeAlign, - style: style, - width: width, - )); + return builder( + BorderSideDto( + color: color, + strokeAlign: strokeAlign, + style: style, + width: width, + ), + ); } /// Returns a [ColorUtility] to manipulate [Color] of the [BorderSideDto] @@ -52,12 +54,16 @@ class BorderSideUtility BorderStyleUtility get style => BorderStyleUtility((style) => _only(style: style)); + T as(BorderSide side) => builder(BorderSideDto.from(side)); + /// Sets the width of the [BorderSideDto] T width(double width) => call(width: width); /// Sets the stroke align of the [BorderSideDto] T strokeAlign(double strokeAlign) => call(strokeAlign: strokeAlign); + T none() => as(BorderSide.none); + /// Creates a [BorderSideDto] with the provided parameters and calls the [builder] function. T call({ Color? color, @@ -80,6 +86,7 @@ class BorderUtility extends DtoUtility { /// Constructor for creating an instance of the class. const BorderUtility(super.builder) : super(valueToDto: BoxBorderDto.from); + BoxBorderDto _symmetric({ BorderSideDto? vertical, BorderSideDto? horizontal, @@ -96,17 +103,6 @@ class BorderUtility return BoxBorderDto(top: side, bottom: side, left: side, right: side); } - T _only({ - BorderSideDto? top, - BorderSideDto? bottom, - BorderSideDto? left, - BorderSideDto? right, - }) { - return builder( - BoxBorderDto(top: top, bottom: bottom, left: left, right: right), - ); - } - BorderDirectionalUtility get _directional => BorderDirectionalUtility((border) => builder(border)); @@ -123,22 +119,22 @@ class BorderUtility /// Method to set the border on the bottom side. BorderSideUtility get bottom { - return BorderSideUtility((side) => _only(bottom: side)); + return BorderSideUtility((side) => only(bottom: side)); } /// Method to set the border on the top side. BorderSideUtility get top { - return BorderSideUtility((side) => _only(top: side)); + return BorderSideUtility((side) => only(top: side)); } /// Method to set the border on the left side. BorderSideUtility get left { - return BorderSideUtility((side) => _only(left: side)); + return BorderSideUtility((side) => only(left: side)); } /// Method to set the border on the right side. BorderSideUtility get right { - return BorderSideUtility((side) => _only(right: side)); + return BorderSideUtility((side) => only(right: side)); } /// Method to set the borders on the vertical sides. @@ -153,6 +149,29 @@ class BorderUtility ); } + /// Returns a [ColorUtility] to manipulate [Color] of the [BorderSideDto] + ColorUtility get color => all.color; + + BorderStyleUtility get style => all.style; + + T width(double width) => all.width(width); + + T strokeAlign(double strokeAlign) => all.strokeAlign(strokeAlign); + + T none() => all.none(); + + /// Method to set the border individually on each side. + T only({ + BorderSideDto? top, + BorderSideDto? bottom, + BorderSideDto? left, + BorderSideDto? right, + }) { + return builder( + BoxBorderDto(top: top, bottom: bottom, left: left, right: right), + ); + } + /// Creates a [BoxBorderDto] with the provided parameters and calls the [builder] function. T call({ Color? color, diff --git a/lib/src/attributes/color/color_util.dart b/lib/src/attributes/color/color_util.dart index cbafd6899..a42f79ad6 100644 --- a/lib/src/attributes/color/color_util.dart +++ b/lib/src/attributes/color/color_util.dart @@ -19,19 +19,6 @@ class ColorUtility T _directive(ColorDirective directive) => builder(ColorDto.directive(directive)); - T withOpacity(double opacity) => _directive(OpacityColorDirective(opacity)); - T withAlpha(int alpha) => _directive(AlphaColorDirective(alpha)); - T darken(int percentage) => _directive(DarkenColorDirective(percentage)); - T lighten(int percentage) => _directive(LightenColorDirective(percentage)); - T saturate(int percentage) => _directive(SaturateColorDirective(percentage)); - T desaturate(int percentage) => - _directive(DesaturateColorDirective(percentage)); - T tint(int percentage) => _directive(TintColorDirective(percentage)); - T shade(int percentage) => _directive(ShadeColorDirective(percentage)); - T brighten(int percentage) => _directive(BrightenColorDirective(percentage)); - - T of(ColorToken ref) => _buildColor(ref()); - MaterialColorUtility get red => MaterialColorUtility(builder, Colors.red); MaterialColorUtility get pink => MaterialColorUtility(builder, Colors.pink); @@ -101,6 +88,19 @@ class ColorUtility MaterialAccentColorUtility(builder, Colors.orangeAccent); MaterialAccentColorUtility get deepOrangeAccent => MaterialAccentColorUtility(builder, Colors.deepOrangeAccent); + T withOpacity(double opacity) => _directive(OpacityColorDirective(opacity)); + T withAlpha(int alpha) => _directive(AlphaColorDirective(alpha)); + T darken(int percentage) => _directive(DarkenColorDirective(percentage)); + T lighten(int percentage) => _directive(LightenColorDirective(percentage)); + T saturate(int percentage) => _directive(SaturateColorDirective(percentage)); + T desaturate(int percentage) => + _directive(DesaturateColorDirective(percentage)); + T tint(int percentage) => _directive(TintColorDirective(percentage)); + T shade(int percentage) => _directive(ShadeColorDirective(percentage)); + T brighten(int percentage) => _directive(BrightenColorDirective(percentage)); + + T of(ColorToken ref) => _buildColor(ref()); + T transparent() => _buildColor(Colors.transparent); T black() => _buildColor(const Color(0xFF000000)); T black87() => _buildColor(const Color(0xDD000000));