Skip to content

Commit

Permalink
fix: window container size adjusts for vertical and horizontal
Browse files Browse the repository at this point in the history
  • Loading branch information
hasansultan92 committed Sep 15, 2024
1 parent 7b1e325 commit 046e453
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 34 deletions.
2 changes: 1 addition & 1 deletion DockDoor/Views/Hover Window/WindowPreview.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ struct WindowPreview: View {
.overlay(isSelected ? CustomizableFluidGradientView().opacity(0.125) : nil)
}
}
.frame(maxWidth: calculatedSize.width, maxHeight: calculatedSize.height, alignment: .leading)
.frame(width: calculatedSize.width, height: calculatedSize.height, alignment: .leading)
}

var body: some View {
Expand Down
65 changes: 32 additions & 33 deletions DockDoor/Views/Hover Window/WindowPreviewHoverContainer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,28 +51,7 @@ struct WindowPreviewHoverContainer: View {
WindowDismissalContainer(appName: appName, mouseLocation: mouseLocation,
bestGuessMonitor: bestGuessMonitor, dockPosition: dockPosition)
}

ScrollViewReader { scrollProxy in
ScrollView(.vertical, showsIndicators: false) {
windowPreviewGrid
.padding(14)
.onAppear {
if !hasAppeared {
hasAppeared.toggle()
runUIUpdates()
}
}
.onChange(of: windowSwitcherCoordinator.currIndex) { newIndex in
withAnimation {
scrollProxy.scrollTo("\(appName)-\(newIndex)", anchor: .center)
}
}
.onChange(of: windows) { _ in
runUIUpdates()
}
}
.opacity(showWindows ? 1 : 0.8)
}
gridContainer()
}
.padding(.top, (!windowSwitcherCoordinator.windowSwitcherActive && appNameStyle == .default && showAppName) ? 25 : 0) // Provide space above the window preview for the Embedded (default) title style when hovering over the Dock.
.dockStyle(cornerRadius: 16)
Expand All @@ -84,17 +63,36 @@ struct WindowPreviewHoverContainer: View {
.frame(maxWidth: bestGuessMonitor.visibleFrame.width - 15, maxHeight: bestGuessMonitor.visibleFrame.height - 15)
}

private var windowPreviewGrid: some View {
Group {
if GridLayoutVertical() {
LazyHGrid(rows: calculateGridInfo(), spacing: 25) {
gridContent
}
} else {
LazyVGrid(columns: calculateGridInfo(), spacing: 25) {
gridContent
}
private func gridContainer() -> some View {
ScrollViewReader { scrollProxy in
ScrollView(.vertical, showsIndicators: false) {
Group {
if GridLayoutVertical() {
LazyHGrid(rows: calculateGridInfo(), spacing: 25) {
gridContent
}
} else {
LazyVGrid(columns: calculateGridInfo(), spacing: 25) {
gridContent
}
}
}.padding(14)
.onAppear {
if !hasAppeared {
hasAppeared.toggle()
runUIUpdates()
}
}
.onChange(of: windowSwitcherCoordinator.currIndex) { newIndex in
withAnimation {
scrollProxy.scrollTo("\(appName)-\(newIndex)", anchor: .center)
}
}
.onChange(of: windows) { _ in
runUIUpdates()
}
}
.opacity(showWindows ? 1 : 0.8)
}
}

Expand Down Expand Up @@ -256,6 +254,7 @@ struct WindowPreviewHoverContainer: View {
} else {
numberOfColumns = maxNumberOfColumns
}
return Array(repeating: GridItem(.flexible(), spacing: 16), count: numberOfColumns)
return mouseLocation == nil ? Array(repeating: GridItem(.fixed(maxColumnWidth), spacing: 16), count: numberOfColumns) :
Array(repeating: GridItem(.flexible(), spacing: 16), count: numberOfColumns)
}
}

0 comments on commit 046e453

Please sign in to comment.