Skip to content

Commit

Permalink
enhance: add dynamic window preview sizing in grid
Browse files Browse the repository at this point in the history
  • Loading branch information
hasansultan92 committed Sep 14, 2024
1 parent 6075047 commit 7b1e325
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
5 changes: 2 additions & 3 deletions DockDoor/Views/Hover Window/WindowPreview.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,12 @@ struct WindowPreview: View {
if let cgImage = windowInfo.image {
Image(decorative: cgImage, scale: 1.0)
.resizable()
.aspectRatio(contentMode: .fill)
.aspectRatio(contentMode: .fit)
.markHidden(isHidden: isMinimized || isHidden)
.overlay(isSelected ? CustomizableFluidGradientView().opacity(0.125) : nil)
}
}
.frame(width: calculatedSize.width, height: calculatedSize.height, alignment: .center)
.frame(maxWidth: calculatedMaxDimensions.width, maxHeight: calculatedMaxDimensions.height)
.frame(maxWidth: calculatedSize.width, maxHeight: calculatedSize.height, alignment: .leading)
}

var body: some View {
Expand Down
19 changes: 12 additions & 7 deletions DockDoor/Views/Hover Window/WindowPreviewHoverContainer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,17 @@ struct WindowPreviewHoverContainer: View {
}
.padding(.top, (!windowSwitcherCoordinator.windowSwitcherActive && appNameStyle == .popover && showAppName) ? 30 : 0) // Provide empty space above the window preview for the Popover title style when hovering over the Dock
.padding(.all, 24)
.frame(maxWidth: bestGuessMonitor.visibleFrame.width, maxHeight: bestGuessMonitor.visibleFrame.height)
.frame(maxWidth: bestGuessMonitor.visibleFrame.width - 15, maxHeight: bestGuessMonitor.visibleFrame.height - 15)
}

private var windowPreviewGrid: some View {
Group {
if GridLayoutVertical() {
LazyHGrid(rows: calculateGridInfo(), spacing: 16) {
LazyHGrid(rows: calculateGridInfo(), spacing: 25) {
gridContent
}
} else {
LazyVGrid(columns: calculateGridInfo(), spacing: 16) {
LazyVGrid(columns: calculateGridInfo(), spacing: 25) {
gridContent
}
}
Expand All @@ -100,10 +100,15 @@ struct WindowPreviewHoverContainer: View {

private var gridContent: some View {
ForEach(windows.indices, id: \.self) { index in
WindowPreview(windowInfo: windows[index], onTap: onWindowTap, index: index,
dockPosition: dockPosition, maxWindowDimension: maxWindowDimension,
bestGuessMonitor: bestGuessMonitor, uniformCardRadius: uniformCardRadius,
currIndex: windowSwitcherCoordinator.currIndex, windowSwitcherActive: windowSwitcherCoordinator.windowSwitcherActive)
WindowPreview(windowInfo: windows[index],
onTap: onWindowTap,
index: index,
dockPosition: dockPosition,
maxWindowDimension: maxWindowDimension,
bestGuessMonitor: bestGuessMonitor,
uniformCardRadius: uniformCardRadius,
currIndex: windowSwitcherCoordinator.currIndex,
windowSwitcherActive: windowSwitcherCoordinator.windowSwitcherActive)
.id("\(appName)-\(index)")
}
}
Expand Down

0 comments on commit 7b1e325

Please sign in to comment.