-
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat (flutter_box): organize the box component and stylesheet (#45)
* feat: add all basic code to box work properly with all specified values in styleSheet.json
- Loading branch information
1 parent
7cef397
commit b1863f4
Showing
17 changed files
with
269 additions
and
805 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -210,4 +210,6 @@ build/ | |
!**/ios/**/default.pbxuser | ||
!**/ios/**/default.perspectivev3 | ||
|
||
# SkynexUI | ||
examples/**/*.lock | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import 'package:skynexui_components/components.dart'; | ||
import 'package:skynexui_components/components/box/flutter/hexcolor.dart'; | ||
|
||
class BoxBaseStyles { | ||
StyleSheet styleSheet; | ||
Breakpoints activeBreakpoint; | ||
dynamic color; | ||
dynamic backgroundColor; | ||
dynamic padding; | ||
dynamic paddingTop; | ||
dynamic paddingLeft; | ||
dynamic paddingRight; | ||
dynamic paddingBottom; | ||
dynamic paddingVertical; | ||
dynamic paddingHorizontal; | ||
dynamic margin; | ||
dynamic marginTop; | ||
dynamic marginLeft; | ||
dynamic marginRight; | ||
dynamic marginBottom; | ||
dynamic marginVertical; | ||
dynamic marginHorizontal; | ||
|
||
BoxBaseStyles({ | ||
required this.styleSheet, | ||
required this.activeBreakpoint, | ||
}) { | ||
// [color] | ||
var colorValue = | ||
resolveValueForBreakpoint(styleSheet.color, activeBreakpoint); | ||
color = (colorValue != null) ? HexColor.fromHex(colorValue) : Colors.black; | ||
|
||
// [backgroundColor] | ||
var backgroundColorValue = | ||
resolveValueForBreakpoint(styleSheet.backgroundColor, activeBreakpoint); | ||
backgroundColor = (backgroundColorValue != null) | ||
? HexColor.fromHex(backgroundColorValue) | ||
: Colors.transparent; | ||
|
||
// [margin] | ||
margin = resolveValueForBreakpoint(styleSheet.margin, activeBreakpoint); | ||
marginVertical = | ||
resolveValueForBreakpoint(styleSheet.marginVertical, activeBreakpoint); | ||
marginHorizontal = resolveValueForBreakpoint( | ||
styleSheet.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; | ||
// [padding] | ||
padding = resolveValueForBreakpoint(styleSheet.padding, activeBreakpoint); | ||
paddingVertical = | ||
resolveValueForBreakpoint(styleSheet.paddingVertical, activeBreakpoint); | ||
paddingHorizontal = resolveValueForBreakpoint( | ||
styleSheet.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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import 'package:skynexui_components/components.dart'; | ||
|
||
extension HexColor on Color { | ||
/// String is in the format "aabbcc" or "ffaabbcc" with an optional leading "#". | ||
static Color fromHex(String hexString) { | ||
final buffer = StringBuffer(); | ||
if (hexString.length == 6 || hexString.length == 7) buffer.write('ff'); | ||
buffer.write(hexString.replaceFirst('#', '')); | ||
return Color(int.parse(buffer.toString(), radix: 16)); | ||
} | ||
|
||
/// Prefixes a hash sign if [leadingHashSign] is set to `true` (default is `true`). | ||
String toHex({bool leadingHashSign = true}) => '${leadingHashSign ? '#' : ''}' | ||
'${alpha.toRadixString(16).padLeft(2, '0')}' | ||
'${red.toRadixString(16).padLeft(2, '0')}' | ||
'${green.toRadixString(16).padLeft(2, '0')}' | ||
'${blue.toRadixString(16).padLeft(2, '0')}'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
b1863f4
There was a problem hiding this comment.
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:
docs-storybook – ./
docs-storybook.vercel.app
docs-storybook-git-main-skynexui.vercel.app
docs-storybook-skynexui.vercel.app
storybook.skynexui.dev
b1863f4
There was a problem hiding this comment.
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:
docs – ./docs
docs-skynexui.vercel.app
skynexui.dev
docs-coral-nine.vercel.app
docs-git-main-skynexui.vercel.app
www.skynexui.dev