Skip to content

Commit c6a6052

Browse files
authored
Merge pull request #485 from hy916/dev
fix:修改文档和添加测试用例
2 parents 9275dd0 + 06b0a21 commit c6a6052

File tree

5 files changed

+20479
-56
lines changed

5 files changed

+20479
-56
lines changed

packages/core/src/Avatar/README.md

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -30,28 +30,11 @@ export default Demo
3030

3131
继承 [View](https://facebook.github.io/react-native/docs/view#props) 组件。
3232

33-
```ts
34-
import { ViewProps } from 'react-native';
35-
36-
export interface AvatarProps extends ViewProps {
37-
/** React Native `Image` 组件 Props */
38-
imageProps?: ImageProps;
39-
/** 图像源(远程URL或本地文件资源)。 */
40-
src?: string | number;
41-
/**
42-
* 尺寸
43-
* @default 40
44-
*/
45-
size?: number;
46-
/**
47-
* 设置圆角
48-
* @default 3
49-
*/
50-
rounded?: number;
51-
/**
52-
* 指定头像的形状
53-
* @default square
54-
*/
55-
shape?: 'circle' | 'square';
56-
}
57-
```
33+
34+
| 参数 | 说明 | 类型 | 默认值 |
35+
|------|------|-----|------|
36+
| `imageProps` | React Native `Image` 组件 Props | obj | - |
37+
| `src` | 图像源(远程URL或本地文件资源) | `string|number` | - |
38+
| `size` | 尺寸 | number | - |
39+
| `rounded` | 设置圆角 | number | - |
40+
| `shape` |指定头像的形状 | `circle|square` | - |

packages/core/src/Rating/README.md

Lines changed: 12 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -97,34 +97,15 @@ export default Demo
9797

9898
### Props
9999

100-
```ts
101-
import { TabsItemIconTypes } from '@uiw/react-native'
102-
103-
export type icoType = [TabsItemIconTypes, TabsItemIconTypes]
104-
export interface RatingProps {
105-
/** 默认选中几个 */
106-
defaultRating?: number;
107-
/** 总数*/
108-
resultRating?: number;
109-
/** icon 大小 */
110-
size?: number;
111-
/** icon 颜色 */
112-
color?: string;
113-
/** actived 激活 unactived 未激活 */
114-
icon?: {
115-
actived?: TabsItemIconTypes,
116-
unactived?: TabsItemIconTypes
117-
};
118-
/**
119-
* void
120-
* @param score type: number 选中几个
121-
*/
122-
onPress?: (score: number) => void;
123-
/** 自定义每项的提示信息 */
124-
tooltips?: string[];
125-
/** 自定义提示信息样式 */
126-
tooltipsStyle?: StyleProp<TextStyle>;
127-
/** 只读模式 */
128-
disabled: boolean
129-
}
130-
```
100+
101+
| 参数 | 说明 | 类型 | 默认值 |
102+
|------|------|-----|------|
103+
| `defaultRating` | 默认选中几个 | number | - |
104+
| `resultRating` | 总数 | number | - |
105+
| `size` | icon 大小 | number | - |
106+
| `color` | icon 颜色 | string | - |
107+
| `icon` | `actived` 激活 `unactived` 未激活 | obj | - |
108+
| `onPress` | 选中事件 | fn | - |
109+
| `tooltips` | 自定义每项的提示信息 | arr | - |
110+
| `resultRating` | 只读模式 | boolean | - |
111+

packages/core/src/SwipeAction/README.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,66 @@ import React,{ useRef } from 'react';
4141
import {SwipeAction} from '@uiw/react-native';
4242
import { View,Text } from 'react-native'
4343

44+
function Demo() {
45+
const ref = useRef()
46+
const right = [
47+
{
48+
text: '查看',
49+
color: 'orange',
50+
x: 250,
51+
},
52+
{
53+
text: '删除',
54+
color: 'red',
55+
x: 250,
56+
},
57+
];
58+
return (
59+
<SwipeAction ref={ref} buttonWidth={60} right={right}>
60+
<View><Text>滑动</Text></View>
61+
</SwipeAction>
62+
);
63+
}
64+
export default Demo;
65+
```
66+
67+
### 禁用
68+
69+
```jsx
70+
import React,{ useRef } from 'react';
71+
import {SwipeAction} from '@uiw/react-native';
72+
import { View,Text } from 'react-native'
73+
74+
function Demo() {
75+
const ref = useRef()
76+
const right = [
77+
{
78+
text: '查看',
79+
color: 'orange',
80+
x: 250,
81+
},
82+
{
83+
text: '删除',
84+
color: 'red',
85+
x: 250,
86+
},
87+
];
88+
return (
89+
<SwipeAction ref={ref} buttonWidth={60} right={right}>
90+
<View><Text>滑动</Text></View>
91+
</SwipeAction>
92+
);
93+
}
94+
export default Demo;
95+
```
96+
97+
### 禁用
98+
99+
```jsx
100+
import React,{ useRef } from 'react';
101+
import {SwipeAction} from '@uiw/react-native';
102+
import { View,Text } from 'react-native'
103+
44104
function Demo() {
45105
const ref = useRef()
46106
const right = [
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
import 'react-native';
2+
import React from 'react';
3+
import NoticeBar from '../lib/NoticeBar';
4+
import Marquee from '../lib/NoticeBar/Marquee'
5+
import { Text, Image } from 'react-native';
6+
import { render, fireEvent } from '@testing-library/react-native';
7+
import { keys, toObject } from '../utils';
8+
9+
const MODES: keys = {
10+
closable: '×',
11+
link: '∟'
12+
}
13+
14+
describe('NoticeBar', () => {
15+
describe.each`
16+
mode
17+
${'closable'}
18+
${'link'}
19+
`('$mode', ({ mode }) => {
20+
it(`should display mode ${mode} noticeBar`, () => {
21+
const { getByText } = render(<NoticeBar mode={mode} />);
22+
expect(getByText(MODES[mode])).toBeTruthy();
23+
});
24+
});
25+
26+
it('icon', () => {
27+
const source = {
28+
uri: 'https://zos.alipayobjects.com/rmsportal/bRnouywfdRsCcLU.png'
29+
}
30+
const customIcon = (
31+
<Image
32+
source={source}
33+
style={{ width: 12, height: 12 }}
34+
/>
35+
)
36+
const { UNSAFE_getByType } = render(<NoticeBar icon={customIcon} />);
37+
const component = UNSAFE_getByType(Image);
38+
expect(component.props.source).toMatchObject(source);
39+
});
40+
41+
it('marqueeProps', () => {
42+
const { UNSAFE_getByType } = render(<NoticeBar marqueeProps={{ style: { fontSize: 12 } }} />);
43+
const component = UNSAFE_getByType(Marquee);
44+
expect(component.props.style).toMatchObject({ fontSize: 12 });
45+
});
46+
47+
// it('onPress', () => {
48+
// const fn = jest.fn();
49+
// const { getByTestId } = render(<NoticeBar onPress={fn}>onPress</NoticeBar>);
50+
// const component = getByTestId('RNE__NoticeBar__wrap');
51+
// fireEvent(component, 'press');
52+
// expect(fn).toHaveBeenCalled();
53+
// });
54+
55+
// it('action', () => {
56+
// const { getByText } = render(<NoticeBar action={<Text>去看看</Text>} />);
57+
// expect(getByText('去看看')).toBeTruthy();
58+
// });
59+
60+
// it('style', () => {
61+
// const { getByTestId } = render(<NoticeBar style={{ height: 50 }} />);
62+
// const component = getByTestId('RNE__NoticeBar__wrap');
63+
// const styles = toObject(component.props.style);
64+
// expect(styles.height).toBe(50);
65+
// });
66+
67+
// it('textStyle', () => {
68+
// const { getByTestId } = render(<NoticeBar textStyle={{ fontSize: 20 }} />);
69+
// const component = getByTestId('RNE__NoticeBar__div');
70+
// const styles = toObject(component.props.style);
71+
// expect(styles.fontSize).toBe(20);
72+
// });
73+
});

0 commit comments

Comments
 (0)