Fix custom menu bar icon packaging
This commit is contained in:
@@ -7,8 +7,7 @@ let package = Package(
|
||||
targets: [
|
||||
.executableTarget(
|
||||
name: "FchatiApp",
|
||||
path: "Sources/FchatiApp",
|
||||
resources: [.process("Resources")]
|
||||
path: "Sources/FchatiApp"
|
||||
),
|
||||
.testTarget(
|
||||
name: "FchatiAppTests",
|
||||
|
||||
|
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.9 KiB |
@@ -14,13 +14,24 @@ struct FchatiApp: App {
|
||||
RootView()
|
||||
.background(WindowConfigurator())
|
||||
} label: {
|
||||
Image("MenuBarIcon", bundle: .module)
|
||||
.renderingMode(.original)
|
||||
MenuBarIcon()
|
||||
}
|
||||
.menuBarExtraStyle(.window)
|
||||
}
|
||||
}
|
||||
|
||||
private struct MenuBarIcon: View {
|
||||
var body: some View {
|
||||
if let url = Bundle.main.url(forResource: "MenuBarIcon", withExtension: "png"),
|
||||
let image = NSImage(contentsOf: url) {
|
||||
Image(nsImage: image)
|
||||
.renderingMode(.original)
|
||||
} else {
|
||||
Image(systemName: "message")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Prevents the popover from closing when clicking outside.
|
||||
private struct WindowConfigurator: NSViewRepresentable {
|
||||
func makeNSView(context: Context) -> NSView {
|
||||
|
||||
Reference in New Issue
Block a user