Extract openImportDialog

This commit is contained in:
Julia Friesel
2018-08-09 09:03:57 +02:00
parent d3d72a396e
commit 53328f608b
+17 -15
View File
@@ -28,21 +28,7 @@ export default class Settings extends Component {
<View style={styles.homeButton}> <View style={styles.homeButton}>
<Button <Button
title={labels.import.button} title={labels.import.button}
onPress={() => { onPress={ openImportDialogAndImport }>
Alert.alert(
labels.import.title,
labels.import.message,
[{
text: labels.import.replaceOption,
onPress: () => getFileContentAndImport({deleteExisting: false})
}, {
text: labels.import.deleteOption,
onPress: () => getFileContentAndImport({deleteExisting: true})
}, {
text: labels.shared.cancel, style: 'cancel', onPress: () => { }
}]
)
}}>
</Button> </Button>
</View> </View>
</View> </View>
@@ -77,6 +63,22 @@ async function openShareDialogAndExport() {
} }
} }
function openImportDialogAndImport() {
Alert.alert(
labels.import.title,
labels.import.message,
[{
text: labels.import.replaceOption,
onPress: () => getFileContentAndImport({ deleteExisting: false })
}, {
text: labels.import.deleteOption,
onPress: () => getFileContentAndImport({ deleteExisting: true })
}, {
text: labels.shared.cancel, style: 'cancel', onPress: () => { }
}]
)
}
async function getFileContentAndImport({ deleteExisting }) { async function getFileContentAndImport({ deleteExisting }) {
let fileInfo let fileInfo
try { try {