Skip to content

Commit 86f7238

Browse files
committed
Add animated, modalPresentationStyle and modalTransitionStyle options for iOS
1 parent f6eea58 commit 86f7238

File tree

11 files changed

+14943
-110
lines changed

11 files changed

+14943
-110
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ Property | Description
9494
`preferredBarTintColor` (String) | The color to tint the background of the navigation bar and the toolbar. [`white`/`#FFFFFF`]
9595
`preferredControlTintColor` (String) | The color to tint the control buttons on the navigation bar and the toolbar. [`gray`/`#808080`]
9696
`readerMode` (Boolean) | A value that specifies whether Safari should enter Reader mode, if it is available. [`true`/`false`]
97+
`animated` (Boolean) | Animate the presentation. [`true`/`false`]
98+
`modalPresentationStyle` (String) | The presentation style for modally presented view controllers. [`none`/`fullScreen`/`pageSheet`/`formSheet`/`currentContext`/`custom`/`overFullScreen`/`overCurrentContext`/`popover`]
99+
`modalTransitionStyle` (String) | The transition style to use when presenting the view controller. [`coverVertical`/`flipHorizontal`/`crossDissolve`/`partialCurl`]
97100
98101
### Android Options
99102
Property | Description

example/.eslintrc.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
11
module.exports = {
22
root: true,
33
extends: '@react-native-community',
4+
rules: {
5+
"comma-dangle": ["error", {
6+
"arrays": "never",
7+
"objects": "never",
8+
"imports": "never",
9+
"exports": "never",
10+
"functions": "never"
11+
}],
12+
"prettier/prettier": ["error", {
13+
"endOfLine": "auto",
14+
"singleQuote": true
15+
}]
16+
}
417
};

example/App.js

Lines changed: 50 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* @flow
77
*/
88

9-
import React, { Component } from 'react'
9+
import React, { Component } from 'react';
1010
import {
1111
Platform,
1212
StyleSheet,
@@ -17,40 +17,43 @@ import {
1717
TextInput,
1818
StatusBar,
1919
Linking
20-
} from 'react-native'
21-
import InAppBrowser from 'react-native-inappbrowser-reborn'
20+
} from 'react-native';
21+
import InAppBrowser from 'react-native-inappbrowser-reborn';
2222

2323
const instructions = Platform.select({
2424
ios: 'Press Cmd+R to reload,\n' + 'Cmd+D or shake for dev menu',
2525
android:
2626
'Double tap R on your keyboard to reload,\n' +
2727
'Shake or press menu button for dev menu'
28-
})
28+
});
2929

