From 6ce88657194b2cd0d9e4e0de537cf1c270946edf Mon Sep 17 00:00:00 2001 From: Henry Heino <46334387+personalizedrefrigerator@users.noreply.github.com> Date: Tue, 18 Jul 2023 06:58:06 -0700 Subject: [PATCH] Mobile: Add JEX export (#8428) --- .eslintignore | 7 +- .gitignore | 7 +- .../{ => ConfigScreen}/ConfigScreen.tsx | 143 +++-------------- .../ConfigScreen/ConfigScreenButton.tsx | 38 +++++ .../NoteExportButton.test.tsx | 57 +++++++ .../NoteExportSection/NoteExportButton.tsx | 114 +++++++++++++ .../NoteExportSection/exportAllFolders.ts | 29 ++++ .../ConfigScreen/configScreenStyles.ts | 137 ++++++++++++++++ packages/app-mobile/jest.config.js | 6 + packages/app-mobile/jest.setup.js | 35 ++++ packages/app-mobile/metro.config.js | 17 +- packages/app-mobile/package.json | 7 + packages/app-mobile/root.tsx | 17 +- packages/app-mobile/utils/fs-driver-rn.ts | 73 +++++++-- .../lib/services/interop/InteropService.ts | 40 +++-- .../interop/InteropService_Exporter_Base.ts | 3 +- .../interop/InteropService_Exporter_Jex.ts | 4 +- .../interop/InteropService_Importer_Base.ts | 3 +- .../interop/InteropService_Importer_Jex.ts | 4 +- packages/lib/services/interop/Module.ts | 17 +- packages/lib/services/interop/types.ts | 10 ++ yarn.lock | 150 ++++++++++++++++++ 22 files changed, 765 insertions(+), 153 deletions(-) rename packages/app-mobile/components/screens/{ => ConfigScreen}/ConfigScreen.tsx (86%) create mode 100644 packages/app-mobile/components/screens/ConfigScreen/ConfigScreenButton.tsx create mode 100644 packages/app-mobile/components/screens/ConfigScreen/NoteExportSection/NoteExportButton.test.tsx create mode 100644 packages/app-mobile/components/screens/ConfigScreen/NoteExportSection/NoteExportButton.tsx create mode 100644 packages/app-mobile/components/screens/ConfigScreen/NoteExportSection/exportAllFolders.ts create mode 100644 packages/app-mobile/components/screens/ConfigScreen/configScreenStyles.ts create mode 100644 packages/app-mobile/jest.setup.js diff --git a/.eslintignore b/.eslintignore index 6c095ee64..943d8f3ad 100644 --- a/.eslintignore +++ b/.eslintignore @@ -422,7 +422,12 @@ packages/app-mobile/components/biometrics/biometricAuthenticate.js packages/app-mobile/components/biometrics/sensorInfo.js packages/app-mobile/components/getResponsiveValue.js packages/app-mobile/components/getResponsiveValue.test.js -packages/app-mobile/components/screens/ConfigScreen.js +packages/app-mobile/components/screens/ConfigScreen/ConfigScreen.js +packages/app-mobile/components/screens/ConfigScreen/ConfigScreenButton.js +packages/app-mobile/components/screens/ConfigScreen/NoteExportSection/NoteExportButton.js +packages/app-mobile/components/screens/ConfigScreen/NoteExportSection/NoteExportButton.test.js +packages/app-mobile/components/screens/ConfigScreen/NoteExportSection/exportAllFolders.js +packages/app-mobile/components/screens/ConfigScreen/configScreenStyles.js packages/app-mobile/components/screens/Note.js packages/app-mobile/components/screens/Notes.js packages/app-mobile/components/screens/UpgradeSyncTargetScreen.js diff --git a/.gitignore b/.gitignore index 2778ecc77..546bf729b 100644 --- a/.gitignore +++ b/.gitignore @@ -407,7 +407,12 @@ packages/app-mobile/components/biometrics/biometricAuthenticate.js packages/app-mobile/components/biometrics/sensorInfo.js packages/app-mobile/components/getResponsiveValue.js packages/app-mobile/components/getResponsiveValue.test.js -packages/app-mobile/components/screens/ConfigScreen.js +packages/app-mobile/components/screens/ConfigScreen/ConfigScreen.js +packages/app-mobile/components/screens/ConfigScreen/ConfigScreenButton.js +packages/app-mobile/components/screens/ConfigScreen/NoteExportSection/NoteExportButton.js +packages/app-mobile/components/screens/ConfigScreen/NoteExportSection/NoteExportButton.test.js +packages/app-mobile/components/screens/ConfigScreen/NoteExportSection/exportAllFolders.js +packages/app-mobile/components/screens/ConfigScreen/configScreenStyles.js packages/app-mobile/components/screens/Note.js packages/app-mobile/components/screens/Notes.js packages/app-mobile/components/screens/UpgradeSyncTargetScreen.js diff --git a/packages/app-mobile/components/screens/ConfigScreen.tsx b/packages/app-mobile/components/screens/ConfigScreen/ConfigScreen.tsx similarity index 86% rename from packages/app-mobile/components/screens/ConfigScreen.tsx rename to packages/app-mobile/components/screens/ConfigScreen/ConfigScreen.tsx index 5046d734a..0ad97c062 100644 --- a/packages/app-mobile/components/screens/ConfigScreen.tsx +++ b/packages/app-mobile/components/screens/ConfigScreen/ConfigScreen.tsx @@ -1,29 +1,32 @@ /* eslint-disable @typescript-eslint/explicit-member-accessibility */ import Slider from '@react-native-community/slider'; const React = require('react'); -import { Platform, Linking, View, Switch, StyleSheet, ScrollView, Text, Button, TouchableOpacity, TextInput, Alert, PermissionsAndroid, TouchableNativeFeedback } from 'react-native'; +import { Platform, Linking, View, Switch, ScrollView, Text, Button, TouchableOpacity, TextInput, Alert, PermissionsAndroid, TouchableNativeFeedback } from 'react-native'; import Setting, { AppType } from '@joplin/lib/models/Setting'; import NavService from '@joplin/lib/services/NavService'; import ReportService from '@joplin/lib/services/ReportService'; import SearchEngine from '@joplin/lib/services/searchengine/SearchEngine'; -import checkPermissions from '../../utils/checkPermissions'; +import checkPermissions from '../../../utils/checkPermissions'; import time from '@joplin/lib/time'; import shim from '@joplin/lib/shim'; -import setIgnoreTlsErrors from '../../utils/TlsUtils'; +import setIgnoreTlsErrors from '../../../utils/TlsUtils'; import { reg } from '@joplin/lib/registry'; import { State } from '@joplin/lib/reducer'; -const { BackButtonService } = require('../../services/back-button.js'); +const { BackButtonService } = require('../../../services/back-button.js'); const VersionInfo = require('react-native-version-info').default; const { connect } = require('react-redux'); -import ScreenHeader from '../ScreenHeader'; +import ScreenHeader from '../../ScreenHeader'; const { _ } = require('@joplin/lib/locale'); -const { BaseScreenComponent } = require('../base-screen.js'); -const { Dropdown } = require('../Dropdown.js'); -const { themeStyle } = require('../global-style.js'); +const { BaseScreenComponent } = require('../../base-screen.js'); +const { Dropdown } = require('../../Dropdown'); +const { themeStyle } = require('../../global-style.js'); const shared = require('@joplin/lib/components/shared/config-shared.js'); import SyncTargetRegistry from '@joplin/lib/SyncTargetRegistry'; import { openDocumentTree } from '@joplin/react-native-saf-x'; -import biometricAuthenticate from '../biometrics/biometricAuthenticate'; +import biometricAuthenticate from '../../biometrics/biometricAuthenticate'; +import configScreenStyles from './configScreenStyles'; +import NoteExportButton from './NoteExportSection/NoteExportButton'; +import ConfigScreenButton from './ConfigScreenButton'; class ConfigScreenComponent extends BaseScreenComponent { public static navigationOptions(): any { @@ -223,94 +226,11 @@ class ConfigScreenComponent extends BaseScreenComponent { public styles() { const themeId = this.props.themeId; - const theme = themeStyle(themeId); if (this.styles_[themeId]) return this.styles_[themeId]; this.styles_ = {}; - const styles: any = { - body: { - flex: 1, - justifyContent: 'flex-start', - flexDirection: 'column', - }, - settingContainer: { - flex: 1, - flexDirection: 'row', - alignItems: 'center', - borderBottomWidth: 1, - borderBottomColor: theme.dividerColor, - paddingTop: theme.marginTop, - paddingBottom: theme.marginBottom, - paddingLeft: theme.marginLeft, - paddingRight: theme.marginRight, - }, - settingText: { - color: theme.color, - fontSize: theme.fontSize, - flex: 1, - paddingRight: 5, - }, - descriptionText: { - color: theme.colorFaded, - fontSize: theme.fontSizeSmaller, - flex: 1, - }, - sliderUnits: { - color: theme.color, - fontSize: theme.fontSize, - marginRight: 10, - }, - settingDescriptionText: { - color: theme.colorFaded, - fontSize: theme.fontSizeSmaller, - flex: 1, - paddingLeft: theme.marginLeft, - paddingRight: theme.marginRight, - paddingBottom: theme.marginBottom, - }, - permissionText: { - color: theme.color, - fontSize: theme.fontSize, - flex: 1, - marginTop: 10, - }, - settingControl: { - color: theme.color, - flex: 1, - }, - textInput: { - color: theme.color, - }, - }; - - styles.settingContainerNoBottomBorder = { ...styles.settingContainer, borderBottomWidth: 0, - paddingBottom: theme.marginBottom / 2 }; - - styles.settingControl.borderBottomWidth = 1; - styles.settingControl.borderBottomColor = theme.dividerColor; - - styles.switchSettingText = { ...styles.settingText }; - styles.switchSettingText.width = '80%'; - - styles.switchSettingContainer = { ...styles.settingContainer }; - styles.switchSettingContainer.flexDirection = 'row'; - styles.switchSettingContainer.justifyContent = 'space-between'; - - styles.linkText = { ...styles.settingText }; - styles.linkText.borderBottomWidth = 1; - styles.linkText.borderBottomColor = theme.color; - styles.linkText.flex = 0; - styles.linkText.fontWeight = 'normal'; - - styles.headerWrapperStyle = { ...styles.settingContainer, ...theme.headerWrapperStyle }; - - styles.switchSettingControl = { ...styles.settingControl }; - delete styles.switchSettingControl.color; - // styles.switchSettingControl.width = '20%'; - styles.switchSettingControl.flex = 0; - - this.styles_[themeId] = StyleSheet.create(styles); + this.styles_[themeId] = configScreenStyles(themeId); return this.styles_[themeId]; } @@ -388,28 +308,16 @@ class ConfigScreenComponent extends BaseScreenComponent { ); } - renderButton(key: string, title: string, clickHandler: ()=> void, options: any = null) { - if (!options) options = {}; - - let descriptionComp = null; - if (options.description) { - descriptionComp = ( - - {options.description} - - ); - } - + private renderButton(key: string, title: string, clickHandler: ()=> void, options: any = null) { return ( - - - -