-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0d68494
commit 50dbc16
Showing
11 changed files
with
168 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import SwiftUI | ||
|
||
extension Color { | ||
init(hex: UInt) { | ||
self.init(nsColor: NSColor(hex: hex)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import SwiftUI | ||
|
||
struct IconState: Equatable { | ||
let icon: TreeNodeContent.Icon | ||
var isHidden: Bool | ||
} | ||
|
||
struct IconsMenu: View { | ||
@Binding var state: [IconState] | ||
|
||
var body: some View { | ||
Menu { | ||
ForEach(Array(state.enumerated()), id: \.offset) { index, icon in | ||
Button(action: { | ||
state[index].isHidden.toggle() | ||
}, label: { | ||
buildButtonLabel(icon) | ||
}) | ||
} | ||
} label: { | ||
Image(systemName: "square.filled.on.square") | ||
} | ||
} | ||
|
||
private func buildButtonLabel(_ state: IconState) -> some View { | ||
HStack { | ||
if state.isHidden { | ||
Text("Show").foregroundStyle(.hidden) | ||
Image(systemName: state.icon.sfSymbol).foregroundStyle(.hidden, .hidden) | ||
} else { | ||
Text("Hide") | ||
Image(systemName: state.icon.sfSymbol) | ||
.foregroundStyle( | ||
Color(hex: state.icon.primaryColor), | ||
state.icon.secondaryColor.map(Color.init(hex:)) ?? Color(hex: state.icon.primaryColor) | ||
) | ||
} | ||
} | ||
} | ||
} | ||
|
||
private extension ShapeStyle where Self == Color { | ||
static var hidden: Color { | ||
Color(hex: 0x9da1a7).opacity(0.5) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters