Application Android et IOS pour l'amicale des élèves
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

BibScreen.js 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // @flow
  2. import * as React from 'react';
  3. import WebViewScreen from "../../components/Screens/WebViewScreen";
  4. import i18n from "i18n-js";
  5. type Props = {
  6. navigation: Object,
  7. }
  8. const BIB_URL = 'https://bibbox.insa-toulouse.fr/';
  9. const CUSTOM_CSS_GENERAL = 'https://etud.insa-toulouse.fr/~amicale_app/custom_css/rooms/customMobile.css';
  10. const CUSTOM_CSS_Bib = 'https://etud.insa-toulouse.fr/~amicale_app/custom_css/rooms/customBibMobile.css';
  11. /**
  12. * Class defining the app's Bib screen.
  13. * This screen uses a webview to render the page
  14. */
  15. export default class AvailableRoomScreen extends React.Component<Props> {
  16. customInjectedJS: string;
  17. customBibInjectedJS: string;
  18. /**
  19. * Defines custom injected JavaScript to improve the page display on mobile
  20. */
  21. constructor() {
  22. super();
  23. this.customInjectedJS =
  24. 'document.querySelector(\'head\').innerHTML += \'<meta name="viewport" content="width=device-width, initial-scale=1.0">\';' +
  25. 'document.querySelector(\'head\').innerHTML += \'<link rel="stylesheet" href="' + CUSTOM_CSS_GENERAL + '" type="text/css"/>\';' +
  26. 'let header = $(".table tbody tr:first");' +
  27. '$("table").prepend("<thead></thead>");true;' + // Fix for crash on ios
  28. '$("thead").append(header);true;';
  29. this.customBibInjectedJS =
  30. 'document.querySelector(\'head\').innerHTML += \'<meta name="viewport" content="width=device-width, initial-scale=1.0">\';' +
  31. 'document.querySelector(\'head\').innerHTML += \'<link rel="stylesheet" href="' + CUSTOM_CSS_Bib + '" type="text/css"/>\';' +
  32. 'if ($(".hero-unit-form").length > 0 && $("#customBackButton").length === 0)' +
  33. '$(".hero-unit-form").append("' +
  34. '<div style=\'width: 100%; display: flex\'>' +
  35. '<a style=\'margin: auto\' href=\'' + BIB_URL + '\'>' +
  36. '<button id=\'customBackButton\' class=\'btn btn-primary\'>Retour</button>' +
  37. '</a>' +
  38. '</div>");true;';
  39. }
  40. render() {
  41. const nav = this.props.navigation;
  42. return (
  43. <WebViewScreen
  44. navigation={nav}
  45. data={[
  46. {
  47. url: BIB_URL,
  48. icon: 'book',
  49. name: i18n.t('availableRoomScreen.bibRoom'),
  50. customJS: this.customBibInjectedJS
  51. },
  52. ]}
  53. customInjectedJS={this.customInjectedJS}
  54. headerTitle={i18n.t('screens.availableRooms')}
  55. hasHeaderBackButton={true}
  56. hasSideMenu={false}
  57. hasFooter={false}/>
  58. );
  59. }
  60. }