Skip to content

Commit 3c85f74

Browse files
authored
fix: ActionSheet 实例优化,组件优化 (#206)
* 编写选项卡组件 * 类型名称请调整,添加组件文档在网站上展示 * #162修复报错 * fix:#162修复报错 * SpeedDial 悬浮标记 * 优化类型 * feat(ActionSheet): Add new component. * fix: ActionSheet 实例优化,组件优化
1 parent 7c03a1a commit 3c85f74

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { Component } from 'react';
22
import { StyleSheet, View, } from 'react-native';
33
import Layout, { Container } from '../../Layout';
4-
import { ActionSheet, Button, ActionSheetItem, Toast, S } from '@uiw/react-native';
4+
import { ActionSheet, Button, ActionSheetItem, Toast } from '@uiw/react-native';
55
import { ComProps } from '../../routes';
66

77
const { Header, Body, Card, Footer } = Layout;
@@ -38,11 +38,11 @@ export default class Index extends Component<IndexProps, IndexState> {
3838
<Button onPress={this.onOpen}>打开 ActionSheet</Button>
3939
<ActionSheet
4040
visible={this.state.visible}
41-
// onCancel={true}
41+
onCancel={true}
4242
>
4343
<ActionSheetItem onPress={() => Toast.info('你点击了按钮一', 2, 'info')}>按钮一</ActionSheetItem>
4444
<ActionSheetItem onPress={() => Toast.info('你点击了按钮二', 2, 'info')}>按钮二</ActionSheetItem>
45-
<ActionSheetItem onPress={this.onCancel}>按钮三</ActionSheetItem>
45+
<ActionSheetItem onPress={this.onCancel}>关闭</ActionSheetItem>
4646
</ActionSheet>
4747
</Body>
4848
<Footer />

packages/core/src/ActionSheet/index.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React from 'react';
22
import { View, Dimensions, StyleSheet, Text, TouchableOpacity, Modal, ModalProps, Animated } from 'react-native';
3-
import Item from './item'
43
export { default as ActionSheetItem } from './item';
54

65
let MainWidth = Dimensions.get('window').width;
@@ -56,16 +55,13 @@ export default class ActionSheet extends React.Component<ActionSheetProps, Actio
5655
})
5756
})
5857
});
59-
}else {
58+
} else {
6059
this.onClose()
6160
}
6261
}
6362
render() {
6463
const { children, visible, cancelText = '取消', onCancel, ...other } = this.props
6564
const { stateVisible } = this.state
66-
if(!stateVisible) {
67-
return null
68-
}
6965
return (
7066
<Modal
7167
animationType="fade" // slide none fade
@@ -75,7 +71,7 @@ export default class ActionSheet extends React.Component<ActionSheetProps, Actio
7571
{...other}
7672
>
7773

78-
<TouchableOpacity activeOpacity={1} style={[styles.position, styles.spread]} onPress={()=>onCancel&&this.onClose()}>
74+
<TouchableOpacity activeOpacity={1} style={[styles.position, styles.spread]} onPress={() => onCancel && this.onClose()}>
7975
<Animated.View style={[styles.spread, styles.backdrop]}>
8076
</Animated.View>
8177
</TouchableOpacity>

0 commit comments

Comments
 (0)