Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

About画面の追加 #8

Merged
merged 4 commits into from
Aug 10, 2024
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
59 changes: 59 additions & 0 deletions Ukam.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
822CDF5027D52C1C00C6B331 /* ApplicationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 822CDF4F27D52C1C00C6B331 /* ApplicationServices.framework */; platformFilter = maccatalyst; };
82302D0F2C669E4300B8BF8C /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 82302D112C669E4300B8BF8C /* Localizable.strings */; };
82302D1D2C66A52C00B8BF8C /* RswiftLibrary in Frameworks */ = {isa = PBXBuildFile; productRef = 82302D1C2C66A52C00B8BF8C /* RswiftLibrary */; };
826008282C67511200ACD8A7 /* AboutViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 826008272C67511200ACD8A7 /* AboutViewController.swift */; };
8260082A2C67511A00ACD8A7 /* AboutView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 826008292C67511A00ACD8A7 /* AboutView.swift */; };
8260082D2C6755A500ACD8A7 /* AcknowledgementsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8260082C2C6755A500ACD8A7 /* AcknowledgementsView.swift */; };
8260083E2C675CA600ACD8A7 /* AcknowledgementsDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8260083D2C675CA600ACD8A7 /* AcknowledgementsDataSource.swift */; };
828688F52C6512A80059CAEE /* PermissionsManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 828688F42C6512A80059CAEE /* PermissionsManager.swift */; };
828688F82C65158B0059CAEE /* PermissionsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 828688F72C65158B0059CAEE /* PermissionsView.swift */; };
828688FA2C651B6E0059CAEE /* PermissionsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 828688F92C651B6E0059CAEE /* PermissionsViewController.swift */; };
Expand Down Expand Up @@ -56,6 +60,10 @@
8260081F2C67497900ACD8A7 /* Ukam.Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Ukam.Release.xcconfig; sourceTree = "<group>"; };
826008202C67499A00ACD8A7 /* Ukam.Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Ukam.Debug.xcconfig; sourceTree = "<group>"; };
826008212C674A0800ACD8A7 /* Version.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Version.xcconfig; sourceTree = "<group>"; };
826008272C67511200ACD8A7 /* AboutViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AboutViewController.swift; sourceTree = "<group>"; };
826008292C67511A00ACD8A7 /* AboutView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AboutView.swift; sourceTree = "<group>"; };
8260082C2C6755A500ACD8A7 /* AcknowledgementsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AcknowledgementsView.swift; sourceTree = "<group>"; };
8260083D2C675CA600ACD8A7 /* AcknowledgementsDataSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AcknowledgementsDataSource.swift; sourceTree = "<group>"; };
828688F42C6512A80059CAEE /* PermissionsManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PermissionsManager.swift; sourceTree = "<group>"; };
828688F72C65158B0059CAEE /* PermissionsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PermissionsView.swift; sourceTree = "<group>"; };
828688F92C651B6E0059CAEE /* PermissionsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PermissionsViewController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -135,6 +143,17 @@
path = Configurations;
sourceTree = "<group>";
};
826008262C6750FB00ACD8A7 /* About */ = {
isa = PBXGroup;
children = (
826008272C67511200ACD8A7 /* AboutViewController.swift */,
826008292C67511A00ACD8A7 /* AboutView.swift */,
8260082C2C6755A500ACD8A7 /* AcknowledgementsView.swift */,
8260083D2C675CA600ACD8A7 /* AcknowledgementsDataSource.swift */,
);
path = About;
sourceTree = "<group>";
};
828688F62C65154B0059CAEE /* Permissions */ = {
isa = PBXGroup;
children = (
Expand All @@ -149,6 +168,7 @@
children = (
828688F62C65154B0059CAEE /* Permissions */,
82B14DFE2C5CDBE7000B08C3 /* Windows */,
826008262C6750FB00ACD8A7 /* About */,
82B14E072C5CF685000B08C3 /* LayoutConstants.swift */,
);
path = Views;
Expand Down Expand Up @@ -209,11 +229,13 @@
buildPhases = (
82C57EF527D46DB900395627 /* Sources */,
82C57EF627D46DB900395627 /* Frameworks */,
82C5D37D2C675B3000395627 /* Copy Acknowledgements */,
82C57EF727D46DB900395627 /* Resources */,
);
buildRules = (
);
dependencies = (
826008372C675AAB00ACD8A7 /* PBXTargetDependency */,
82302D1F2C66A54300B8BF8C /* PBXTargetDependency */,
);
name = Ukam;
Expand Down Expand Up @@ -255,6 +277,7 @@
mainGroup = 82C57EF027D46DB900395627;
packageReferences = (
82302D1B2C66A4F900B8BF8C /* XCRemoteSwiftPackageReference "R.swift" */,
826008342C675A9700ACD8A7 /* XCRemoteSwiftPackageReference "LicensePlist" */,
);
productRefGroup = 82C57EFA27D46DB900395627 /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -320,6 +343,21 @@
shellPath = /bin/sh;
shellScript = "hoshi_cli=\"$PROJECT_DIR/.vendor/hoshi.app/Contents/hoshi-cli\"\n\nwork_dir=$(mktemp -d)\nfunction cleanup {\n rm -rf \"$work_dir\"\n}\ntrap cleanup EXIT\n\n$hoshi_cli publish --project \"$PROJECT_DIR/localize\" --outDir \"$work_dir\" app\n\ncp \"$work_dir/app/strings/en.strings\" \"$PROJECT_DIR/Ukam/en.lproj/Localizable.strings\"\ncp \"$work_dir/app/strings/ja.strings\" \"$PROJECT_DIR/Ukam/ja.lproj/Localizable.strings\"\n";
};
82C5D37D2C675B3000395627 /* Copy Acknowledgements */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Copy Acknowledgements";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "echo \"Will copy acknowledgements\"\n\nACKNOWLEDGEMENTS_DIR=${BUILT_PRODUCTS_DIR}/${CONTENTS_FOLDER_PATH}/com.mono0926.LicensePlist.Output\nDESTINATION_PATH=${BUILT_PRODUCTS_DIR}/${CONTENTS_FOLDER_PATH}/Settings.bundle/\n\necho $ACKNOWLEDGEMENTS_DIR\necho $DESTINATION_PATH\n\n\n#cp -r \"${ACKNOWLEDGEMENTS_DIR}\"/* \"${DESTINATION_PATH}\"\n#rm -rf \"${ACKNOWLEDGEMENTS_DIR}\"\n";
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
Expand All @@ -329,13 +367,17 @@
files = (
828688F52C6512A80059CAEE /* PermissionsManager.swift in Sources */,
822CDF3E27D4C6CD00C6B331 /* MenuManager.swift in Sources */,
8260083E2C675CA600ACD8A7 /* AcknowledgementsDataSource.swift in Sources */,
82B14E022C5CDC0E000B08C3 /* WindowsView.swift in Sources */,
82B14E042C5CE172000B08C3 /* WindowsViewDataSource.swift in Sources */,
8260082A2C67511A00ACD8A7 /* AboutView.swift in Sources */,
822CDF4127D4C72E00C6B331 /* Window.swift in Sources */,
82B14E062C5CED30000B08C3 /* WindowItemView.swift in Sources */,
828688FA2C651B6E0059CAEE /* PermissionsViewController.swift in Sources */,
828688F82C65158B0059CAEE /* PermissionsView.swift in Sources */,
82C57EFD27D46DB900395627 /* AppDelegate.swift in Sources */,
8260082D2C6755A500ACD8A7 /* AcknowledgementsView.swift in Sources */,
826008282C67511200ACD8A7 /* AboutViewController.swift in Sources */,
82B14E002C5CDBF7000B08C3 /* WindowsViewController.swift in Sources */,
822CDF4427D4C79300C6B331 /* WindowManager.swift in Sources */,
82B14E082C5CF685000B08C3 /* LayoutConstants.swift in Sources */,
Expand All @@ -349,6 +391,10 @@
isa = PBXTargetDependency;
productRef = 82302D1E2C66A54300B8BF8C /* RswiftGenerateInternalResources */;
};
826008372C675AAB00ACD8A7 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
productRef = 826008362C675AAB00ACD8A7 /* LicensePlistBuildTool */;
};
/* End PBXTargetDependency section */

