Commit Graph

17 Commits

Author SHA1 Message Date
Brent Vatne 346858a552 Add StyleSheet.setStyleAttributePreprocessor
Summary:
**Motivation**

On Exponent we load fonts dynamically and assign their native names by appending a session id, so that fonts from one Exponent "experience" do not clash with each other. So, before sending the `fontFamily` to native, we want to change it to the Exponent-scoped `fontFamily`.

Example:

```js
// Before rendering your app
StyleSheet.setStyleAttributePreprocessor('fontFamily', _processFontFamily);

function _processFontFamily(name) {
  // Pass system fonts through
  if (!name || Constants.systemFonts.indexOf(name) >= 0) {
    return name;
  }

  if (!Font.isLoaded(name)) {
    if (__DEV__) {
      console.error(`${name} is not a system font and has not been loaded through Exponent.Font.loadAsync. If you intended to use a system font, make sure you typed the name correctly and that it is supported by the current operating system. If this is a custom font, be sure to load it with Exponent.Font.loadAsync`);
    } else {
      return 'system';
    }
  }

  return `ExponentFont-
Closes https://github.com/facebook/react-native/pull/11138

Differential Revision: D4245518

Pulled By: mkonicek

fbshipit-source-id: bd2452b1129d6675aa7b88e41351f8bb61fa20a3
2016-11-29 15:28:32 -08:00
David Aurelio 3683beb88a RN: Update React (2/2)
Reviewed By: kentaromiura

Differential Revision: D4026114

fbshipit-source-id: 67808af91454d95941fea01eef58a4d9086f46e1
2016-11-04 05:43:44 -07:00
Martin Kralik c0218957fd Updated documentation for hairlineWidth
Summary:
Not seeing a hairline thick line is a common source of confusion with a simple cause. Let's warn about it.
Closes https://github.com/facebook/react-native/pull/9589

Differential Revision: D3770879

Pulled By: mkonicek

fbshipit-source-id: f1637e17832982fa8fb9b7f485056c452b38b3db
2016-08-25 08:00:24 -07:00
James Ide 8eed600d5b Define Flow types for style and stylesheet objects, more checking
Summary:
- Define a Styles type for the object that gets passed into StyleSheet.create
- Define a StyleSheet type that is returned from StyleSheet.create
- Clean up the type declarations in StyleSheet.create
Closes https://github.com/facebook/react-native/pull/8882

Differential Revision: D3587964

Pulled By: gabelevi

fbshipit-source-id: 629e0176484436848be69b1417638e1200a3669a
2016-08-15 10:43:34 -07:00
Brent Vatne a564af853f Throw flow error when trying to access a style that is not defined on a stylesheet
Summary:
I thought it would be useful to help clear out references to no longer used styles and also catch typos on style names to have flow error when we try to access a style that isn't defined.

Example:

```javascript
export default class AuthenticationScreen extends React.Component {
  render() {
    // This throws an error because `continer` is misspelled
    return (
      <View style={styles.continer} />
    )
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
  },
}
```

```javascript
export default class AuthenticationScreen extends React.Component {
  render() {
    // This throws an error because no fancyContainer style is defined
    return (
      <View style={[styles.container, styles.fancyContainer]} />
    )
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
  },
}
```

All credit goes to jeffmo in this tweet: https://twitter.com/lbljeffmo/status/755179096271888385

Also included in the PR is some cleanup on styles that
Closes https://github.com/facebook/react-native/pull/8876

Differential Revision: D3584983

Pulled By: yungsters

fbshipit-source-id: 0ee0e12ff3d976c137d932688e323c26690e0a52
2016-07-18 23:28:25 -07:00
David Aurelio bd60d828c5 Remove `node_modules/react` from the list of discoverable haste modules
Summary: This removes `node_modules/react` from the list of directories that are used for haste module resolutions. Modules required from React are now imported with `require('react/lib/…')`.

Reviewed By: astreet

Differential Revision: D3509863

fbshipit-source-id: 32cd34e2b8496f0a6676dbe6bb1eacc18124c01e
2016-07-05 06:44:33 -07:00
Spencer Ahrens e79f5d7e7a add StyleSheet.absoluteFill convenience constant
Summary:
It's annoying and inefficient to create styles like

```
  wrapper: {
    position: 'absolute',
    left: 0,
    right: 0,
    top: 0,
    bottom: 0,
  },
```

all the time, so this makes a handy constant for reuse and a helper method to create customized
styles.

Reviewed By: devknoll

Differential Revision: D3389612

fbshipit-source-id: 88fbe9e8ca32a0bc937bf275cf5ae0739ee21302
2016-06-06 16:13:42 -07:00
sunnylqm 53355c692a Add a missing parenthese
Summary: Closes https://github.com/facebook/react-native/pull/6724

Differential Revision: D3115214

fb-gh-sync-id: 2b97ed162c15d8e6ad4ce4906a8b6fcba44864ca
fbshipit-source-id: 2b97ed162c15d8e6ad4ce4906a8b6fcba44864ca
2016-03-30 10:04:54 -07:00
Manas 9b9cc6b543 Documents StyleSheet.flatten()
Summary:Indicates the purpose and an alternative use for the method too.
Closes https://github.com/facebook/react-native/pull/6662

Differential Revision: D3099823

Pulled By: vjeux

