diff options
Diffstat (limited to 'src/view/com/util/forms/DropdownButton.tsx')
-rw-r--r-- | src/view/com/util/forms/DropdownButton.tsx | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/view/com/util/forms/DropdownButton.tsx b/src/view/com/util/forms/DropdownButton.tsx index 2946c5ca0..dcabe5455 100644 --- a/src/view/com/util/forms/DropdownButton.tsx +++ b/src/view/com/util/forms/DropdownButton.tsx @@ -1,5 +1,6 @@ import React, {useRef} from 'react' import { + Dimensions, Share, StyleProp, StyleSheet, @@ -21,6 +22,7 @@ import {usePalette} from 'lib/hooks/usePalette' import {useTheme} from 'lib/ThemeContext' const HITSLOP = {left: 10, top: 10, right: 10, bottom: 10} +const ESTIMATED_MENU_ITEM_HEIGHT = 52 export interface DropdownItem { icon?: IconProp @@ -67,10 +69,15 @@ export function DropdownButton({ if (!menuWidth) { menuWidth = 200 } + const winHeight = Dimensions.get('window').height + const estimatedMenuHeight = items.length * ESTIMATED_MENU_ITEM_HEIGHT const newX = openToRight ? pageX + width + rightOffset : pageX + width - menuWidth - const newY = pageY + height + bottomOffset + let newY = pageY + height + bottomOffset + if (newY + estimatedMenuHeight > winHeight) { + newY -= estimatedMenuHeight + } createDropdownMenu( newX, newY, @@ -114,6 +121,7 @@ export function PostDropdownBtn({ itemHref, isAuthor, onCopyPostText, + onOpenTranslate, onDeletePost, }: { style?: StyleProp<ViewStyle> @@ -124,6 +132,7 @@ export function PostDropdownBtn({ itemTitle: string isAuthor: boolean onCopyPostText: () => void + onOpenTranslate: () => void onDeletePost: () => void }) { const store = useStores() @@ -153,6 +162,13 @@ export function PostDropdownBtn({ }, }, { + icon: 'language', + label: 'Translate...', + onPress() { + onOpenTranslate() + }, + }, + { icon: 'circle-exclamation', label: 'Report post', onPress() { |