Move reusable components to separate folder, password view refactoring
This commit is contained in:
@@ -2,7 +2,7 @@ import React, { Component } from 'react'
|
|||||||
import { ScrollView } from 'react-native'
|
import { ScrollView } from 'react-native'
|
||||||
import Hyperlink from 'react-native-hyperlink'
|
import Hyperlink from 'react-native-hyperlink'
|
||||||
import AppText from '../app-text'
|
import AppText from '../app-text'
|
||||||
import SettingsSegment from './settings-segment'
|
import SettingsSegment from './common/settings-segment'
|
||||||
import styles from '../../styles/index'
|
import styles from '../../styles/index'
|
||||||
import labels, { links } from '../../i18n/en/settings'
|
import labels, { links } from '../../i18n/en/settings'
|
||||||
import replace from '../helpers/replace-url-with-text'
|
import replace from '../helpers/replace-url-with-text'
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Alert } from 'react-native'
|
import { Alert } from 'react-native'
|
||||||
import { shared as sharedLabels } from '../../i18n/en/labels'
|
import { shared as sharedLabels } from '../../../i18n/en/labels'
|
||||||
|
|
||||||
export default function alertError(msg) {
|
export default function alertError(msg) {
|
||||||
Alert.alert(sharedLabels.errorTitle, msg)
|
Alert.alert(sharedLabels.errorTitle, msg)
|
||||||
@@ -4,8 +4,8 @@ import { View, Alert } from 'react-native'
|
|||||||
import nodejs from 'nodejs-mobile-react-native'
|
import nodejs from 'nodejs-mobile-react-native'
|
||||||
import { requestHash, openDb } from '../../../db'
|
import { requestHash, openDb } from '../../../db'
|
||||||
|
|
||||||
import PasswordField from '../password/password-field'
|
import PasswordField from './password-field'
|
||||||
import SettingsButton from '../settings-button'
|
import SettingsButton from '../common/settings-button'
|
||||||
|
|
||||||
import settings from '../../../i18n/en/settings'
|
import settings from '../../../i18n/en/settings'
|
||||||
import { shared } from '../../../i18n/en/labels'
|
import { shared } from '../../../i18n/en/labels'
|
||||||
@@ -79,7 +79,7 @@ export default class ConfirmWithPassword extends Component {
|
|||||||
onPress={this.initPasswordCheck}
|
onPress={this.initPasswordCheck}
|
||||||
disabled={!password}
|
disabled={!password}
|
||||||
>
|
>
|
||||||
{settings.deleteSegment.title}
|
{shared.confirmToProceed}
|
||||||
</SettingsButton>
|
</SettingsButton>
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
|
|||||||
+2
-2
@@ -2,8 +2,8 @@ import React from 'react'
|
|||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
|
|
||||||
import { TouchableOpacity } from 'react-native'
|
import { TouchableOpacity } from 'react-native'
|
||||||
import AppText from '../app-text'
|
import AppText from '../../app-text'
|
||||||
import styles from '../../styles'
|
import styles from '../../../styles'
|
||||||
|
|
||||||
const SettingsButton = ({ children, ...props }) => {
|
const SettingsButton = ({ children, ...props }) => {
|
||||||
return (
|
return (
|
||||||
+2
-2
@@ -2,8 +2,8 @@ import React from 'react'
|
|||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
|
|
||||||
import { View } from 'react-native'
|
import { View } from 'react-native'
|
||||||
import AppText from '../app-text'
|
import AppText from '../../app-text'
|
||||||
import styles from '../../styles'
|
import styles from '../../../styles'
|
||||||
|
|
||||||
const SettingsSegment = ({ children, ...props }) => {
|
const SettingsSegment = ({ children, ...props }) => {
|
||||||
const style = [styles.settingsSegment, props.style]
|
const style = [styles.settingsSegment, props.style]
|
||||||
@@ -4,9 +4,9 @@ import { Alert, ToastAndroid } from 'react-native'
|
|||||||
|
|
||||||
import { clearDb, isDbEmpty } from '../../../db'
|
import { clearDb, isDbEmpty } from '../../../db'
|
||||||
import { hasEncryptionObservable } from '../../../local-storage'
|
import { hasEncryptionObservable } from '../../../local-storage'
|
||||||
import SettingsButton from '../settings-button'
|
import SettingsButton from '../common/settings-button'
|
||||||
import ConfirmWithPassword from '../common/confirm-with-password'
|
import ConfirmWithPassword from '../common/confirm-with-password'
|
||||||
import alertError from '../alert-error'
|
import alertError from '../common/alert-error'
|
||||||
|
|
||||||
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'
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import Share from 'react-native-share'
|
|||||||
|
|
||||||
import { getCycleDaysSortedByDate } from '../../../db'
|
import { getCycleDaysSortedByDate } from '../../../db'
|
||||||
import getDataAsCsvDataUri from '../../../lib/import-export/export-to-csv'
|
import getDataAsCsvDataUri from '../../../lib/import-export/export-to-csv'
|
||||||
import alertError from '../alert-error'
|
import alertError from '../common/alert-error'
|
||||||
import settings from '../../../i18n/en/settings'
|
import settings from '../../../i18n/en/settings'
|
||||||
import { EXPORT_FILE_NAME } from './constants'
|
import { EXPORT_FILE_NAME } from './constants'
|
||||||
import RNFS from 'react-native-fs'
|
import RNFS from 'react-native-fs'
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import rnfs from 'react-native-fs'
|
|||||||
import importCsv from '../../../lib/import-export/import-from-csv'
|
import importCsv from '../../../lib/import-export/import-from-csv'
|
||||||
import { shared as sharedLabels } from '../../../i18n/en/labels'
|
import { shared as sharedLabels } from '../../../i18n/en/labels'
|
||||||
import labels from '../../../i18n/en/settings'
|
import labels from '../../../i18n/en/settings'
|
||||||
import alertError from '../alert-error'
|
import alertError from '../common/alert-error'
|
||||||
|
|
||||||
export default function openImportDialogAndImport() {
|
export default function openImportDialogAndImport() {
|
||||||
Alert.alert(
|
Alert.alert(
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { ScrollView } from 'react-native'
|
import { ScrollView } from 'react-native'
|
||||||
import AppText from '../../app-text'
|
import AppText from '../../app-text'
|
||||||
import SettingsSegment from '../settings-segment'
|
import SettingsSegment from '../common/settings-segment'
|
||||||
import SettingsButton from '../settings-button'
|
import SettingsButton from '../common/settings-button'
|
||||||
import openImportDialogAndImport from './import-dialog'
|
import openImportDialogAndImport from './import-dialog'
|
||||||
import openShareDialogAndExport from './export-dialog'
|
import openShareDialogAndExport from './export-dialog'
|
||||||
import DeleteData from './delete-data'
|
import DeleteData from './delete-data'
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import Hyperlink from 'react-native-hyperlink'
|
|||||||
import styles, { iconStyles } from '../../../styles'
|
import styles, { iconStyles } from '../../../styles'
|
||||||
import labels from '../../../i18n/en/settings'
|
import labels from '../../../i18n/en/settings'
|
||||||
import AppText from '../../app-text'
|
import AppText from '../../app-text'
|
||||||
import SettingsSegment from '../settings-segment'
|
import SettingsSegment from '../common/settings-segment'
|
||||||
import TempSlider from './temp-slider'
|
import TempSlider from './temp-slider'
|
||||||
import UseCervixSetting from './use-cervix'
|
import UseCervixSetting from './use-cervix'
|
||||||
import Icon from 'react-native-vector-icons/Entypo'
|
import Icon from 'react-native-vector-icons/Entypo'
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import {
|
|||||||
import { secondaryColor } from '../../../styles/index'
|
import { secondaryColor } from '../../../styles/index'
|
||||||
import labels from '../../../i18n/en/settings'
|
import labels from '../../../i18n/en/settings'
|
||||||
import config from '../../../config'
|
import config from '../../../config'
|
||||||
import alertError from '../alert-error'
|
import alertError from '../common/alert-error'
|
||||||
|
|
||||||
export default class TempSlider extends Component {
|
export default class TempSlider extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
|
|||||||
@@ -1,23 +0,0 @@
|
|||||||
import { Alert } from 'react-native'
|
|
||||||
import { openDb } from '../../../db'
|
|
||||||
import { shared } from '../../../i18n/en/labels'
|
|
||||||
|
|
||||||
export default async function checkPassword({hash, onCancel, onTryAgain }) {
|
|
||||||
try {
|
|
||||||
await openDb(hash)
|
|
||||||
return true
|
|
||||||
} catch (err) {
|
|
||||||
Alert.alert(
|
|
||||||
shared.incorrectPassword,
|
|
||||||
shared.incorrectPasswordMessage,
|
|
||||||
[{
|
|
||||||
text: shared.cancel,
|
|
||||||
onPress: onCancel
|
|
||||||
}, {
|
|
||||||
text: shared.tryAgain,
|
|
||||||
onPress: onTryAgain
|
|
||||||
}]
|
|
||||||
)
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2,7 +2,7 @@ import React, { Component } from 'react'
|
|||||||
import { View } from 'react-native'
|
import { View } from 'react-native'
|
||||||
import settings from '../../../i18n/en/settings'
|
import settings from '../../../i18n/en/settings'
|
||||||
import EnterNewPassword from './enter-new-password'
|
import EnterNewPassword from './enter-new-password'
|
||||||
import SettingsButton from '../settings-button'
|
import SettingsButton from '../common/settings-button'
|
||||||
import showBackUpReminder from './show-backup-reminder'
|
import showBackUpReminder from './show-backup-reminder'
|
||||||
|
|
||||||
export default class CreatePassword extends Component {
|
export default class CreatePassword extends Component {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import React, { Component } from 'react'
|
|||||||
import labels from '../../../i18n/en/settings'
|
import labels from '../../../i18n/en/settings'
|
||||||
import { changeEncryptionAndRestartApp } from '../../../db'
|
import { changeEncryptionAndRestartApp } from '../../../db'
|
||||||
import ConfirmWithPassword from '../common/confirm-with-password'
|
import ConfirmWithPassword from '../common/confirm-with-password'
|
||||||
import SettingsButton from '../settings-button'
|
import SettingsButton from '../common/settings-button'
|
||||||
|
|
||||||
export default class DeletePassword extends Component {
|
export default class DeletePassword extends Component {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ import nodejs from 'nodejs-mobile-react-native'
|
|||||||
|
|
||||||
import { requestHash, changeEncryptionAndRestartApp } from '../../../db'
|
import { requestHash, changeEncryptionAndRestartApp } from '../../../db'
|
||||||
import AppText from '../../app-text'
|
import AppText from '../../app-text'
|
||||||
import PasswordField from './password-field'
|
import PasswordField from '../common/password-field'
|
||||||
import SettingsButton from '../settings-button'
|
import SettingsButton from '../common/settings-button'
|
||||||
|
|
||||||
import styles from '../../../styles'
|
import styles from '../../../styles'
|
||||||
import settings from '../../../i18n/en/settings'
|
import settings from '../../../i18n/en/settings'
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import React, { Component } from 'react'
|
import React, { Component } from 'react'
|
||||||
import { View, ScrollView } from 'react-native'
|
import { ScrollView } from 'react-native'
|
||||||
import CreatePassword from './create'
|
import CreatePassword from './create'
|
||||||
import ChangePassword from './update'
|
import ChangePassword from './update'
|
||||||
import DeletePassword from './delete'
|
import DeletePassword from './delete'
|
||||||
import SettingsSegment from '../settings-segment'
|
import SettingsSegment from '../common/settings-segment'
|
||||||
import AppText from '../../app-text'
|
import AppText from '../../app-text'
|
||||||
import {
|
import {
|
||||||
hasEncryptionObservable
|
hasEncryptionObservable
|
||||||
@@ -14,8 +14,7 @@ export default class PasswordSetting extends Component {
|
|||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props)
|
super(props)
|
||||||
this.state = {
|
this.state = {
|
||||||
showUpdateAndDelete: hasEncryptionObservable.value,
|
isPasswordSet: hasEncryptionObservable.value,
|
||||||
showCreate: !hasEncryptionObservable.value,
|
|
||||||
isChangingPassword: false,
|
isChangingPassword: false,
|
||||||
isDeletingPassword: false
|
isDeletingPassword: false
|
||||||
}
|
}
|
||||||
@@ -32,43 +31,37 @@ export default class PasswordSetting extends Component {
|
|||||||
render() {
|
render() {
|
||||||
|
|
||||||
const {
|
const {
|
||||||
showUpdateAndDelete,
|
isPasswordSet,
|
||||||
isChangingPassword,
|
isChangingPassword,
|
||||||
isDeletingPassword,
|
isDeletingPassword,
|
||||||
showCreate
|
|
||||||
} = this.state
|
} = this.state
|
||||||
|
|
||||||
|
const {
|
||||||
|
title,
|
||||||
|
explainerEnabled,
|
||||||
|
explainerDisabled
|
||||||
|
} = labels.passwordSettings
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ScrollView>
|
<ScrollView>
|
||||||
<SettingsSegment title={labels.passwordSettings.title}>
|
<SettingsSegment title={title}>
|
||||||
|
<AppText>
|
||||||
|
{ isPasswordSet ? explainerEnabled : explainerDisabled }
|
||||||
|
</AppText>
|
||||||
|
|
||||||
{showUpdateAndDelete ?
|
{ !isPasswordSet && <CreatePassword/> }
|
||||||
<AppText>{labels.passwordSettings.explainerEnabled}</AppText>
|
|
||||||
:
|
|
||||||
<AppText>{labels.passwordSettings.explainerDisabled}</AppText>
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
{ (isPasswordSet && !isDeletingPassword) && (
|
||||||
showUpdateAndDelete && (
|
<ChangePassword
|
||||||
<View>
|
onStartChangingPassword = {this.onChangingPassword}
|
||||||
{(isChangingPassword
|
/>
|
||||||
|| !isChangingPassword && !isDeletingPassword)
|
)}
|
||||||
&& <ChangePassword
|
|
||||||
onStartChangingPassword = {this.onChangingPassword}
|
|
||||||
/>}
|
|
||||||
{(isDeletingPassword
|
|
||||||
|| !isChangingPassword && !isDeletingPassword)
|
|
||||||
&& <DeletePassword
|
|
||||||
onStartDeletingPassword = {this.onDeletingPassword}
|
|
||||||
/>}
|
|
||||||
</View>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
{showCreate &&
|
|
||||||
<CreatePassword/>
|
|
||||||
}
|
|
||||||
|
|
||||||
|
{ (isPasswordSet && !isChangingPassword) && (
|
||||||
|
<DeletePassword
|
||||||
|
onStartDeletingPassword = {this.onDeletingPassword}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</SettingsSegment>
|
</SettingsSegment>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import React, { Component } from 'react'
|
import React, { Component } from 'react'
|
||||||
import settings from '../../../i18n/en/settings'
|
import settings from '../../../i18n/en/settings'
|
||||||
import EnterNewPassword from './enter-new-password'
|
import EnterNewPassword from './enter-new-password'
|
||||||
import SettingsButton from '../settings-button'
|
import SettingsButton from '../common/settings-button'
|
||||||
import showBackUpReminder from './show-backup-reminder'
|
import showBackUpReminder from './show-backup-reminder'
|
||||||
import ConfirmWithPassword from '../common/confirm-with-password'
|
import ConfirmWithPassword from '../common/confirm-with-password'
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import React, { Component } from 'react'
|
|||||||
import {
|
import {
|
||||||
ScrollView,
|
ScrollView,
|
||||||
} from 'react-native'
|
} from 'react-native'
|
||||||
import SettingsSegment from '../settings-segment'
|
import SettingsSegment from '../common/settings-segment'
|
||||||
import TempReminderPicker from './temp-reminder-picker'
|
import TempReminderPicker from './temp-reminder-picker'
|
||||||
import PeriodReminderPicker from './period-reminder'
|
import PeriodReminderPicker from './period-reminder'
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -11,7 +11,7 @@ export const shared = {
|
|||||||
incorrectPasswordMessage: 'That password is incorrect.',
|
incorrectPasswordMessage: 'That password is incorrect.',
|
||||||
tryAgain: 'Try again',
|
tryAgain: 'Try again',
|
||||||
ok: 'OK',
|
ok: 'OK',
|
||||||
unlock: 'Unlock',
|
confirmToProceed: 'Confirm to proceed',
|
||||||
date: 'Date',
|
date: 'Date',
|
||||||
cycleDayWithLinebreak: 'Cycle\nday',
|
cycleDayWithLinebreak: 'Cycle\nday',
|
||||||
loading: 'Loading ...',
|
loading: 'Loading ...',
|
||||||
|
|||||||
Reference in New Issue
Block a user