Introduces data management section redesign
This commit is contained in:
@@ -3,12 +3,13 @@ import RNFS from 'react-native-fs'
|
|||||||
import { Alert, ToastAndroid } from 'react-native'
|
import { Alert, ToastAndroid } from 'react-native'
|
||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
|
|
||||||
import { clearDb, isDbEmpty } from '../../../db'
|
import Button from '../../common/button'
|
||||||
import { hasEncryptionObservable } from '../../../local-storage'
|
|
||||||
import SettingsButton from '../shared/settings-button'
|
|
||||||
import ConfirmWithPassword from '../shared/confirm-with-password'
|
import ConfirmWithPassword from '../shared/confirm-with-password'
|
||||||
import alertError from '../shared/alert-error'
|
import alertError from '../shared/alert-error'
|
||||||
|
|
||||||
|
import { clearDb, isDbEmpty } from '../../../db'
|
||||||
|
import { hasEncryptionObservable } from '../../../local-storage'
|
||||||
import settings from '../../../i18n/en/settings'
|
import settings from '../../../i18n/en/settings'
|
||||||
import { shared as sharedLabels } from '../../../i18n/en/labels'
|
import { shared as sharedLabels } from '../../../i18n/en/labels'
|
||||||
import { EXPORT_FILE_NAME } from './constants'
|
import { EXPORT_FILE_NAME } from './constants'
|
||||||
@@ -18,6 +19,7 @@ const exportedFilePath = `${RNFS.DocumentDirectoryPath}/${EXPORT_FILE_NAME}`
|
|||||||
export default class DeleteData extends Component {
|
export default class DeleteData extends Component {
|
||||||
constructor() {
|
constructor() {
|
||||||
super()
|
super()
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
isPasswordSet: hasEncryptionObservable.value,
|
isPasswordSet: hasEncryptionObservable.value,
|
||||||
isConfirmingWithPassword: false
|
isConfirmingWithPassword: false
|
||||||
@@ -92,9 +94,9 @@ export default class DeleteData extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SettingsButton onPress={this.alertBeforeDeletion}>
|
<Button isCTA onPress={this.alertBeforeDeletion}>
|
||||||
{settings.deleteSegment.title}
|
{settings.deleteSegment.title}
|
||||||
</SettingsButton>
|
</Button>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,22 @@
|
|||||||
import React, { Component } from 'react'
|
import React, { Component } from 'react'
|
||||||
import { ScrollView, View } from 'react-native'
|
|
||||||
import AppText from '../../common/app-text'
|
|
||||||
import Segment from '../../common/segment'
|
|
||||||
import AppLoadingView from '../../common/app-loading'
|
import AppLoadingView from '../../common/app-loading'
|
||||||
import SettingsButton from '../shared/settings-button'
|
import AppPage from '../../common/app-page'
|
||||||
|
import AppText from '../../common/app-text'
|
||||||
|
import Button from '../../common/button'
|
||||||
|
import Segment from '../../common/segment'
|
||||||
|
|
||||||
import { openImportDialog, getFileContent, importData } from './import-dialog'
|
import { openImportDialog, getFileContent, importData } from './import-dialog'
|
||||||
import openShareDialogAndExport from './export-dialog'
|
import openShareDialogAndExport from './export-dialog'
|
||||||
import DeleteData from './delete-data'
|
import DeleteData from './delete-data'
|
||||||
|
|
||||||
import labels from '../../../i18n/en/settings'
|
import labels from '../../../i18n/en/settings'
|
||||||
|
|
||||||
export default class DataManagement extends Component {
|
export default class DataManagement extends Component {
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props)
|
super(props)
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
currentAction: null
|
currentAction: null
|
||||||
@@ -51,41 +55,36 @@ export default class DataManagement extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { currentAction } = this.state
|
const { currentAction, isLoading } = this.state
|
||||||
|
const isDeletingData = currentAction === 'delete'
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View flex={1}>
|
<AppPage>
|
||||||
{this.state.isLoading && <AppLoadingView />}
|
{isLoading && <AppLoadingView />}
|
||||||
{!this.state.isLoading &&
|
{!isLoading &&
|
||||||
<ScrollView>
|
<React.Fragment>
|
||||||
<View>
|
|
||||||
<Segment title={labels.export.button}>
|
<Segment title={labels.export.button}>
|
||||||
<AppText>{labels.export.segmentExplainer}</AppText>
|
<AppText>{labels.export.segmentExplainer}</AppText>
|
||||||
<SettingsButton onPress={this.startExport}>
|
<Button isCTA onPress={this.startExport}>
|
||||||
{labels.export.button}
|
{labels.export.button}
|
||||||
</SettingsButton>
|
</Button>
|
||||||
</Segment>
|
</Segment>
|
||||||
<Segment title={labels.import.button}>
|
<Segment title={labels.import.button}>
|
||||||
<AppText>{labels.import.segmentExplainer}</AppText>
|
<AppText>{labels.import.segmentExplainer}</AppText>
|
||||||
<SettingsButton
|
<Button isCTA onPress= {this.startImport}>
|
||||||
onPress= {this.startImport}
|
|
||||||
>
|
|
||||||
{labels.import.button}
|
{labels.import.button}
|
||||||
</SettingsButton>
|
</Button>
|
||||||
</Segment>
|
</Segment>
|
||||||
<Segment
|
<Segment title={labels.deleteSegment.title} last>
|
||||||
title={labels.deleteSegment.title}
|
|
||||||
last
|
|
||||||
>
|
|
||||||
<AppText>{labels.deleteSegment.explainer}</AppText>
|
<AppText>{labels.deleteSegment.explainer}</AppText>
|
||||||
<DeleteData
|
<DeleteData
|
||||||
isDeletingData = { currentAction === 'delete' }
|
isDeletingData = {isDeletingData}
|
||||||
onStartDeletion = {() => this.setCurrentAction('delete')}
|
onStartDeletion = {() => this.setCurrentAction('delete')}
|
||||||
/>
|
/>
|
||||||
</Segment>
|
</Segment>
|
||||||
</View>
|
</React.Fragment>
|
||||||
</ScrollView>
|
|
||||||
}
|
}
|
||||||
</View>
|
</AppPage>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user