-
Notifications
You must be signed in to change notification settings - Fork 11
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
feat(exoflex): Theme Styles #362
feat(exoflex): Theme Styles #362
Conversation
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.
Wow, this is really comprehensive theme configuration!
titleStyle={titleStyle} | ||
iconStyle={iconStyle} | ||
titleContainerStyle={[ | ||
themeStyle?.accordion?.titleContainerStyle, |
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.
I think it's better if we flatten the themeStyle
first as there could be a chance that the user using a style that generated by StyleSheet.create()
for the theme style.
Ref: https://facebook.github.io/react-native/docs/stylesheet.html#flatten
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.
Would you clarify whether to apply StyleSheet.flatten
specifically at this part or everywhere?
Mostly these styles are used for internal Views
and Texts
, which are also using styles generated by StyleSheet.create
. These props here are for View
, Text
, and AnimatedIcon
(which is an Animated.View
). Is StyleSheet.flatten
necessary?
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.
When we create a style using StyleSheet.create()
and use it, it will return the ID instead of the style object:
For example:
const styles = StyleSheet.create({
listItem: {
flex: 1,
fontSize: 16,
color: 'white',
},
selectedListItem: {
color: 'green',
},
});
StyleSheet.flatten(styles.listItem);
// returns { flex: 1, fontSize: 16, color: 'white' }
// Simply styles.listItem would return its ID (number)
That's why it would be safer to flatten it first to get the style object instead of doing optional chaining over the ID which is a number.
And I think it would be ideal if we flatten the themeStyle
every time we want to use it. Because there is a high chance that the user will use the generated style object from StyleSheet.create()
, not the pure object.
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.
When we create a style using StyleSheet.create() and use it, it will return the ID instead of the style object
Yup, I know about this.
But, now I'm confused. Our component props
have style
, someStyle
, and someContainerStyle
which will most likely come from StyleSheet.create()
, yet we simply pass them on without calling StyleSheet.flatten()
. Shall we also flatten those styles or are these two different cases?
Note that I'm following the way we're passing style
from props
towards the component.
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.
Discussed in person and we'll create a different PR to use StyleSheet.flatten()
on all styles that come from the user.
Nevermind, after further discussion, we figured out that there was a misunderstanding and there's no need to use StyleSheet.flatten()
.
Will resolve #320