Skip to content

Commit

Permalink
fix: make UX better for window sizing options
Browse files Browse the repository at this point in the history
closes #337
  • Loading branch information
ejbills committed Nov 18, 2024
1 parent a0cd6d0 commit 5eea380
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 35 deletions.
19 changes: 19 additions & 0 deletions DockDoor/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -894,6 +894,9 @@
}
}
}
},
"1/%lldx" : {

},
"Accessibility" : {
"localizations" : {
Expand Down Expand Up @@ -4289,6 +4292,7 @@
},
"Can you even see this?" : {
"comment" : "Window size option",
"extractionState" : "stale",
"localizations" : {
"af" : {
"stringUnit" : {
Expand Down Expand Up @@ -6251,6 +6255,7 @@
},
"Default (Medium Large)" : {
"comment" : "Window size option",
"extractionState" : "stale",
"localizations" : {
"af" : {
"stringUnit" : {
Expand Down Expand Up @@ -8927,6 +8932,7 @@
},
"Extra Extra Small" : {
"comment" : "Window size option",
"extractionState" : "stale",
"localizations" : {
"af" : {
"stringUnit" : {
Expand Down Expand Up @@ -9106,6 +9112,7 @@
},
"Extra Small" : {
"comment" : "Window size option",
"extractionState" : "stale",
"localizations" : {
"af" : {
"stringUnit" : {
Expand Down Expand Up @@ -12322,6 +12329,7 @@
},
"Large" : {
"comment" : "Window size option",
"extractionState" : "stale",
"localizations" : {
"af" : {
"stringUnit" : {
Expand Down Expand Up @@ -13035,6 +13043,7 @@
},
"Medium" : {
"comment" : "Window size option",
"extractionState" : "stale",
"localizations" : {
"af" : {
"stringUnit" : {
Expand Down Expand Up @@ -18393,6 +18402,9 @@
}
}
}
},
"Preview windows are sized to 1/%lld of your screen dimensions" : {

},
"Quit App" : {
"extractionState" : "stale",
Expand Down Expand Up @@ -24107,6 +24119,7 @@
},
"Small" : {
"comment" : "Window size option",
"extractionState" : "stale",
"localizations" : {
"af" : {
"stringUnit" : {
Expand Down Expand Up @@ -24821,6 +24834,7 @@
},
"Subatomic" : {
"comment" : "Window size option",
"extractionState" : "stale",
"localizations" : {
"af" : {
"stringUnit" : {
Expand Down Expand Up @@ -28742,6 +28756,7 @@
},
"What is this? A window for ANTS?" : {
"comment" : "Window size option",
"extractionState" : "stale",
"localizations" : {
"af" : {
"stringUnit" : {
Expand Down Expand Up @@ -30527,8 +30542,12 @@
}
}
}
},
"Window Preview Size" : {

},
"Window Size" : {
"extractionState" : "stale",
"localizations" : {
"af" : {
"stringUnit" : {
Expand Down
53 changes: 18 additions & 35 deletions DockDoor/Views/Settings/MainSettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ struct MainSettingsView: View {
.foregroundColor(.gray)
}

SizePickerView()
WindowSizeSliderView()

sliderSetting(title: String(localized: "Window Image Cache Lifespan"),
value: $screenCaptureCacheLifespan,
Expand Down Expand Up @@ -157,46 +157,29 @@ struct MainSettingsView: View {
}
}

struct SizePickerView: View {
struct WindowSizeSliderView: View {
@Default(.sizingMultiplier) var sizingMultiplier
@Default(.bufferFromDock) var bufferFromDock

var body: some View {
VStack(spacing: 20) {
Picker("Window Size", selection: $sizingMultiplier) {
ForEach(2 ... 10, id: \.self) { size in
Text(getLabel(for: CGFloat(size))).tag(CGFloat(size))
VStack(alignment: .leading) {
HStack {
Slider(value: $sizingMultiplier, in: 2 ... 10, step: 1) {
Text("Window Preview Size")
}
.buttonStyle(PlainButtonStyle())
.frame(width: 400)

Text("1/\(Int(sizingMultiplier))x")
.frame(width: 50)
.foregroundColor(.gray)
}
.scaledToFit()
.onChange(of: sizingMultiplier) { _ in
SharedPreviewWindowCoordinator.shared.windowSize = getWindowSize()
}
}
}

private func getLabel(for size: CGFloat) -> String {
switch size {
case 2:
String(localized: "Large", comment: "Window size option")
case 3:
String(localized: "Default (Medium Large)", comment: "Window size option")
case 4:
String(localized: "Medium", comment: "Window size option")
case 5:
String(localized: "Small", comment: "Window size option")
case 6:
String(localized: "Extra Small", comment: "Window size option")
case 7:
String(localized: "Extra Extra Small", comment: "Window size option")
case 8:
String(localized: "What is this? A window for ANTS?", comment: "Window size option")
case 9:
String(localized: "Subatomic", comment: "Window size option")
case 10:
String(localized: "Can you even see this?", comment: "Window size option")
default:
"Unknown Size"
Text("Preview windows are sized to 1/\(Int(sizingMultiplier)) of your screen dimensions")
.font(.footnote)
.foregroundColor(.gray)
}
.onChange(of: sizingMultiplier) { _ in
SharedPreviewWindowCoordinator.shared.windowSize = getWindowSize()
}
}
}

0 comments on commit 5eea380

Please sign in to comment.