3030
export default class App extends Component {
31-
constructor (props) {
32-
super(props)
31+
constructor(props) {
32+
super(props);
3333

3434
this.state = {
3535
url: 'https://www.google.com'
36-
}
36+
};
3737
}
3838

39-
sleep (timeout) {
40-
return new Promise(resolve => setTimeout(resolve, timeout))
39+
sleep(timeout) {
40+
return new Promise(resolve => setTimeout(resolve, timeout));
4141
}
4242

43-
async openLink () {
44-
const { url } = this.state
43+
async openLink() {
44+
const { url } = this.state;
4545
try {
4646
if (await InAppBrowser.isAvailable()) {
47-
StatusBar.setBarStyle('light-content')
47+
StatusBar.setBarStyle('light-content');
4848
const result = await InAppBrowser.open(url, {
4949
// iOS Properties
5050
dismissButtonStyle: 'cancel',
5151
preferredBarTintColor: '#453AA4',
5252
preferredControlTintColor: 'white',
5353
readerMode: false,
54+
animated: true,
55+
modalPresentationStyle: 'fullScreen',
56+
modalTransitionStyle: 'partialCurl',
5457
// Android Properties
5558
showTitle: true,
5659
toolbarColor: '#6200EE',
@@ -69,58 +72,67 @@ export default class App extends Component {
6972
headers: {
7073
'my-custom-header': 'my custom header value'
7174
}
72-
})
73-
await this.sleep(800)
74-
Alert.alert('Response', JSON.stringify(result))
75-
} else Linking.openURL(url)
75+
});
76+
await this.sleep(800);
77+
Alert.alert('Response', JSON.stringify(result));
78+
} else {
79+
Linking.openURL(url);
80+
}
7681
} catch (error) {
77-
Alert.alert(error.message)
82+
Alert.alert(error.message);
7883
}
7984
}
8085

81-
getDeepLink (path = '') {
82-
const scheme = 'my-demo'
83-
const prefix = Platform.OS === 'android' ? `${scheme}://demo/` : `${scheme}://`
84-
return prefix + path
86+
getDeepLink(path = '') {
87+
const scheme = 'my-demo';
88+
const prefix =
89+
Platform.OS === 'android' ? `${scheme}://demo/` : `${scheme}://`;
90+
return prefix + path;
8591
}
8692

87-
async tryDeepLinking () {
88-
const redirectToURL = `https://proyecto26.github.io/react-native-inappbrowser/`
89-
const redirectUrl = this.getDeepLink('home')
90-
const url = `${redirectToURL}?redirect_url=${encodeURIComponent(redirectUrl)}`
93+
async tryDeepLinking() {
94+
const redirectToURL =
95+
'https://proyecto26.github.io/react-native-inappbrowser/';
96+
const redirectUrl = encodeURIComponent(this.getDeepLink('home'));
97+
const url = `${redirectToURL}?redirect_url=${redirectUrl}`;
9198
try {
9299
if (await InAppBrowser.isAvailable()) {
93-
const result = await InAppBrowser.openAuth(url, redirectUrl)
94-
await this.sleep(800)
95-
Alert.alert('Response', JSON.stringify(result))
100+
const result = await InAppBrowser.openAuth(url, redirectUrl);
101+
await this.sleep(800);
102+
Alert.alert('Response', JSON.stringify(result));
96103
} else {
97-
Alert.alert('InAppBrowser is not supported :/')
104+
Alert.alert('InAppBrowser is not supported :/');
98105
}
99106
} catch (error) {
100-
Alert.alert('Something’s wrong with the app :(')
107+
Alert.alert('Something’s wrong with the app :(');
101108
}
102109
}
103110

104-
render () {
111+
render() {
105112
return (
106113
<View style={styles.container}>
107-
<StatusBar barStyle='dark-content' />
108-
<Text style={styles.welcome}>{'Welcome InAppBrowser\nfor React Native!'}</Text>
114+
<StatusBar barStyle="dark-content" />
115+
<Text style={styles.welcome}>
116+
{'Welcome InAppBrowser\nfor React Native!'}
117+
</Text>
109118
<Text style={styles.instructions}>Type the url</Text>
110119
<TextInput
111120
style={styles.urlInput}
112-
onChangeText={(text) => this.setState({ url: text })}
121+
onChangeText={text => this.setState({ url: text })}
113122
value={this.state.url}
114123
/>
115124
<View style={styles.openButton}>
116-
<Button title='Open link' onPress={() => this.openLink()} />
125+
<Button title="Open link" onPress={() => this.openLink()} />
117126
</View>
118127
<View style={styles.openButton}>
119-
<Button title='Try deep linking' onPress={() => this.tryDeepLinking()} />
128+
<Button
129+
title="Try deep linking"
130+
onPress={() => this.tryDeepLinking()}
131+
/>
120132
</View>
121133
<Text style={styles.instructions}>{instructions}</Text>
122134
</View>
123-
)
135+
);
124136
}
125137
}
126138

@@ -152,4 +164,4 @@ const styles = StyleSheet.create({
152164
paddingTop: Platform.OS === 'ios' ? 0 : 20,
153165
paddingBottom: Platform.OS === 'ios' ? 0 : 20
154166
}
155-
})
167+
});

example/ios/Podfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ DEPENDENCIES:
107107
- React-RCTText (from `../node_modules/react-native/Libraries/Text`)
108108
- React-RCTVibration (from `../node_modules/react-native/Libraries/Vibration`)
109109
- React-RCTWebSocket (from `../node_modules/react-native/Libraries/WebSocket`)
110-
- RNInAppBrowser (from `/Users/jdnichollsc/dev/react-native/inappbrowser/example/node_modules/react-native-inappbrowser-reborn`)
110+
- RNInAppBrowser (from `../node_modules/react-native-inappbrowser-reborn`)
111111
- yoga (from `../node_modules/react-native/ReactCommon/yoga`)
112112

113113
SPEC REPOS:
@@ -158,7 +158,7 @@ EXTERNAL SOURCES:
158158
React-RCTWebSocket:
159159
:path: "../node_modules/react-native/Libraries/WebSocket"
160160
RNInAppBrowser:
161-
:path: "/Users/jdnichollsc/dev/react-native/inappbrowser/example/node_modules/react-native-inappbrowser-reborn"
161+
:path: "../node_modules/react-native-inappbrowser-reborn"
162162
yoga:
163163
:path: "../node_modules/react-native/ReactCommon/yoga"
164164

0 commit comments

Comments
 (0)