0
I am developing an APP that contains several texts, so the font size of the texts are imported from a single variable.
I’m trying to add an option to make the font bigger, and save the size of the chosen font, but, I’m not getting it.
Follows the code that altering and volley the variable tamanhoFonte
.
import React, { Component} from 'react';
import {
Text,
Button,
AsyncStorage,
View
} from 'react-native';
//Variável que é exportada para todos os textos
export var tamanhoFonte = 18;
export var corTexto = `#646567`;
export var nightMode = false;
export default class Variaveis extends Component {
_storeData() {
AsyncStorage.setItem('tamanhoFonte',tamanhoFonte)
}
_retrieveData() {
AsyncStorage.getItem('tamanhoFonte')
this.setState({tamanhoFonte:tamanhoFonte})
}
componentWillMount() {
this._retrieveData();
}
constructor(props) {
super(props);
this.state = { tamanhoFonte: tamanhoFonte }
}
mudaFonte = () => {
this.setState({tamanhoFonte: this.state.tamanhoFonte+1})
this._storeData();
}
render() {
return (
<View>
<Text>{this.state.tamanhoFonte} </Text>
<Button title="Muda fonte" onPress={() => { this.mudaFonte() }} />
</View>)
}
}