Skip to content

Commit

Permalink
enhance: allow window preview hover container to overflow and form a …
Browse files Browse the repository at this point in the history
…grid
  • Loading branch information
hasansultan92 committed Sep 9, 2024
1 parent 539ef09 commit 8af3b5d
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions DockDoor/Views/Hover Window/WindowPreviewHoverContainer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,21 @@ struct WindowPreviewHoverContainer: View {
return CGPoint(x: maxWidth, y: maxHeight)
}

var gridLayout: [GridItem] {
let availableWidth = bestGuessMonitor.visibleFrame.width - 30
let columnWidth = maxWindowDimension.x
var numberOfColumns = 0
let maxNumberOfColumns = Int(availableWidth / columnWidth)
if windows.count < maxNumberOfColumns {
numberOfColumns = windows.count
} else {
numberOfColumns = maxNumberOfColumns
}
return Array(repeating: GridItem(.flexible(), spacing: 16), count: numberOfColumns)
}

var body: some View {
let orientationIsHorizontal = dockPosition == .bottom || windowSwitcherCoordinator.windowSwitcherActive
let isVerticalScroll = dockPosition == .bottom || windowSwitcherCoordinator.windowSwitcherActive

ZStack {
if let mouseLocation {
Expand All @@ -54,8 +67,8 @@ struct WindowPreviewHoverContainer: View {
}

ScrollViewReader { scrollProxy in
ScrollView(orientationIsHorizontal ? .horizontal : .vertical, showsIndicators: false) {
DynStack(direction: orientationIsHorizontal ? .horizontal : .vertical, spacing: 16) {
ScrollView(isVerticalScroll ? .horizontal : .vertical, showsIndicators: false) {
LazyVGrid(columns: gridLayout, spacing: 16) {
ForEach(windows.indices, id: \.self) { index in
WindowPreview(windowInfo: windows[index], onTap: onWindowTap, index: index,
dockPosition: dockPosition, maxWindowDimension: maxWindowDimension,
Expand Down

0 comments on commit 8af3b5d

Please sign in to comment.