Skip to content

Commit

Permalink
chore: refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
ejbills committed Dec 30, 2024
1 parent c6bf13e commit 06a9f75
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 30 deletions.
4 changes: 2 additions & 2 deletions DockDoor.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,9 @@
3A105FD42C1BED5B0015EC66 /* Components */ = {
isa = PBXGroup;
children = (
BBE153BF2D21FA2300CD3D4A /* StyledGroupBox.swift */,
3A105FD82C1C049E0015EC66 /* dockStyle.swift */,
BBE153BD2D2126C000CD3D4A /* MaterialPill.swift */,
BBE153BF2D21FA2300CD3D4A /* StyledGroupBox.swift */,
BBE692182D17AD9C0093B4A5 /* DangerButton.swift */,
3A1622C62C8D5A5C00D318EE /* EnabledActionRowView.swift */,
BBF383962C94A25B00B39A23 /* sliderSetting.swift */,
Expand Down Expand Up @@ -247,7 +248,6 @@
3A1622B32C8C099200D318EE /* Button Styles */,
BB04405F2C77AD27009F1D33 /* CodableColor.swift */,
05C0C7172C60629C000ADAC6 /* AXUIElement.swift */,
3A105FD82C1C049E0015EC66 /* dockStyle.swift */,
);
path = Extensions;
sourceTree = "<group>";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ struct DockStyleModifier: ViewModifier {
.blendMode(.plusLighter)
}
.overlay {
RoundedRectangle(cornerRadius: cornerRadius + 1, style: .continuous)
.stroke(.black.opacity(0.2), lineWidth: 1)
.padding(-1)
RoundedRectangle(cornerRadius: cornerRadius, style: .continuous)
.strokeBorder(Color.primary.opacity(0.1), lineWidth: 0.5)
}
}
.padding(2)
Expand Down
1 change: 0 additions & 1 deletion DockDoor/Extensions/Button Styles/AccentButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ struct AccentButtonStyle: ButtonStyle {
.onHover { newHovering in
hovering = newHovering
}
.foregroundStyle(.white)
.font(.system(size: small ? 10 : 14, weight: .medium))
}
}
3 changes: 3 additions & 0 deletions DockDoor/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -19465,6 +19465,9 @@
}
}
}
},
"Minimize All" : {

},
"Minimum number of colors reached." : {
"localizations" : {
Expand Down
47 changes: 26 additions & 21 deletions DockDoor/Views/Hover Window/WindowPreviewHoverContainer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,7 @@ struct WindowPreviewHoverContainer: View {
}
hoverTitleLabelView(labelSize: labelSize)

if hoveringAppIcon {
Button("Close All") {
closeAllWindows()
}
.buttonStyle(AccentButtonStyle(color: .red, small: true))
.transition(.opacity)
}
massOperations(hoveringAppIcon)
}
.padding(.top, 10)
.padding(.leading)
Expand All @@ -175,13 +169,7 @@ struct WindowPreviewHoverContainer: View {
}
hoverTitleLabelView(labelSize: labelSize)

if hoveringAppIcon {
Button("Close All") {
closeAllWindows()
}
.buttonStyle(AccentButtonStyle(color: .red, small: true))
.transition(.opacity)
}
massOperations(hoveringAppIcon)
}
.padding(EdgeInsets(top: -11.5, leading: 15, bottom: -1.5, trailing: 1.5))
.animation(.spring(response: 0.3), value: hoveringAppIcon)
Expand All @@ -202,13 +190,7 @@ struct WindowPreviewHoverContainer: View {
}
hoverTitleLabelView(labelSize: labelSize)

if hoveringAppIcon {
Button("Close All") {
closeAllWindows()
}
.buttonStyle(AccentButtonStyle(color: .red, small: true))
.transition(.opacity)
}
massOperations(hoveringAppIcon)
}
.padding(.vertical, 5)
.padding(.horizontal, 10)
Expand All @@ -225,6 +207,24 @@ struct WindowPreviewHoverContainer: View {
}
}

@ViewBuilder
func massOperations(_ shouldDisplay: Bool) -> some View {
if shouldDisplay {
Group {
Button("Close All") {
closeAllWindows()
}
.buttonStyle(AccentButtonStyle(small: true))

Button("Minimize All") {
minimizeAllWindows()
}
.buttonStyle(AccentButtonStyle(small: true))
}
.transition(.opacity)
}
}

@ViewBuilder
private func hoverTitleLabelView(labelSize: CGSize) -> some View {
switch appNameStyle {
Expand Down Expand Up @@ -409,6 +409,11 @@ struct WindowPreviewHoverContainer: View {
windows.forEach { WindowUtil.closeWindow(windowInfo: $0) }
}

private func minimizeAllWindows() {
windowStates.removeAll()
windows.forEach { _ = WindowUtil.toggleMinimize(windowInfo: $0) }
}

private func handleWindowAction(_ action: WindowAction, at index: Int) {
guard index < windowStates.count else { return }
var window = windowStates[index]
Expand Down
6 changes: 3 additions & 3 deletions DockDoor/consts.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ extension Defaults.Keys {
static let fadeOutDuration = Key<CGFloat>("fadeOutDuration", default: 0.4)
static let previewHoverAction = Key<PreviewHoverAction>("previewHoverAction", default: .none)

static let maxColumns = Key<CGFloat>("maxColumns", default: 0)
static let maxRows = Key<CGFloat>("maxRows", default: 0)

static let showAnimations = Key<Bool>("showAnimations", default: true)
static let gradientColorPalette = Key<GradientColorPaletteSettings>("gradientColorPalette", default: .init())
static let enableWindowSwitcher = Key<Bool>("enableWindowSwitcher", default: true)
Expand Down Expand Up @@ -54,6 +51,9 @@ extension Defaults.Keys {
static let trafficLightButtonsVisibility = Key<TrafficLightButtonsVisibility>("trafficLightButtonsVisibility", default: .dimmedOnPreviewHover)
static let trafficLightButtonsPosition = Key<TrafficLightButtonsPosition>("trafficLightButtonsPosition", default: .topLeft)

static let maxColumns = Key<CGFloat>("maxColumns", default: 2)
static let maxRows = Key<CGFloat>("maxRows", default: 2)

static let windowSwitcherPlacementStrategy = Key<WindowSwitcherPlacementStrategy>("windowSwitcherPlacementStrategy", default: .screenWithMouse)
static let windowSwitcherControlPosition = Key<WindowSwitcherControlPosition>("windowSwitcherControlPosition", default: .topTrailing)
static let dimInSwitcherUntilSelected = Key<Bool>("dimInSwitcherUntilSelected", default: false)
Expand Down

0 comments on commit 06a9f75

Please sign in to comment.