Skip to content

Commit 74da38e

Browse files
committed
Merge branch 'dev' of https://github.com/uiwjs/react-native-uiw into dev
2 parents f944c63 + a066e3d commit 74da38e

File tree

41 files changed

+1144
-21137
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1144
-21137
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ jobs:
2020

2121
- run: yarn install
2222
- run: npm run build
23+
- run: npm run test
2324
- run: npm run doc
2425
- run: rm -rf packages/docs/doc
2526
- run: mkdir -p packages/docs/doc

.github/workflows/pull_request.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ jobs:
1717

1818
- run: yarn install
1919
- run: npm run build
20+
- run: npm run test
2021
- run: npm run doc
2122
- run: rm -rf packages/docs/doc
2223
- run: mkdir -p packages/docs/doc

example/examples/src/routes/SpeedDial/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export default class Index extends Component<IndexProps, IndexState> {
4242
children={[
4343
{
4444
icon: <Icon name="plus" color="#fff" size={18} />,
45-
title: <Text>'Add'</Text>,
45+
title: <Text>Add</Text>,
4646
onPress: () => console.log('Add'),
4747
},
4848
{

example/examples/src/routes/TextArea/index.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export default class TextAreaView extends Component<TextAreaProps> {
1414
value1: '只读状态不可输入',
1515
value3: '自定义输入框样式',
1616
value4: '',
17+
value5: '',
1718
};
1819

1920
render() {
@@ -35,6 +36,16 @@ export default class TextAreaView extends Component<TextAreaProps> {
3536
placeholder="默认提示语"
3637
/>
3738
</Card>
39+
<Card title="根据内容自动调整高度" style={styles.card}>
40+
<TextArea
41+
onChange={(value5: string) => {
42+
this.setState({value5});
43+
}}
44+
value={this.state.value5}
45+
placeholder="默认提示语"
46+
autoSize
47+
/>
48+
</Card>
3849
<Card title="展示字数" style={styles.card}>
3950
<TextArea
4051
onChange={(value4: string) => {

packages/core/src/ActionSheet/index.tsx

Lines changed: 64 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import React, { useEffect, useState } from 'react';
22
import { View, Dimensions, StyleSheet, TextStyle, StyleProp, ViewStyle } from 'react-native';
33
import Modal, { ModalProps } from '../Modal';
44
import ActionSheetItem from './item';
@@ -33,84 +33,80 @@ interface ActionSheetState {
3333
control: 'props' | 'state';
3434
}
3535

36-
export default class ActionSheet extends React.Component<ActionSheetProps, ActionSheetState> {
37-
constructor(props: ActionSheetProps) {
38-
super(props);
39-
this.state = {
40-
stateVisible: !!props.visible,
41-
control: 'props',
42-
};
43-
}
44-
static getDerivedStateFromProps(props: ActionSheetProps, state: ActionSheetState) {
36+
export default function ActionSheet(props: ActionSheetProps) {
37+
const {
38+
children,
39+
visible: props_visible,
40+
activeOpacity,
41+
underlayColor,
42+
cancelText = '取消',
43+
dividerStyle,
44+
onCancel,
45+
containerStyle,
46+
textStyle,
47+
...other
48+
} = props;
49+
50+
const visible = !!props_visible;
51+
52+
const [state, setState] = useState({
53+
stateVisible: !!visible,
54+
control: 'props',
55+
});
56+
57+
useEffect(() => {
4558
if (props.visible === state.stateVisible && state.control === 'state') {
46-
return {
59+
setState({
4760
control: 'props',
4861
stateVisible: props.visible,
49-
};
62+
});
5063
}
5164
if (props.visible !== state.stateVisible) {
5265
if (state.control === 'state') {
53-
return {
54-
control: 'props',
55-
};
66+
setState({ ...state, control: 'props' });
5667
}
57-
return {
68+
setState({
5869
control: 'props',
59-
stateVisible: props.visible,
60-
};
70+
stateVisible: !!props.visible,
71+
});
6172
}
62-
return null;
63-
}
64-
onClose = () => {
65-
this.setState({ stateVisible: false, control: 'state' });
73+
}, [state.stateVisible]);
74+
75+
const onClose = () => {
76+
setState({ stateVisible: false, control: 'state' });
6677
};
6778

68-
render() {
69-
const {
70-
children,
71-
visible,
72-
activeOpacity,
73-
underlayColor,
74-
cancelText = '取消',
75-
dividerStyle,
76-
onCancel,
77-
containerStyle,
78-
textStyle,
79-
...other
80-
} = this.props;
81-
const { stateVisible } = this.state;
82-
return (
83-
<Modal
84-
placement="bottom"
85-
animationType="fade" // slide none fade
86-
transparent={true}
87-
{...other}
88-
visible={stateVisible}
89-
onClosed={this.onClose}
90-
>
91-
<>
92-
{React.Children.toArray(children).map((item, index) => (
93-
<View key={index}>
94-
{index !== 0 && <View style={StyleSheet.flatten([styles.itemDivider, dividerStyle?.itemDivider])} />}
95-
{React.cloneElement(item as React.DetailedReactHTMLElement<any, HTMLElement>, {
96-
activeOpacity: activeOpacity,
97-
underlayColor: underlayColor,
98-
})}
99-
</View>
100-
))}
101-
<View style={StyleSheet.flatten([styles.actionDivider, dividerStyle?.actionDivider])} />
102-
<ActionSheetItem
103-
activeOpacity={activeOpacity}
104-
underlayColor={underlayColor}
105-
onPress={this.onClose}
106-
children={cancelText}
107-
containerStyle={containerStyle}
108-
textStyle={textStyle}
109-
/>
110-
</>
111-
</Modal>
112-
);
113-
}
79+
return (
80+
<Modal
81+
placement="bottom"
82+
animationType="fade" // slide none fade
83+
transparent={true}
84+
{...other}
85+
visible={state.stateVisible}
86+
onClosed={onClose}
87+
>
88+
<>
89+
{React.Children.toArray(children).map((item, index) => (
90+
<View key={index}>
91+
{index !== 0 && <View style={StyleSheet.flatten([styles.itemDivider, dividerStyle?.itemDivider])} />}
92+
{React.cloneElement(item as React.DetailedReactHTMLElement<any, HTMLElement>, {
93+
activeOpacity: activeOpacity,
94+
underlayColor: underlayColor,
95+
})}
96+
</View>
97+
))}
98+
<View style={StyleSheet.flatten([styles.actionDivider, dividerStyle?.actionDivider])} />
99+
<ActionSheetItem
100+
activeOpacity={activeOpacity}
101+
underlayColor={underlayColor}
102+
onPress={onClose}
103+
children={cancelText}
104+
containerStyle={containerStyle}
105+
textStyle={textStyle}
106+
/>
107+
</>
108+
</Modal>
109+
);
114110
}
115111

116112
const styles = StyleSheet.create({

packages/core/src/ActionSheet/item.tsx

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,23 @@ export interface ActionSheetItemProps {
2727

2828
export interface ActionSheetItemState {}
2929

30-
export default class ActionSheetItem extends React.Component<ActionSheetItemProps, ActionSheetItemState> {
31-
render() {
32-
const {
33-
onPress = () => {},
34-
activeOpacity = 1,
35-
underlayColor = '#f1f1f1',
36-
containerStyle,
37-
textStyle,
38-
children,
39-
} = this.props;
40-
return (
41-
<TouchableHighlight activeOpacity={activeOpacity} underlayColor={underlayColor} onPress={onPress}>
42-
<View style={StyleSheet.flatten([styles.actionSheetItem, containerStyle])}>
43-
<Text style={StyleSheet.flatten([styles.actionSheetItemText, textStyle])}>{children}</Text>
44-
</View>
45-
</TouchableHighlight>
46-
);
47-
}
30+
export default function ActionSheetItem(props: ActionSheetItemProps) {
31+
const {
32+
onPress = () => {},
33+
activeOpacity = 1,
34+
underlayColor = '#f1f1f1',
35+
containerStyle,
36+
textStyle,
37+
children,
38+
} = props;
39+
40+
return (
41+
<TouchableHighlight activeOpacity={activeOpacity} underlayColor={underlayColor} onPress={onPress}>
42+
<View style={StyleSheet.flatten([styles.actionSheetItem, containerStyle])}>
43+
<Text style={StyleSheet.flatten([styles.actionSheetItemText, textStyle])}>{children}</Text>
44+
</View>
45+
</TouchableHighlight>
46+
);
4847
}
4948

5049
const styles = StyleSheet.create({

packages/core/src/Avatar/index.tsx

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { Component } from 'react';
1+
import React from 'react';
22
import { View, ViewProps, Image, ImageProps, StyleSheet } from 'react-native';
33

44
const styles = StyleSheet.create({
@@ -36,31 +36,23 @@ export interface AvatarProps extends ViewProps {
3636
shape?: 'circle' | 'square';
3737
}
3838

39-
export default class Avatar extends Component<AvatarProps> {
40-
static defaultProps: AvatarProps = {
41-
src: defaultImage,
42-
shape: 'square',
43-
rounded: 3,
44-
size: 40,
45-
};
46-
render() {
47-
const { style, src, size, shape, rounded, imageProps, ...otherProps } = this.props;
48-
return (
49-
<View
50-
style={[
51-
styles.defalut,
52-
style,
53-
{ width: size, height: size },
54-
{ borderRadius: shape === 'circle' ? size! / 2 : rounded },
55-
]}
56-
{...otherProps}
57-
>
58-
<Image
59-
style={{ width: size, height: size }}
60-
source={typeof src === 'number' ? src : { uri: src as string }}
61-
{...imageProps}
62-
/>
63-
</View>
64-
);
65-
}
39+
export default function Avatar(props: AvatarProps) {
40+
const { style, src = defaultImage, size = 40, shape = 'square', rounded = 3, imageProps, ...otherProps } = props;
41+
return (
42+
<View
43+
style={[
44+
styles.defalut,
45+
style,
46+
{ width: size, height: size },
47+
{ borderRadius: shape === 'circle' ? size! / 2 : rounded },
48+
]}
49+
{...otherProps}
50+
>
51+
<Image
52+
style={{ width: size, height: size }}
53+
source={typeof src === 'number' ? src : { uri: src as string }}
54+
{...imageProps}
55+
/>
56+
</View>
57+
);
6658
}

packages/core/src/Button/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ export default Demo
227227

228228
| 属性 | 说明 | 类型 | 默认值 |
229229
| --- | --- | --- | --- |
230-
| color | 自定义颜色 | `string` |
230+
| color | 自定义颜色 | `string` | -|
231231
| disabled | 是否禁用 | `boolean` | `false` |
232232
| bordered | 设置是否显示边框 | `boolean` | `true` |
233233
| loading | 加载状态 | `boolean` | `false` |

packages/core/src/Calendar/index.tsx

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useEffect, useState } from 'react';
2-
import { View, Text, ViewProps, StyleSheet, TouchableOpacity, Dimensions, Platform } from 'react-native';
2+
import { View, Text, ViewProps, TextProps, StyleSheet, TouchableOpacity, Dimensions, Platform } from 'react-native';
33
import Icon from '../Icon';
44
import Ellipsis from '../Ellipsis';
55
import { getMonths, getWeeksArray, daysArrProps, getType, getNameLen } from './utils';
@@ -112,7 +112,7 @@ const Calendar = (props: CalendarProps) => {
112112

113113
let nameLen = getNameLen(day.lunarHolidays);
114114
let lineHeight =
115-
lunarHoliday === true && Platform.OS === 'ios' ? 0 : lunarHoliday === true ? MainWidth < 1000 ? 18 : 55 : MainWidth < 1000 ? MainWidth / 7 - 4.5 : MainWidth / 14.5;
115+
lunarHoliday === true && Platform.OS === 'ios' ? 0 : lunarHoliday === true ? 18 : MainWidth / 7 - 4.5;
116116
let paddingTop = lunarHoliday === true ? 4 : 0;
117117
let colorType = '';
118118
if (day.colorType === '') {
@@ -211,9 +211,9 @@ const Calendar = (props: CalendarProps) => {
211211
setCurrentMonth(toMonth);
212212
setCurrentDays(toDays);
213213
};
214-
// const goCurrentDay = (day: number) => {
215-
// setCurrentDays(day);
216-
// };
214+
const goCurrentDay = (day: number) => {
215+
setCurrentDays(day);
216+
};
217217

218218
return (
219219
<View style={{ flex: 1, position: 'relative' }}>
@@ -298,10 +298,10 @@ const styles = StyleSheet.create({
298298
},
299299
calendarWeekdays: {
300300
flexDirection: 'row',
301-
justifyContent: 'space-around',
301+
justifyContent: 'space-between',
302302
alignItems: 'center',
303-
paddingHorizontal: MainWidth < 1000 ? MainWidth / 7 - 33 : MainWidth / 30,
304-
paddingTop: 12,
303+
paddingHorizontal: MainWidth / 7 - 33,
304+
paddingTop: 10,
305305
},
306306
calendarWedText: {
307307
color: '#616161',
@@ -312,12 +312,12 @@ const styles = StyleSheet.create({
312312
},
313313
weekDay: {
314314
flexDirection: 'row',
315-
paddingHorizontal: 22,
315+
paddingHorizontal: 2,
316316
},
317317
dateBase: {
318-
marginHorizontal: 8,
319-
width: MainWidth < 1000 ? MainWidth / 7 - 4.5 : MainWidth / 14,
320-
height: MainHeight < 300 ? MainWidth / 7 - 4.5 : MainWidth / 14,
318+
marginHorizontal: 2,
319+
width: MainWidth / 7 - 4.5,
320+
height: MainWidth / 7 - 4.5,
321321
...Platform.select({
322322
ios: {},
323323
android: {
@@ -327,15 +327,15 @@ const styles = StyleSheet.create({
327327
},
328328
currentMonth: {
329329
backgroundColor: '#329BCB',
330-
borderRadius: 60,
330+
borderRadius: 50,
331331
},
332332
selectMonth: {
333333
borderWidth: 1,
334334
borderColor: '#329BCB',
335-
borderRadius: 60,
335+
borderRadius: 50,
336336
},
337337
otherMonth: {
338-
borderRadius: 60,
338+
borderRadius: 50,
339339
},
340340
dayText: {
341341
textAlign: 'center',

0 commit comments

Comments
 (0)