Add web linking and proper share controls
This commit is contained in:
parent
39058cd36a
commit
ed146a582c
15 changed files with 50 additions and 243 deletions
|
@ -1,72 +0,0 @@
|
|||
import React from 'react'
|
||||
import Toast from '../util/Toast'
|
||||
import Clipboard from '@react-native-clipboard/clipboard'
|
||||
import {StyleSheet, Text, TouchableOpacity, View} from 'react-native'
|
||||
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
|
||||
import {useStores} from '../../../state'
|
||||
import {s, colors} from '../../lib/styles'
|
||||
|
||||
export const snapPoints = ['30%']
|
||||
|
||||
export function Component({
|
||||
title,
|
||||
href,
|
||||
newTab,
|
||||
}: {
|
||||
title: string
|
||||
href: string
|
||||
newTab: boolean
|
||||
}) {
|
||||
const store = useStores()
|
||||
|
||||
const onPressOpenNewTab = () => {
|
||||
store.shell.closeModal()
|
||||
store.nav.newTab(href)
|
||||
}
|
||||
|
||||
const onPressCopy = () => {
|
||||
Clipboard.setString(href)
|
||||
store.shell.closeModal()
|
||||
Toast.show('Link copied', {
|
||||
position: Toast.positions.TOP,
|
||||
})
|
||||
}
|
||||
|
||||
return (
|
||||
<View>
|
||||
<Text style={[s.textCenter, s.bold, s.mb10, s.f16]}>{title || href}</Text>
|
||||
<View style={s.p10}>
|
||||
{newTab ? (
|
||||
<TouchableOpacity onPress={onPressOpenNewTab} style={styles.btn}>
|
||||
<FontAwesomeIcon
|
||||
icon="arrow-up-right-from-square"
|
||||
style={styles.icon}
|
||||
/>
|
||||
<Text style={[s.f16, s.black]}>Open in new tab</Text>
|
||||
</TouchableOpacity>
|
||||
) : undefined}
|
||||
<TouchableOpacity onPress={onPressCopy} style={styles.btn}>
|
||||
<FontAwesomeIcon icon="link" style={styles.icon} />
|
||||
<Text style={[s.f16, s.black]}>Copy to clipboard</Text>
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
btn: {
|
||||
flexDirection: 'row',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
width: '100%',
|
||||
borderColor: colors.gray5,
|
||||
borderWidth: 1,
|
||||
borderRadius: 4,
|
||||
padding: 10,
|
||||
marginBottom: 10,
|
||||
},
|
||||
icon: {
|
||||
marginRight: 8,
|
||||
},
|
||||
})
|
|
@ -7,9 +7,7 @@ import {createCustomBackdrop} from '../util/BottomSheetCustomBackdrop'
|
|||
|
||||
import * as models from '../../../state/models/shell-ui'
|
||||
|
||||
import * as LinkActionsModal from './LinkActions'
|
||||
import * as ConfirmModal from './Confirm'
|
||||
import * as SharePostModal from './SharePost.native'
|
||||
import * as EditProfileModal from './EditProfile'
|
||||
import * as CreateSceneModal from './CreateScene'
|
||||
import * as InviteToSceneModal from './InviteToScene'
|
||||
|
@ -41,27 +39,13 @@ export const Modal = observer(function Modal() {
|
|||
|
||||
let snapPoints: (string | number)[] = CLOSED_SNAPPOINTS
|
||||
let element
|
||||
if (store.shell.activeModal?.name === 'link-actions') {
|
||||
snapPoints = LinkActionsModal.snapPoints
|
||||
element = (
|
||||
<LinkActionsModal.Component
|
||||
{...(store.shell.activeModal as models.LinkActionsModel)}
|
||||
/>
|
||||
)
|
||||
} else if (store.shell.activeModal?.name === 'confirm') {
|
||||
if (store.shell.activeModal?.name === 'confirm') {
|
||||
snapPoints = ConfirmModal.snapPoints
|
||||
element = (
|
||||
<ConfirmModal.Component
|
||||
{...(store.shell.activeModal as models.ConfirmModel)}
|
||||
/>
|
||||
)
|
||||
} else if (store.shell.activeModal?.name === 'share-post') {
|
||||
snapPoints = SharePostModal.snapPoints
|
||||
element = (
|
||||
<SharePostModal.Component
|
||||
{...(store.shell.activeModal as models.SharePostModel)}
|
||||
/>
|
||||
)
|
||||
} else if (store.shell.activeModal?.name === 'edit-profile') {
|
||||
snapPoints = EditProfileModal.snapPoints
|
||||
element = (
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
import React from 'react'
|
||||
import {Button, StyleSheet, Text, TouchableOpacity, View} from 'react-native'
|
||||
import Toast from '../util/Toast'
|
||||
import Clipboard from '@react-native-clipboard/clipboard'
|
||||
import {s} from '../../lib/styles'
|
||||
import {useStores} from '../../../state'
|
||||
|
||||
export const snapPoints = ['30%']
|
||||
|
||||
export function Component({href}: {href: string}) {
|
||||
const store = useStores()
|
||||
const onPressCopy = () => {
|
||||
Clipboard.setString(href)
|
||||
Toast.show('Link copied', {
|
||||
position: Toast.positions.TOP,
|
||||
})
|
||||
store.shell.closeModal()
|
||||
}
|
||||
const onClose = () => store.shell.closeModal()
|
||||
|
||||
return (
|
||||
<View>
|
||||
<Text style={[s.textCenter, s.bold, s.mb10]}>Share this post</Text>
|
||||
<Text style={[s.textCenter, s.mb10]}>{href}</Text>
|
||||
<Button title="Copy to clipboard" onPress={onPressCopy} />
|
||||
<View style={s.p10}>
|
||||
<TouchableOpacity onPress={onClose} style={styles.closeBtn}>
|
||||
<Text style={s.textCenter}>Close</Text>
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
closeBtn: {
|
||||
width: '100%',
|
||||
borderColor: '#000',
|
||||
borderWidth: 1,
|
||||
borderRadius: 4,
|
||||
padding: 10,
|
||||
},
|
||||
})
|
|
@ -1,57 +0,0 @@
|
|||
import React, {forwardRef, useState, useImperativeHandle} from 'react'
|
||||
import {Button, StyleSheet, Text, TouchableOpacity, View} from 'react-native'
|
||||
import {Modal} from './WebModal'
|
||||
import Toast from '../util/Toast'
|
||||
import {s} from '../../lib/styles'
|
||||
|
||||
export const ShareModal = forwardRef(function ShareModal({}: {}, ref) {
|
||||
const [isOpen, setIsOpen] = useState<boolean>(false)
|
||||
const [uri, setUri] = useState<string>('')
|
||||
|
||||
useImperativeHandle(ref, () => ({
|
||||
open(uri: string) {
|
||||
console.log('sharing', uri)
|
||||
setUri(uri)
|
||||
setIsOpen(true)
|
||||
},
|
||||
}))
|
||||
|
||||
const onPressCopy = () => {
|
||||
// TODO
|
||||
Toast.show('Link copied', {
|
||||
position: Toast.positions.TOP,
|
||||
})
|
||||
}
|
||||
const onClose = () => {
|
||||
setIsOpen(false)
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
{isOpen && (
|
||||
<Modal onClose={onClose}>
|
||||
<View>
|
||||
<Text style={[s.textCenter, s.bold, s.mb10]}>Share this post</Text>
|
||||
<Text style={[s.textCenter, s.mb10]}>{uri}</Text>
|
||||
<Button title="Copy to clipboard" onPress={onPressCopy} />
|
||||
<View style={s.p10}>
|
||||
<TouchableOpacity onPress={onClose} style={styles.closeBtn}>
|
||||
<Text style={s.textCenter}>Close</Text>
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
</View>
|
||||
</Modal>
|
||||
)}
|
||||
</>
|
||||
)
|
||||
})
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
closeBtn: {
|
||||
width: '100%',
|
||||
borderColor: '#000',
|
||||
borderWidth: 1,
|
||||
borderRadius: 4,
|
||||
padding: 10,
|
||||
},
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue