Fix license screen flicker

This commit is contained in:
Julia Friesel
2019-01-02 14:47:43 +01:00
parent 2c1b856234
commit 480e4533be
+18 -16
View File
@@ -10,7 +10,7 @@ export default class AppWrapper extends Component {
constructor() { constructor() {
super() super()
this.state = { this.state = {
showLicense: true retrievingLicenseSetting: true
} }
nodejs.start('main.js') nodejs.start('main.js')
this.checkLicenseAgreement() this.checkLicenseAgreement()
@@ -18,25 +18,27 @@ export default class AppWrapper extends Component {
async checkLicenseAgreement() { async checkLicenseAgreement() {
const agreed = await getLicenseFlag() const agreed = await getLicenseFlag()
if (agreed) this.setState({showLicense: false}) this.setState({retrievingLicenseSetting: false})
if (!agreed) this.setState({showLicense: true})
} }
render() { render() {
return ( const whiteScreen = <View style={{ flex: 1 }}></View>
this.state.showLicense ? const licenseScreen = <License setLicense={() => {
<License setLicense={() => this.setState({showLicense: false})}/> this.setState({showLicense: false})
: }}/>
<View style={{ flex: 1 }}> const passwordPrompt = <PasswordPrompt showApp={() => {
{this.state.showApp ?
<App/>
:
<PasswordPrompt
showApp={() => {
this.setState({showApp: true}) this.setState({showApp: true})
}} }}/>
/>
if (this.state.retrievingLicenseSetting) {
return whiteScreen
} else if (this.state.showLicense) {
return licenseScreen
} else if (!this.state.showApp) {
return passwordPrompt
} else {
return <App/>
} }
</View>
)
} }
} }