fb-gh-sync-id: 44633161a3df9b11d44afaed72fe6127f0b6bf7b
fbshipit-source-id: 44633161a3df9b11d44afaed72fe6127f0b6bf7b
2016-03-25 15:13:17 -07:00
Sebastian Markbage 433fb336af Refactor Attribute Processing (Step 4)
Summary:This avoids flattening styles in most common cases. It diffs against the nested
arrays. The special case is when a property gets removed, it creates an object
that stores the removed keys which then gets resolved using a second pass
through the nested array.

You can conceptually think of this algorithm as:
1) Diff and store changes as you go
2) If something was removed, flatten as necessary

I also merged in another commit that renames the StyleSheetRegistry to ReactNativePropRegistry. There is nothing in here that makes it specific to styles anymore. That's just a decoupled view attribute configuration option. This registry can be used for any set of nested props, if we even want to keep this feature at all.

Reviewed By: vjeux

Differential Revision: D2492885

fb-gh-sync-id: c976ac28b7e63545132c36da0ee0c1c562e7c9e5
shipit-source-id: c976ac28b7e63545132c36da0ee0c1c562e7c9e5
2016-03-24 15:13:24 -07:00
Kyle Corbitt cd89016ee7 PixelRatio.pixel()
Summary:
This implements #5073. It adds a static method `PixelRatio.pixel()` which returns the smallest drawable line width, primarily for use in styles.

It also updates the example apps to use the new function.
Closes https://github.com/facebook/react-native/pull/5076

Reviewed By: svcscm

Differential Revision: D2799849

Pulled By: nicklockwood

fb-gh-sync-id: b83a77790601fe882affbf65531114e7c5cf4bdf
2016-01-15 05:15:31 -08:00
Brent Vatne 0da2004e88 Expose additional private modules
Summary: - TextInputState as TextInput.State
- Touchable
- flattenStyle as StyleSheet.flatten
- ReactNativeART as ART

Original discussion in #1821
Closes https://github.com/facebook/react-native/pull/3308

Reviewed By: sebmarkbage

Differential Revision: D2527152

Pulled By: javache

fb-gh-sync-id: 19d4ef9d4c0e6587b9f0793e1ca624aebb034f3b
2015-11-05 03:35:18 -08:00
Amjad Masad 096f1d9c4c Updates from Fri 10 Apr
- Implemented response headers when using `XMLHttpRequest` | Nick Lockwood
- [ReactNative] Don't redbox on flow config errors | Spencer Ahrens
- [ReactNative] Fix suggestions in TextInput when setting value prop | Spencer Ahrens
- Link LinkingIOS in SampleApp | Nick Lockwood
- unify use of password and secureTextEntry for TextInput | Nick Lockwood
- Added random js queue+execution time sampling in react native | Bryce Redd
- [react_native] JS files from D1980312:     [react_native] Fix webview | Andrei Coman
- [react-packager] Correct module extension regexp | Amjad Masad
- [react-packager] Implement the browser field package.json spec | Amjad Masad
- [ReactNative] Bring back crash reporting | Alex Kotliarskyi
- Remove duplicate word | Nick Lockwood
- NavigatorIOS navigationBarHidden property support | Nick Lockwood
- [Scroll] Include content insets in scroll events | Nick Lockwood
2015-04-10 01:33:10 -07:00
Christopher Chedeau ead3a740ca Second Update from Tue 24 Mar 2015-03-24 19:34:12 -07:00
Christopher Chedeau 5baffa03fd Second Updates from Mon 23 Mar
- [ReactNative] Use deprecated ix in TabBarExample | Amjad Masad
- [ReactNative] Expanded license on obj-c files | Christopher Chedeau
- [ReactNative] Expanded license on js files | Christopher Chedeau
- [ReactNative] Fix React Devtools integration | Alex Kotliarskyi
- [Text] Account for font leading so descenders are not clipped | James Ide
- [ReactNative] Expanded license on js packager files | Christopher Chedeau
- more UIExplorer flow | Basil Hosmer
- [react-packager] Pick up package changes while running | Amjad Masad
- Added a graph view and a ReactNative metric that displays current queue and execution time for the JS thread. | Bryce Redd
- [ReactNative] Add NativeModules and DeviceEventEmitter to react-native exports | Alex Kotliarskyi
2015-03-23 15:07:33 -07:00
Christopher Chedeau f7cf017d29 Updates from Tue 17 Mar
- [ReactNative] Remove pushNotification prop from renderApplication | Eric Vicenti
- [react_native] Stub VibrationIOS on Android | Andy Street
- [ReactNative] Simplify and test interpolators | Christopher Chedeau
- [ReactNative] Increase timeout for obj-c tests | Christopher Chedeau
- [ReactNative] Updated RKText to new UIManager system | Nick Lockwood
- [ReactNative] Unforked RCTShadowView, moved RKTextView into FBReactKitTextModule | Nick Lockwood
- [ReactKit] Remove NativeModulesDeprecated | Spencer Ahrens
- [ReactNative] Allow single callbacks in NativeModules | Spencer Ahrens
- [ReactNative] s/RK/RCT in OSS | Spencer Ahrens
- [ReactNative] Cleanup StyleSheet API | Christopher Chedeau
- [RCTVibration] Basic Vibration API | Christopher Chedeau
- [React Native] Prevent crash in redbox code with two thrown errors | Ben Alpert
- [ReactNative] unbreak Android | Andrew Rasmussen
2015-03-17 13:43:53 -07:00
Ben Alpert a15603d8f1 Initial commit 2015-01-29 17:10:49 -08:00