Skip to content

Commit

Permalink
Added landscape support
Browse files Browse the repository at this point in the history
Closes #11
  • Loading branch information
Alessio Cancian committed Sep 2, 2021
1 parent 7853010 commit e2f73c9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
13 changes: 9 additions & 4 deletions lib/ActionSheetCustom.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import BlurView from './BlurView'
import { Platform } from 'react-native'

const WARN_COLOR = '#FF3B30'
const MAX_HEIGHT = Math.round(Dimensions.get('window').height * 0.8)

const getMaxHeight = () => {
return Math.round(Dimensions.get('window').height * 0.8)
}

class ActionSheet extends React.Component {
static defaultProps = {
Expand All @@ -20,9 +23,10 @@ class ActionSheet extends React.Component {

onLayout = (e: LayoutChangeEvent) => {
let translateY = e.nativeEvent.layout.height
let scrollEnabled = translateY > MAX_HEIGHT
const maxHeight = getMaxHeight()
let scrollEnabled = translateY > maxHeight
if (scrollEnabled) {
translateY = MAX_HEIGHT
translateY = maxHeight
}
this.setState({
translateY,
Expand Down Expand Up @@ -175,6 +179,7 @@ class ActionSheet extends React.Component {
<Modal visible={visible}
animationType='none'
transparent
supportedOrientations={["portrait", "landscape"]}
onRequestClose={this._cancel}
>
<SafeAreaView style={[styles.wrapper]}>
Expand All @@ -189,7 +194,7 @@ class ActionSheet extends React.Component {
iosStyle ? styles.bodyIos : (darkMode ? styles.bodyDark : styles.body),
{
opacity: translateY ? 1 : 0,
maxHeight: MAX_HEIGHT + 1,
maxHeight: getMaxHeight() + 1,
transform: [{
translateY: sheetAnim.interpolate({
inputRange: [0, 1],
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@alessiocancian/react-native-actionsheet",
"version": "3.0.4",
"version": "3.1.0",
"description": "Cross platform ActionSheet. This component implements a custom ActionSheet and provides the same way to drawing it on the defferent platforms(iOS and Android). Actually, In order to keep the best effect, it still uses the ActionSheetIOS on iOS.",
"main": "lib/index.js",
"types": "lib/ts/index.d.ts",
Expand Down

0 comments on commit e2f73c9

Please sign in to comment.