Skip to content

Commit 26ac496

Browse files
committed
fix:修复合并冲突问题
2 parents f13d4de + d3b3e62 commit 26ac496

File tree

13 files changed

+224
-161
lines changed

13 files changed

+224
-161
lines changed

packages/core/src/Card/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ function Demo() {
4545
export default Demo
4646
```
4747
### 可点击选中带操作卡片
48-
```jsx mdx:preview
48+
```jsx
4949
import React, { useState } from 'react';
5050
import { SafeAreaView, View, Image } from 'react-native';
5151
import Card from '@uiw/react-native/lib/Card';
@@ -86,6 +86,7 @@ const Demo = () => {
8686
}
8787
export default Demo
8888
```
89+
8990
#### 属性
9091
## CardProps
9192

packages/core/src/Divider/README.md

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ import React,{Component, Fragment } from "react"
1010
import { View, Text } from 'react-native';
1111
import { Divider } from '@uiw/react-native';
1212

13-
class Demo extends Component {
14-
render() {
13+
function Demo() {
1514
return (
1615
<Fragment>
1716
<Text>分割线</Text>
@@ -21,7 +20,6 @@ class Demo extends Component {
2120
<Text>分割线</Text>
2221
</Fragment>
2322
);
24-
}
2523
}
2624
export default Demo
2725

@@ -36,8 +34,7 @@ import React,{Component, Fragment } from "react"
3634
import { View, Text } from 'react-native';
3735
import { Divider } from '@uiw/react-native';
3836

39-
class Demo extends Component {
40-
render() {
37+
function Demo() {
4138
return (
4239
<Fragment>
4340
<Text>分割线</Text>
@@ -46,7 +43,6 @@ class Demo extends Component {
4643
<Divider label="OR" gutter={100}/>
4744
</Fragment>
4845
);
49-
}
5046
}
5147
export default Demo
5248

@@ -59,8 +55,7 @@ import React,{Component, Fragment } from "react"
5955
import { View, Text } from 'react-native';
6056
import { Divider } from '@uiw/react-native';
6157

62-
class Demo extends Component {
63-
render() {
58+
function Demo() {
6459
return (
6560
<Fragment>
6661
<Text>分割线</Text>
@@ -71,7 +66,6 @@ class Demo extends Component {
7166
<Divider label="right" orientation="right" labelStyle={{ fontWeight: 'bold' }} />
7267
</Fragment>
7368
);
74-
}
7569
}
7670
export default Demo
7771

@@ -84,14 +78,12 @@ import React,{Component} from "react"
8478
import { View, Text } from 'react-native';
8579
import { Divider } from '@uiw/react-native';
8680

87-
class Demo extends Component {
88-
render() {
81+
function Demo() {
8982
return (
9083
<View style={{ height: 200 }}>
9184
<Divider type="vertical" label="OR" />
9285
</View>
9386
);
94-
}
9587
}
9688
export default Demo
9789

packages/core/src/List/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ export default function Demo() {
179179
| `data` | 渲染头部 | [] | - |
180180
| `flat` | 当值为 `true` 使用 `FlatList` 组件渲染列表,当值为 `false` 时,使用 `View` 渲染界面 | Boolean | `true` |
181181
| `renderItem` | 当使用 `data` 时,可以用 `renderItem` 自定义渲染列表项 | ({item}) => { } | - |
182-
| `title` | 设置所有 `Item` 左边补白 | Number | `16` |
182+
| `title` | 标题 | React.ReactNode | - |
183183
| `titleStyle` | 当设置 `title` 参数之后可以设置其标题容器样式。| ViewStyle | - |
184184
| `horizontal` | 设置为 `true` 则变为水平布局模式。(`flat=true` 支持) | Boolean | `false` |
185185
| `numColumns` | 多列布局只能在非水平模式下使用,即必须是 `horizontal={false}`。此时组件内元素会从左到右从上到下按 `Z` 字形排列,类似启用了 `flexWrap` 的布局。组件内元素必须是等高的——暂时还无法支持瀑布流布局。(`flat=true` 支持) | Number | - |

packages/core/src/Radio/index.tsx

Lines changed: 66 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { Component } from 'react';
1+
import React, { Component, useEffect, useState } from 'react';
22
import {
33
View,
44
ViewProps,
@@ -60,104 +60,86 @@ export interface RadioState {
6060
control: 'state' | 'props';
6161
}
6262

63-
export default class Radio extends Component<RadioProps, RadioState> {
64-
static defaultProps: RadioProps = {
65-
checked: false,
66-
circleSize: 20,
67-
checkedColor: '#008EF0',
68-
borderColor: '#bdc1cc',
69-
color: '#c3c5c7',
70-
thumbSize: 12,
71-
};
72-
constructor(props: RadioProps) {
73-
super(props);
74-
this.state = {
75-
checked: props.checked,
76-
sizeValue: new Animated.Value(0),
77-
control: 'state',
78-
};
79-
}
80-
componentDidMount() {
81-
this.animatedStart(this.props.checked);
82-
}
83-
static getDerivedStateFromProps(props: RadioProps, state: RadioState) {
63+
export default function Radio(props: RadioProps) {
64+
const [state, setState] = useState({
65+
checked: props.checked,
66+
sizeValue: new Animated.Value(0),
67+
control: 'state',
68+
});
69+
70+
useEffect(() => {
71+
animatedStart(props.checked);
72+
}, []);
73+
74+
useEffect(() => {
8475
if (state.control === 'state' && props.checked === state.checked) {
85-
return {
86-
control: 'props',
87-
};
76+
return setState({ ...state, control: 'props' });
8877
}
8978
if (props.checked !== state.checked) {
9079
Animated.spring(state.sizeValue, {
9180
toValue: !!props.checked ? props.thumbSize! : 0,
9281
overshootClamping: true,
9382
useNativeDriver: false,
9483
}).start();
95-
return {
96-
checked: props.checked,
97-
control: 'props',
98-
};
84+
return setState({ ...state, checked: props.checked, control: 'props' });
9985
}
100-
return null;
101-
}
102-
animatedStart(checked?: boolean) {
103-
Animated.spring(this.state.sizeValue, {
104-
toValue: !!checked ? this.props.thumbSize! : 0,
86+
}, [props.checked]);
87+
88+
function animatedStart(checked?: boolean) {
89+
Animated.spring(state.sizeValue, {
90+
toValue: !!checked ? props.thumbSize! : 0,
10591
overshootClamping: true,
10692
useNativeDriver: false,
10793
}).start();
10894
}
109-
handlePress = (event: GestureResponderEvent) => {
110-
const { onPress } = this.props;
111-
this.setState({ checked: true, control: 'state' }, () => {
112-
this.animatedStart(true);
113-
onPress && onPress(event);
114-
});
95+
96+
const handlePress = (event: GestureResponderEvent) => {
97+
const { onPress } = props;
98+
setState({ ...state, checked: true, control: 'state' });
99+
100+
animatedStart(true);
101+
onPress && onPress(event);
115102
};
116-
render() {
117-
const {
118-
style,
119-
color,
120-
circleSize,
121-
thumbSize,
122-
disabled,
123-
checkedColor,
124-
borderColor: bdColor,
125-
...otherProps
126-
} = this.props;
127-
const sizeValue = this.state.sizeValue.interpolate({
128-
inputRange: [0, thumbSize!],
129-
outputRange: [0, thumbSize!],
130-
// extrapolate: 'clamp',
131-
});
132-
const backgroundColor = disabled ? color : checkedColor;
133-
const borderColor = disabled ? color : bdColor;
134-
return (
135-
<View testID="RNE__Radio__wrap" style={[styles.defalut, style]} {...otherProps}>
136-
<TouchableOpacity
137-
disabled={disabled}
138-
style={[styles.touch]}
139-
onPress={this.handlePress}
140-
testID="RNE__Radio__view"
103+
104+
const { style, color, circleSize, thumbSize, disabled, checkedColor, borderColor: bdColor, ...otherProps } = props;
105+
const sizeValue = state.sizeValue.interpolate({
106+
inputRange: [0, thumbSize!],
107+
outputRange: [0, thumbSize!],
108+
// extrapolate: 'clamp',
109+
});
110+
const backgroundColor = disabled ? color : checkedColor;
111+
const borderColor = disabled ? color : bdColor;
112+
113+
return (
114+
<View testID="RNE__Radio__wrap" style={[styles.defalut, style]} {...otherProps}>
115+
<TouchableOpacity disabled={disabled} style={[styles.touch]} onPress={handlePress} testID="RNE__Radio__view">
116+
<Animated.View
117+
style={[styles.checkBg, { width: circleSize, height: circleSize, borderColor }]}
118+
testID="RNE__Radio__border"
141119
>
142120
<Animated.View
143-
style={[styles.checkBg, { width: circleSize, height: circleSize, borderColor }]}
144-
testID="RNE__Radio__border"
121+
style={[styles.check, { width: sizeValue, height: sizeValue, backgroundColor }]}
122+
testID="RNE__Radio__box"
123+
/>
124+
</Animated.View>
125+
{props.children && (
126+
<MaybeTextOrView
127+
// eslint-disable-next-line
128+
style={[styles.label, { opacity: disabled ? 0.3 : 1 }]}
145129
>
146-
<Animated.View
147-
style={[styles.check, { width: sizeValue, height: sizeValue, backgroundColor }]}
148-
testID="RNE__Radio__box"
149-
/>
150-
</Animated.View>
151-
{this.props.children && (
152-
<MaybeTextOrView
153-
// eslint-disable-next-line
154-
style={[styles.label, { opacity: disabled ? 0.3 : 1 }]}
155-
>
156-
{this.props.children}
157-
</MaybeTextOrView>
158-
)}
159-
</TouchableOpacity>
160-
</View>
161-
);
162-
}
130+
{props.children}
131+
</MaybeTextOrView>
132+
)}
133+
</TouchableOpacity>
134+
</View>
135+
);
163136
}
137+
138+
Radio.defaultProps = {
139+
checked: false,
140+
circleSize: 20,
141+
checkedColor: '#008EF0',
142+
borderColor: '#bdc1cc',
143+
color: '#c3c5c7',
144+
thumbSize: 12,
145+
} as RadioProps;

packages/core/src/Result/index.tsx

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,15 @@ export interface ResultProps extends ViewProps {
4949
message?: React.ReactNode;
5050
}
5151

52-
export default class Result extends Component<ResultProps> {
53-
static defaultProps: ResultProps = {};
54-
render() {
55-
const { style, title, message, img, ...otherProps } = this.props;
56-
return (
57-
<View style={[styles.defalut, style]} {...otherProps}>
58-
{img}
59-
{title && <MaybeTextOrView style={styles.title}>{title}</MaybeTextOrView>}
60-
{message && <MaybeTextOrView style={styles.message}>{message}</MaybeTextOrView>}
61-
</View>
62-
);
63-
}
52+
export default function Result(props: ResultProps) {
53+
const { style, title, message, img, ...otherProps } = props;
54+
return (
55+
<View style={[styles.defalut, style]} {...otherProps}>
56+
{img}
57+
{title && <MaybeTextOrView style={styles.title}>{title}</MaybeTextOrView>}
58+
{message && <MaybeTextOrView style={styles.message}>{message}</MaybeTextOrView>}
59+
</View>
60+
);
6461
}
62+
63+
Result.defaultProps = {} as ResultProps;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
### 日志管理
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import Preview from 'src/component/Preview';
2+
import md from './README.md';
3+
4+
const transformImageUri = (url: string) => {
5+
const reqImage = (require as any).context!('./', true, /\.(png|gif|jpg|svg)$/);
6+
const urlAddr = reqImage(url);
7+
return urlAddr;
8+
};
9+
10+
const DEMO = () => (
11+
<Preview
12+
{...md}
13+
transformImageUri={transformImageUri}
14+
path="website/src/pages/docs/react-native-template/log-management/README.md"
15+
/>
16+
);
17+
18+
export default DEMO;

website/src/pages/docs/react-native-template/mock-data/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ export default connect(
7979
)(Dome);
8080
8181
```
82-
### 三、modal文件处理
82+
### 三、使用react-query调用api
83+
[react-query](https://tanstack.com/query/latest) 更详细的使用,请参照官方文档
8384

8485
```
8586
import { Alert } from 'react-native';

0 commit comments

Comments
 (0)