8000 Customize app info panel in preparation of links for app review · codeface-io/Codeface@49ab7dc · GitHub
[go: up one dir, main page]

Skip to content

Commit 49ab7dc

Browse files
committed
Customize app info panel in preparation of links for app review
1 parent 878a47f commit 49ab7dc

File tree

8 files changed

+103
-15
lines changed

8 files changed

+103
-15
lines changed

Code/App/AboutPanel.swift

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import SwiftUI
2+
import Foundation
3+
import SwiftyToolz
4+
5+
@MainActor
6+
enum AboutPanel
7+
{
8+
static func show(sender: Any? = nil)
9+
{
10+
shared.makeKeyAndOrderFront(sender)
11+
}
12+
13+
static let shared: NSPanel =
14+
{
15+
let panel = NSPanel(contentViewController: NSHostingController(rootView: AboutView()))
16+
panel.title = "About \(Bundle.main.name ?? "This App")"
17+
return panel
18+
}()
19+
}
20+
21+
struct AboutView: View
22+
{
23+
var body: some View
24+
{
25+
Center
26+
{
27+
VStack(spacing: 10)
28+
{
29+
AppIcon()
30+
.frame(minWidth: 100, minHeight: 100)
31+
32+
if let name = Bundle.main.name
33+
{
34+
Text(name)
35+
.font(.title)
36+
.fixedSize()
37+
}
38+
39+
if let version = Bundle.main.version,
40+
let buildNumber = Bundle.main.buildNumber
41+
{
42+
Text("Version \(version) (\(buildNumber))")
43+
.fixedSize()
44+
}
45+
46+
if let copyright = Bundle.main.copyright
47+
{
48+
Text(copyright)
49+
.fixedSize()
50+
}
51+
}
52+
.padding()
53+
}
54+
}
55+
}