/* Begin PBXVariantGroup section */
Expand Down Expand Up @@ -605,6 +651,14 @@
minimumVersion = 7.5.0;
};
};
826008342C675A9700ACD8A7 /* XCRemoteSwiftPackageReference "LicensePlist" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/mono0926/LicensePlist.git";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 3.25.1;
};
};
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
Expand All @@ -618,6 +672,11 @@
package = 82302D1B2C66A4F900B8BF8C /* XCRemoteSwiftPackageReference "R.swift" */;
productName = "plugin:RswiftGenerateInternalResources";
};
826008362C675AAB00ACD8A7 /* LicensePlistBuildTool */ = {
isa = XCSwiftPackageProductDependency;
package = 826008342C675A9700ACD8A7 /* XCRemoteSwiftPackageReference "LicensePlist" */;
productName = "plugin:LicensePlistBuildTool";
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = 82C57EF127D46DB900395627 /* Project object */;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,41 @@
{
"pins" : [
{
"identity" : "apikit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/ishkawa/APIKit.git",
"state" : {
"revision" : "b839e53b870104798035b279d2a6168b0a2227b1",
"version" : "5.4.0"
}
},
{
"identity" : "heliumlogger",
"kind" : "remoteSourceControl",
"location" : "https://github.com/Kitura/HeliumLogger.git",
"state" : {
"revision" : "fc2a71597ae974da5282d751bcc11965964bccce",
"version" : "2.0.0"
}
},
{
"identity" : "licenseplist",
"kind" : "remoteSourceControl",
"location" : "https://github.com/mono0926/LicensePlist.git",
"state" : {
"revision" : "f3f802009c9f71ad46356adb453fcb57b8931ff9",
"version" : "3.25.1"
}
},
{
"identity" : "loggerapi",
"kind" : "remoteSourceControl",
"location" : "https://github.com/Kitura/LoggerAPI.git",
"state" : {
"revision" : "4e6b45e850ffa275e8e26a24c6454fd709d5b6ac",
"version" : "2.0.0"
}
},
{
"identity" : "r.swift",
"kind" : "remoteSourceControl",
Expand All @@ -18,6 +54,24 @@
"version" : "1.5.0"
}
},
{
"identity" : "swift-html-entities",
"kind" : "remoteSourceControl",
"location" : "https://github.com/Kitura/swift-html-entities.git",
"state" : {
"revision" : "d8ca73197f59ce260c71bd6d7f6eb8bbdccf508b",
"version" : "4.0.1"
}
},
{
"identity" : "swift-log",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-log.git",
"state" : {
"revision" : "9cb486020ebf03bfa5b5df985387a14a98744537",
"version" : "1.6.1"
}
},
{
"identity" : "xcodeedit",
"kind" : "remoteSourceControl",
Expand All @@ -26,6 +80,15 @@
"revision" : "b6b67389a0f1a6fdd9c6457a8ab5b02eaab13c5c",
"version" : "2.9.2"
}
},
{
"identity" : "yams",
"kind" : "remoteSourceControl",
"location" : "https://github.com/jpsim/Yams.git",
"state" : {
"revision" : "3036ba9d69cf1fd04d433527bc339dc0dc75433d",
"version" : "5.1.3"
}
}
],
"version" : 2
Expand Down
14 changes: 0 additions & 14 deletions Ukam/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="22505" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22505"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Application-->
Expand Down Expand Up @@ -680,18 +679,5 @@
</objects>
<point key="canvasLocation" x="75" y="0.0"/>
</scene>
<!--View Controller-->
<scene sceneID="hIz-AP-VOD">
<objects>
<viewController id="XfG-lQ-9wD" customClass="ViewController" customModule="Ukam" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" id="m2S-Jp-Qdl">
<rect key="frame" x="0.0" y="0.0" width="480" height="270"/>
<autoresizingMask key="autoresizingMask"/>
</view>
</viewController>
<customObject id="rPt-NT-nkU" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="75" y="655"/>
</scene>
</scenes>
</document>
27 changes: 27 additions & 0 deletions Ukam/Managers/MenuManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ class MenuManager: NSObject {
popover.behavior = .transient
return popover
}()

private var aboutWindow: NSWindow?

init(windowManager: WindowManager, permissionsManager: PermissionsManager) {
self.windowManager = windowManager
Expand All @@ -40,13 +42,27 @@ class MenuManager: NSObject {
}

statusBarMenu.autoenablesItems = true
statusBarMenu.addItem(
withTitle: R.string.localizable.status_menu_about(),
action: #selector(MenuManager.showAbout),
keyEquivalent: "").target = self
statusBarMenu.addItem(
withTitle: R.string.localizable.status_menu_exit(),
action: #selector(MenuManager.exitApp),
keyEquivalent: "").target = self

windowsViewController.delegate = self
}

@objc func showAbout() {
let aboutWindow = self.aboutWindow ?? {
let newWindow = AboutViewController.createWindow()
newWindow.delegate = self
self.aboutWindow = newWindow
return newWindow
}()
aboutWindow.makeKeyAndOrderFront(nil)
}

@objc func exitApp() {
NSApplication.shared.terminate(self)
Expand Down Expand Up @@ -87,3 +103,14 @@ extension MenuManager: WindowsViewControllerDelegate {
popover.close()
}
}

extension MenuManager: NSWindowDelegate {
func windowWillClose(_ notification: Notification) {
guard let window = notification.object as? NSWindow
else { return }

if window == aboutWindow {
aboutWindow = nil
}
}
}
45 changes: 45 additions & 0 deletions Ukam/Views/About/AboutView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//
// AboutView.swift
// Ukam
//
// Created by Nobuhiro Ito on 2024/08/10.
//

import SwiftUI

struct AboutView: View {
let versionString = { () -> String in
let marketingVersion = (Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String) ?? ""
let buildNumber = (Bundle.main.infoDictionary?["CFBundleVersion"] as? String) ?? ""
return "\(marketingVersion) (\(buildNumber))"
}()

@State private var showingSheet = false

var body: some View {
VStack(spacing: LayoutConstants.padding * 2) {
VStack(alignment: .center) {
Image(.imageIcon)
Text(R.string.localizable.app_name()).font(.title)
Text(versionString).font(.subheadline)
Text(R.string.localizable.about_view_copyright())
.font(.subheadline)
}
VStack(alignment: .trailing) {
Button(R.string.localizable.about_view_acknowledgements()) {
self.showingSheet.toggle()
}
.sheet(isPresented: $showingSheet) {
AcknowledgementsView(dataSource: BundleAcknowledgementsDataSource())
}
}
.frame(maxWidth: .infinity, alignment: .trailing)
}
.frame(maxWidth: LayoutConstants.aboutViewWidth)
.padding(LayoutConstants.padding * 2)
}
}

#Preview {
AboutView()
}
Loading