PlatformStyleSheet.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /**
  2. * Copyright 2016 Facebook, Inc.
  3. *
  4. * You are hereby granted a non-exclusive, worldwide, royalty-free license to
  5. * use, copy, modify, and distribute this software in source code or binary
  6. * form for use in connection with the web services and APIs provided by
  7. * Facebook.
  8. *
  9. * As with any software that integrates with the Facebook platform, your use
  10. * of this software is subject to the Facebook Developer Principles and
  11. * Policies [http://developers.facebook.com/policy/]. This copyright notice
  12. * shall be included in all copies or substantial portions of the software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  17. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  20. * DEALINGS IN THE SOFTWARE
  21. *
  22. * @providesModule F8StyleSheet
  23. * @flow
  24. */
  25. 'use strict'
  26. import {StyleSheet, Platform} from 'react-native'
  27. export function create(styles) {
  28. const platformStyles = {}
  29. Object.keys(styles).forEach((name) => {
  30. let {ios, android, ...style} = {...styles[name]}
  31. if (ios && Platform.OS === 'ios') {
  32. style = {...style, ...ios}
  33. }
  34. if (android && Platform.OS === 'android') {
  35. style = {...style, ...android}
  36. }
  37. platformStyles[name] = style
  38. // platformStyles[name]['borderWidth'] = 1
  39. })
  40. return StyleSheet.create(platformStyles)
  41. }