Code/App/CodefaceApp.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ struct CodefaceApp: App
4242
}
4343
.commands
4444
{
45+
CommandGroup(replacing: .appInfo)
46+
{
47+
Button("About Codeface")
48+
{
49+
AboutPanel.show()
50+
}
51+
}
52+
4553
CommandGroup(after: .appInfo)
4654
{
4755
if let focusedDocumentWindow

Code/App/In App Purchase/Subscription Panel/SubscriptionPanel.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,7 @@ struct SubscriptionPanel: View
5858

5959
HStack(spacing: 0)
6060
{
61-
Image("AppIconImage")
62-
.resizable()
63-
.aspectRatio(contentMode: .fit)
61+
AppIcon()
6462

6563
GeometryReader
6664
{

Code/App/TestingDashboard.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ struct TestingDashboard: Scene
2222
NSApp.debugLogWindows()
2323
}
2424

25+
LargeButton("Log Bundle Infos")
26+
{
27+
Bundle.main.debugLogInfos()
28+
}
29+
2530
Spacer()
2631
}
2732
.frame(maxWidth: 250)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import SwiftUI
2+
import FoundationToolz
3+
import SwiftyToolz
4+
5+
struct AppIcon: View
6+
{
7+
var body: some View
8+
{
9+
let iconName = Bundle.main.iconName ?? "AppIcon"
10+
11+
if let nsImage = NSImage(named: iconName)
12+
{
13+
Image(nsImage: nsImage)
14+
.resizable()
15+
.aspectRatio(contentMode: .fit)
16+
}
17+
else
18+
{
19+
let errorMessage = "Found no image named '\(iconName)'"
20+
Text(errorMessage)
21+
.onAppear { log(error: errorMessage) }
22+
}
23+
}
24+
}

XCodeProject/Codeface.xcodeproj/project.pbxproj

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@
5252
964464BE295204DB0004382F /* CodebaseAnalysisContentPanel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 964464BD295204DB0004382F /* CodebaseAnalysisContentPanel.swift */; };
5353
964464BF295204F70004382F /* PathBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 964464BA295204900004382F /* PathBar.swift */; };
5454
964464C02952052C0004382F /* CodebaseProcessor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 964464BB295204900004382F /* CodebaseProcessor.swift */; };
55+
9651AC0E29D2F7940054FB52 /* AboutPanel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9651AC0D29D2F7940054FB52 /* AboutPanel.swift */; };
56+
9651AC1229D310EC0054FB52 /* AppIcon.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9651AC1129D310EC0054FB52 /* AppIcon.swift */; };
5557
9656A69F25287F0D00D4CF26 /* SwiftyToolz in Frameworks */ = {isa = PBXBuildFile; productRef = 9656A69E25287F0D00D4CF26 /* SwiftyToolz */; };
5658
965795AE2954652C00CB9F3F /* EmptyProcesorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 965795AD2954652C00CB9F3F /* EmptyProcesorView.swift */; };
5759
965795B12954687300CB9F3F /* CodebaseProcessorState.swift in Sources */ = {isa = PBXBuildFile; fileRef = 965795B02954687300CB9F3F /* CodebaseProcessorState.swift */; };
@@ -188,6 +190,9 @@
188190
964464BA295204900004382F /* PathBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PathBar.swift; sourceTree = "<group>"; };
189191
964464BB295204900004382F /* CodebaseProcessor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CodebaseProcessor.swift; sourceTree = "<group>"; };
190192
964464BD295204DB0004382F /* CodebaseAnalysisContentPanel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CodebaseAnalysisContentPanel.swift; sourceTree = "<group>"; };
193+
9651AC0D29D2F7940054FB52 /* AboutPanel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AboutPanel.swift; sourceTree = "<group>"; };
194+
9651AC1129D310EC0054FB52 /* AppIcon.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppIcon.swift; sourceTree = "<group>"; };
195+
9651AC1329D313460054FB52 /* FoundationToolz */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = FoundationToolz; path = ../../FoundationToolz; sourceTree = "<group>"; };
191196
965795AD2954652C00CB9F3F /* EmptyProcesorView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmptyProcesorView.swift; sourceTree = "<group>"; };
192197
965795B02954687300CB9F3F /* CodebaseProcessorState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CodebaseProcessorState.swift; sourceTree = "<group>"; };
193198
965795B22954697700CB9F3F /* Search.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Search.swift; sourceTree = "<group>"; };
@@ -657,6 +662,7 @@
657662
9E00727C218E250E0094BD1C /* CodefaceApp.swift */,
658663
961BB8F229D1938A005E6080 /* CodefaceAppDelegate.swift */,
659664
960C4D6A29C3C170009282A2 /* TestingDashboard.swift */,
665+
9651AC0D29D2F7940054FB52 /* AboutPanel.swift */,
660666
964151E029D0F968008E6074 /* FindAndFilterMenuOptions.swift */,
661667
964151DE29D0F925008E6074 /* ViewMenuOptions.swift */,
662668
965A7AD629649FB7006C5A3A /* Document Window */,
@@ -696,6 +702,7 @@
696702
9E95A6FA218C73C7009A58A9 = {
697703
isa = PBXGroup;
698704
children = (
705+
9651AC1329D313460054FB52 /* FoundationToolz */,
699706
96E0C0BC29D0800F0087A79F /* SwiftyToolz */,
700707
9E00727A218E250E0094BD1C /* Code */,
701708
96E5A9C629BD171A00B0A913 /* App Store Synced.storekit */,
@@ -748,6 +755,7 @@
748755
961D497429A26A8A00E95E99 /* RelativeFilePath.swift */,
749756
96E479CF28359C9900762FD7 /* AnimatableLine.swift */,
750757
961BB8F429D19E1E005E6080 /* NSApplication+NSWindow.swift */,
758+
9651AC1129D310EC0054FB52 /* AppIcon.swift */,
751759
);
752760
path = "Framework-Candidates";
753761
sourceTree = "<group>";
@@ -931,6 +939,7 @@
931939
96D59CC3294AB895003C55B5 /* CodebaseCentralView.swift in Sources */,
932940
96106E662962DF1C0002F13C /* CodeSymbolArtifact+CodeSymbol.swift in Sources */,
933941
96E135072962DD5900DF8A43 /* ArtifactViewModel+Layout.swift in Sources */,
942+
9651AC1229D310EC0054FB52 /* AppIcon.swift in Sources */,
934943
96E5A9C329BCC87200B0A913 /* ProductID+Codeface.swift in Sources */,
935944
96E479D228359CCE00762FD7 /* ArtifactView.swift in Sources */,
936945
961D497529A26A8A00E95E99 /* RelativeFilePath.swift in Sources */,
@@ -955,6 +964,7 @@
955964
9619A2B92967104E00863BC0 /* CodeArtifact+Metrics.swift in Sources */,
956965
9619A2B22966E57700863BC0 /* CodebaseAnalysis.swift in Sources */,
957966
964464C02952052C0004382F /* CodebaseProcessor.swift in Sources */,
967+
9651AC0E29D2F7940054FB52 /* AboutPanel.swift in Sources */,
958968
96E0C0C529D084A00087A79F /* Center.swift in Sources */,
959969
9619A2B42966E87C00863BC0 /* ProcessingFailureView.swift in Sources */,
960970
960A7AAE28ABB0A000F334CA /* CodeView.swift in Sources */,
Binary file not shown.

XCodeProject/Codeface/Assets.xcassets/AppIconImage.imageset/Contents.json

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)
0