Skip to content

Commit 5f1185e

Browse files
authored
Merge pull request #2 from yongqianvip/dev
修复安卓端ActionSheet在UI方面的问题
2 parents 4a0f63b + 7c797fa commit 5f1185e

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-overlayer",
3-
"version": "0.2.0",
3+
"version": "0.2.1",
44
"scripts": {
55
"start": "node node_modules/react-native/local-cli/cli.js start",
66
"test": "jest"

src/ActionSheet.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,26 @@ const borderRadius = 12;
1414
class ActionSheet extends React.Component {
1515
constructor(props){
1616
super(props);
17-
const {options, buttons} = props
1817
this.state = {
19-
actionSheetTop: new Animated.Value(options.itemHeight * buttons.length + 8 + options.itemHeight)
18+
actionSheetTop: new Animated.Value(DeviceConst.height) // 默认组件在屏幕(底部)外
2019
}
2120
this.renderButtonItem = this.renderButtonItem.bind(this);
2221
this.hideActionSheet = this.hideActionSheet.bind(this);
2322
DeviceEventEmitter.addListener("hide-actionSheet", this.hideActionSheet);
2423
}
2524
componentDidMount(){
26-
Animated.timing(this.state.actionSheetTop, {
27-
toValue: -(DeviceConst.dangerBottomHeight + 10),
25+
const {options, buttons} = this.props
26+
Animated.timing(this.state.actionSheetTop, { // 以动画的形式从下往上弹出actionSheet
27+
toValue: DeviceConst.height - DeviceConst.dangerBottomHeight - (buttons.length + 1) * options.itemHeight - 8 - (DeviceConst.isAndroid ? 20 : 10) ,
2828
duration: 300,
2929
}).start();
3030
}
3131
componentWillUnmount(){
3232
DeviceEventEmitter.removeAllListeners("hide-actionSheet");
3333
}
3434
hideActionSheet(callback){
35-
const {options, buttons} = this.props
3635
Animated.timing(this.state.actionSheetTop, {
37-
toValue: options.itemHeight * buttons.length + 8 + options.itemHeight,
36+
toValue: DeviceConst.height,
3837
duration: 300,
3938
}).start(callback ? callback : null);
4039
}

src/RRCActionSheet.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export default class OverlayActionSheet {
6060
let key;
6161
const backgroundColor = ActionSheetOptions.backgroundColor && typeof ActionSheetOptions.backgroundColor == 'string' ? ActionSheetOptions.backgroundColor : defaultBackgroundColor
6262
const overlayView = (
63-
<TouchableOpacity activeOpacity={1} type={'actionSheet'} style={{ width, height, backgroundColor: backgroundColor, alignItems: 'center', justifyContent: 'flex-end',}} onPress={()=>{
63+
<TouchableOpacity activeOpacity={1} type={'actionSheet'} style={{ width, height, backgroundColor: backgroundColor, alignItems: 'center'}} onPress={()=>{
6464
DeviceEventEmitter.emit("hide-actionSheet", ()=>{
6565
RRCTopView.removeAlert(key);
6666
});

0 commit comments

Comments
 (0)