diff --git a/components/BaseContainer.js b/components/BaseContainer.js index 7a11829..69c8468 100644 --- a/components/BaseContainer.js +++ b/components/BaseContainer.js @@ -16,7 +16,8 @@ type Props = { headerRightButton: React.Node, children: React.Node, hasTabs: boolean, - hasBackButton: boolean + hasBackButton: boolean, + hasSideMenu: boolean, } type State = { @@ -32,6 +33,7 @@ export default class BaseContainer extends React.Component { headerRightButton: , hasTabs: false, hasBackButton: false, + hasSideMenu: true, }; @@ -69,6 +71,29 @@ export default class BaseContainer extends React.Component { this.willBlurSubscription.remove(); } + getMainContainer() { + return ( + + this.toggle()}> + + + } + rightButton={this.props.headerRightButton} + hasTabs={this.props.hasTabs} + hasBackButton={this.props.hasBackButton}/> + {this.props.children} + + ); + } + + render() { return ( { width: '100%', height: '100%' }}> - this.updateMenuState(isOpen)}> - - this.toggle()}> - - - } - rightButton={this.props.headerRightButton} - hasTabs={this.props.hasTabs} - hasBackButton={this.props.hasBackButton}/> - {this.props.children} - - + {this.props.hasSideMenu ? + this.updateMenuState(isOpen)}> + {this.getMainContainer()} + : + this.getMainContainer()} ); } diff --git a/components/FetchedDataSectionList.js b/components/FetchedDataSectionList.js index 8473715..abb74ed 100644 --- a/components/FetchedDataSectionList.js +++ b/components/FetchedDataSectionList.js @@ -272,6 +272,10 @@ export default class FetchedDataSectionList extends React.Component {this.hasTabs() ? { this.dataSet = [ { name: "Amicale", - route: "amicale", + route: "AmicaleScreen", icon: "web", - link: AMICALE_LINK }, { name: "Wiketud", - route: "wiketud", + route: "WiketudScreen", icon: "wikipedia", - link: WIKETUD_LINK }, { name: "Tutor'INSA", - route: "tutorinsa", + route: "TutorInsaScreen", icon: "school", - link: TUTOR_INSA_LINK + }, + { + name: "Salles dispo", + route: "AvailableRoomScreen", + icon: "calendar-check", }, { name: i18n.t('screens.menuSelf'), diff --git a/components/WebViewScreen.js b/components/WebViewScreen.js new file mode 100644 index 0000000..4950937 --- /dev/null +++ b/components/WebViewScreen.js @@ -0,0 +1,102 @@ +// @flow + +import * as React from 'react'; +import {Linking, Platform, View} from 'react-native'; +import {Spinner} from 'native-base'; +import WebView from "react-native-webview"; +import Touchable from "react-native-platform-touchable"; +import CustomMaterialIcon from "../components/CustomMaterialIcon"; +import ThemeManager from "../utils/ThemeManager"; +import BaseContainer from "../components/BaseContainer"; + +type Props = { + navigation: Object, + url: string, + customInjectedJS: string, + headerTitle: string, + hasHeaderBackButton: boolean, + hasSideMenu: boolean, +} + +/** + * Class defining a webview screen. + */ +export default class WebViewScreen extends React.Component { + + static defaultProps = { + customInjectedJS: '', + hasBackButton: false, + hasSideMenu: true, + }; + + webview: WebView; + + openWebLink() { + Linking.openURL(this.props.url).catch((err) => console.error('Error opening link', err)); + } + + getHeaderButton(clickAction: Function, icon: string) { + return ( + clickAction()}> + + + ); + } + + getRefreshButton() { + return ( + + {this.getHeaderButton(() => this.openWebLink(), 'web')} + {this.getHeaderButton(() => this.refreshWebview(), 'refresh')} + + ); + }; + + refreshWebview() { + this.webview.reload(); + } + + render() { + const nav = this.props.navigation; + return ( + + (this.webview = ref)} + source={{uri: this.props.url}} + style={{ + width: '100%', + height: '100%', + }} + startInLoadingState={true} + injectedJavaScript={this.props.customInjectedJS} + javaScriptEnabled={true} + renderLoading={() => + + + + } + /> + + ); + } +} + diff --git a/navigation/AppNavigator.js b/navigation/AppNavigator.js index 1b47029..f9fb664 100644 --- a/navigation/AppNavigator.js +++ b/navigation/AppNavigator.js @@ -9,9 +9,14 @@ import AboutDependenciesScreen from '../screens/About/AboutDependenciesScreen'; import ProxiwashAboutScreen from '../screens/Proxiwash/ProxiwashAboutScreen'; import ProximoAboutScreen from '../screens/Proximo/ProximoAboutScreen'; import SelfMenuScreen from '../screens/SelfMenuScreen'; +import TutorInsaScreen from "../screens/TutorInsaScreen"; +import AmicaleScreen from "../screens/AmicaleScreen"; +import WiketudScreen from "../screens/WiketudScreen"; +import AvailableRoomScreen from "../screens/AvailableRoomScreen"; import DebugScreen from '../screens/DebugScreen'; import {fromRight} from "react-navigation-transitions"; + /** * Create a stack navigator using the drawer to handle navigation between screens */ @@ -25,6 +30,10 @@ function createAppContainerWithInitialRoute(initialRoute: string) { AboutScreen: {screen: AboutScreen}, AboutDependenciesScreen: {screen: AboutDependenciesScreen}, SelfMenuScreen: {screen: SelfMenuScreen}, + TutorInsaScreen: {screen: TutorInsaScreen}, + AmicaleScreen: {screen: AmicaleScreen}, + WiketudScreen: {screen: WiketudScreen}, + AvailableRoomScreen: {screen: AvailableRoomScreen}, ProxiwashAboutScreen: {screen: ProxiwashAboutScreen}, ProximoAboutScreen: {screen: ProximoAboutScreen}, DebugScreen: {screen: DebugScreen}, diff --git a/screens/AmicaleScreen.js b/screens/AmicaleScreen.js new file mode 100644 index 0000000..0fcc6cd --- /dev/null +++ b/screens/AmicaleScreen.js @@ -0,0 +1,32 @@ +// @flow + +import * as React from 'react'; +import ThemeManager from "../utils/ThemeManager"; +import WebViewScreen from "../components/WebViewScreen"; + +type Props = { + navigation: Object, +} + + +const URL = 'https://www.etud.insa-toulouse.fr/~amicale'; + +/** + * Class defining the app's planex screen. + * This screen uses a webview to render the planex page + */ +export default class AmicaleScreen extends React.Component { + + render() { + const nav = this.props.navigation; + return ( + + ); + } +} + diff --git a/screens/AvailableRoomScreen.js b/screens/AvailableRoomScreen.js new file mode 100644 index 0000000..5abeae7 --- /dev/null +++ b/screens/AvailableRoomScreen.js @@ -0,0 +1,40 @@ +// @flow + +import * as React from 'react'; +import ThemeManager from "../utils/ThemeManager"; +import WebViewScreen from "../components/WebViewScreen"; + +type Props = { + navigation: Object, +} + + +const URL = 'http://planex.insa-toulouse.fr/salles.php'; + +/** + * Class defining the app's planex screen. + * This screen uses a webview to render the planex page + */ +export default class AvailableRoomScreen extends React.Component { + + customInjectedJS: string; + + constructor() { + super(); + this.customInjectedJS = ''; + } + + render() { + const nav = this.props.navigation; + return ( + + ); + } +} + diff --git a/screens/PlanexScreen.js b/screens/PlanexScreen.js index 8ca6cb2..426a157 100644 --- a/screens/PlanexScreen.js +++ b/screens/PlanexScreen.js @@ -1,13 +1,8 @@ // @flow import * as React from 'react'; -import {Platform, View} from 'react-native'; -import {Spinner} from 'native-base'; -import WebView from "react-native-webview"; -import Touchable from "react-native-platform-touchable"; -import CustomMaterialIcon from "../components/CustomMaterialIcon"; import ThemeManager from "../utils/ThemeManager"; -import BaseContainer from "../components/BaseContainer"; +import WebViewScreen from "../components/WebViewScreen"; type Props = { navigation: Object, @@ -18,13 +13,13 @@ const PLANEX_URL = 'http://planex.insa-toulouse.fr/'; const CUSTOM_CSS_GENERAL = 'https://srv-falcon.etud.insa-toulouse.fr/~amicale_app/custom_css/planex/customMobile.css'; const CUSTOM_CSS_NIGHTMODE = 'https://srv-falcon.etud.insa-toulouse.fr/~amicale_app/custom_css/planex/customDark.css'; + /** * Class defining the app's planex screen. * This screen uses a webview to render the planex page */ -export default class PlanningScreen extends React.Component { +export default class PlanexScreen extends React.Component { - webview: WebView; customInjectedJS: string; constructor() { @@ -36,54 +31,15 @@ export default class PlanningScreen extends React.Component { this.customInjectedJS += 'document.querySelector(\'head\').innerHTML += \'\';'; } - - getRefreshButton() { - return ( - this.refreshWebview()}> - - - ); - }; - - refreshWebview() { - this.webview.reload(); - } - render() { const nav = this.props.navigation; return ( - - (this.webview = ref)} - source={{uri: PLANEX_URL}} - style={{ - width: '100%', - height: '100%', - }} - startInLoadingState={true} - injectedJavaScript={this.customInjectedJS} - javaScriptEnabled={true} - renderLoading={() => - - - - } - /> - + ); } } diff --git a/screens/SelfMenuScreen.js b/screens/SelfMenuScreen.js index 1cb9c23..3e9257c 100644 --- a/screens/SelfMenuScreen.js +++ b/screens/SelfMenuScreen.js @@ -64,6 +64,10 @@ export default class SelfMenuScreen extends FetchedDataSectionList { return true; } + hasSideMenu() : boolean { + return false; + } + createDataset(fetchedData: Object) { let result = []; // Prevent crash by giving a default value when fetchedData is empty (not yet available) diff --git a/screens/TutorInsaScreen.js b/screens/TutorInsaScreen.js new file mode 100644 index 0000000..62d7b50 --- /dev/null +++ b/screens/TutorInsaScreen.js @@ -0,0 +1,32 @@ +// @flow + +import * as React from 'react'; +import ThemeManager from "../utils/ThemeManager"; +import WebViewScreen from "../components/WebViewScreen"; + +type Props = { + navigation: Object, +} + + +const URL = 'https://www.etud.insa-toulouse.fr/~tutorinsa/'; + +/** + * Class defining the app's planex screen. + * This screen uses a webview to render the planex page + */ +export default class TutorInsaScreen extends React.Component { + + render() { + const nav = this.props.navigation; + return ( + + ); + } +} + diff --git a/screens/WiketudScreen.js b/screens/WiketudScreen.js new file mode 100644 index 0000000..7eb555d --- /dev/null +++ b/screens/WiketudScreen.js @@ -0,0 +1,32 @@ +// @flow + +import * as React from 'react'; +import ThemeManager from "../utils/ThemeManager"; +import WebViewScreen from "../components/WebViewScreen"; + +type Props = { + navigation: Object, +} + + +const URL = 'https://www.etud.insa-toulouse.fr/wiketud'; + +/** + * Class defining the app's planex screen. + * This screen uses a webview to render the planex page + */ +export default class WiketudScreen extends React.Component { + + render() { + const nav = this.props.navigation; + return ( + + ); + } +} +