Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ struct CustomActionConfigurationView: View {
columns: 3,
roundTop: false
) { anchor in
IconView(action: .constant(anchor.iconAction))
IconView(action: anchor.iconAction)
}

if action.anchor ?? .center == .center || action.anchor == .macOSCenter {
Expand Down
4 changes: 2 additions & 2 deletions Loop/Luminare/Settings/Keybindings/KeybindItemView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ struct KeybindItemView: View {
} label: {
HStack(spacing: 0) {
HStack(spacing: 8) {
IconView(action: $keybind)
IconView(action: keybind)

Text(keybind.getName())
.lineLimit(1)
Expand Down Expand Up @@ -227,7 +227,7 @@ struct KeybindItemView: View {
sections + [moreSection]
) { item in
HStack(spacing: 8) {
IconView(action: .constant(.init(item)))
IconView(action: .init(item))
Text(item.name)
}
}
Expand Down
39 changes: 27 additions & 12 deletions Loop/Window Management/WindowAction+Image.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,24 +57,22 @@ extension WindowAction {
}

struct IconView: View {
@Binding var action: WindowAction
@State var frame: CGRect = .init(x: 0, y: 0, width: 1, height: 1)
let action: WindowAction

let size = CGSize(width: 14, height: 10)
let inset: CGFloat = 2
let outerCornerRadius: CGFloat = 3
@State private var frame: CGRect = .init(x: 0, y: 0, width: 1, height: 1)

private let size = CGSize(width: 14, height: 10)
private let inset: CGFloat = 2
private let outerCornerRadius: CGFloat = 3

var body: some View {
if action.direction == .cycle, let first = action.cycle?.first {
IconView(action: .constant(first))
IconView(action: first)
.id(first.id)
.animation(LuminareConstants.fastAnimation, value: first)
} else {
ZStack {
if let icon = action.icon {
icon
.font(.system(size: 8))
.fontWeight(.bold)
.frame(width: size.width, height: size.height)
} else {
if frame.size.area != 0 {
ZStack {
RoundedRectangle(cornerRadius: outerCornerRadius - inset)
.frame(
Expand All @@ -95,6 +93,23 @@ struct IconView: View {
refreshFrame()
}
}
} else {
Group {
if let icon = action.icon {
icon
.font(.system(size: 8))
.fontWeight(.bold)
} else if action.direction == .cycle {
Image(._18PxRepeat4)
.resizable()
.scaledToFit()
} else {
Image(._18PxRuler)
.resizable()
.scaledToFit()
}
}
.frame(width: size.width, height: size.height)
}
}
.clipShape(.rect(cornerRadius: outerCornerRadius - inset))
Expand Down