Skip to content

Commit

Permalink
Merge pull request #6 from shilokuma-inc/feat/menuBar
Browse files Browse the repository at this point in the history
【FEAT】メニューバーにアイコン設置
  • Loading branch information
mrs1669 authored May 19, 2024
2 parents 1051ad9 + aa5e3c5 commit 3faad40
Show file tree
Hide file tree
Showing 7 changed files with 110 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@

/* Begin PBXBuildFile section */
4F3978132BF912B800E462C0 /* QuickKeyAssistantApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F3978122BF912B800E462C0 /* QuickKeyAssistantApp.swift */; };
4F3978152BF912B800E462C0 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F3978142BF912B800E462C0 /* ContentView.swift */; };
4F3978172BF912B900E462C0 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4F3978162BF912B900E462C0 /* Assets.xcassets */; };
4F39781A2BF912B900E462C0 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4F3978192BF912B900E462C0 /* Preview Assets.xcassets */; };
4F3978252BF912B900E462C0 /* QuickKeyAssistantAppTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F3978242BF912B900E462C0 /* QuickKeyAssistantAppTests.swift */; };
4F39782F2BF912B900E462C0 /* QuickKeyAssistantAppUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F39782E2BF912B900E462C0 /* QuickKeyAssistantAppUITests.swift */; };
4F3978312BF912B900E462C0 /* QuickKeyAssistantAppUITestsLaunchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F3978302BF912B900E462C0 /* QuickKeyAssistantAppUITestsLaunchTests.swift */; };
4F6896B32BF9FDAD00EF0D4D /* MenuView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F6896B22BF9FDAD00EF0D4D /* MenuView.swift */; };
4F8F72412BF9FAFD00EB1869 /* Extension+NSImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F8F72402BF9FAFD00EB1869 /* Extension+NSImage.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand All @@ -36,7 +37,6 @@
/* Begin PBXFileReference section */
4F39780F2BF912B800E462C0 /* QuickKeyAssistantApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = QuickKeyAssistantApp.app; sourceTree = BUILT_PRODUCTS_DIR; };
4F3978122BF912B800E462C0 /* QuickKeyAssistantApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuickKeyAssistantApp.swift; sourceTree = "<group>"; };
4F3978142BF912B800E462C0 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
4F3978162BF912B900E462C0 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
4F3978192BF912B900E462C0 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
4F39781B2BF912B900E462C0 /* QuickKeyAssistantApp.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = QuickKeyAssistantApp.entitlements; sourceTree = "<group>"; };
Expand All @@ -45,6 +45,8 @@
4F39782A2BF912B900E462C0 /* QuickKeyAssistantAppUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = QuickKeyAssistantAppUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
4F39782E2BF912B900E462C0 /* QuickKeyAssistantAppUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuickKeyAssistantAppUITests.swift; sourceTree = "<group>"; };
4F3978302BF912B900E462C0 /* QuickKeyAssistantAppUITestsLaunchTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuickKeyAssistantAppUITestsLaunchTests.swift; sourceTree = "<group>"; };
4F6896B22BF9FDAD00EF0D4D /* MenuView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MenuView.swift; sourceTree = "<group>"; };
4F8F72402BF9FAFD00EB1869 /* Extension+NSImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Extension+NSImage.swift"; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -96,7 +98,8 @@
isa = PBXGroup;
children = (
4F3978122BF912B800E462C0 /* QuickKeyAssistantApp.swift */,
4F3978142BF912B800E462C0 /* ContentView.swift */,
4F6896B22BF9FDAD00EF0D4D /* MenuView.swift */,
4F8F72402BF9FAFD00EB1869 /* Extension+NSImage.swift */,
4F3978162BF912B900E462C0 /* Assets.xcassets */,
4F39781B2BF912B900E462C0 /* QuickKeyAssistantApp.entitlements */,
4F3978182BF912B900E462C0 /* Preview Content */,
Expand Down Expand Up @@ -259,7 +262,8 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
4F3978152BF912B800E462C0 /* ContentView.swift in Sources */,
4F6896B32BF9FDAD00EF0D4D /* MenuView.swift in Sources */,
4F8F72412BF9FAFD00EB1869 /* Extension+NSImage.swift in Sources */,
4F3978132BF912B800E462C0 /* QuickKeyAssistantApp.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -430,6 +434,7 @@
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities";
INFOPLIST_KEY_LSUIElement = YES;
INFOPLIST_KEY_NSHumanReadableCopyright = "";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
Expand Down Expand Up @@ -459,6 +464,7 @@
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities";
INFOPLIST_KEY_LSUIElement = YES;
INFOPLIST_KEY_NSHumanReadableCopyright = "";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "MenuIcon.svg",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 0 additions & 24 deletions QuickKeyAssistantApp/QuickKeyAssistantApp/ContentView.swift

This file was deleted.

19 changes: 19 additions & 0 deletions QuickKeyAssistantApp/QuickKeyAssistantApp/Extension+NSImage.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// Extension+NSImage.swift
// QuickKeyAssistantApp
//
// Created by 村石 拓海 on 2024/05/19.
//

import SwiftUI

extension NSImage {
func resizeImage(named name: String, to newSize: NSSize) -> NSImage? {
guard let image = NSImage(named: name) else { return nil }
let resizedImage = NSImage(size: newSize)
resizedImage.lockFocus()
image.draw(in: NSRect(origin: .zero, size: newSize))
resizedImage.unlockFocus()
return resizedImage
}
}
18 changes: 18 additions & 0 deletions QuickKeyAssistantApp/QuickKeyAssistantApp/MenuView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// MenuView.swift
// QuickKeyAssistantApp
//
// Created by 村石 拓海 on 2024/05/19.
//

import SwiftUI

struct MenuView: View {
var body: some View {
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
}
}

#Preview {
MenuView()
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,14 @@ import SwiftUI
@main
struct QuickKeyAssistantApp: App {
var body: some Scene {
WindowGroup {
ContentView()
MenuBarExtra {
MenuView()
} label: {
if let image = NSImage().resizeImage(named: "MenuIcon", to: NSSize(width: 18, height: 18)) {
Image(nsImage: image)
} else {
Text("")
}
}
}
}

0 comments on commit 3faad40

Please sign in to comment.