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.

BaseContainer.js 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // @flow
  2. import * as React from 'react';
  3. import {Container, Right} from "native-base";
  4. import CustomHeader from "./CustomHeader";
  5. import CustomSideMenu from "./CustomSideMenu";
  6. import CustomMaterialIcon from "./CustomMaterialIcon";
  7. import {Platform, View} from "react-native";
  8. import ThemeManager from "../utils/ThemeManager";
  9. import Touchable from "react-native-platform-touchable";
  10. type Props = {
  11. navigation: Object,
  12. headerTitle: string,
  13. headerRightButton: React.Node,
  14. children: React.Node
  15. }
  16. type State = {
  17. isOpen: boolean
  18. }
  19. export default class BaseContainer extends React.Component<Props, State> {
  20. static defaultProps = {
  21. headerRightButton: <View/>
  22. };
  23. state = {
  24. isOpen: false,
  25. };
  26. toggle() {
  27. this.setState({
  28. isOpen: !this.state.isOpen,
  29. });
  30. }
  31. updateMenuState(isOpen: boolean) {
  32. this.setState({isOpen});
  33. }
  34. render() {
  35. return (
  36. <View style={{
  37. backgroundColor: ThemeManager.getCurrentThemeVariables().containerBgColor,
  38. width: '100%',
  39. height: '100%'
  40. }}>
  41. <CustomSideMenu navigation={this.props.navigation} isOpen={this.state.isOpen}
  42. onChange={(isOpen) => this.updateMenuState(isOpen)}>
  43. <Container>
  44. <CustomHeader navigation={this.props.navigation} title={this.props.headerTitle}
  45. leftButton={
  46. <Touchable
  47. style={{padding: 6}}
  48. onPress={() => this.toggle()}>
  49. <CustomMaterialIcon
  50. color={Platform.OS === 'ios' ? ThemeManager.getCurrentThemeVariables().brandPrimary : "#fff"}
  51. icon="menu"/>
  52. </Touchable>
  53. }
  54. rightButton={this.props.headerRightButton}/>
  55. {this.props.children}
  56. </Container>
  57. </CustomSideMenu>
  58. </View>
  59. );
  60. }
  61. }