const React = require('react'); const Component = React.Component; const { Platform, TouchableOpacity, Linking, View, Switch, Slider, StyleSheet, Text, Button, ScrollView, TextInput } = require('react-native'); const { connect } = require('react-redux'); const { ScreenHeader } = require('lib/components/screen-header.js'); const { _, setLocale } = require('lib/locale.js'); const { BaseScreenComponent } = require('lib/components/base-screen.js'); const { Dropdown } = require('lib/components/Dropdown.js'); const { themeStyle } = require('lib/components/global-style.js'); const Setting = require('lib/models/Setting.js'); const shared = require('lib/components/shared/config-shared.js'); const SyncTargetRegistry = require('lib/SyncTargetRegistry'); const { reg } = require('lib/registry.js'); const VersionInfo = require('react-native-version-info').default; class ConfigScreenComponent extends BaseScreenComponent { static navigationOptions(options) { return { header: null }; } constructor() { super(); this.styles_ = {}; shared.init(this); this.checkSyncConfig_ = async () => { await shared.checkSyncConfig(this, this.state.settings); } this.saveButton_press = () => { return shared.saveSettings(this); }; } UNSAFE_componentWillMount() { this.setState({ settings: this.props.settings }); } styles() { const themeId = this.props.theme; const theme = themeStyle(themeId); if (this.styles_[themeId]) return this.styles_[themeId]; this.styles_ = {}; let styles = { 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.color, fontSize: theme.fontSize, flex: 1, }, sliderUnits: { color: theme.color, fontSize: theme.fontSize, }, settingDescriptionText: { color: theme.color, fontSize: theme.fontSize, 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, }, } styles.settingContainerNoBottomBorder = Object.assign({}, styles.settingContainer, { borderBottomWidth: 0, paddingBottom: theme.marginBottom / 2, }); styles.settingControl.borderBottomWidth = 1; styles.settingControl.borderBottomColor = theme.strongDividerColor; styles.switchSettingText = Object.assign({}, styles.settingText); styles.switchSettingText.width = '80%'; styles.switchSettingContainer = Object.assign({}, styles.settingContainer); styles.switchSettingContainer.flexDirection = 'row'; styles.switchSettingContainer.justifyContent = 'space-between'; styles.linkText = Object.assign({}, styles.settingText); styles.linkText.borderBottomWidth = 1; styles.linkText.borderBottomColor = theme.color; styles.linkText.flex = 0; styles.linkText.fontWeight = 'normal'; styles.headerWrapperStyle = Object.assign({}, styles.settingContainer, theme.headerWrapperStyle) styles.switchSettingControl = Object.assign({}, styles.settingControl); delete styles.switchSettingControl.color; //styles.switchSettingControl.width = '20%'; styles.switchSettingControl.flex = 0; this.styles_[themeId] = StyleSheet.create(styles); return this.styles_[themeId]; } renderHeader(key, title) { const theme = themeStyle(this.props.theme); return ( {title} ); } sectionToComponent(key, section, settings) { const theme = themeStyle(this.props.theme); const settingComps = []; for (let i = 0; i < section.metadatas.length; i++) { const md = section.metadatas[i]; if (section.name === 'sync' && md.key === 'sync.resourceDownloadMode') { const syncTargetMd = SyncTargetRegistry.idToMetadata(settings['sync.target']); if (syncTargetMd.supportsConfigCheck) { const messages = shared.checkSyncConfigMessages(this); const statusComp = !messages.length ? null : ( {messages[0]} {messages.length >= 1 ? ({messages[1]}) : null} ); settingComps.push(