Skip to content

Commit fa27407

Browse files
authored
Merge pull request #4027 from StoDevX/fix-4026-link-highlight
Replace ActionSheetIOS usage with cross-platform library
2 parents 6aec75f + 2c964e9 commit fa27407

File tree

5 files changed

+24
-16
lines changed

5 files changed

+24
-16
lines changed

modules/markdown/link.js

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
// @flow
22

33
import * as React from 'react'
4-
import {ActionSheetIOS, Clipboard} from 'react-native'
4+
import {Clipboard} from 'react-native'
55
import glamorous from 'glamorous-native'
66
import {openUrl} from '@frogpond/open-url'
7+
import {connectActionSheet} from '@expo/react-native-action-sheet'
78

89
import * 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

2225
type 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}

modules/markdown/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"test": "jest"
1010
},
1111
"peerDependencies": {
12+
"@expo/react-native-action-sheet": "3.0.3",
1213
"glamorous-native": "^2.0.0",
1314
"react": "^16.0.0",
1415
"react-native": "^0.60.0"

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
},
9393
"dependencies": {
9494
"@callstack/react-theme-provider": "3.0.3",
95+
"@expo/react-native-action-sheet": "3.0.3",
9596
"@frogpond/titlecase": "1.0.0",
9697
"@hawkrives/react-native-alternate-icons": "0.4.7",
9798
"@mapbox/react-native-mapbox-gl": "6.1.3",

source/app.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {Provider as PaperProvider} from 'react-native-paper'
1515
import {makeStore, initRedux} from './redux'
1616
import * as navigation from './navigation'
1717
import {ThemeProvider} from '@frogpond/app-theme'
18+
import {ActionSheetProvider} from '@expo/react-native-action-sheet'
1819

1920
const store = makeStore()
2021
initRedux(store)
@@ -27,10 +28,12 @@ export default class App extends React.Component<Props> {
2728
<ReduxProvider store={store}>
2829
<PaperProvider>
2930
<ThemeProvider>
30-
<navigation.AppNavigator
31-
onNavigationStateChange={navigation.trackScreenChanges}
32-
persistenceKey={navigation.persistenceKey}
33-
/>
31+
<ActionSheetProvider>
32+
<navigation.AppNavigator
33+
onNavigationStateChange={navigation.trackScreenChanges}
34+
persistenceKey={navigation.persistenceKey}
35+
/>
36+
</ActionSheetProvider>
3437
</ThemeProvider>
3538
</PaperProvider>
3639
</ReduxProvider>

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,11 @@
685685
exec-sh "^0.3.2"
686686
minimist "^1.2.0"
687687

688+
689+
version "3.0.3"
690+
resolved "https://registry.yarnpkg.com/@expo/react-native-action-sheet/-/react-native-action-sheet-3.0.3.tgz#1d69a2668784961c6d458babe52e9a02893936a2"
691+
integrity sha512-MsVDCDQwJthoolqUqbg1nF8hmzA2gYfvnUV6j/h4gXPSKsrLqdaQz+Vi5onCB18oxmUZbYQ1+QNU+n1PwTp0Zw==
692+
688693
"@frogpond/[email protected]":
689694
version "1.0.0"
690695
resolved "https://registry.yarnpkg.com/@frogpond/titlecase/-/titlecase-1.0.0.tgz#993e5371c31b58a839e76fdc531053c55b1a2736"

0 commit comments

Comments
 (0)