Skip to content

Commit

Permalink
doc: update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
BANG88 committed Dec 11, 2018
1 parent cd4dfe2 commit 2437eca
Show file tree
Hide file tree
Showing 47 changed files with 808 additions and 72 deletions.
2 changes: 1 addition & 1 deletion components/accordion/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// tslint:disable:jsx-no-multiline-js

import React from 'react';
import { StyleProp, Text, View, ViewStyle } from 'react-native';
import RNAccordion, { AccordionProps } from 'react-native-collapsible/Accordion';
Expand Down
2 changes: 1 addition & 1 deletion components/action-sheet/AndroidContainer.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// tslint:disable:jsx-no-multiline-js

import React from 'react';
import { ActionSheetIOSOptions, Text, TouchableHighlight, View } from 'react-native';
import Modal from '../modal/ModalView';
Expand Down
2 changes: 1 addition & 1 deletion components/badge/demo/basic.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// tslint:disable:jsx-no-multiline-js

/* tslint:disable:no-console */
import React from 'react';
import { ScrollView, View } from 'react-native';
Expand Down
2 changes: 1 addition & 1 deletion components/button/demo/basic.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ title:

````jsx
/* tslint:disable:no-unused-variable */
// tslint:disable:jsx-no-multiline-js

import React from 'react';
import { Button, WhiteSpace, WingBlank } from '@ant-design/react-native';

Expand Down
2 changes: 1 addition & 1 deletion components/button/demo/basic.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* tslint:disable:no-unused-variable */
// tslint:disable:jsx-no-multiline-js

import React from 'react';
import { Button, WhiteSpace, WingBlank } from '../../';

Expand Down
2 changes: 1 addition & 1 deletion components/card/CardHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* tslint:disable:jsx-no-multiline-js */

import React from 'react';
import { Image, ImageStyle, StyleProp, Text, View, ViewStyle } from 'react-native';
import { WithTheme, WithThemeStyles } from '../style';
Expand Down
80 changes: 77 additions & 3 deletions components/checkbox/demo/basic.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,80 @@ title:

