Move reusable components to separate folder, password view refactoring

This commit is contained in:
mashazyu
2019-01-07 23:28:48 +01:00
committed by Sofiya Tepikin
parent 94940238a6
commit bee0550372
20 changed files with 49 additions and 79 deletions
+25 -32
View File
@@ -1,9 +1,9 @@
import React, { Component } from 'react'
import { View, ScrollView } from 'react-native'
import { ScrollView } from 'react-native'
import CreatePassword from './create'
import ChangePassword from './update'
import DeletePassword from './delete'
import SettingsSegment from '../settings-segment'
import SettingsSegment from '../common/settings-segment'
import AppText from '../../app-text'
import {
hasEncryptionObservable
@@ -14,8 +14,7 @@ export default class PasswordSetting extends Component {
constructor(props) {
super(props)
this.state = {
showUpdateAndDelete: hasEncryptionObservable.value,
showCreate: !hasEncryptionObservable.value,
isPasswordSet: hasEncryptionObservable.value,
isChangingPassword: false,
isDeletingPassword: false
}
@@ -32,43 +31,37 @@ export default class PasswordSetting extends Component {
render() {
const {
showUpdateAndDelete,
isPasswordSet,
isChangingPassword,
isDeletingPassword,
showCreate
} = this.state
const {
title,
explainerEnabled,
explainerDisabled
} = labels.passwordSettings
return (
<ScrollView>
<SettingsSegment title={labels.passwordSettings.title}>
<SettingsSegment title={title}>
<AppText>
{ isPasswordSet ? explainerEnabled : explainerDisabled }
</AppText>
{showUpdateAndDelete ?
<AppText>{labels.passwordSettings.explainerEnabled}</AppText>
:
<AppText>{labels.passwordSettings.explainerDisabled}</AppText>
}
{ !isPasswordSet && <CreatePassword/> }
{
showUpdateAndDelete && (
<View>
{(isChangingPassword
|| !isChangingPassword && !isDeletingPassword)
&& <ChangePassword
onStartChangingPassword = {this.onChangingPassword}
/>}
{(isDeletingPassword
|| !isChangingPassword && !isDeletingPassword)
&& <DeletePassword
onStartDeletingPassword = {this.onDeletingPassword}
/>}
</View>
)
}
{showCreate &&
<CreatePassword/>
}
{ (isPasswordSet && !isDeletingPassword) && (
<ChangePassword
onStartChangingPassword = {this.onChangingPassword}
/>
)}
{ (isPasswordSet && !isChangingPassword) && (
<DeletePassword
onStartDeletingPassword = {this.onDeletingPassword}
/>
)}
</SettingsSegment>
</ScrollView>
)