|
1 | 1 | <script lang="ts"> |
2 | 2 | import { onMount, onDestroy } from 'svelte' |
3 | 3 | import FilePane from './FilePane.svelte' |
| 4 | + import PaneResizer from './PaneResizer.svelte' |
4 | 5 | import LoadingIcon from '../LoadingIcon.svelte' |
5 | 6 | import { |
6 | 7 | loadAppStatus, |
|
52 | 53 | let rightVolumeId = $state(DEFAULT_VOLUME_ID) |
53 | 54 | let volumes = $state<VolumeInfo[]>([]) |
54 | 55 | let initialized = $state(false) |
| 56 | + let leftPaneWidthPercent = $state(50) |
55 | 57 |
|
56 | 58 | // Sorting state - per-pane |
57 | 59 | let leftSortBy = $state<SortColumn>(DEFAULT_SORT_BY) |
|
511 | 513 | showHiddenFiles = settings.showHiddenFiles |
512 | 514 | leftViewMode = status.leftViewMode |
513 | 515 | rightViewMode = status.rightViewMode |
| 516 | + leftPaneWidthPercent = status.leftPaneWidthPercent |
514 | 517 |
|
515 | 518 | // Load sort state |
516 | 519 | leftSortBy = status.leftSortBy |
|
726 | 729 | cleanupNetworkDiscovery() |
727 | 730 | }) |
728 | 731 |
|
| 732 | + function handlePaneResize(widthPercent: number) { |
| 733 | + leftPaneWidthPercent = widthPercent |
| 734 | + } |
| 735 | +
|
| 736 | + function handlePaneResizeEnd() { |
| 737 | + void saveAppStatus({ leftPaneWidthPercent }) |
| 738 | + } |
| 739 | +
|
| 740 | + function handlePaneResizeReset() { |
| 741 | + leftPaneWidthPercent = 50 |
| 742 | + void saveAppStatus({ leftPaneWidthPercent: 50 }) |
| 743 | + } |
| 744 | +
|
729 | 745 | // Focus the container after initialization so keyboard events work |
730 | 746 | $effect(() => { |
731 | 747 | if (initialized) { |
|
950 | 966 | aria-label="File explorer" |
951 | 967 | > |
952 | 968 | {#if initialized} |
953 | | - <FilePane |
954 | | - bind:this={leftPaneRef} |
955 | | - paneId="left" |
956 | | - initialPath={leftPath} |
957 | | - volumeId={leftVolumeId} |
958 | | - volumePath={leftVolumePath} |
959 | | - isFocused={focusedPane === 'left'} |
960 | | - {showHiddenFiles} |
961 | | - viewMode={leftViewMode} |
962 | | - sortBy={leftSortBy} |
963 | | - sortOrder={leftSortOrder} |
964 | | - onPathChange={handleLeftPathChange} |
965 | | - onVolumeChange={handleLeftVolumeChange} |
966 | | - onRequestFocus={handleLeftFocus} |
967 | | - onSortChange={handleLeftSortChange} |
968 | | - onNetworkHostChange={handleLeftNetworkHostChange} |
969 | | - onCancelLoading={handleLeftCancelLoading} |
970 | | - /> |
971 | | - <FilePane |
972 | | - bind:this={rightPaneRef} |
973 | | - paneId="right" |
974 | | - initialPath={rightPath} |
975 | | - volumeId={rightVolumeId} |
976 | | - volumePath={rightVolumePath} |
977 | | - isFocused={focusedPane === 'right'} |
978 | | - {showHiddenFiles} |
979 | | - viewMode={rightViewMode} |
980 | | - sortBy={rightSortBy} |
981 | | - sortOrder={rightSortOrder} |
982 | | - onPathChange={handleRightPathChange} |
983 | | - onVolumeChange={handleRightVolumeChange} |
984 | | - onRequestFocus={handleRightFocus} |
985 | | - onSortChange={handleRightSortChange} |
986 | | - onNetworkHostChange={handleRightNetworkHostChange} |
987 | | - onCancelLoading={handleRightCancelLoading} |
988 | | - /> |
| 969 | + <div class="pane-wrapper" style="width: {leftPaneWidthPercent}%"> |
| 970 | + <FilePane |
| 971 | + bind:this={leftPaneRef} |
| 972 | + paneId="left" |
| 973 | + initialPath={leftPath} |
| 974 | + volumeId={leftVolumeId} |
| 975 | + volumePath={leftVolumePath} |
| 976 | + isFocused={focusedPane === 'left'} |
| 977 | + {showHiddenFiles} |
| 978 | + viewMode={leftViewMode} |
| 979 | + sortBy={leftSortBy} |
| 980 | + sortOrder={leftSortOrder} |
| 981 | + onPathChange={handleLeftPathChange} |
| 982 | + onVolumeChange={handleLeftVolumeChange} |
| 983 | + onRequestFocus={handleLeftFocus} |
| 984 | + onSortChange={handleLeftSortChange} |
| 985 | + onNetworkHostChange={handleLeftNetworkHostChange} |
| 986 | + onCancelLoading={handleLeftCancelLoading} |
| 987 | + /> |
| 988 | + </div> |
| 989 | + <PaneResizer onResize={handlePaneResize} onResizeEnd={handlePaneResizeEnd} onReset={handlePaneResizeReset} /> |
| 990 | + <div class="pane-wrapper" style="width: {100 - leftPaneWidthPercent}%"> |
| 991 | + <FilePane |
| 992 | + bind:this={rightPaneRef} |
| 993 | + paneId="right" |
| 994 | + initialPath={rightPath} |
| 995 | + volumeId={rightVolumeId} |
| 996 | + volumePath={rightVolumePath} |
| 997 | + isFocused={focusedPane === 'right'} |
| 998 | + {showHiddenFiles} |
| 999 | + viewMode={rightViewMode} |
| 1000 | + sortBy={rightSortBy} |
| 1001 | + sortOrder={rightSortOrder} |
| 1002 | + onPathChange={handleRightPathChange} |
| 1003 | + onVolumeChange={handleRightVolumeChange} |
| 1004 | + onRequestFocus={handleRightFocus} |
| 1005 | + onSortChange={handleRightSortChange} |
| 1006 | + onNetworkHostChange={handleRightNetworkHostChange} |
| 1007 | + onCancelLoading={handleRightCancelLoading} |
| 1008 | + /> |
| 1009 | + </div> |
989 | 1010 | {:else} |
990 | 1011 | <LoadingIcon /> |
991 | 1012 | {/if} |
|
999 | 1020 | gap: 0; |
1000 | 1021 | outline: none; |
1001 | 1022 | } |
| 1023 | +
|
| 1024 | + .pane-wrapper { |
| 1025 | + display: flex; |
| 1026 | + flex-direction: column; |
| 1027 | + height: 100%; |
| 1028 | + min-width: 0; |
| 1029 | + } |
1002 | 1030 | </style> |
0 commit comments