2023-02-22 15:13:39 +02:00
|
|
|
import { themeStyle } from '@joplin/lib/theme';
|
2020-11-13 19:09:28 +02:00
|
|
|
import * as React from 'react';
|
2023-03-13 18:26:56 +02:00
|
|
|
import { useMemo, useState } from 'react';
|
2020-11-13 19:09:28 +02:00
|
|
|
import NoteList from '../NoteList/NoteList';
|
|
|
|
import NoteListControls from '../NoteListControls/NoteListControls';
|
|
|
|
import { Size } from '../ResizableLayout/utils/types';
|
|
|
|
import styled from 'styled-components';
|
|
|
|
|
|
|
|
interface Props {
|
|
|
|
resizableLayoutEventEmitter: any;
|
|
|
|
size: Size;
|
|
|
|
visible: boolean;
|
|
|
|
themeId: number;
|
|
|
|
}
|
|
|
|
|
|
|
|
const StyledRoot = styled.div`
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
2020-11-15 21:30:04 +02:00
|
|
|
overflow: hidden;
|
2021-07-06 15:02:22 +02:00
|
|
|
width: 100%;
|
2020-11-13 19:09:28 +02:00
|
|
|
`;
|
|
|
|
|
|
|
|
export default function NoteListWrapper(props: Props) {
|
2023-02-22 15:13:39 +02:00
|
|
|
const theme = themeStyle(props.themeId);
|
2023-03-13 18:26:56 +02:00
|
|
|
const [controlHeight, setControlHeight] = useState(theme.topRowHeight);
|
|
|
|
|
|
|
|
const onContentHeightChange = (sameRow: boolean) => {
|
|
|
|
if (sameRow) {
|
|
|
|
setControlHeight(theme.topRowHeight);
|
|
|
|
} else {
|
|
|
|
setControlHeight(theme.topRowHeight * 2);
|
|
|
|
}
|
|
|
|
};
|
2023-02-22 15:13:39 +02:00
|
|
|
|
2020-11-13 19:09:28 +02:00
|
|
|
const noteListSize = useMemo(() => {
|
|
|
|
return {
|
|
|
|
width: props.size.width,
|
2023-02-22 15:13:39 +02:00
|
|
|
height: props.size.height - controlHeight,
|
2020-11-13 19:09:28 +02:00
|
|
|
};
|
2023-02-22 15:13:39 +02:00
|
|
|
}, [props.size, controlHeight]);
|
2020-11-13 19:09:28 +02:00
|
|
|
|
|
|
|
return (
|
|
|
|
<StyledRoot>
|
2023-03-13 18:26:56 +02:00
|
|
|
<NoteListControls height={controlHeight} width={noteListSize.width} onContentHeightChange={onContentHeightChange}/>
|
2020-11-13 19:09:28 +02:00
|
|
|
<NoteList resizableLayoutEventEmitter={props.resizableLayoutEventEmitter} size={noteListSize} visible={props.visible}/>
|
|
|
|
</StyledRoot>
|
|
|
|
);
|
|
|
|
}
|