Skip to content

Commit

Permalink
fix/decoration-merge (#190)
Browse files Browse the repository at this point in the history
  • Loading branch information
nank1ro authored Nov 5, 2024
1 parent 1bbe4cd commit 367b69b
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 36 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.15.1

- **FIX**: Decoration merge

## 0.15.0

- **FEAT**: New `ShadDatePicker` component.
Expand Down
20 changes: 11 additions & 9 deletions lib/src/components/alert.dart
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,17 @@ class ShadAlert extends StatelessWidget {
effectiveAlertTheme.iconPadding ??
const EdgeInsets.only(right: 12);

final effectiveDecoration = decoration ??
effectiveAlertTheme.decoration ??
ShadDecoration(
border: ShadBorder.all(
color: theme.colorScheme.border,
radius: theme.radius,
padding: const EdgeInsets.all(16),
),
);
final defaultDecoration = ShadDecoration(
border: ShadBorder.all(
color: theme.colorScheme.border,
radius: theme.radius,
padding: const EdgeInsets.all(16),
),
);

final effectiveDecoration = defaultDecoration
.mergeWith(effectiveAlertTheme.decoration)
.mergeWith(decoration);

final effectiveIconColor = iconColor ??
effectiveAlertTheme.iconColor ??
Expand Down
4 changes: 2 additions & 2 deletions lib/src/components/calendar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1144,8 +1144,8 @@ class _ShadCalendarState extends State<ShadCalendar> {
.5;

final effectiveDecoration =
theme.calendarTheme.decoration?.mergeWith(widget.decoration) ??
widget.decoration;
(theme.calendarTheme.decoration ?? const ShadDecoration())
.mergeWith(widget.decoration);

final effectiveSpacingBetweenMonths = widget.spacingBetweenMonths ??
theme.calendarTheme.spacingBetweenMonths ??
Expand Down
15 changes: 8 additions & 7 deletions lib/src/components/context_menu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,8 @@ class ShadContextMenuState extends State<ShadContextMenu> {
const EdgeInsets.symmetric(vertical: 4);

final effectiveDecoration =
widget.decoration ?? theme.contextMenuTheme.decoration;
(theme.contextMenuTheme.decoration ?? const ShadDecoration())
.mergeWith(widget.decoration);

final effectiveFilter = widget.filter ?? theme.contextMenuTheme.filter;

Expand Down Expand Up @@ -688,12 +689,12 @@ class _ShadContextMenuItemState extends State<ShadContextMenuItem> {
theme.contextMenuTheme.buttonVariant ??
ShadButtonVariant.ghost;

final effectiveDecoration = widget.decoration ??
theme.contextMenuTheme.itemDecoration ??
const ShadDecoration(
secondaryBorder: ShadBorder.none,
secondaryFocusedBorder: ShadBorder.none,
);
final effectiveDecoration = const ShadDecoration(
secondaryBorder: ShadBorder.none,
secondaryFocusedBorder: ShadBorder.none,
)
.mergeWith(theme.contextMenuTheme.itemDecoration)
.mergeWith(widget.decoration);

final effectiveTextStyle = widget.textStyle ??
theme.contextMenuTheme.textStyle ??
Expand Down
18 changes: 9 additions & 9 deletions lib/src/components/resizable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -277,15 +277,15 @@ class ShadResizablePanelGroupState extends State<ShadResizablePanelGroup> {
theme.resizableTheme.dividerColor ??
theme.colorScheme.border;

final effectiveHandleDecoration = widget.handleDecoration ??
theme.resizableTheme.handleDecoration ??
ShadDecoration(
color: theme.colorScheme.border,
border: ShadBorder.all(
radius: const BorderRadius.all(Radius.circular(4)),
width: 0,
),
);
final effectiveHandleDecoration = ShadDecoration(
color: theme.colorScheme.border,
border: ShadBorder.all(
radius: const BorderRadius.all(Radius.circular(4)),
width: 0,
),
)
.mergeWith(theme.resizableTheme.handleDecoration)
.mergeWith(widget.handleDecoration);

final effectiveHandlePadding = widget.handlePadding ??
theme.resizableTheme.handlePadding ??
Expand Down
12 changes: 5 additions & 7 deletions lib/src/components/tabs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -280,13 +280,11 @@ class ShadTabsState<T> extends State<ShadTabs<T>> with RestorationMixin {
final effectivePadding =
widget.padding ?? tabsTheme.padding ?? EdgeInsets.zero;

final effectiveDecoration = widget.decoration ??
tabsTheme.decoration ??
ShadDecoration(
merge: false,
color: theme.colorScheme.muted,
border: ShadBorder.all(radius: theme.radius, width: 0),
);
final effectiveDecoration = ShadDecoration(
merge: false,
color: theme.colorScheme.muted,
border: ShadBorder.all(radius: theme.radius, width: 0),
).mergeWith(tabsTheme.decoration).mergeWith(widget.decoration);

final effectiveGap = widget.gap ?? tabsTheme.gap ?? 8;

Expand Down
4 changes: 3 additions & 1 deletion lib/src/components/tooltip.dart
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ class _ShadTooltipState extends State<ShadTooltip> {
final effectiveEffects = widget.effects ?? theme.tooltipTheme.effects ?? [];
final effectivePadding = widget.padding ?? theme.tooltipTheme.padding;
final effectiveDecoration =
widget.decoration ?? theme.tooltipTheme.decoration;
(theme.tooltipTheme.decoration ?? const ShadDecoration())
.mergeWith(widget.decoration);

final effectiveAnchor = widget.anchor ??
theme.tooltipTheme.anchor ??
const ShadAnchorAuto(
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: shadcn_ui
description: shadcn-ui ported in Flutter. Awesome UI components for Flutter, fully customizable.
version: 0.15.0
version: 0.15.1
homepage: https://flutter-shadcn-ui.mariuti.com
repository: https://github.com/nank1ro/flutter-shadcn-ui
documentation: https://flutter-shadcn-ui.mariuti.com
Expand Down

0 comments on commit 367b69b

Please sign in to comment.