[Demo Source Code](https://github.com/ant-design/ant-design-mobile-rn/blob/master/components/checkbox/demo/basic.tsx)

````jsx
// todos: include('./basic.tsx')
````
```jsx
import React from 'react';
import { Text, View } from 'react-native';
import { Checkbox, List, WhiteSpace } from '@ant-design/react-native';
const AgreeItem = Checkbox.AgreeItem;
const CheckboxItem = Checkbox.CheckboxItem;
export default class BasicCheckboxExample extends React.Component {
constructor(props, context) {
super(props, context);
this.state = {
checkBox1: true,
agreeItem1: true,
checkboxItem1: true,
};
}
render() {
return (
<View>
<View style={{ padding: 10 }}>
<Checkbox
checked={this.state.checkBox1}
style={{ color: '#f00' }}
onChange={event => {
this.setState({ checkBox1: event.target.checked });
}}
/>
<WhiteSpace />
<Checkbox>Checkbox</Checkbox>
<WhiteSpace />
<Checkbox checked disabled />
<WhiteSpace />
<Checkbox disabled />
</View>

<WhiteSpace />
<AgreeItem>
Agree agreement agreement agreement agreement agreement agreement
agreement
</AgreeItem>
<WhiteSpace />
<AgreeItem
checked={this.state.agreeItem1}
checkboxStyle={{ color: '#f00' }}
onChange={event => {
this.setState({ agreeItem1: event.target.checked });
}}
>
Agree agreement
</AgreeItem>
<WhiteSpace />
<AgreeItem disabled>Not selected. Not editable</AgreeItem>
<WhiteSpace />
<AgreeItem checked disabled>
Force selected. Not editable
</AgreeItem>

<List style={{ marginTop: 12 }}>
<Text style={{ marginTop: 12 }}>Multiple options</Text>
<CheckboxItem
checked={this.state.checkboxItem1}
onChange={event => {
this.setState({ checkboxItem1: event.target.checked });
}}
>
Option 1
</CheckboxItem>
<CheckboxItem>Option 2</CheckboxItem>
<CheckboxItem disabled>Option 3</CheckboxItem>
<CheckboxItem disabled checked>
Option 4
</CheckboxItem>
</List>
</View>
);
}
}
```
2 changes: 1 addition & 1 deletion components/checkbox/demo/basic.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// tslint:disable:jsx-no-multiline-js

import React from 'react';
import { Text, View } from 'react-native';
import { Checkbox, List, WhiteSpace } from '../../';
Expand Down
41 changes: 38 additions & 3 deletions components/date-picker-view/demo/basic.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,41 @@ title:

[Demo Source Code](https://github.com/ant-design/ant-design-mobile-rn/blob/master/components/date-picker-view/demo/basic.tsx)

````jsx
// todos: include('./basic.tsx')
````
```jsx
import React from 'react';
import { Text, View } from 'react-native';
import { DatePickerView } from '@ant-design/react-native';
export default class DatePickerViewExample extends React.Component {
constructor() {
super(...arguments);
this.state = {
value: undefined,
};
this.onChange = value => {
console.log(value);
this.setState({ value });
};
this.onValueChange = (...args) => {
console.log(args);
};
}
render() {
return (
<View>
<Text style={{ margin: 16 }}>Start DateTime</Text>
<DatePickerView
value={this.state.value}
onChange={this.onChange}
onValueChange={this.onValueChange}
/>
<Text style={{ margin: 16 }}>End DateTime</Text>
<DatePickerView
value={this.state.value}
onChange={this.onChange}
onValueChange={this.onValueChange}
/>
</View>
);
}
}
```
38 changes: 35 additions & 3 deletions components/date-picker/demo/basic.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,38 @@ title:

[Demo Source Code](https://github.com/ant-design/ant-design-mobile-rn/blob/master/components/date-picker/demo/basic.tsx)

````jsx
// todos: include('./basic.tsx')
````
```jsx
import React from 'react';
import { View } from 'react-native';
import { DatePicker, List } from '@ant-design/react-native';
// const now = new Date();
export default class PopupExample extends React.Component {
constructor(props) {
super(props);
this.onChange = value => {
this.setState({ value });
};
this.state = {
value: undefined,
};
}
render() {
return (
<View>
<List>
<DatePicker
value={this.state.value}
mode="date"
minDate={new Date(2015, 7, 6)}
maxDate={new Date(2026, 11, 3)}
onChange={this.onChange}
format="YYYY-MM-DD"
>
<List.Item arrow="horizontal">Select Date</List.Item>
</DatePicker>
</List>
</View>
);
}
}
```
2 changes: 1 addition & 1 deletion components/date-picker/demo/basic.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// tslint:disable:jsx-no-multiline-js

/* tslint:disable:no-console */
import React from 'react';
import { View } from 'react-native';
Expand Down
2 changes: 1 addition & 1 deletion components/date-picker/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* tslint:disable:jsx-no-multiline-js */

import PropTypes from 'prop-types';
import React from 'react';
import RCDatePicker from 'rmc-date-picker/lib/DatePicker';
Expand Down
87 changes: 84 additions & 3 deletions components/drawer/demo/basic.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,87 @@ title:

[Demo Source Code](https://github.com/ant-design/ant-design-mobile-rn/blob/master/components/drawer/demo/basic.tsx)

````jsx
// todos: include('./basic.tsx')
````
```jsx
import React from 'react';
import { ScrollView, StyleSheet, Text, View } from 'react-native';
import { Button, Drawer, List, WhiteSpace } from '@ant-design/react-native';
const styles = StyleSheet.create({
container: {
flex: 1,
},
});
export default class DrawerExample extends React.Component {
constructor() {
super(...arguments);
this.onOpenChange = isOpen => {
/* tslint:disable: no-console */
console.log('是否打开了 Drawer', isOpen.toString());
};
}
render() {
const itemArr = Array.apply(null, Array(20))
.map(function(_, i) {
return i;
})
.map((_i, index) => {
if (index === 0) {
return (
<List.Item
key={index}
thumb="https://zos.alipayobjects.com/rmsportal/eOZidTabPoEbPeU.png"
multipleLine
>
<View
style={{
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
}}
>
<Text>Categories - {index}</Text>
<Button
type="primary"
size="small"
onPress={() => this.drawer.closeDrawer()}
>
close drawer
</Button>
</View>
</List.Item>
);
}
return (
<List.Item
key={index}
thumb="https://zos.alipayobjects.com/rmsportal/eOZidTabPoEbPeU.png"
>
<Text>Categories - {index}</Text>
</List.Item>
);
});
// Todo: https://github.com/DefinitelyTyped/DefinitelyTyped
const sidebar = (
<ScrollView style={[styles.container]}>
<List>{itemArr}</List>
</ScrollView>
);
return (
<Drawer
sidebar={sidebar}
position="left"
open={false}
drawerRef={el => (this.drawer = el)}
onOpenChange={this.onOpenChange}
drawerBackgroundColor="#ccc"
>
<View style={{ flex: 1, marginTop: 114, padding: 8 }}>
<Button onPress={() => this.drawer && this.drawer.openDrawer()}>
Open drawer
</Button>
<WhiteSpace />
</View>
</Drawer>
);
}
}
```
2 changes: 1 addition & 1 deletion components/drawer/demo/basic.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// tslint:disable:jsx-no-multiline-js

import React from 'react';
import { ScrollView, StyleSheet, Text, View } from 'react-native';
import { Button, Drawer, List, WhiteSpace } from '../../';
Expand Down
2 changes: 1 addition & 1 deletion components/drawer/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* tslint:disable:jsx-no-multiline-js */

import React from 'react';
import DrawerLayout from 'react-native-drawer-layout';
import { DrawerProps } from './PropsType';
Expand Down
2 changes: 1 addition & 1 deletion components/flex/demo/basic.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ name: Flex
[Demo Source Code](https://github.com/ant-design/ant-design-mobile-rn/blob/master/components/flex/demo/basic.tsx)

````jsx
// tslint:disable:jsx-no-multiline-js

import React from 'react';
import { ScrollView, Text, TouchableWithoutFeedback, View } from 'react-native';
import { Button, Flex, WhiteSpace, WingBlank } from '../../';
Expand Down
2 changes: 1 addition & 1 deletion components/flex/demo/basic.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// tslint:disable:jsx-no-multiline-js

import React from 'react';
import { ScrollView, Text, TouchableWithoutFeedback, View } from 'react-native';
import { Button, Flex, WhiteSpace, WingBlank } from '../../';
Expand Down
2 changes: 1 addition & 1 deletion components/grid/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* tslint:disable:jsx-no-multiline-js */

import React from 'react';
import { Dimensions, Image, StyleProp, StyleSheet, Text, View, ViewStyle } from 'react-native';
import Carousel, { CarouselProps } from '../carousel/index';
Expand Down
Loading

0 comments on commit 2437eca

Please sign in to comment.