Changeset View
Changeset View
Standalone View
Standalone View
native/chat/reaction-message-utils.js
Show First 20 Lines • Show All 128 Lines • ▼ Show 20 Lines | type ReactionSelectionPopoverPosition = { | ||||
}, | }, | ||||
+popoverLocation: 'above' | 'below', | +popoverLocation: 'above' | 'below', | ||||
}; | }; | ||||
function useReactionSelectionPopoverPosition({ | function useReactionSelectionPopoverPosition({ | ||||
initialCoordinates, | initialCoordinates, | ||||
verticalBounds, | verticalBounds, | ||||
margin, | margin, | ||||
}: ReactionSelectionPopoverPositionArgs): ReactionSelectionPopoverPosition { | }: ReactionSelectionPopoverPositionArgs): ReactionSelectionPopoverPosition { | ||||
const reactionSelectionPopoverHeight = 56; | const calculatedMargin = getCalculatedMargin(margin); | ||||
const calculatedMargin = margin ?? 16; | |||||
const windowWidth = useSelector(state => state.dimensions.width); | const windowWidth = useSelector(state => state.dimensions.width); | ||||
const popoverLocation: 'above' | 'below' = (() => { | const popoverLocation: 'above' | 'below' = (() => { | ||||
const { y, height } = initialCoordinates; | const { y, height } = initialCoordinates; | ||||
const contentTop = y; | const contentTop = y; | ||||
const contentBottom = y + height; | const contentBottom = y + height; | ||||
const boundsTop = verticalBounds.y; | const boundsTop = verticalBounds.y; | ||||
Show All 38 Lines | return React.useMemo( | ||||
() => ({ | () => ({ | ||||
popoverLocation, | popoverLocation, | ||||
containerStyle, | containerStyle, | ||||
}), | }), | ||||
[popoverLocation, containerStyle], | [popoverLocation, containerStyle], | ||||
); | ); | ||||
} | } | ||||
export { useSendReaction, useReactionSelectionPopoverPosition }; | function getCalculatedMargin(margin: ?number): number { | ||||
return margin ?? 16; | |||||
} | |||||
const reactionSelectionPopoverHeight = 56; | |||||
export { | |||||
useSendReaction, | |||||
useReactionSelectionPopoverPosition, | |||||
getCalculatedMargin, | |||||
reactionSelectionPopoverHeight, | |||||
}; |