Skip to content

TagSpaces is an offline, open source, document manager with tagging support

chore: improving ui on small screens

Ilian Sapundshiev20e9ec49dd66
diff --git a/src/renderer/components/EntryContainer.tsx b/src/renderer/components/EntryContainer.tsx
index b12de5660..073a04cd1 100644
--- a/src/renderer/components/EntryContainer.tsx
+++ b/src/renderer/components/EntryContainer.tsx
@@ -51,7 +51,7 @@ import useEventListener from '-/utils/useEventListener';
import { TS } from '-/tagspaces.namespace';
import FileView from '-/components/FileView';
import { Pro } from '-/pro';
-import { Switch } from '@mui/material';
+import { Switch, useMediaQuery } from '@mui/material';
import { useTheme } from '@mui/material/styles';
import EntryContainerTabs from '-/components/EntryContainerTabs';
import EntryContainerNav from '-/components/EntryContainerNav';
@@ -105,6 +105,8 @@ function EntryContainer() {
tabIndex !== undefined,
);
+ const smallScreen = useMediaQuery(theme.breakpoints.down('md'));
+
const [isFullscreen, setFullscreen] = useState<boolean>(false);
// eslint-disable-next-line no-unused-vars
const [ignored, forceUpdate] = useReducer((x) => x + 1, 0, undefined);
@@ -773,10 +775,12 @@ function EntryContainer() {
startClosingEntry={startClosingEntry}
isEntryInFullWidth={isEntryInFullWidth}
desktopMode={desktopMode}
+ smallScreen={smallScreen}
/>
<EntryContainerNav
isFile={openedEntry.isFile}
startClosingEntry={startClosingEntry}
+ smallScreen={smallScreen}
/>
</Box>
{tabs()}
diff --git a/src/renderer/components/EntryContainerNav.tsx b/src/renderer/components/EntryContainerNav.tsx
index cf082fa29..e3af11043 100644
--- a/src/renderer/components/EntryContainerNav.tsx
+++ b/src/renderer/components/EntryContainerNav.tsx
@@ -15,11 +15,12 @@ import { usePerspectiveActionsContext } from '-/hooks/usePerspectiveActionsConte
interface Props {
isFile: boolean;
+ smallScreen: boolean;
startClosingEntry: (event) => void;
}
function EntryContainerNav(props: Props) {
- const { isFile, startClosingEntry } = props;
+ const { isFile, startClosingEntry, smallScreen } = props;
const { setActions } = usePerspectiveActionsContext();
const keyBindings = useSelector(getKeyBindingObject);
const { t } = useTranslation();
@@ -53,7 +54,6 @@ function EntryContainerNav(props: Props) {
>
<PrevDocumentIcon />
</TsIconButton>
-
<TsIconButton
tooltip={t('core:openNextFileTooltip')}
keyBinding={keyBindings['nextDocument']}
@@ -68,15 +68,17 @@ function EntryContainerNav(props: Props) {
</TsIconButton>
</>
)}
- <TsIconButton
- tooltip={t('core:closeEntry')}
- keyBinding={keyBindings['closeViewer']}
- onClick={startClosingEntry}
- aria-label={t('core:closeEntry')}
- data-tid="fileContainerCloseOpenedFile"
- >
- <CloseIcon />
- </TsIconButton>
+ {!smallScreen && (
+ <TsIconButton
+ tooltip={t('core:closeEntry')}
+ keyBinding={keyBindings['closeViewer']}
+ onClick={startClosingEntry}
+ aria-label={t('core:closeEntry')}
+ data-tid="fileContainerCloseOpenedFile"
+ >
+ <CloseIcon />
+ </TsIconButton>
+ )}
</div>
);
}
diff --git a/src/renderer/components/EntryContainerTitle.tsx b/src/renderer/components/EntryContainerTitle.tsx
index 9575bc170..99beb8948 100644
--- a/src/renderer/components/EntryContainerTitle.tsx
+++ b/src/renderer/components/EntryContainerTitle.tsx
@@ -26,7 +26,11 @@ import {
extractDirectoryName,
} from '@tagspaces/tagspaces-common/paths';
import Tooltip from '-/components/Tooltip';
-import { FolderIcon, MoreMenuIcon } from '-/components/CommonIcons';
+import {
+ FolderIcon,
+ MoreMenuIcon,
+ ArrowBackIcon,
+} from '-/components/CommonIcons';
import AppConfig from '-/AppConfig';
import EntryContainerMenu from '-/components/EntryContainerMenu';
import Box from '@mui/material/Box';
@@ -62,6 +66,7 @@ interface Props {
startClosingEntry: (event) => void;
isEntryInFullWidth: boolean;
desktopMode: boolean;
+ smallScreen: boolean;
}
function EntryContainerTitle(props: Props) {
@@ -71,6 +76,7 @@ function EntryContainerTitle(props: Props) {
startClosingEntry,
isEntryInFullWidth,
desktopMode,
+ smallScreen,
} = props;
const { t } = useTranslation();
const theme = useTheme();
@@ -152,6 +158,24 @@ function EntryContainerTitle(props: Props) {
WebkitAppRegion: 'drag',
}}
>
+ {smallScreen && (
+ <TsIconButton
+ title={t('closeButtonDialog')}
+ aria-label="close"
+ tabIndex={-1}
+ style={{
+ // @ts-ignore
+ WebkitAppRegion: 'no-drag',
+ // marginTop: 5,
+ // marginLeft: 5,
+ //float: 'left',
+ }}
+ data-tid="fileContainerCloseOpenedFile"
+ onClick={startClosingEntry}
+ >
+ <ArrowBackIcon />
+ </TsIconButton>
+ )}
{openedEntry.isFile ? (
<>
{fileChanged ? (
diff --git a/src/renderer/components/dialogs/CreateEditLocationDialog.tsx b/src/renderer/components/dialogs/CreateEditLocationDialog.tsx
index 7cd84d398..2d77b5b62 100644
--- a/src/renderer/components/dialogs/CreateEditLocationDialog.tsx
+++ b/src/renderer/components/dialogs/CreateEditLocationDialog.tsx
@@ -558,7 +558,7 @@ function CreateEditLocationDialog(props: Props) {
const disableLocationTypeSwitch: boolean = selectedLocation !== undefined;
const theme = useTheme();
- const fullScreen = useMediaQuery(theme.breakpoints.down('md'));
+ const smallScreen = useMediaQuery(theme.breakpoints.down('md'));
let locationTypeName = t('core:localLocation');
if (defaultType === locationType.TYPE_CLOUD) {
@@ -570,7 +570,7 @@ function CreateEditLocationDialog(props: Props) {
disabled={disableConfirmButton()}
onClick={preConfirm}
data-tid="confirmLocationCreation"
- variant={fullScreen ? 'outlined' : 'contained'}
+ variant={smallScreen ? 'outlined' : 'contained'}
>
{t('core:ok')}
</TsButton>
@@ -580,10 +580,10 @@ function CreateEditLocationDialog(props: Props) {
<Dialog
open={open}
onClose={onClose}
- fullScreen={fullScreen}
+ fullScreen={smallScreen}
keepMounted
scroll="paper"
- PaperComponent={fullScreen ? Paper : DraggablePaper}
+ PaperComponent={smallScreen ? Paper : DraggablePaper}
aria-labelledby="draggable-dialog-title"
onKeyDown={(event) => {
if (event.key === 'Enter' || event.keyCode === 13) {
@@ -597,24 +597,15 @@ function CreateEditLocationDialog(props: Props) {
}}
>
<TsDialogTitle
- dialogTitle={t('core:editLocationTitle')}
+ dialogTitle={
+ selectedLocation
+ ? t('core:editLocationTitle')
+ : t('core:createLocationTitle')
+ }
closeButtonTestId="closeCreateEditLocationTID"
onClose={onClose}
actionSlot={okButton}
- >
- {selectedLocation ? (
- <>
- <Typography
- style={{ display: 'block', marginTop: -5 }}
- variant="overline"
- >
- {t('core:locationType') + ': ' + locationTypeName}
- </Typography>
- </>
- ) : (
- t('core:createLocationTitle')
- )}
- </TsDialogTitle>
+ ></TsDialogTitle>
<DialogContent
style={{
overflow: 'auto',
@@ -640,6 +631,16 @@ function CreateEditLocationDialog(props: Props) {
confirmDialogTID="confirmConfirmEncryptionChanged"
confirmDialogContentTID="confirmConfirmEncryptionChangedContent"
/>
+ {selectedLocation && (
+ <>
+ <Typography
+ style={{ display: 'block', marginTop: -5, marginLeft: 15 }}
+ variant="overline"
+ >
+ {t('core:locationType') + ': ' + locationTypeName}
+ </Typography>
+ </>
+ )}
<Accordion defaultExpanded>
<AccordionDetails style={{ paddingTop: 16 }}>
<FormGroup>
@@ -1163,7 +1164,7 @@ function CreateEditLocationDialog(props: Props) {
</Accordion>
)}
</DialogContent>
- {!fullScreen && (
+ {!smallScreen && (
<TsDialogActions>
<TsButton onClick={() => onClose()}>{t('core:cancel')}</TsButton>
{okButton}
diff --git a/src/renderer/components/dialogs/NewFileDialog.tsx b/src/renderer/components/dialogs/NewFileDialog.tsx
index b56834c74..fbf25451d 100644
--- a/src/renderer/components/dialogs/NewFileDialog.tsx
+++ b/src/renderer/components/dialogs/NewFileDialog.tsx
@@ -22,7 +22,7 @@ import {
formatDateTime4Tag,
} from '@tagspaces/tagspaces-common/misc';
import DialogContent from '@mui/material/DialogContent';
-import DialogTitle from '@mui/material/DialogTitle';
+import TsDialogTitle from '-/components/dialogs/components/TsDialogTitle';
import Dialog from '@mui/material/Dialog';
import Paper from '@mui/material/Paper';
import DraggablePaper from '-/components/DraggablePaper';
@@ -57,12 +57,12 @@ function NewFileDialog(props: Props) {
useCurrentLocationContext();
const { currentDirectoryPath } = useDirectoryContentContext();
const { targetDirectoryPath } = useTargetPathContext();
-
+ const haveError = useRef<boolean>(false);
const firstRWLocation = getFirstRWLocation();
const [ignored, forceUpdate] = useReducer((x) => x + 1, 0, undefined);
const theme = useTheme();
- const fullScreen = useMediaQuery(theme.breakpoints.down('md'));
+ const smallScreen = useMediaQuery(theme.breakpoints.down('md'));
const fileName = useRef<string>(
(fileType === 'url' ? 'link' : 'note') +
AppConfig.beginTagContainer +
@@ -70,7 +70,6 @@ function NewFileDialog(props: Props) {
AppConfig.endTagContainer,
);
- const haveError = useRef<boolean>(false);
const fileContent = useRef<string>(
fileType === 'txt' || fileType === 'md'
? 'Created in ' +
@@ -119,20 +118,35 @@ function NewFileDialog(props: Props) {
}
}
+ const okButton = (
+ <TsButton
+ data-tid="createTID"
+ variant={smallScreen ? 'outlined' : 'contained'}
+ onClick={() => {
+ createFile(fileType, targetDirectoryPath);
+ }}
+ disabled={haveError.current}
+ >
+ {t('core:ok')}
+ </TsButton>
+ );
+
return (
<Dialog
open={open}
onClose={onClose}
- fullScreen={fullScreen}
+ fullScreen={smallScreen}
keepMounted
aria-labelledby="draggable-dialog-title"
- PaperComponent={fullScreen ? Paper : DraggablePaper}
+ PaperComponent={smallScreen ? Paper : DraggablePaper}
scroll="paper"
>
- <DialogTitle style={{ cursor: 'move' }} id="draggable-dialog-title">
- {getFileType()}
- <DialogCloseButton testId="closeCreateDialogTID" onClose={onClose} />
- </DialogTitle>
+ <TsDialogTitle
+ dialogTitle={getFileType()}
+ onClose={onClose}
+ closeButtonTestId="closeCreateDialogTID"
+ actionSlot={okButton}
+ ></TsDialogTitle>
<DialogContent
style={{
paddingTop: 10,
@@ -172,7 +186,7 @@ function NewFileDialog(props: Props) {
)}
<TargetPath />
</DialogContent>
- {fileType && (
+ {!smallScreen && fileType && (
<TsDialogActions>
<TsButton
data-tid="backTID"
@@ -182,16 +196,7 @@ function NewFileDialog(props: Props) {
>
{t('core:cancel')}
</TsButton>
- <TsButton
- data-tid="createTID"
- variant="contained"
- onClick={() => {
- createFile(fileType, targetDirectoryPath);
- }}
- disabled={haveError.current}
- >
- {t('core:ok')}
- </TsButton>
+ {okButton}
</TsDialogActions>
)}
</Dialog>
diff --git a/src/renderer/components/dialogs/components/TsDialogActions.tsx b/src/renderer/components/dialogs/components/TsDialogActions.tsx
index 1a7c74707..93750779c 100644
--- a/src/renderer/components/dialogs/components/TsDialogActions.tsx
+++ b/src/renderer/components/dialogs/components/TsDialogActions.tsx
@@ -30,13 +30,13 @@ function TSDialogActions(props: TSDialogActions) {
const { children, style } = props;
const desktopMode = useSelector(isDesktopMode);
const theme = useTheme();
- const fullScreen = useMediaQuery(theme.breakpoints.down('md'));
+ const smallScreen = useMediaQuery(theme.breakpoints.down('md'));
return (
<DialogActions
{...props}
style={{
- padding: fullScreen ? '10px 30px 30px 30px' : 'inherited',
+ padding: smallScreen ? '10px 30px 30px 30px' : 'inherited',
...style,
}}
>
diff --git a/src/renderer/components/dialogs/components/TsDialogTitle.tsx b/src/renderer/components/dialogs/components/TsDialogTitle.tsx
index abf637645..5a6ce2c92 100644
--- a/src/renderer/components/dialogs/components/TsDialogTitle.tsx
+++ b/src/renderer/components/dialogs/components/TsDialogTitle.tsx
@@ -47,7 +47,7 @@ function TsDialogTitle(props: TSDialogTitle) {
const { t } = useTranslation();
const desktopMode = useSelector(isDesktopMode);
const theme = useTheme();
- const fullScreen = useMediaQuery(theme.breakpoints.down('md'));
+ const smallScreen = useMediaQuery(theme.breakpoints.down('md'));
const closeButton = (
<DialogCloseButton testId={closeButtonTestId} onClose={onClose} />
);
@@ -68,20 +68,24 @@ function TsDialogTitle(props: TSDialogTitle) {
return (
<DialogTitle
- id="draggable-dialog-title"
+ id={smallScreen ? '' : 'draggable-dialog-title'}
{...props}
style={{
- cursor: 'move',
+ cursor: smallScreen ? 'unset' : 'move',
...style,
}}
>
- {fullScreen ? (
- <div style={{ textAlign: 'center' }}>
- {backButton}
- {title}
- {actionSlot && <span style={{ float: 'right' }}>{actionSlot}</span>}
- {children}
- </div>
+ {smallScreen ? (
+ <>
+ <div style={{ display: 'flex' }}>
+ {backButton}
+ <span style={{ alignSelf: 'center', margin: '0 auto' }}>
+ {title}
+ </span>
+ {actionSlot && <span style={{ float: 'right' }}>{actionSlot}</span>}
+ </div>
+ <div style={{ textAlign: 'center' }}>{children}</div>
+ </>
) : (
<>
{title}