provide an anchor to our actionsheet (#261)

This commit is contained in:
HeyImChris 2020-03-20 10:15:07 -07:00 коммит произвёл GitHub
Родитель 36306e3849
Коммит b25c2efadf
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 7 добавлений и 1 удалений

Просмотреть файл

@ -15,6 +15,7 @@ var {
StyleSheet,
Text,
View,
findNodeHandle,
} = ReactNative;
var BUTTONS = [
@ -32,10 +33,12 @@ class ActionSheetExample extends React.Component<{}, $FlowFixMeState> {
clicked: 'none',
};
anchorRef = React.createRef();
render() {
return (
<View>
<Text onPress={this.showActionSheet} style={style.button}>
<Text onPress={this.showActionSheet} style={style.button} ref={this.anchorRef}>
Click to show the ActionSheet
</Text>
<Text>
@ -49,6 +52,9 @@ class ActionSheetExample extends React.Component<{}, $FlowFixMeState> {
ActionSheetIOS.showActionSheetWithOptions({
options: BUTTONS,
cancelButtonIndex: CANCEL_INDEX,
anchor: this.anchorRef.current
? findNodeHandle(this.anchorRef.current)
: undefined,
destructiveButtonIndex: DESTRUCTIVE_INDEX,
},
(buttonIndex) => {