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.

App.js 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import React from 'react';
  2. import {Dimensions, StyleSheet, View, Text} from 'react-native';
  3. import {StyleProvider} from 'native-base';
  4. import AppNavigator from './navigation/AppNavigator';
  5. import ThemeManager from './utils/ThemeManager';
  6. import LocaleManager from './utils/LocaleManager';
  7. import * as Font from 'expo-font';
  8. export default class App extends React.Component {
  9. constructor(props) {
  10. super(props);
  11. LocaleManager.getInstance().initTranslations();
  12. this.updateTheme = this.updateTheme.bind(this);
  13. this.state = {
  14. isLoading: true,
  15. currentTheme: undefined,
  16. };
  17. }
  18. async componentWillMount() {
  19. await Font.loadAsync({
  20. 'Roboto': require('native-base/Fonts/Roboto.ttf'),
  21. 'Roboto_medium': require('native-base/Fonts/Roboto_medium.ttf'),
  22. });
  23. ThemeManager.getInstance().setUpdateThemeCallback(this.updateTheme);
  24. await ThemeManager.getInstance().getDataFromPreferences();
  25. this.setState({
  26. isLoading: false,
  27. currentTheme: ThemeManager.getInstance().getCurrentTheme()
  28. });
  29. }
  30. updateTheme() {
  31. console.log('update theme called');
  32. // Change not propagating, need to restart the app
  33. // this.setState({
  34. // currentTheme: ThemeManager.getInstance().getCurrentTheme()
  35. // });
  36. }
  37. render() {
  38. if (this.state.isLoading) {
  39. return <View/>;
  40. }
  41. console.log('rendering');
  42. // console.log(this.state.currentTheme.variables.containerBgColor);
  43. return (
  44. <StyleProvider style={this.state.currentTheme}>
  45. <AppNavigator/>
  46. </StyleProvider>);
  47. }
  48. }