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

Messing with SwiftUI #20

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
4 changes: 4 additions & 0 deletions DefaultBrowser.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
C5A333771BDAF6EA000767B2 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C5A333761BDAF6EA000767B2 /* AppDelegate.swift */; };
C5A333791BDAF6EA000767B2 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C5A333781BDAF6EA000767B2 /* Assets.xcassets */; };
C5A3337C1BDAF6EA000767B2 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = C5A3337A1BDAF6EA000767B2 /* MainMenu.xib */; };
C5AF631129327A380087D317 /* AboutView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C5AF631029327A380087D317 /* AboutView.swift */; };
C5E39DC21BE83B48004E722B /* Defaults.swift in Sources */ = {isa = PBXBuildFile; fileRef = C5E39DC11BE83B48004E722B /* Defaults.swift */; };
/* End PBXBuildFile section */

Expand All @@ -23,6 +24,7 @@
C5A3337D1BDAF6EA000767B2 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
C5AEAF5D29292C0A00F57C2F /* test.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = test.html; sourceTree = "<group>"; };
C5AEAF5E29292C2900F57C2F /* .github */ = {isa = PBXFileReference; lastKnownFileType = folder; path = .github; sourceTree = "<group>"; };
C5AF631029327A380087D317 /* AboutView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AboutView.swift; sourceTree = "<group>"; };
C5C938A0249BF1AD0008EF81 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
C5E39DC11BE83B48004E722B /* Defaults.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Defaults.swift; sourceTree = "<group>"; };
C5E39DC31BE893EA004E722B /* Default Browser.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = "Default Browser.entitlements"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -63,6 +65,7 @@
isa = PBXGroup;
children = (
C5A333761BDAF6EA000767B2 /* AppDelegate.swift */,
C5AF631029327A380087D317 /* AboutView.swift */,
C58951F31BEAD8BA0093EE2E /* SystemUtilities.swift */,
C5E39DC11BE83B48004E722B /* Defaults.swift */,
C5A333781BDAF6EA000767B2 /* Assets.xcassets */,
Expand Down Expand Up @@ -189,6 +192,7 @@
buildActionMask = 2147483647;
files = (
C58951F41BEAD8BA0093EE2E /* SystemUtilities.swift in Sources */,
C5AF631129327A380087D317 /* AboutView.swift in Sources */,
C5E39DC21BE83B48004E722B /* Defaults.swift in Sources */,
C5A333771BDAF6EA000767B2 /* AppDelegate.swift in Sources */,
);
Expand Down
50 changes: 50 additions & 0 deletions DefaultBrowser/AboutView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
//
// About.swift
// Default Browser
//
// Created by Cameron Little on 2022-11-26.
// Copyright © 2022 Cameron Little. All rights reserved.
//

import SwiftUI

let shortVersion = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String ?? "<unknown>"
let buildNumber = Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") as? String ?? "<unknown>"

@available(macOS 10.15, *)
extension Text {
func withSmallFontStyle() -> some View {
self
.font(.system(size: NSFont.smallSystemFontSize))
.multilineTextAlignment(.center)
}
}

@available(macOS 10.15, *)
struct AboutView: View {
var body: some View {
VStack(spacing: 20) {
Image("AppIcon")
.resizable()
.scaledToFill()
.frame(width: 32, height: 100)
Text("DefaultBrowser will automatically open links using the last browser you've used. You can disable this temporarily by clicking the menu icon and choosing a browser.")
VStack(spacing: 8) {
Text("Version \(shortVersion) (\(buildNumber))")
Text("Built by [Cameron Little](https://camlittle.com)")
Text("[GitHub project](https://github.com/apexskier/DefaultBrowser)")
}
.font(.system(size: NSFont.smallSystemFontSize))
.multilineTextAlignment(.center)
}
.frame(maxWidth: 340)
.padding(.all)
}
}

@available(macOS 10.15.0, *)
struct AboutView_Previews: PreviewProvider {
static var previews: some View {
AboutView()
}
}
2 changes: 1 addition & 1 deletion DefaultBrowser/Base.lproj/MainMenu.xib
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@
<rect key="frame" x="0.0" y="0.0" width="351" height="20"/>
<clipView key="contentView" drawsBackground="NO" id="HLa-tW-YeF">
<rect key="frame" x="1" y="1" width="349" height="18"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="none" columnReordering="NO" columnSelection="YES" columnResizing="NO" autosaveColumns="NO" rowHeight="16" rowSizeStyle="automatic" viewBased="YES" id="1Y3-hC-x8X">
<rect key="frame" x="0.0" y="0.0" width="349" height="18"/>
Expand Down
2 changes: 1 addition & 1 deletion DefaultBrowser/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>130</string>
<string>153</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>LSMinimumSystemVersion</key>
Expand Down