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.

SettingsScreen.js 2.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import React from 'react';
  2. import {Container, Content, Left, ListItem, Right, Text, List, CheckBox, Button} from "native-base";
  3. import CustomHeader from "../components/CustomHeader";
  4. import ThemeManager from '../utils/ThemeManager';
  5. import i18n from "i18n-js";
  6. import {NavigationActions, StackActions} from "react-navigation";
  7. import CustomMaterialIcon from "../components/CustomMaterialIcon";
  8. const nightModeKey = 'nightMode';
  9. export default class SettingsScreen extends React.Component {
  10. state = {
  11. nightMode: ThemeManager.getInstance().getNightMode(),
  12. };
  13. toggleNightMode() {
  14. this.setState({nightMode: !this.state.nightMode});
  15. ThemeManager.getInstance().setNightmode(!this.state.nightMode);
  16. // Alert.alert(i18n.t('settingsScreen.nightMode'), i18n.t('settingsScreen.restart'));
  17. this.resetStack();
  18. }
  19. resetStack() {
  20. const resetAction = StackActions.reset({
  21. index: 0,
  22. key: null,
  23. actions: [NavigationActions.navigate({ routeName: 'Main' })],
  24. });
  25. this.props.navigation.dispatch(resetAction);
  26. this.props.navigation.navigate('Settings');
  27. }
  28. render() {
  29. const nav = this.props.navigation;
  30. return (
  31. <Container>
  32. <CustomHeader navigation={nav} title={i18n.t('screens.settings')}/>
  33. <Content>
  34. <List>
  35. <ListItem
  36. button
  37. onPress={() => this.toggleNightMode()}
  38. >
  39. <Left>
  40. <CustomMaterialIcon icon={'theme-light-dark'} />
  41. <Text>
  42. {i18n.t('settingsScreen.nightMode')}
  43. </Text>
  44. </Left>
  45. <Right style={{flex: 1}}>
  46. <CheckBox checked={this.state.nightMode}
  47. onPress={() => this.toggleNightMode()}/>
  48. </Right>
  49. </ListItem>
  50. </List>
  51. </Content>
  52. </Container>
  53. );
  54. }
  55. }