Skip to content

Commit

Permalink
fix: needs rereview
Browse files Browse the repository at this point in the history
  • Loading branch information
omariosouto committed Feb 8, 2022
1 parent 8dd2d0e commit 2c0f449
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 39 deletions.
106 changes: 67 additions & 39 deletions lib/components/box/flutter/box_base_styles.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ double? doubleValueResolver(value, defaultValue, activeBreakpoint) {
value,
activeBreakpoint,
);
return (baseValue != null) ? double.parse(baseValue) : defaultValue;
return (baseValue != null)
? double.parse(baseValue.replaceAll('px', ''))
: defaultValue;
}

class BoxBaseStyles {
Expand All @@ -44,10 +46,10 @@ class BoxBaseStyles {
dynamic color = '#000000';
dynamic backgroundColor = 'transparent';
dynamic padding;
double paddingTop = 0;
double paddingLeft = 0;
double paddingRight = 0;
double paddingBottom = 0;
dynamic paddingTop;
dynamic paddingLeft;
dynamic paddingRight;
dynamic paddingBottom;
dynamic paddingVertical;
dynamic paddingHorizontal;
dynamic margin;
Expand Down Expand Up @@ -110,45 +112,71 @@ class BoxBaseStyles {
styleSheet.marginVertical, marginVertical, activeBreakpoint);
marginHorizontal = doubleValueResolver(
styleSheet.marginHorizontal, marginHorizontal, activeBreakpoint);
marginTop =
resolveValueForBreakpoint(styleSheet.marginTop, activeBreakpoint) ??
marginVertical ??
margin;
marginLeft =
resolveValueForBreakpoint(styleSheet.marginLeft, activeBreakpoint) ??
marginHorizontal ??
margin;
marginRight =
resolveValueForBreakpoint(styleSheet.marginRight, activeBreakpoint) ??
marginHorizontal ??
margin;
marginBottom =
resolveValueForBreakpoint(styleSheet.marginBottom, activeBreakpoint) ??
marginVertical ??
margin;
marginTop = doubleValueResolver(
styleSheet.marginTop,
marginTop,
activeBreakpoint,
) ??
marginVertical ??
margin;
marginBottom = doubleValueResolver(
styleSheet.marginBottom,
marginBottom,
activeBreakpoint,
) ??
marginVertical ??
margin;
marginLeft = doubleValueResolver(
styleSheet.marginLeft,
marginLeft,
activeBreakpoint,
) ??
marginHorizontal ??
margin;
marginRight = doubleValueResolver(
styleSheet.marginRight,
marginRight,
activeBreakpoint,
) ??
marginHorizontal ??
margin;

// [padding]
padding = double.parse(
resolveValueForBreakpoint(styleSheet.padding, activeBreakpoint));
padding =
doubleValueResolver(styleSheet.padding, padding, activeBreakpoint);
paddingVertical = doubleValueResolver(
styleSheet.paddingVertical, paddingVertical, activeBreakpoint);
paddingHorizontal = doubleValueResolver(
styleSheet.paddingHorizontal, paddingHorizontal, activeBreakpoint);
paddingTop =
resolveValueForBreakpoint(styleSheet.paddingTop, activeBreakpoint) ??
paddingVertical ??
padding;
paddingLeft =
resolveValueForBreakpoint(styleSheet.paddingLeft, activeBreakpoint) ??
paddingHorizontal ??
padding;
paddingRight =
resolveValueForBreakpoint(styleSheet.paddingRight, activeBreakpoint) ??
paddingHorizontal ??
padding;
paddingBottom =
resolveValueForBreakpoint(styleSheet.paddingBottom, activeBreakpoint) ??
paddingVertical ??
padding;

paddingTop = doubleValueResolver(
styleSheet.paddingTop,
paddingTop,
activeBreakpoint,
) ??
paddingVertical ??
padding;
paddingBottom = doubleValueResolver(
styleSheet.paddingBottom,
paddingBottom,
activeBreakpoint,
) ??
paddingVertical ??
padding as double;
paddingLeft = doubleValueResolver(
styleSheet.paddingLeft,
paddingLeft,
activeBreakpoint,
) ??
paddingHorizontal ??
padding;
paddingRight = doubleValueResolver(
styleSheet.paddingRight,
paddingRight,
activeBreakpoint,
) ??
paddingHorizontal ??
padding;

// [flexDirection]
flexDirection =
Expand Down
1 change: 1 addition & 0 deletions lib/core/breakpoints/breakpoints.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ dynamic resolveValueForBreakpoint(
for (var i = currentBreakpointOrder; i! >= 0; i--) {
var breakpoint = breakpointsOrderByOrder[i];
if (value.containsKey(breakpoint) && value[breakpoint] != null) {
// Remove px
return value[breakpoint];
}
}
Expand Down

3 comments on commit 2c0f449

@vercel
Copy link

@vercel vercel bot commented on 2c0f449 Feb 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 2c0f449 Feb 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

sknui-demobase-react – ./examples/demo_base

sknui-demobase-react.vercel.app
sknui-demobase-react-git-main-skynexui.vercel.app
sknui-demobase-react-skynexui.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 2c0f449 Feb 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.