Application Android et IOS pour l'amicale des élèves https://play.google.com/store/apps/details?id=fr.amicaleinsat.application
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.

BaseContainer.js 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. // @flow
  2. import * as React from 'react';
  3. import {Container} from "native-base";
  4. import CustomHeader from "./CustomHeader";
  5. import {MaterialCommunityIcons} from "@expo/vector-icons";
  6. import {Platform, View} from "react-native";
  7. import ThemeManager from "../utils/ThemeManager";
  8. import Touchable from "react-native-platform-touchable";
  9. type Props = {
  10. navigation: Object,
  11. headerTitle: string,
  12. headerSubtitle: string,
  13. headerRightButton: React.Node,
  14. children: React.Node,
  15. hasTabs: boolean,
  16. hasBackButton: boolean,
  17. hasSideMenu: boolean,
  18. enableRotation: boolean,
  19. hideHeaderOnLandscape: boolean,
  20. }
  21. type State = {
  22. isHeaderVisible: boolean
  23. }
  24. export default class BaseContainer extends React.Component<Props, State> {
  25. static defaultProps = {
  26. headerRightButton: <View/>,
  27. hasTabs: false,
  28. hasBackButton: false,
  29. hasSideMenu: true,
  30. enableRotation: false,
  31. hideHeaderOnLandscape: false,
  32. headerSubtitle: '',
  33. };
  34. state = {
  35. isHeaderVisible: true,
  36. };
  37. onDrawerPress: Function;
  38. constructor() {
  39. super();
  40. this.onDrawerPress = this.onDrawerPress.bind(this);
  41. }
  42. onDrawerPress() {
  43. this.props.navigation.toggleDrawer();
  44. }
  45. render() {
  46. // console.log("rendering BaseContainer");
  47. return (
  48. <Container>
  49. {this.state.isHeaderVisible ?
  50. <CustomHeader
  51. navigation={this.props.navigation}
  52. title={this.props.headerTitle}
  53. subtitle={this.props.headerSubtitle}
  54. leftButton={
  55. <Touchable
  56. style={{padding: 6}}
  57. onPress={this.onDrawerPress}>
  58. <MaterialCommunityIcons
  59. color={Platform.OS === 'ios' ? ThemeManager.getCurrentThemeVariables().brandPrimary : "#fff"}
  60. size={26}
  61. name="menu"/>
  62. </Touchable>
  63. }
  64. rightButton={this.props.headerRightButton}
  65. hasTabs={this.props.hasTabs}
  66. hasBackButton={this.props.hasBackButton}/>
  67. : <View/>}
  68. {this.props.children}
  69. </Container>
  70. );
  71. }
  72. }