Skip to content

Commit

Permalink
feat: support cache SplitPane Position of Panel and reset SplitPane p… (
Browse files Browse the repository at this point in the history
  • Loading branch information
mumiao authored May 31, 2021
1 parent ad5319f commit e23a6b0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/controller/workbench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@ import { singleton } from 'tsyringe';

export interface IWorkbenchController {
readonly splitPanePos: string[];
readonly horizontalSplitPanePos: string[];
onPaneSizeChange?: (newSize: number) => void;
onHorizontalPaneSizeChange?: (newSize: number) => void;
}

@singleton()
export class WorkbenchController
extends Controller
implements IWorkbenchController {
// Group Pos locate here temporary, we can move it to state or localStorage in future.
public splitPanePos: string[] = ['300px', 'auto'];
public horizontalSplitPanePos: string[] = ['70%', 'auto'];

constructor() {
super();
Expand All @@ -20,4 +22,7 @@ export class WorkbenchController
public onPaneSizeChange = (newSize) => {
this.splitPanePos = newSize;
};

public onHorizontalPaneSizeChange = (newSize) =>
(this.horizontalSplitPanePos = newSize);
}
10 changes: 8 additions & 2 deletions src/workbench/workbench.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,10 @@ export function WorkbenchView(props: IWorkbench & IWorkbenchController) {
sideBar,
statusBar,
onPaneSizeChange,
onHorizontalPaneSizeChange,
splitPanePos,
horizontalSplitPanePos,
} = props;

return (
<div id={ID_APP} className={appClassName} tabIndex={0}>
<div className={workbenchClassName}>
Expand All @@ -85,10 +86,15 @@ export function WorkbenchView(props: IWorkbench & IWorkbenchController) {
primary="first"
split="horizontal"
allowResize={true}
onChange={onHorizontalPaneSizeChange}
>
{!panel.maximize ? (
<Pane
initialSize="70%"
initialSize={
panel.hidden
? '100%'
: horizontalSplitPanePos[0]
}
maxSize="99%"
minSize="10%"
>
Expand Down

0 comments on commit e23a6b0

Please sign in to comment.