mirror of
https://github.com/laurent22/joplin.git
synced 2025-01-29 19:13:59 +02:00
Mobile: Hide advanced settings by default (#9730)
This commit is contained in:
parent
33ed7545a9
commit
691618b50c
@ -1,6 +1,6 @@
|
||||
import * as React from 'react';
|
||||
import { Platform, Linking, View, Switch, ScrollView, Text, TouchableOpacity, Alert, PermissionsAndroid, Dimensions, AccessibilityInfo } from 'react-native';
|
||||
import Setting, { AppType, SettingMetadataSection } from '@joplin/lib/models/Setting';
|
||||
import Setting, { AppType, SettingItem, SettingMetadataSection } from '@joplin/lib/models/Setting';
|
||||
import NavService from '@joplin/lib/services/NavService';
|
||||
import SearchEngine from '@joplin/lib/services/search/SearchEngine';
|
||||
import checkPermissions from '../../../utils/checkPermissions';
|
||||
@ -28,7 +28,7 @@ import ExportProfileButton, { exportProfileButtonTitle } from './NoteExportSecti
|
||||
import SettingComponent from './SettingComponent';
|
||||
import ExportDebugReportButton, { exportDebugReportTitle } from './NoteExportSection/ExportDebugReportButton';
|
||||
import SectionSelector from './SectionSelector';
|
||||
import { TextInput } from 'react-native-paper';
|
||||
import { Button, TextInput } from 'react-native-paper';
|
||||
|
||||
interface ConfigScreenState {
|
||||
settings: any;
|
||||
@ -330,6 +330,7 @@ class ConfigScreenComponent extends BaseScreenComponent<ConfigScreenProps, Confi
|
||||
|
||||
public sectionToComponent(key: string, section: SettingMetadataSection, settings: any, isSelected: boolean) {
|
||||
const settingComps: ReactElement[] = [];
|
||||
const advancedSettingComps: ReactElement[] = [];
|
||||
|
||||
const headerTitle = Setting.sectionNameToLabel(section.name);
|
||||
|
||||
@ -352,10 +353,18 @@ class ConfigScreenComponent extends BaseScreenComponent<ConfigScreenProps, Confi
|
||||
return this.state.searchQuery.length > 0 && hasSearchMatches;
|
||||
};
|
||||
|
||||
const addSettingComponent = (component: ReactElement, relatedText: string|string[]) => {
|
||||
const addSettingComponent = (
|
||||
component: ReactElement,
|
||||
relatedText: string|string[],
|
||||
settingMetadata?: SettingItem,
|
||||
) => {
|
||||
const hiddenBySearch = this.state.searching && !matchesSearchQuery(relatedText);
|
||||
if (component && !hiddenBySearch) {
|
||||
settingComps.push(component);
|
||||
if (settingMetadata?.advanced) {
|
||||
advancedSettingComps.push(component);
|
||||
} else {
|
||||
settingComps.push(component);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -424,6 +433,7 @@ class ConfigScreenComponent extends BaseScreenComponent<ConfigScreenProps, Confi
|
||||
addSettingComponent(
|
||||
settingComp,
|
||||
relatedText,
|
||||
md,
|
||||
);
|
||||
}
|
||||
|
||||
@ -531,7 +541,7 @@ class ConfigScreenComponent extends BaseScreenComponent<ConfigScreenProps, Confi
|
||||
}
|
||||
}
|
||||
|
||||
if (!settingComps.length) return null;
|
||||
if (!settingComps.length && !advancedSettingComps.length) return null;
|
||||
if (!isSelected && !this.state.searching) return null;
|
||||
|
||||
const headerComponent = (
|
||||
@ -545,11 +555,31 @@ class ConfigScreenComponent extends BaseScreenComponent<ConfigScreenProps, Confi
|
||||
</TouchableOpacity>
|
||||
);
|
||||
|
||||
const renderAdvancedSettings = () => {
|
||||
if (!advancedSettingComps.length) return null;
|
||||
|
||||
const toggleAdvancedLabel = this.state.showAdvancedSettings ? _('Hide Advanced Settings') : _('Show Advanced Settings');
|
||||
return (
|
||||
<>
|
||||
<Button
|
||||
style={{ marginBottom: 20 }}
|
||||
icon={this.state.showAdvancedSettings ? 'menu-down' : 'menu-right'}
|
||||
onPress={() => this.setState({ showAdvancedSettings: !this.state.showAdvancedSettings })}
|
||||
>
|
||||
<Text>{toggleAdvancedLabel}</Text>
|
||||
</Button>
|
||||
|
||||
{this.state.showAdvancedSettings ? advancedSettingComps : null}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<View key={key} onLayout={(event: any) => this.onSectionLayout(key, event)}>
|
||||
<View>
|
||||
{this.state.searching ? headerComponent : null}
|
||||
{settingComps}
|
||||
{renderAdvancedSettings()}
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user