Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: [MDS-525] Fix EdgeInsetsGeometry behaviour that is passed in as props #166

Merged
merged 2 commits into from
May 17, 2023
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
14 changes: 8 additions & 6 deletions lib/src/widgets/buttons/button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -355,12 +355,14 @@ class MoonButton extends StatelessWidget {

final EdgeInsets resolvedDirectionalPadding = effectivePadding.resolve(Directionality.of(context));

final EdgeInsetsDirectional correctedPadding = EdgeInsetsDirectional.fromSTEB(
leading == null && label != null ? resolvedDirectionalPadding.left : 0,
resolvedDirectionalPadding.top,
trailing == null && label != null ? resolvedDirectionalPadding.right : 0,
resolvedDirectionalPadding.bottom,
);
final EdgeInsetsGeometry correctedPadding = padding == null
? EdgeInsetsDirectional.fromSTEB(
leading == null && label != null ? resolvedDirectionalPadding.left : 0,
resolvedDirectionalPadding.top,
trailing == null && label != null ? resolvedDirectionalPadding.right : 0,
resolvedDirectionalPadding.bottom,
)
: resolvedDirectionalPadding;

final Duration effectiveHoverEffectDuration = hoverEffectDuration ??
context.moonEffects?.controlHoverEffect.hoverDuration ??
Expand Down
14 changes: 8 additions & 6 deletions lib/src/widgets/chips/chip.dart
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,14 @@ class MoonChip extends StatelessWidget {

final EdgeInsets resolvedDirectionalPadding = effectivePadding.resolve(Directionality.of(context));

final EdgeInsetsDirectional correctedPadding = EdgeInsetsDirectional.fromSTEB(
leading == null && label != null ? resolvedDirectionalPadding.left : 0,
resolvedDirectionalPadding.top,
trailing == null && label != null ? resolvedDirectionalPadding.right : 0,
resolvedDirectionalPadding.bottom,
);
final EdgeInsetsGeometry correctedPadding = padding == null
? EdgeInsetsDirectional.fromSTEB(
leading == null && label != null ? resolvedDirectionalPadding.left : 0,
resolvedDirectionalPadding.top,
trailing == null && label != null ? resolvedDirectionalPadding.right : 0,
resolvedDirectionalPadding.bottom,
)
: resolvedDirectionalPadding;
return MoonBaseControl(
autofocus: autofocus,
isFocusable: isFocusable,
Expand Down
4 changes: 3 additions & 1 deletion lib/src/widgets/popover/popover.dart
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,8 @@ class MoonPopoverState extends State<MoonPopover> with RouteAware, SingleTickerP
final EdgeInsetsGeometry effectiveContentPadding =
widget.contentPadding ?? context.moonTheme?.popoverTheme.properties.contentPadding ?? const EdgeInsets.all(12);

final EdgeInsets resolvedContentPadding = effectiveContentPadding.resolve(Directionality.of(context));

final List<BoxShadow> effectivePopoverShadows =
widget.popoverShadows ?? context.moonTheme?.popoverTheme.shadows.popoverShadows ?? MoonShadows.light.sm;

Expand Down Expand Up @@ -448,7 +450,7 @@ class MoonPopoverState extends State<MoonPopover> with RouteAware, SingleTickerP
child: Container(
key: _popoverKey,
constraints: BoxConstraints(maxWidth: popoverPositionParameters.popoverMaxWidth),
padding: effectiveContentPadding,
padding: resolvedContentPadding,
decoration: ShapeDecoration(
color: effectiveBackgroundColor,
shadows: effectivePopoverShadows,
Expand Down
14 changes: 8 additions & 6 deletions lib/src/widgets/tag/tag.dart
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,14 @@ class MoonTag extends StatelessWidget {

final EdgeInsets resolvedDirectionalPadding = effectivePadding.resolve(Directionality.of(context));

final EdgeInsetsDirectional correctedPadding = EdgeInsetsDirectional.fromSTEB(
leading == null && label != null ? resolvedDirectionalPadding.left : 0,
resolvedDirectionalPadding.top,
trailing == null && label != null ? resolvedDirectionalPadding.right : 0,
resolvedDirectionalPadding.bottom,
);
final EdgeInsetsGeometry correctedPadding = padding == null
? EdgeInsetsDirectional.fromSTEB(
leading == null && label != null ? resolvedDirectionalPadding.left : 0,
resolvedDirectionalPadding.top,
trailing == null && label != null ? resolvedDirectionalPadding.right : 0,
resolvedDirectionalPadding.bottom,
)
: resolvedDirectionalPadding;

return Semantics(
label: semanticLabel,
Expand Down
6 changes: 4 additions & 2 deletions lib/src/widgets/toast/toast.dart
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ class MoonToast {
final EdgeInsetsGeometry effectiveContentPadding =
padding ?? context.moonTheme?.toastTheme.properties.contentPadding ?? EdgeInsets.all(MoonSizes.sizes.x2s);

final EdgeInsets resolvedContentPadding = effectiveContentPadding.resolve(Directionality.of(context));

final List<BoxShadow> effectiveToastShadows =
toastShadows ?? context.moonTheme?.toastTheme.shadows.toastShadows ?? MoonShadows.light.lg;

Expand Down Expand Up @@ -170,8 +172,8 @@ class MoonToast {
duration: effectiveTransitionDuration,
style: DefaultTextStyle.of(context).style.copyWith(color: effectiveElementColor),
child: Container(
margin: margin ?? effectiveContentPadding,
padding: effectiveContentPadding,
margin: margin ?? resolvedContentPadding,
padding: resolvedContentPadding,
decoration: ShapeDecoration(
color: effectiveBackgroundColor,
shadows: effectiveToastShadows,
Expand Down
4 changes: 3 additions & 1 deletion lib/src/widgets/tooltip/tooltip.dart
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,8 @@ class _MoonTooltipState extends State<MoonTooltip> with RouteAware, SingleTicker
final EdgeInsetsGeometry effectiveContentPadding =
widget.contentPadding ?? context.moonTheme?.tooltipTheme.properties.contentPadding ?? const EdgeInsets.all(12);

final EdgeInsets resolvedContentPadding = effectiveContentPadding.resolve(Directionality.of(context));

final List<BoxShadow> effectiveTooltipShadows =
widget.tooltipShadows ?? context.moonTheme?.tooltipTheme.shadows.tooltipShadows ?? MoonShadows.light.sm;

Expand Down Expand Up @@ -504,7 +506,7 @@ class _MoonTooltipState extends State<MoonTooltip> with RouteAware, SingleTicker
child: Container(
key: _tooltipKey,
constraints: BoxConstraints(maxWidth: tooltipPositionParameters.tooltipMaxWidth),
padding: effectiveContentPadding,
padding: resolvedContentPadding,
decoration: ShapeDecoration(
color: effectiveBackgroundColor,
shadows: effectiveTooltipShadows,
Expand Down