Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mobile: Settings screen: Create separate pages for each screen #8567

Merged
merged 33 commits into from Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
2e11d5b
Mobile: Refactor config screen into multiple files
personalizedrefrigerator Jul 27, 2023
33ed2b8
Fix base-screen.js imports
personalizedrefrigerator Jul 27, 2023
09fc493
Mobile: Use section structure also for custom sections
personalizedrefrigerator Jul 27, 2023
6f43437
Fix filesystem sync path selector
personalizedrefrigerator Jul 27, 2023
689a3de
Group settings by section
personalizedrefrigerator Jul 27, 2023
a2f074b
Show section headings to the left of settings in tablet mode
personalizedrefrigerator Jul 27, 2023
830a974
Restyle section headings
personalizedrefrigerator Jul 27, 2023
c92d2a4
Merge remote-tracking branch 'upstream/dev' into pr/settings-rework
personalizedrefrigerator Jul 28, 2023
954db22
Fix sidebar scroll not scrolling to currently selected item
personalizedrefrigerator Jul 28, 2023
9684c38
Merge remote-tracking branch 'upstream/dev' into pr/settings-rework
personalizedrefrigerator Aug 16, 2023
252c5c0
Fix build
personalizedrefrigerator Aug 16, 2023
b510084
Icon for each section
personalizedrefrigerator Aug 17, 2023
3743c3e
Sidebar: Fix scroll
personalizedrefrigerator Aug 17, 2023
9247076
Sidebar: Use selection color for selected buttons
personalizedrefrigerator Aug 17, 2023
89643f5
Default to the general section
personalizedrefrigerator Aug 19, 2023
f026cb8
Merge remote-tracking branch 'upstream/dev' into pr/settings-rework
personalizedrefrigerator Sep 2, 2023
460496a
Merge remote-tracking branch 'upstream/dev' into pr/settings-rework
personalizedrefrigerator Oct 23, 2023
7ff9a8f
Add subheadings, fix width of section selector
personalizedrefrigerator Oct 23, 2023
5bc2ef8
Show general tab by default when in tablet mode
personalizedrefrigerator Oct 23, 2023
7efa3c9
Revert several unnecessary changes
personalizedrefrigerator Oct 23, 2023
ea8d65c
Re-enable throw on unsupported setting type
personalizedrefrigerator Oct 23, 2023
cb9c894
markdown toolbar -> editor toolbar
personalizedrefrigerator Oct 24, 2023
a835503
Update Joplin cloud description
personalizedrefrigerator Oct 24, 2023
be2d388
Enable/disable -> Toggle
personalizedrefrigerator Oct 24, 2023
40a0a63
Export all notes -> Export your data
personalizedrefrigerator Oct 24, 2023
ed14c42
Remove "Markdown plugins: " prefix
personalizedrefrigerator Oct 24, 2023
3dbe2fc
Style adjustments
personalizedrefrigerator Oct 24, 2023
7b4dab8
Update icons
personalizedrefrigerator Oct 24, 2023
68552c1
Re-word markdownPlugins setting description
personalizedrefrigerator Oct 24, 2023
4733969
Slight increase in tab height
personalizedrefrigerator Oct 25, 2023
adee7c6
Partial accessibility fixes
personalizedrefrigerator Oct 25, 2023
26c30b0
Announce section label instead of ID
personalizedrefrigerator Oct 26, 2023
7405cce
Merge remote-tracking branch 'upstream/dev' into pr/settings-rework
personalizedrefrigerator Oct 26, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 16 additions & 2 deletions .eslintignore
Expand Up @@ -423,6 +423,7 @@ packages/app-mobile/components/Dropdown.test.js
packages/app-mobile/components/Dropdown.js
packages/app-mobile/components/ExtendedWebView.js
packages/app-mobile/components/FolderPicker.js
packages/app-mobile/components/Icon.js
packages/app-mobile/components/Modal.js
packages/app-mobile/components/NoteBodyViewer/NoteBodyViewer.js
packages/app-mobile/components/NoteBodyViewer/hooks/useEditPopup.test.js
Expand Down Expand Up @@ -463,17 +464,29 @@ packages/app-mobile/components/SelectDateTimeDialog.js
packages/app-mobile/components/SideMenu.js
packages/app-mobile/components/TextInput.js
packages/app-mobile/components/app-nav.js
packages/app-mobile/components/base-screen.js
packages/app-mobile/components/biometrics/BiometricPopup.js
packages/app-mobile/components/biometrics/biometricAuthenticate.js
packages/app-mobile/components/biometrics/sensorInfo.js
packages/app-mobile/components/getResponsiveValue.test.js
packages/app-mobile/components/getResponsiveValue.js
packages/app-mobile/components/screens/ConfigScreen/ConfigScreen.js
packages/app-mobile/components/screens/ConfigScreen/ConfigScreenButton.js
packages/app-mobile/components/screens/ConfigScreen/FileSystemPathSelector.js
packages/app-mobile/components/screens/ConfigScreen/NoteExportSection/ExportDebugReportButton.js
packages/app-mobile/components/screens/ConfigScreen/NoteExportSection/ExportProfileButton.js
packages/app-mobile/components/screens/ConfigScreen/NoteExportSection/NoteExportButton.test.js
packages/app-mobile/components/screens/ConfigScreen/NoteExportSection/NoteExportButton.js
packages/app-mobile/components/screens/ConfigScreen/NoteExportSection/exportAllFolders.js
packages/app-mobile/components/screens/ConfigScreen/NoteExportSection/utils/exportAllFolders.js
packages/app-mobile/components/screens/ConfigScreen/NoteExportSection/utils/exportDebugReport.js
packages/app-mobile/components/screens/ConfigScreen/NoteExportSection/utils/exportProfile.js
packages/app-mobile/components/screens/ConfigScreen/SectionHeader.js
packages/app-mobile/components/screens/ConfigScreen/SectionSelector.js
packages/app-mobile/components/screens/ConfigScreen/SettingComponent.js
packages/app-mobile/components/screens/ConfigScreen/SettingItem.js
packages/app-mobile/components/screens/ConfigScreen/SettingsButton.js
packages/app-mobile/components/screens/ConfigScreen/SettingsToggle.js
packages/app-mobile/components/screens/ConfigScreen/configScreenStyles.js
packages/app-mobile/components/screens/ConfigScreen/types.js
packages/app-mobile/components/screens/LogScreen.js
packages/app-mobile/components/screens/Note.js
packages/app-mobile/components/screens/Notes.js
Expand Down Expand Up @@ -596,6 +609,7 @@ packages/lib/commands/index.js
packages/lib/commands/openMasterPasswordDialog.js
packages/lib/commands/synchronize.js
packages/lib/components/EncryptionConfigScreen/utils.js
packages/lib/components/shared/config/config-shared.js
packages/lib/components/shared/config/shouldShowMissingPasswordWarning.test.js
packages/lib/components/shared/config/shouldShowMissingPasswordWarning.js
packages/lib/components/shared/note-screen-shared.js
Expand Down
18 changes: 16 additions & 2 deletions .gitignore
Expand Up @@ -405,6 +405,7 @@ packages/app-mobile/components/Dropdown.test.js
packages/app-mobile/components/Dropdown.js
packages/app-mobile/components/ExtendedWebView.js
packages/app-mobile/components/FolderPicker.js
packages/app-mobile/components/Icon.js
packages/app-mobile/components/Modal.js
packages/app-mobile/components/NoteBodyViewer/NoteBodyViewer.js
packages/app-mobile/components/NoteBodyViewer/hooks/useEditPopup.test.js
Expand Down Expand Up @@ -445,17 +446,29 @@ packages/app-mobile/components/SelectDateTimeDialog.js
packages/app-mobile/components/SideMenu.js
packages/app-mobile/components/TextInput.js
packages/app-mobile/components/app-nav.js
packages/app-mobile/components/base-screen.js
packages/app-mobile/components/biometrics/BiometricPopup.js
packages/app-mobile/components/biometrics/biometricAuthenticate.js
packages/app-mobile/components/biometrics/sensorInfo.js
packages/app-mobile/components/getResponsiveValue.test.js
packages/app-mobile/components/getResponsiveValue.js
packages/app-mobile/components/screens/ConfigScreen/ConfigScreen.js
packages/app-mobile/components/screens/ConfigScreen/ConfigScreenButton.js
packages/app-mobile/components/screens/ConfigScreen/FileSystemPathSelector.js
packages/app-mobile/components/screens/ConfigScreen/NoteExportSection/ExportDebugReportButton.js
packages/app-mobile/components/screens/ConfigScreen/NoteExportSection/ExportProfileButton.js
packages/app-mobile/components/screens/ConfigScreen/NoteExportSection/NoteExportButton.test.js
packages/app-mobile/components/screens/ConfigScreen/NoteExportSection/NoteExportButton.js
packages/app-mobile/components/screens/ConfigScreen/NoteExportSection/exportAllFolders.js
packages/app-mobile/components/screens/ConfigScreen/NoteExportSection/utils/exportAllFolders.js
packages/app-mobile/components/screens/ConfigScreen/NoteExportSection/utils/exportDebugReport.js
packages/app-mobile/components/screens/ConfigScreen/NoteExportSection/utils/exportProfile.js
packages/app-mobile/components/screens/ConfigScreen/SectionHeader.js
packages/app-mobile/components/screens/ConfigScreen/SectionSelector.js
packages/app-mobile/components/screens/ConfigScreen/SettingComponent.js
packages/app-mobile/components/screens/ConfigScreen/SettingItem.js
packages/app-mobile/components/screens/ConfigScreen/SettingsButton.js
packages/app-mobile/components/screens/ConfigScreen/SettingsToggle.js
packages/app-mobile/components/screens/ConfigScreen/configScreenStyles.js
packages/app-mobile/components/screens/ConfigScreen/types.js
packages/app-mobile/components/screens/LogScreen.js
packages/app-mobile/components/screens/Note.js
packages/app-mobile/components/screens/Notes.js
Expand Down Expand Up @@ -578,6 +591,7 @@ packages/lib/commands/index.js
packages/lib/commands/openMasterPasswordDialog.js
packages/lib/commands/synchronize.js
packages/lib/components/EncryptionConfigScreen/utils.js
packages/lib/components/shared/config/config-shared.js
packages/lib/components/shared/config/shouldShowMissingPasswordWarning.test.js
packages/lib/components/shared/config/shouldShowMissingPasswordWarning.js
packages/lib/components/shared/note-screen-shared.js
Expand Down
11 changes: 6 additions & 5 deletions packages/app-desktop/gui/ConfigScreen/ConfigScreen.tsx
Expand Up @@ -12,7 +12,7 @@ const { connect } = require('react-redux');
const { themeStyle } = require('@joplin/lib/theme');
const pathUtils = require('@joplin/lib/path-utils');
import SyncTargetRegistry from '@joplin/lib/SyncTargetRegistry';
const shared = require('@joplin/lib/components/shared/config/config-shared.js');
import * as shared from '@joplin/lib/components/shared/config/config-shared.js';
import ClipperConfigScreen from '../ClipperConfigScreen';
import restart from '../../services/restart';
import PluginService from '@joplin/lib/services/plugins/PluginService';
Expand All @@ -35,9 +35,10 @@ class ConfigScreenComponent extends React.Component<any, any> {
public constructor(props: any) {
super(props);

shared.init(this, reg);
shared.init(reg);

this.state = {
...shared.defaultScreenState,
selectedSectionName: 'general',
screenName: '',
changedSettingKeys: [],
Expand Down Expand Up @@ -98,7 +99,7 @@ class ConfigScreenComponent extends React.Component<any, any> {
}

public sectionByName(name: string) {
const sections = shared.settingsSections({ device: 'desktop', settings: this.state.settings });
const sections = shared.settingsSections({ device: AppType.Desktop, settings: this.state.settings });
for (const section of sections) {
if (section.name === name) return section;
}
Expand Down Expand Up @@ -699,7 +700,7 @@ class ConfigScreenComponent extends React.Component<any, any> {

const hasChanges = this.hasChanges();

const settingComps = shared.settingsToComponents2(this, 'desktop', settings, this.state.selectedSectionName);
const settingComps = shared.settingsToComponents2(this, AppType.Desktop, settings, this.state.selectedSectionName);

// screenComp is a custom config screen, such as the encryption config screen or keymap config screen.
// These screens handle their own loading/saving of settings and have bespoke rendering.
Expand All @@ -708,7 +709,7 @@ class ConfigScreenComponent extends React.Component<any, any> {

if (screenComp) containerStyle.display = 'none';

const sections = shared.settingsSections({ device: 'desktop', settings });
const sections = shared.settingsSections({ device: AppType.Desktop, settings });

const needRestartComp: any = this.state.needRestart ? (
<div style={{ ...theme.textStyle, padding: 10, paddingLeft: 24, backgroundColor: theme.warningBackgroundColor, color: theme.color }}>
Expand Down
6 changes: 4 additions & 2 deletions packages/app-desktop/gui/ConfigScreen/Sidebar.tsx
@@ -1,4 +1,4 @@
import { SettingSectionSource } from '@joplin/lib/models/Setting';
import { AppType, SettingSectionSource } from '@joplin/lib/models/Setting';
import * as React from 'react';
import { useMemo } from 'react';
import Setting from '@joplin/lib/models/Setting';
Expand Down Expand Up @@ -93,7 +93,9 @@ export default function Sidebar(props: Props) {
const selected = props.selection === section.name;
return (
<StyledListItem key={section.name} isSubSection={Setting.isSubSection(section.name)} selected={selected} onClick={() => { props.onSelectionChange({ section: section }); }}>
<StyledListItemIcon className={Setting.sectionNameToIcon(section.name)} />
<StyledListItemIcon
className={Setting.sectionNameToIcon(section.name, AppType.Desktop)}
/>
<StyledListItemLabel>
{Setting.sectionNameToLabel(section.name)}
</StyledListItemLabel>
Expand Down
44 changes: 44 additions & 0 deletions packages/app-mobile/components/Icon.tsx
@@ -0,0 +1,44 @@

import * as React from 'react';
import { TextStyle } from 'react-native';
const FontAwesomeIcon = require('react-native-vector-icons/FontAwesome5').default;

interface Props {
name: string;
style: TextStyle;

// If `null` is given, the content must be labeled elsewhere.
accessibilityLabel: string|null;
}

const Icon: React.FC<Props> = props => {
// Matches:
// 1. A prefix of word characters (\w+)
// 2. A suffix of non-spaces (\S+)
// An "fa-" at the beginning of the suffix is ignored.
const nameMatch = props.name.match(/^(\w+)\s+(?:fa-)?(\S+)$/);

const namePrefix = nameMatch ? nameMatch[1] : '';
const nameSuffix = nameMatch ? nameMatch[2] : props.name;

// If there's no label, make sure that the screen reader doesn't try
// to read the characters from the icon font (they don't make sense
// without the icon font applied).
const accessibilityHidden = props.accessibilityLabel === null;

return (
<FontAwesomeIcon
brand={namePrefix.startsWith('fab')}
solid={namePrefix.startsWith('fas')}
accessibilityLabel={props.accessibilityLabel}
aria-hidden={accessibilityHidden}
importantForAccessibility={
accessibilityHidden ? 'no-hide-descendants' : 'yes'
}
name={nameSuffix}
style={props.style}
/>
);
};

export default Icon;
@@ -1,12 +1,12 @@
const React = require('react');
const { StyleSheet } = require('react-native');
import * as React from 'react';
import { StyleSheet } from 'react-native';
const { themeStyle } = require('./global-style.js');

const rootStyles_ = {};
const rootStyles_: Record<number, any> = {};

class BaseScreenComponent extends React.Component {
class BaseScreenComponent<Props, State> extends React.Component<Props, State> {

rootStyle(themeId) {
protected rootStyle(themeId: number) {
const theme = themeStyle(themeId);
if (rootStyles_[themeId]) return rootStyles_[themeId];
rootStyles_[themeId] = StyleSheet.create({
Expand All @@ -19,4 +19,5 @@ class BaseScreenComponent extends React.Component {
}
}

module.exports = { BaseScreenComponent };
export { BaseScreenComponent };
export default BaseScreenComponent;