Skip to content

Commit

Permalink
Fixed broken keyboard grid
Browse files Browse the repository at this point in the history
  • Loading branch information
superhighfives committed Sep 25, 2024
1 parent f9023e4 commit 8b79490
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 16 deletions.
1 change: 0 additions & 1 deletion Pika.xcodeproj/xcshareddata/xcschemes/Pika.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = "zh-Hans"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
48 changes: 34 additions & 14 deletions Pika/Views/KeyboardShortcutGrid.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ struct KeyboardShortcutGrid: View {
let width = geometry.size.width
let height = geometry.size.height

let quarterHorizontalUnit = width / 4
let horizontalUnit = width / 5
let verticalUnit = floor(height / 3)

VStack(spacing: 0.0) {
Expand All @@ -20,7 +20,7 @@ struct KeyboardShortcutGrid: View {
event: PikaConstants.ncTriggerPickForeground,
keys: ["", "D"]
)
.frame(width: quarterHorizontalUnit, height: verticalUnit)
.frame(width: horizontalUnit, height: verticalUnit)

Divider()
.frame(height: verticalUnit)
Expand All @@ -30,7 +30,7 @@ struct KeyboardShortcutGrid: View {
event: PikaConstants.ncTriggerPickBackground,
keys: ["", "", "D"]
)
.frame(width: quarterHorizontalUnit, height: verticalUnit)
.frame(width: horizontalUnit, height: verticalUnit)

Divider()
.frame(height: verticalUnit)
Expand All @@ -40,7 +40,7 @@ struct KeyboardShortcutGrid: View {
event: PikaConstants.ncTriggerCopyForeground,
keys: ["", "C"]
)
.frame(width: quarterHorizontalUnit, height: verticalUnit)
.frame(width: horizontalUnit, height: verticalUnit)

Divider()
.frame(height: verticalUnit)
Expand All @@ -50,20 +50,40 @@ struct KeyboardShortcutGrid: View {
event: PikaConstants.ncTriggerCopyBackground,
keys: ["", "", "C"]
)
.frame(width: quarterHorizontalUnit, height: verticalUnit)
.frame(width: horizontalUnit, height: verticalUnit)

Divider()
.frame(height: verticalUnit)

KeyboardShortcutItem(
title: PikaText.textColorSystemPickerForeground,
event: PikaConstants.ncTriggerSystemPickerForeground,
keys: ["", "S"]
)
.frame(width: horizontalUnit, height: verticalUnit)
}

Divider()
.frame(maxWidth: .infinity)

// Copy
HStack(spacing: 0) {
KeyboardShortcutItem(
title: PikaText.textColorSystemPickerBackground,
event: PikaConstants.ncTriggerSystemPickerBackground,
keys: ["", "", "S"]
)
.frame(width: horizontalUnit, height: verticalUnit)

Divider()
.frame(height: verticalUnit)

KeyboardShortcutItem(
title: PikaText.textColorUndo,
event: PikaConstants.ncTriggerUndo,
keys: ["", "z"]
)
.frame(width: quarterHorizontalUnit, height: verticalUnit)
.frame(width: horizontalUnit, height: verticalUnit)

Divider()
.frame(height: verticalUnit)
Expand All @@ -73,7 +93,7 @@ struct KeyboardShortcutGrid: View {
event: PikaConstants.ncTriggerRedo,
keys: ["", "Z"]
)
.frame(width: quarterHorizontalUnit, height: verticalUnit)
.frame(width: horizontalUnit, height: verticalUnit)

Divider()
.frame(height: verticalUnit)
Expand All @@ -83,7 +103,7 @@ struct KeyboardShortcutGrid: View {
event: PikaConstants.ncTriggerSwap,
keys: ["", "", "X"]
)
.frame(width: quarterHorizontalUnit, height: verticalUnit)
.frame(width: horizontalUnit, height: verticalUnit)

Divider()
.frame(height: verticalUnit)
Expand All @@ -93,7 +113,7 @@ struct KeyboardShortcutGrid: View {
event: PikaConstants.ncTriggerPreferences,
keys: ["", ","]
)
.frame(width: quarterHorizontalUnit, height: verticalUnit)
.frame(width: horizontalUnit, height: verticalUnit)
}

Divider()
Expand All @@ -105,7 +125,7 @@ struct KeyboardShortcutGrid: View {
event: PikaConstants.ncTriggerFormatHex,
keys: ["", "1"]
)
.frame(width: quarterHorizontalUnit, height: verticalUnit)
.frame(width: horizontalUnit, height: verticalUnit)

Divider()
.frame(height: verticalUnit)
Expand All @@ -115,7 +135,7 @@ struct KeyboardShortcutGrid: View {
event: PikaConstants.ncTriggerFormatRGB,
keys: ["", "2"]
)
.frame(width: quarterHorizontalUnit, height: verticalUnit)
.frame(width: horizontalUnit, height: verticalUnit)

Divider()
.frame(height: verticalUnit)
Expand All @@ -125,7 +145,7 @@ struct KeyboardShortcutGrid: View {
event: PikaConstants.ncTriggerFormatHSB,
keys: ["", "3"]
)
.frame(width: quarterHorizontalUnit, height: verticalUnit)
.frame(width: horizontalUnit, height: verticalUnit)

Divider()
.frame(height: verticalUnit)
Expand All @@ -135,7 +155,7 @@ struct KeyboardShortcutGrid: View {
event: PikaConstants.ncTriggerFormatHSL,
keys: ["", "4"]
)
.frame(width: quarterHorizontalUnit, height: verticalUnit)
.frame(width: horizontalUnit, height: verticalUnit)

Divider()
.frame(height: verticalUnit)
Expand All @@ -145,7 +165,7 @@ struct KeyboardShortcutGrid: View {
event: PikaConstants.ncTriggerFormatOpenGL,
keys: ["", "5"]
)
.frame(width: quarterHorizontalUnit, height: verticalUnit)
.frame(width: horizontalUnit, height: verticalUnit)
}
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
Expand Down
5 changes: 4 additions & 1 deletion Pika/Views/KeyboardShortcutItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ struct KeyboardShortcutItem: View {
Text(title)
.font(.system(size: 11, design: .rounded))
.opacity(0.6)
.padding(10.0)
.multilineTextAlignment(.center)
HStack(spacing: 4.0) {
ForEach(keys, id: \.self) { key in
KeyboardShortcutKey { Text(key) }
Expand All @@ -36,6 +38,7 @@ struct KeyboardShortcutItem: View {

struct KeyboardShortcutItem_Previews: PreviewProvider {
static var previews: some View {
KeyboardShortcutItem(title: "Copy Example", event: PikaConstants.ncTriggerPickForeground, keys: ["A", "B"])
KeyboardShortcutItem(title: "Copy example but with a much longer text", event: PikaConstants.ncTriggerPickForeground, keys: ["A", "B"])
.frame(width: 100.0, height: 100.0)
}
}

0 comments on commit 8b79490

Please sign in to comment.