Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 28 additions & 6 deletions packages/stac/lib/src/parsers/widgets/stac_border/stac_border.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:stac/src/parsers/widgets/stac_border_side/stac_border_side.dart';
import 'package:stac/src/parsers/widgets/stac_double/stac_double.dart';
import 'package:stac/src/utils/color_utils.dart';

Expand All @@ -9,10 +10,16 @@ part 'stac_border.g.dart';
@freezed
abstract class StacBorder with _$StacBorder {
const factory StacBorder({
// Uniform border properties (applies to all sides)
String? color,
@Default(BorderStyle.solid) BorderStyle borderStyle,
@Default(StacDouble(1.0)) StacDouble width,
@Default(StacDouble(BorderSide.strokeAlignInside)) StacDouble strokeAlign,
// Individual border sides
StacBorderSide? top,
StacBorderSide? right,
StacBorderSide? bottom,
StacBorderSide? left,
}) = _StacBorder;

factory StacBorder.fromJson(Map<String, dynamic> json) =>
Expand All @@ -21,11 +28,26 @@ abstract class StacBorder with _$StacBorder {

extension StacBorderParser on StacBorder {
Border parse(BuildContext context) {
return Border.all(
color: color.toColor(context) ?? const Color(0xFF000000),
width: width.parse,
style: borderStyle,
strokeAlign: strokeAlign.parse,
);
// Check if individual border sides are specified
final hasIndividualSides =
top != null || right != null || bottom != null || left != null;

if (hasIndividualSides) {
// Use individual border sides
return Border(
top: top.parse(context),
right: right.parse(context),
bottom: bottom.parse(context),
left: left.parse(context),
);
} else {
// Fall back to uniform border behavior for all sides
return Border.all(
color: color.toColor(context) ?? const Color(0xFF000000),
width: width.parse,
style: borderStyle,
strokeAlign: strokeAlign.parse,
);
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading