11// @flow
22
33import * as React from 'react'
4- import { ActionSheetIOS , Clipboard } from 'react-native'
4+ import { Clipboard } from 'react-native'
55import glamorous from 'glamorous-native'
66import { openUrl } from '@frogpond/open-url'
7+ import { connectActionSheet } from '@expo/react-native-action-sheet'
78
89import * as c from '@frogpond/colors'
910
@@ -17,27 +18,20 @@ type Props = {
1718 href : string ,
1819 title ?: string ,
1920 children : React . ChildrenArray < string > ,
21+ showShareActionSheetWithOptions : any ,
22+ showActionSheetWithOptions : any ,
2023}
2124
2225type Callback = ( { title ?: string , href : string } ) => any
2326
24- export class Link extends React . PureComponent < Props > {
27+ class Link extends React . PureComponent < Props > {
2528 options : Array < [ string , Callback ] > = [
2629 [ 'Open' , ( { href} : { href : string } ) => openUrl ( href ) ] ,
2730 [
2831 'Copy' ,
2932 ( { title, href} : { href : string , title ?: string } ) =>
3033 Clipboard . setString ( `${ href } ${ title ? ' ' + title : '' } ` ) ,
3134 ] ,
32- [
33- 'Share…' ,
34- ( { href} : { href : string } ) =>
35- ActionSheetIOS . showShareActionSheetWithOptions (
36- { url : href } ,
37- this . onShareFailure ,
38- this . onShareSuccess ,
39- ) ,
40- ] ,
4135 [ 'Cancel' , ( ) => { } ] ,
4236 ]
4337
@@ -46,7 +40,7 @@ export class Link extends React.PureComponent<Props> {
4640 }
4741
4842 onLongPress = ( ) => {
49- return ActionSheetIOS . showActionSheetWithOptions (
43+ return this . props . showActionSheetWithOptions (
5044 {
5145 options : this . options . map ( ( [ name ] ) => name ) ,
5246 title : this . props . title ,
@@ -74,3 +68,7 @@ export class Link extends React.PureComponent<Props> {
7468 )
7569 }
7670}
71+
72+ const ConnectedLink = connectActionSheet ( Link )
73+
74+ export { ConnectedLink as Link }
0 commit comments