diff --git a/components/Sidebar.js b/components/Sidebar.js index df8844e..dcded25 100644 --- a/components/Sidebar.js +++ b/components/Sidebar.js @@ -3,16 +3,17 @@ import * as React from 'react'; import {Dimensions, FlatList, Image, Platform, StyleSheet, View} from 'react-native'; import i18n from "i18n-js"; -import * as WebBrowser from 'expo-web-browser'; +import {openBrowser} from "../utils/WebBrowser"; import SidebarDivider from "./SidebarDivider"; import SidebarItem from "./SidebarItem"; -import {TouchableRipple} from "react-native-paper"; +import {TouchableRipple, withTheme} from "react-native-paper"; const deviceWidth = Dimensions.get("window").width; type Props = { navigation: Object, state: Object, + theme: Object, }; type State = { @@ -22,7 +23,7 @@ type State = { /** * Component used to render the drawer menu content */ -export default class SideBar extends React.PureComponent { +class SideBar extends React.PureComponent { dataSet: Array; @@ -31,6 +32,7 @@ export default class SideBar extends React.PureComponent { }; getRenderItem: Function; + colors: Object; /** * Generate the dataset @@ -126,6 +128,7 @@ export default class SideBar extends React.PureComponent { }, ]; this.getRenderItem = this.getRenderItem.bind(this); + this.colors = props.theme.colors; } /** @@ -138,7 +141,7 @@ export default class SideBar extends React.PureComponent { if (item.link === undefined) this.props.navigation.navigate(item.route); else - WebBrowser.openBrowserAsync(item.link); + openBrowser(item.link, this.colors.primary); } /** @@ -218,3 +221,5 @@ const styles = StyleSheet.create({ marginTop: Platform.OS === "android" ? -3 : undefined } }); + +export default withTheme(SideBar); diff --git a/screens/HomeScreen.js b/screens/HomeScreen.js index 7fdae18..f7c8d57 100644 --- a/screens/HomeScreen.js +++ b/screens/HomeScreen.js @@ -4,13 +4,13 @@ import * as React from 'react'; import {View} from 'react-native'; import i18n from "i18n-js"; import DashboardItem from "../components/EventDashboardItem"; -import * as WebBrowser from 'expo-web-browser'; import WebSectionList from "../components/WebSectionList"; import {Text, withTheme} from 'react-native-paper'; import FeedItem from "../components/FeedItem"; import SquareDashboardItem from "../components/SquareDashboardItem"; import PreviewEventDashboardItem from "../components/PreviewEventDashboardItem"; import {stringToDate} from "../utils/Planning"; +import {openBrowser} from "../utils/WebBrowser"; // import DATA from "../dashboard_data.json"; @@ -70,7 +70,7 @@ class HomeScreen extends React.Component { } onTutorInsaClick() { - WebBrowser.openBrowserAsync("https://www.etud.insa-toulouse.fr/~tutorinsa/"); + openBrowser("https://www.etud.insa-toulouse.fr/~tutorinsa/", this.colors.primary); } onProximoClick() { @@ -402,7 +402,7 @@ class HomeScreen extends React.Component { } openLink(link: string) { - WebBrowser.openBrowserAsync(link); + openBrowser(link, this.colors.primary); } /** diff --git a/utils/WebBrowser.js b/utils/WebBrowser.js new file mode 100644 index 0000000..61238df --- /dev/null +++ b/utils/WebBrowser.js @@ -0,0 +1,11 @@ +// @flow + +import * as React from 'react'; +import * as WebBrowser from 'expo-web-browser'; + +export function openBrowser(url: string, color: string) { + WebBrowser.openBrowserAsync(url, { + toolbarColor: color, + enableBarCollapsing: true, + }); +}