mirror of
https://github.com/zoriya/react-native-web.git
synced 2026-05-27 08:13:46 +00:00
Add new components
- ActivityIndicator - Portal - StaticContainer - StaticRenderer
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
# ActivityIndicator
|
||||
|
||||
## Props
|
||||
|
||||
[...View props](./View.md)
|
||||
|
||||
**animating**: bool = true
|
||||
|
||||
Whether to show the indicator (true, the default) or hide it (false).
|
||||
|
||||
**color**: string = #999999
|
||||
|
||||
The foreground color of the spinner (default is gray).
|
||||
|
||||
**hidesWhenStopped**: bool = true
|
||||
|
||||
Whether the indicator should hide when not animating (true by default).
|
||||
|
||||
**size**: oneOf('small, 'large')
|
||||
|
||||
Size of the indicator. Small has a height of `20`, large has a height of `36`.
|
||||
|
||||
## Examples
|
||||
|
||||
```js
|
||||
import React, { ActivityIndicator, Component, StyleSheet, View } from 'react-native'
|
||||
|
||||
class ToggleAnimatingActivityIndicator extends Component {
|
||||
constructor(props) {
|
||||
super(props)
|
||||
this.state = { animating: true }
|
||||
}
|
||||
|
||||
componentDidMount: function() {
|
||||
this.setToggleTimeout();
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<ActivityIndicator
|
||||
animating={this.state.animating}
|
||||
size="large"
|
||||
style={[styles.centering, { height: 80 }]}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
_setToggleTimeout() {
|
||||
setTimeout(() => {
|
||||
this.setState({ animating: !this.state.animating })
|
||||
this._setToggleTimeout()
|
||||
}, 1200)
|
||||
}
|
||||
})
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
centering: {
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center'
|
||||
},
|
||||
gray: {
|
||||
backgroundColor: '#cccccc'
|
||||
},
|
||||
horizontal: {
|
||||
flexDirection: 'row',
|
||||
justifyContent: 'space-around'
|
||||
}
|
||||
})
|
||||
```
|
||||
@@ -76,7 +76,7 @@ Used to locate a view in end-to-end tests.
|
||||
|
||||
```js
|
||||
import placeholderAvatar from './placeholderAvatar.png'
|
||||
import React, { Component, Image, PropTypes, StyleSheet } from 'react-native-web'
|
||||
import React, { Component, Image, PropTypes, StyleSheet } from 'react-native'
|
||||
|
||||
export default class ImageExample extends Component {
|
||||
constructor(props, context) {
|
||||
|
||||
@@ -15,7 +15,7 @@ Content to display over the image.
|
||||
## Examples
|
||||
|
||||
```js
|
||||
import React, { Component, ListView, PropTypes } from 'react-native-web'
|
||||
import React, { Component, ListView, PropTypes } from 'react-native'
|
||||
|
||||
export default class ListViewExample extends Component {
|
||||
static propTypes = {}
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
# Portal
|
||||
|
||||
`Portal` is used to render modal content on top of everything else in the
|
||||
application. It passes modal views all the way up to the root element created
|
||||
by `AppRegistry.runApplication`.
|
||||
|
||||
There can only be one `Portal` instance rendered in an application, and this
|
||||
instance is controlled by React Native for Web.
|
||||
|
||||
## Methods
|
||||
|
||||
static **allocateTag**()
|
||||
|
||||
Creates a new unique tag for the modal that your component is rendering. A
|
||||
good place to allocate a tag is in `componentWillMount`. Returns a string. See
|
||||
`showModal` and `closeModal`.
|
||||
|
||||
static **closeModal**(tag: string)
|
||||
|
||||
Remove a modal from the collection of modals to be rendered. The `tag` must
|
||||
exactly match the tag previous passed to `showModal` to identify the React
|
||||
component.
|
||||
|
||||
static **getOpenModals**()
|
||||
|
||||
Get an array of all the open modals, as identified by their tag string.
|
||||
|
||||
static **showModal**(tag: string, component: any)
|
||||
|
||||
Render a new modal. The `tag` must be unique as it is used to identify the
|
||||
React component to render. This same tag can later be used in `closeModal`.
|
||||
|
||||
## Examples
|
||||
|
||||
```js
|
||||
import React, { Portal, Text, Touchable } from 'react-native'
|
||||
|
||||
export default class PortalExample extends Component {
|
||||
componentWillMount() {
|
||||
this._portalTag = Portal.allocateTag()
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<Touchable onPress={this._handlePortalOpen.bind(this)}>
|
||||
<Text>Open portal</Text>
|
||||
</Touchable>
|
||||
)
|
||||
}
|
||||
|
||||
_handlePortalClose(e) {
|
||||
Portal.closeModal(this._portalTag)
|
||||
}
|
||||
|
||||
_handlePortalOpen(e) {
|
||||
Portal.showModal(this._portalTag, this._renderPortalContent())
|
||||
}
|
||||
|
||||
_renderPortalContent() {
|
||||
return (
|
||||
<Touchable onPress={this._handlePortalClose.bind(this)}>
|
||||
<Text>Close portal</Text>
|
||||
</Touchable>
|
||||
)
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -43,7 +43,7 @@ time the view is scrolled.
|
||||
## Examples
|
||||
|
||||
```js
|
||||
import React, { Component, ScrollView, StyleSheet } from 'react-native-web'
|
||||
import React, { Component, ScrollView, StyleSheet } from 'react-native'
|
||||
import Item from './Item'
|
||||
|
||||
export default class ScrollViewExample extends Component {
|
||||
|
||||
@@ -74,7 +74,7 @@ Used to locate this view in end-to-end tests.
|
||||
## Examples
|
||||
|
||||
```js
|
||||
import React, { Component, PropTypes, StyleSheet, Text } from 'react-native-web'
|
||||
import React, { Component, PropTypes, StyleSheet, Text } from 'react-native'
|
||||
|
||||
export default class PrettyText extends Component {
|
||||
static propTypes = {
|
||||
|
||||
@@ -150,7 +150,7 @@ user edits to the value set `editable={false}`.
|
||||
## Examples
|
||||
|
||||
```js
|
||||
import React, { Component, StyleSheet, TextInput } from 'react-native-web'
|
||||
import React, { Component, StyleSheet, TextInput } from 'react-native'
|
||||
|
||||
export default class TextInputExample extends Component {
|
||||
constructor(props, context) {
|
||||
|
||||
@@ -84,7 +84,7 @@ Delay in ms, from the release of the touch, before `onPressOut` is called.
|
||||
## Examples
|
||||
|
||||
```js
|
||||
import React, { Component, PropTypes, Touchable } from 'react-native-web'
|
||||
import React, { Component, PropTypes, Touchable } from 'react-native'
|
||||
|
||||
export default class Example extends Component {
|
||||
static propTypes = {}
|
||||
|
||||
@@ -168,7 +168,7 @@ Used to locate this view in end-to-end tests.
|
||||
## Examples
|
||||
|
||||
```js
|
||||
import React, { Component, PropTypes, StyleSheet, View } from 'react-native-web'
|
||||
import React, { Component, PropTypes, StyleSheet, View } from 'react-native'
|
||||
|
||||
export default class ViewExample extends Component {
|
||||
render() {
|
||||
|
||||
Reference in New Issue
Block a user