blob: 84060ac01c4be9b6b21645412f56fb8814e1452f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
import React from 'react'
import {observer} from 'mobx-react-lite'
import {StyleProp, Text, TouchableOpacity, ViewStyle} from 'react-native'
import {useStores} from '../../../state'
import {LinkActionsModel} from '../../../state/models/shell-ui'
export const Link = observer(function Link({
style,
href,
title,
children,
}: {
style?: StyleProp<ViewStyle>
href: string
title?: string
children?: React.ReactNode
}) {
const store = useStores()
const onPress = () => {
store.shell.closeModal() // close any active modals
store.nav.navigate(href)
}
const onLongPress = () => {
store.shell.openModal(new LinkActionsModel(href, title || href))
}
return (
<TouchableOpacity
style={style}
onPress={onPress}
onLongPress={onLongPress}
delayPressIn={50}>
{children ? children : <Text>{title || 'link'}</Text>}
</TouchableOpacity>
)
})
|