From 50de4a67b0c06a5a3f54c81fadf56b34fe8ccb52 Mon Sep 17 00:00:00 2001 From: Eric Vicenti Date: Mon, 4 May 2015 14:33:05 -0700 Subject: [PATCH] [ReactNative] Navigator use flattenStyle Summary: A hack was implemented in Navigator to do this manually, but there is a proper function to get these styles for setting native props @public Test Plan: Testing Navigator behavior on iOS and Android --- .../CustomComponents/Navigator/Navigator.js | 24 +++---------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/Libraries/CustomComponents/Navigator/Navigator.js b/Libraries/CustomComponents/Navigator/Navigator.js index 6d09b656e..26c6a46bd 100644 --- a/Libraries/CustomComponents/Navigator/Navigator.js +++ b/Libraries/CustomComponents/Navigator/Navigator.js @@ -40,13 +40,13 @@ var Platform = require('Platform'); var React = require('React'); var StaticContainer = require('StaticContainer.react'); var StyleSheet = require('StyleSheet'); -var StyleSheetRegistry = require('StyleSheetRegistry'); var Subscribable = require('Subscribable'); var TimerMixin = require('react-timer-mixin'); var View = require('View'); -var getNavigatorContext = require('getNavigatorContext'); var clamp = require('clamp'); +var flattenStyle = require('flattenStyle'); +var getNavigatorContext = require('getNavigatorContext'); var invariant = require('invariant'); var keyMirror = require('keyMirror'); var merge = require('merge'); @@ -67,24 +67,6 @@ function getuid() { return __uid++; } -function resolveStyle(styles) { - // The styles for a scene are a prop in the style format, which can be an object, - // a number (which refers to the StyleSheetRegistry), or an arry of objects/numbers. - // This function resolves the actual style values so we can call setNativeProps with - // matching styles. - var resolvedStyle = {}; - if (!Array.isArray(styles)) { - styles = [styles]; - } - styles.forEach((style) => { - if (typeof style === 'number') { - style = StyleSheetRegistry.getStyleByID(style); - } - resolvedStyle = merge(resolvedStyle, style); - }); - return resolvedStyle; -} - // styles moved to the top of the file so getDefaultProps can refer to it var styles = StyleSheet.create({ container: { @@ -698,7 +680,7 @@ var Navigator = React.createClass({ */ _enableScene: function(sceneIndex) { // First, determine what the defined styles are for scenes in this navigator - var sceneStyle = resolveStyle(this.props.sceneStyle); + var sceneStyle = flattenStyle(this.props.sceneStyle); // Then restore the left value for this scene var enabledSceneNativeProps = { left: sceneStyle.left,