Skip to content

Commit 8579b8e

Browse files
author
hy
committed
Merge branch 'dev' of github.com:uiwjs/react-native-uiw into dev
2 parents a72904e + c99be70 commit 8579b8e

File tree

6 files changed

+70
-27
lines changed

6 files changed

+70
-27
lines changed

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

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ import {SafeAreaView, Dimensions, ActivityIndicator} from 'react-native';
33
import {TransitionImage} from '@uiw/react-native';
44
import Layout from '../../Layout';
55
const TransitionImageDemo = (props: any) => {
6-
const {Header, Body} = Layout;
6+
const [state, setState] = React.useState<any>({
7+
url1: 'https://iknow-pic.cdn.bcebos.com/810a19d8bc3eb135828572d2ab1ea8d3fd1f441d',
8+
url3: undefined,
9+
});
10+
const {Header, Body, Card} = Layout;
711
const {route} = props;
812
const description = route.params.description;
913
const title = route.params.title;
@@ -12,19 +16,26 @@ const TransitionImageDemo = (props: any) => {
1216
<SafeAreaView style={{flex: 1}}>
1317
<Header title={title} description={description} />
1418
<Body style={{paddingLeft: 16, paddingRight: 16}}>
15-
<TransitionImage
16-
source={{
17-
uri: 'https://iknow-pic.cdn.bcebos.com/810a19d8bc3eb135828572d2ab1ea8d3fd1f441d',
18-
}}
19-
style={{width: 200, height: 200}}
20-
PlaceholderContent={<ActivityIndicator />}
21-
// placeholderStyle={{backgroundColor: 'red'}}
22-
// containerStyle={{backgroundColor: '#eee'}}
23-
transition={true}
24-
transitionDuration={1000}
25-
onPress={() => console.log('点击图片回调事件')}
26-
onLongPress={() => console.log('长按组件回调事件')}
27-
/>
19+
<Card title="基础用法">
20+
<TransitionImage
21+
source={{uri: state.url1}}
22+
style={{width: 100, height: 100}}
23+
PlaceholderContent={<ActivityIndicator />}
24+
transition={true}
25+
transitionDuration={1000}
26+
onPress={() => console.log('点击图片回调事件')}
27+
onLongPress={() => console.log('长按组件回调事件')}
28+
/>
29+
</Card>
30+
<Card title="加载失败">
31+
<TransitionImage
32+
source={{uri: state.url3}}
33+
style={{width: 100, height: 100}}
34+
PlaceholderContent={<ActivityIndicator />}
35+
transition={true}
36+
transitionDuration={1000}
37+
/>
38+
</Card>
2839
</Body>
2940
</SafeAreaView>
3041
);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"@babel/plugin-proposal-decorators": "~7.20.7",
5151
"@babel/preset-env": "~7.20.2",
5252
"@babel/preset-typescript": "~7.18.6",
53-
"babel-preset-react-native": "4.0.2",
53+
"babel-preset-react-native": "4.0.1",
5454
"fs-extra": "~10.1.0",
5555
"metro-react-native-babel-preset": "0.73.6",
5656
"react": "18.0.0",

packages/core/src/Form/comps/tree.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ const FormTree = ({
100100
<Modal visible={visible} placement="bottom" onClosed={() => setVisible(false)}>
101101
<ScrollView style={{ height: 400 }}>
102102
<Tree
103+
defaultCheckedKeys={value}
103104
treeData={options}
104105
defaultExpandAll
105106
onCheck={(value: any) => {

packages/core/src/Swiper/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ export default SwiperDemo
3838
| borderRadius | 圆角边框 | Number | 0 |
3939
| autoplay | 是否开启定时器 | Boolean | true|
4040
| dotStyle | 圆点类型 ( dot : 圆点, block : 方块 ) | String | dot |
41-
| loading | 加载状态 | Boolean | false |
41+
| loading | 加载中状态 | Boolean | false |

packages/core/src/Swiper/index.tsx

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,23 @@ export interface dataSourceType {
1717
}
1818
export type dotType = 'dot' | 'block';
1919
export interface SwiperProps {
20-
// 数据源
20+
/** 图片数据源 */
2121
dataSource?: dataSourceType[];
22-
// 轮播图宽度
22+
/** 轮播图宽度 */
2323
width?: number;
24-
// 轮播图高度
24+
/** 轮播图高度 */
2525
height?: number;
26-
// 播放时间
26+
/** 播放时间 */
2727
time?: number;
28-
// 圆角边框
28+
/** 圆角边框 */
2929
borderRadius?: number;
30-
// 是否开启自动播放
30+
/** 是否开启自动播放 */
3131
autoplay?: boolean;
32-
// 指示点样式 dot: 圆点 block: 方块
32+
/** 指示点样式 dot: 圆点 block: 方块 */
3333
dotStyle?: dotType;
34-
// 初始位置
34+
/** 初始位置 */
3535
index?: number;
36+
/** 是否加载中 */
3637
loading?: boolean;
3738
}
3839
const Swiper = (porps: SwiperProps) => {
@@ -105,7 +106,12 @@ const Swiper = (porps: SwiperProps) => {
105106
let offSetX = e.nativeEvent.contentOffset.x;
106107
let mentWidth = e.nativeEvent.layoutMeasurement.width;
107108
let page = offSetX / mentWidth;
108-
109+
// 第一张图片
110+
if (page === 0 && offSetX <= 0) {
111+
setCurIndex(dataSource.length - 1);
112+
scrollToRef.current.scrollTo({ x: dataSource.length * width, y: 0, animated: false }); // 让 ScrollView 定位到最后一张图片
113+
}
114+
// 最后一张图片
109115
if (page === dataSource.length) {
110116
setCurIndex(0);
111117
scrollToRef.current.scrollTo({ x: 0, y: 0, animated: false });

packages/core/src/TransitionImage/README.md

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function Demo() {
1919
<Fragment>
2020
<TransitionImage
2121
source={{ uri: 'https://avatars.githubusercontent.com/u/24369183?v=4' }}
22-
style={{ width: 200, height: 200, }}
22+
style={{ width: 100, height: 100, }}
2323
onPress={()=> console.log('点击图片回调事件')}
2424
onLongPress={()=> console.log('长按组件回调事件')}
2525
/>
@@ -42,7 +42,7 @@ function Demo() {
4242
<Fragment>
4343
<TransitionImage
4444
source={{ uri: 'https://avatars.githubusercontent.com/u/24369183?v=4' }}
45-
style={{ width: 200, height: 200, }}
45+
style={{ width: 100, height: 100, }}
4646
PlaceholderContent={<ActivityIndicator />}
4747
placeholderStyle={{backgroundColor: '#000a'}}
4848
containerStyle={{backgroundColor:'#eee',}}
@@ -57,6 +57,31 @@ function Demo() {
5757
export default Demo
5858
```
5959

60+
### 失败加载
61+
62+
```jsx mdx:preview&background=#bebebe29
63+
import React, { useState } from 'react';
64+
import { Fragment } from 'react';
65+
import { TransitionImage } from '@uiw/react-native';
66+
import { ActivityIndicator } from 'react-native';
67+
68+
function Demo() {
69+
return (
70+
<Fragment>
71+
<TransitionImage
72+
source={{ uri: undefined }}
73+
style={{ width: 100, height: 100 }}
74+
placeholderStyle={{backgroundColor: '#000a'}}
75+
containerStyle={{backgroundColor:'#eee',}}
76+
transition={true}
77+
transitionDuration={1000}
78+
/>
79+
</Fragment>
80+
);
81+
}
82+
export default Demo
83+
```
84+
6085
### Props
6186

6287
```js

0 commit comments

Comments
 (0)