Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
133 changes: 72 additions & 61 deletions docs/refreshcontrol.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,17 @@ This component is used inside a ScrollView or ListView to add pull to refresh fu

```SnackPlayer name=RefreshControl&supportedPlatforms=ios,android
import React from 'react';
import {
ScrollView,
RefreshControl,
StyleSheet,
Text,
SafeAreaView,
} from 'react-native';
import Constants from 'expo-constants';
import { RefreshControl, SafeAreaView, ScrollView, StyleSheet, Text } from 'react-native';

const wait = (timeout) => {
return new Promise(resolve => {
setTimeout(resolve, timeout);
});
return new Promise(resolve => setTimeout(resolve, timeout));
}

const App = () => {
const [refreshing, setRefreshing] = React.useState(false);

const onRefresh = React.useCallback(() => {
setRefreshing(true);

wait(2000).then(() => setRefreshing(false));
}, []);

Expand All @@ -38,7 +28,10 @@ const App = () => {
<ScrollView
contentContainerStyle={styles.scrollView}
refreshControl={
<RefreshControl refreshing={refreshing} onRefresh={onRefresh} />
<RefreshControl
refreshing={refreshing}
onRefresh={onRefresh}
/>
}
>
<Text>Pull down to see RefreshControl indicator</Text>
Expand All @@ -50,7 +43,6 @@ const App = () => {
const styles = StyleSheet.create({
container: {
flex: 1,
marginTop: Constants.statusBarHeight,
},
scrollView: {
flex: 1,
Expand All @@ -63,7 +55,7 @@ const styles = StyleSheet.create({
export default App;
```

**Note:** `refreshing` is a controlled prop, this is why it needs to be set to true in the `onRefresh` function otherwise the refresh indicator will stop immediately.
> Note: `refreshing` is a controlled prop, this is why it needs to be set to `true` in the `onRefresh` function otherwise the refresh indicator will stop immediately.

---

Expand All @@ -73,100 +65,119 @@ export default App;

Inherits [View Props](view.md#props).

### `refreshing`
---

### <div class="label required basic">Required</div>**`refreshing`**

Whether the view should be indicating an active refresh.

| Type | Required |
| ---- | -------- |
| bool | Yes |
| Type |
| ------- |
| boolean |

---

### `onRefresh`
### `colors` <div class="label android">Android</div>

Called when the view starts refreshing.
The colors (at least one) that will be used to draw the refresh indicator.

| Type | Required |
| -------- | -------- |
| function | No |
| Type |
| ---------------------------- |
| array of [colors](colors.md) |

---

### `colors`
### `enabled` <div class="label android">Android</div>

The colors (at least one) that will be used to draw the refresh indicator.
Whether the pull to refresh functionality is enabled.

| Type | Required | Platform |
| --------------------------- | -------- | -------- |
| array of [color](colors.md) | No | Android |
| Type | Default |
| ------- | ------- |
| boolean | `true` |

---

### `enabled`
### `onRefresh`

Whether the pull to refresh functionality is enabled.
Called when the view starts refreshing.

| Type | Required | Platform |
| ---- | -------- | -------- |
| bool | No | Android |
| Type |
| -------- |
| function |

---

### `progressBackgroundColor`
### `progressBackgroundColor` <div class="label android">Android</div>

The background color of the refresh indicator.

| Type | Required | Platform |
| ------------------ | -------- | -------- |
| [color](colors.md) | No | Android |
| Type |
| ------------------ |
| [color](colors.md) |

---

### `progressViewOffset`
### `progressViewOffset` <div class="label android">Android</div>

Progress view top offset
Progress view top offset.

| Type | Required | Platform |
| ------ | -------- | -------- |
| number | No | Android |
| Type | Default |
| ------ | ------- |
| number | `0` |

---

### `size`
### `size` <div class="label android">Android</div>

Size of the refresh indicator, see RefreshControl.SIZE.
Size of the refresh indicator.

| Type | Required | Platform |
| ---------------------------------------------------------------------- | -------- | -------- |
| enum(RefreshLayoutConsts.SIZE.DEFAULT, RefreshLayoutConsts.SIZE.LARGE) | No | Android |
| Type | Default |
| ---------------------------------------------------------------- | -------------------------------- |
| [RefreshControl.SIZE](refreshcontrol.md#refreshlayoutconstssize) | RefreshLayoutConsts.SIZE.DEFAULT |

---

### `tintColor`
### `tintColor` <div class="label ios">iOS</div>

The color of the refresh indicator.

| Type | Required | Platform |
| ------------------ | -------- | -------- |
| [color](colors.md) | No | iOS |
| Type |
| ------------------ |
| [color](colors.md) |

---

### `title`
### `title` <div class="label ios">iOS</div>

The title displayed under the refresh indicator.

| Type | Required | Platform |
| ------ | -------- | -------- |
| string | No | iOS |
| Type |
| ------ |
| string |

---

### `titleColor`
### `titleColor` <div class="label ios">iOS</div>

The color of the refresh indicator title.

| Type |
| ------------------ |
| [color](colors.md) |

## Type Definitions

### RefreshLayoutConsts.SIZE

The SwipeRefreshLayout Android component constants. The acctual component size may vary between devices. You can read more about the native component in the [Android documentation](https://developer.android.com/reference/androidx/swiperefreshlayout/widget/SwipeRefreshLayout).

| Type |
| ---- |
| enum |

Title color.
**Constants:**

| Type | Required | Platform |
| ------------------ | -------- | -------- |
| [color](colors.md) | No | iOS |
| Name | Type | Value | Description |
| ------- | ---- | ----- | --------------------------- |
| DEFAULT | int | `1` | Default RefreshControl size |
| LARGE | int | `0` | Large RefreshControl size |
6 changes: 2 additions & 4 deletions website/static/css/docs.css
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,7 @@ figcaption {

/* Right side navigation */
.onPageNav {
overflow: visible;
overflow-y: auto;
flex: 0 0 246px;
}

.onPageNav a,
Expand All @@ -197,7 +196,7 @@ figcaption {
}

.onPageNav ul ul {
padding: 8px 0 0 16px;
padding: 8px 0 0 14px;
}

.onPageNav ul ul li {
Expand Down Expand Up @@ -335,7 +334,6 @@ td .label.required {
height: 6px;
border-radius: 100%;
margin-left: 2px;
margin-right: -12px;
white-space: nowrap;
overflow: hidden;
color: transparent;
Expand Down
2 changes: 1 addition & 1 deletion website/static/css/react-native.css
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ body,
max-width: 900px;
}
.docMainWrapper > *:last-child {
margin-right: 20px;
margin-right: 14px;
}
}

Expand Down