Skip to content

Commit

Permalink
🐞 Fix few bugs in custom action configuration view
Browse files Browse the repository at this point in the history
  • Loading branch information
MrKai77 committed Aug 30, 2024
1 parent 5b41df6 commit a277c15
Showing 1 changed file with 31 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ struct CustomActionConfigurationView: View {
}

@ViewBuilder private func tabPicker() -> some View {
LuminarePicker(elements: Tab.allCases, selection: $currentTab, columns: 2, roundBottom: false) { tab in
LuminarePicker(elements: Tab.allCases, selection: $currentTab.animation(LuminareSettingsWindow.animation), columns: 2, roundBottom: false) { tab in
HStack(spacing: 6) {
tab.image
Text(tab.rawValue)
Expand All @@ -91,26 +91,46 @@ struct CustomActionConfigurationView: View {
}

@ViewBuilder private func unitToggle() -> some View {
LuminareToggle("Use pixels", isOn: Binding(get: { action.unit == .pixels }, set: { action.unit = $0 ? .pixels : .percentage }))
LuminareToggle(
"Use pixels",
isOn: Binding(
get: {
if action.unit == nil {
action.unit = .percentage
}

return action.unit == .pixels
},
set: {
action.unit = $0 ? .pixels : .percentage
}
)
)
}

@ViewBuilder private func actionButtons() -> some View {
HStack(spacing: 8) {
Button("Preview") {
previewAction()
}
.disabled(action.sizeMode != .custom)
Button("Preview") {}
.onLongPressGesture( // Allows for a press-and-hold gesture to show the preview
minimumDuration: 100.0,
maximumDistance: .infinity,
pressing: { pressing in
if pressing {
guard let screen = NSScreen.main else { return }
previewController.open(screen: screen, startingAction: action)
} else {
previewController.close()
}
},
perform: {}
)
.disabled(action.sizeMode != .custom)

Button("Close") { isPresented = false }
}
.buttonStyle(LuminareCompactButtonStyle())
}

private func previewAction() {
guard let screen = NSScreen.main else { return }
previewController.open(screen: screen, startingAction: action)
}

@ViewBuilder private func positionConfiguration() -> some View {
LuminareSection {
LuminareToggle(
Expand Down

0 comments on commit a277c15

Please sign in to comment.