-
Notifications
You must be signed in to change notification settings - Fork 24k
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
Adds support for platform specific styles in StyleSheet #7033
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ | |
var PixelRatio = require('PixelRatio'); | ||
var StyleSheetRegistry = require('StyleSheetRegistry'); | ||
var StyleSheetValidation = require('StyleSheetValidation'); | ||
var Platform = require('Platform'); | ||
|
||
var flatten = require('flattenStyle'); | ||
|
||
|
@@ -93,9 +94,19 @@ module.exports = { | |
*/ | ||
create(obj: {[key: string]: any}): {[key: string]: number} { | ||
var result = {}; | ||
|
||
for (var key in obj) { | ||
StyleSheetValidation.validateStyle(key, obj); | ||
result[key] = StyleSheetRegistry.registerStyle(obj[key]); | ||
|
||
let {ios, android, ...style} = obj[key]; | ||
if (ios && Platform.OS === 'ios') { | ||
style = {...style, ...ios}; | ||
} | ||
if (android && Platform.OS === 'android') { | ||
style = {...style, ...android}; | ||
} | ||
|
||
StyleSheetValidation.validateStyle(key, style); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you sure this is correct? This looks different from the previous code, where There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmmm... You're right. I'll take a look at this again. Thanks for pointing it out. |
||
result[key] = StyleSheetRegistry.registerStyle(style); | ||
} | ||
return result; | ||
} | ||
|
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.
semi: Missing semicolon.