Skip to content

Commit b146e1c

Browse files
authored
Merge pull request #34 from MrLoh/patch-2
Provide example how to restore old status bar style
2 parents 85b21d1 + 8cb9e75 commit b146e1c

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,32 @@ The StatusBar will keep the last one provided in your app. So if the StatusBar i
203203
})
204204
```
205205

206+
If you need to restore the old bar style, after the browser is dismissed, you can try and patch the StatusBar.setBarStyle function to store the old value like so:
207+
208+
```js
209+
// patch StatusBar.setBarStyle to make style accessible
210+
const _setBarStyle = StatusBar.setBarStyle;
211+
StatusBar.setBarStyle = (style) => {
212+
StatusBar.currentStyle = style;
213+
_setBarStyle(style);
214+
};
215+
```
216+
217+
You can than restore the old bar style after the browser has been dismissed like this:
218+
219+
```javascript
220+
async openInBrowser(url) {
221+
try {
222+
const oldStyle = StatusBar.currentStyle
223+
StatusBar.setBarStyle('dark-content')
224+
await InAppBrowser.open(url)
225+
if(oldStyle) StatusBar.setBarStyle(oldStyle)
226+
} catch (error) {
227+
Alert.alert(error.message);
228+
}
229+
})
230+
```
231+
206232
## Credits 👍
207233
* **Expo:** [WebBrowser](https://docs.expo.io/versions/latest/sdk/webbrowser)
208234
* **React Native Custom Tabs:** [Chrome Custom Tabs for React Native](https://github.com/droibit/react-native-custom-tabs)

0 commit comments

Comments
 (0)