diff --git a/Xcodes.xcodeproj/project.pbxproj b/Xcodes.xcodeproj/project.pbxproj index 6ace20e2..078e3507 100644 --- a/Xcodes.xcodeproj/project.pbxproj +++ b/Xcodes.xcodeproj/project.pbxproj @@ -115,8 +115,7 @@ E81D7EA02805250100A205FC /* Collection+.swift in Sources */ = {isa = PBXBuildFile; fileRef = E81D7E9F2805250100A205FC /* Collection+.swift */; }; E832EAF82B0FBCF4001B570D /* RuntimeInstallationStepDetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E832EAF72B0FBCF4001B570D /* RuntimeInstallationStepDetailView.swift */; }; E84B7D0D2B296A8900DBDA2B /* NavigationSplitViewWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = E84B7D0C2B296A8900DBDA2B /* NavigationSplitViewWrapper.swift */; }; - E84B7D0F2B30986700DBDA2B /* InfoPane2.swift in Sources */ = {isa = PBXBuildFile; fileRef = E84B7D0E2B30986700DBDA2B /* InfoPane2.swift */; }; - E84CF8C12B0FEB8300ECA259 /* RuntimesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E84CF8C02B0FEB8300ECA259 /* RuntimesView.swift */; }; + E84E4F522B323A5F003F3959 /* CornerRadiusModifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = E84E4F512B323A5F003F3959 /* CornerRadiusModifier.swift */; }; E86671272B309D2F0048559A /* PlatformsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E86671262B309D2F0048559A /* PlatformsView.swift */; }; E87AB3C52939B65E00D72F43 /* Hardware.swift in Sources */ = {isa = PBXBuildFile; fileRef = E87AB3C42939B65E00D72F43 /* Hardware.swift */; }; E87DD6EB25D053FA00D86808 /* Progress+.swift in Sources */ = {isa = PBXBuildFile; fileRef = E87DD6EA25D053FA00D86808 /* Progress+.swift */; }; @@ -313,8 +312,7 @@ E81D7E9F2805250100A205FC /* Collection+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Collection+.swift"; sourceTree = ""; }; E832EAF72B0FBCF4001B570D /* RuntimeInstallationStepDetailView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RuntimeInstallationStepDetailView.swift; sourceTree = ""; }; E84B7D0C2B296A8900DBDA2B /* NavigationSplitViewWrapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationSplitViewWrapper.swift; sourceTree = ""; }; - E84B7D0E2B30986700DBDA2B /* InfoPane2.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InfoPane2.swift; sourceTree = ""; }; - E84CF8C02B0FEB8300ECA259 /* RuntimesView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RuntimesView.swift; sourceTree = ""; }; + E84E4F512B323A5F003F3959 /* CornerRadiusModifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CornerRadiusModifier.swift; sourceTree = ""; }; E856BB73291EDD3D00DC438B /* XcodesKit */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = XcodesKit; path = Xcodes/XcodesKit; sourceTree = ""; }; E86671262B309D2F0048559A /* PlatformsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlatformsView.swift; sourceTree = ""; }; E87AB3C42939B65E00D72F43 /* Hardware.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Hardware.swift; sourceTree = ""; }; @@ -651,9 +649,8 @@ B0C6AD0A2AD9178E00E64698 /* IdenticalBuildView.swift */, B0C6AD0C2AD91D7900E64698 /* IconView.swift */, E832EAF72B0FBCF4001B570D /* RuntimeInstallationStepDetailView.swift */, - E84CF8C02B0FEB8300ECA259 /* RuntimesView.swift */, - E84B7D0E2B30986700DBDA2B /* InfoPane2.swift */, E86671262B309D2F0048559A /* PlatformsView.swift */, + E84E4F512B323A5F003F3959 /* CornerRadiusModifier.swift */, ); path = InfoPane; sourceTree = ""; @@ -875,7 +872,6 @@ CA9FF8CF25959A9700E47BAF /* HelperXPCShared.swift in Sources */, CA735109257BF96D00EA9CF8 /* AttributedText.swift in Sources */, CAFBDC4E2599B33D003DCC5A /* MainToolbar.swift in Sources */, - E84CF8C12B0FEB8300ECA259 /* RuntimesView.swift in Sources */, CA11E7BA2598476C00D2EE1C /* XcodeCommands.swift in Sources */, CAA8589B25A2B83000ACF8C0 /* Aria2CError.swift in Sources */, 536CFDD2263C94DE00026CE0 /* SignedInView.swift in Sources */, @@ -904,6 +900,7 @@ B0403CFC2AD9A6BF00137C09 /* InstalledStateButtons.swift in Sources */, 36741BFF291E50F500A85AAE /* FileError.swift in Sources */, CA9FF8872595607900E47BAF /* InstalledXcode.swift in Sources */, + E84E4F522B323A5F003F3959 /* CornerRadiusModifier.swift in Sources */, B0403CF22AD934B600137C09 /* CompatibilityView.swift in Sources */, B0403CFE2ADA712C00137C09 /* InfoPaneControls.swift in Sources */, 53CBAB2C263DCC9100410495 /* XcodesAlert.swift in Sources */, @@ -929,7 +926,6 @@ E8B20CBF2A2EDEC20057D816 /* SDKs+Xcode.swift in Sources */, CA9FF877259528CC00E47BAF /* Version+XcodeReleases.swift in Sources */, CABFAA2D2592FBFC00380FEE /* Configure.swift in Sources */, - E84B7D0F2B30986700DBDA2B /* InfoPane2.swift in Sources */, E84B7D0D2B296A8900DBDA2B /* NavigationSplitViewWrapper.swift in Sources */, CA73510D257BFCEF00EA9CF8 /* NSAttributedString+.swift in Sources */, CAFBDB952598FE96003DCC5A /* FocusedValues.swift in Sources */, diff --git a/Xcodes/Frontend/InfoPane/CompatibilityView.swift b/Xcodes/Frontend/InfoPane/CompatibilityView.swift index a81183bf..f5a583b7 100644 --- a/Xcodes/Frontend/InfoPane/CompatibilityView.swift +++ b/Xcodes/Frontend/InfoPane/CompatibilityView.swift @@ -29,10 +29,7 @@ struct CompatibilityView: View { .font(.largeTitle) } } - .frame(maxWidth: .infinity, alignment: .leading) - .padding() - .background(.background) - .clipShape(RoundedRectangle(cornerRadius: 5, style: .continuous)) + .xcodesBackground() } else { EmptyView() } diff --git a/Xcodes/Frontend/InfoPane/CornerRadiusModifier.swift b/Xcodes/Frontend/InfoPane/CornerRadiusModifier.swift new file mode 100644 index 00000000..4d9d7e27 --- /dev/null +++ b/Xcodes/Frontend/InfoPane/CornerRadiusModifier.swift @@ -0,0 +1,35 @@ +// +// CornerRadiusModifier.swift +// Xcodes +// +// Created by Matt Kiazyk on 2023-12-19. +// + +import Foundation +import SwiftUI + +struct CornerRadiusModifier: ViewModifier { + func body(content: Content) -> some View { + content + .frame(maxWidth: .infinity, alignment: .leading) + .padding() + .background(.background) + .clipShape(RoundedRectangle(cornerRadius: 5, style: .continuous)) + } +} + +extension View { + func xcodesBackground() -> some View { + self.modifier( + CornerRadiusModifier() + ) + } +} + +struct Previews_CornerRadius_Previews: PreviewProvider { + static var previews: some View { + HStack { + Text("XCODES RULES!") + }.xcodesBackground() + } +} diff --git a/Xcodes/Frontend/InfoPane/IdenticalBuildView.swift b/Xcodes/Frontend/InfoPane/IdenticalBuildView.swift index c09f20a8..04ef3b82 100644 --- a/Xcodes/Frontend/InfoPane/IdenticalBuildView.swift +++ b/Xcodes/Frontend/InfoPane/IdenticalBuildView.swift @@ -33,10 +33,7 @@ struct IdenticalBuildsView: View { .font(.subheadline) } } - .frame(maxWidth: .infinity, alignment: .leading) - .padding() - .background(.background) - .clipShape(RoundedRectangle(cornerRadius: 5, style: .continuous)) + .xcodesBackground() .accessibilityElement() .accessibility(label: Text("IdenticalBuilds")) .accessibility(value: Text(accessibilityDescription)) diff --git a/Xcodes/Frontend/InfoPane/InfoPane.swift b/Xcodes/Frontend/InfoPane/InfoPane.swift index 624e89f1..36f33872 100644 --- a/Xcodes/Frontend/InfoPane/InfoPane.swift +++ b/Xcodes/Frontend/InfoPane/InfoPane.swift @@ -8,34 +8,55 @@ import struct XCModel.SDKs struct InfoPane: View { let xcode: Xcode - var body: some View { - ScrollView { - VStack(alignment: .leading, spacing: 16) { - IconView(installState: xcode.installState) - .frame(maxWidth: .infinity, alignment: .center) - - Text(verbatim: "Xcode \(xcode.description) \(xcode.version.buildMetadataIdentifiersDisplay)") - .font(.title) - - InfoPaneControls(xcode: xcode) - - Divider() - - Group { - RuntimesView(xcode: xcode) + ScrollView(.vertical) { + HStack(alignment: .top) { + VStack { + VStack(spacing: 5) { + HStack { + IconView(installState: xcode.installState) + + Text(verbatim: "Xcode \(xcode.description) \(xcode.version.buildMetadataIdentifiersDisplay)") + .font(.title) + .frame(maxWidth: .infinity, alignment: .leading) + } + InfoPaneControls(xcode: xcode) + } + .xcodesBackground() + + + VStack { + Text("Platforms") + .font(.title3) + .frame(maxWidth: .infinity, alignment: .leading) + PlatformsView(xcode: xcode) + } + .xcodesBackground() + } + + VStack(alignment: .leading) { ReleaseDateView(date: xcode.releaseDate, url: xcode.releaseNotesURL) - ReleaseNotesView(url: xcode.releaseNotesURL) - IdenticalBuildsView(builds: xcode.identicalBuilds) CompatibilityView(requiredMacOSVersion: xcode.requiredMacOSVersion) - SDKsView(sdks: xcode.sdks) - CompilersView(compilers: xcode.compilers) + IdenticalBuildsView(builds: xcode.identicalBuilds) + SDKandCompilers } - - Spacer() + .frame(width: 200) + } } } + + @ViewBuilder + var SDKandCompilers: some View { + VStack(alignment: .leading, spacing: 16) { + SDKsView(sdks: xcode.sdks) + CompilersView(compilers: xcode.compilers) + } + .frame(maxWidth: .infinity, alignment: .leading) + .padding() + .background(.background) + .clipShape(RoundedRectangle(cornerRadius: 5, style: .continuous)) + } } #Preview(XcodePreviewName.allCases[0].rawValue) { makePreviewContent(for: 0) } diff --git a/Xcodes/Frontend/InfoPane/InfoPane2.swift b/Xcodes/Frontend/InfoPane/InfoPane2.swift deleted file mode 100644 index 8f8eaa8d..00000000 --- a/Xcodes/Frontend/InfoPane/InfoPane2.swift +++ /dev/null @@ -1,176 +0,0 @@ -// -// InfoPane2.swift -// Xcodes -// -// Created by Matt Kiazyk on 2023-12-18. -// - -import AppKit -import Path -import SwiftUI -import Version -import struct XCModel.Compilers -import struct XCModel.SDKs - -struct InfoPane2: View { - - let xcode: Xcode - var body: some View { - ScrollView(.vertical) { - HStack(alignment: .top) { - VStack { - VStack(spacing: 5) { - HStack { - IconView(installState: xcode.installState) - - Text(verbatim: "Xcode \(xcode.description) \(xcode.version.buildMetadataIdentifiersDisplay)") - .font(.title) - .frame(maxWidth: .infinity, alignment: .leading) - } - InfoPaneControls(xcode: xcode) - } - .frame(maxWidth: .infinity, alignment: .leading) - .padding() - .background(.background) - .clipShape(RoundedRectangle(cornerRadius: 5, style: .continuous)) - - - VStack { - Text("Platforms") - .font(.title3) - .frame(maxWidth: .infinity, alignment: .leading) - PlatformsView(xcode: xcode) - } - .frame(maxWidth: .infinity, alignment: .leading) - .padding() - .background(.background) - .clipShape(RoundedRectangle(cornerRadius: 5, style: .continuous)) - } - - VStack(alignment: .leading) { - ReleaseDateView(date: xcode.releaseDate, url: xcode.releaseNotesURL) - CompatibilityView(requiredMacOSVersion: xcode.requiredMacOSVersion) - IdenticalBuildsView(builds: xcode.identicalBuilds) - SDKandCompilers - } - .frame(width: 200) - - } - } - } - - @ViewBuilder - var SDKandCompilers: some View { - VStack(alignment: .leading, spacing: 16) { - SDKsView(sdks: xcode.sdks) - CompilersView(compilers: xcode.compilers) - } - .frame(maxWidth: .infinity, alignment: .leading) - .padding() - .background(.background) - .clipShape(RoundedRectangle(cornerRadius: 5, style: .continuous)) - } -} - -#Preview(XcodePreviewName.allCases[0].rawValue) { makePreviewContent(for: 0) } -#Preview(XcodePreviewName.allCases[1].rawValue) { makePreviewContent(for: 1) } -#Preview(XcodePreviewName.allCases[2].rawValue) { makePreviewContent(for: 2) } -#Preview(XcodePreviewName.allCases[3].rawValue) { makePreviewContent(for: 3) } -#Preview(XcodePreviewName.allCases[4].rawValue) { makePreviewContent(for: 4) } - -private func makePreviewContent(for index: Int) -> some View { - let name = XcodePreviewName.allCases[index] - return InfoPane2(xcode: xcodeDict[name]!) - .environmentObject(configure(AppState()) { - $0.allXcodes = [xcodeDict[name]!] - }) - .frame(width: 600, height: 400) - .padding() -} - -enum Preview2Name: String, CaseIterable, Identifiable { - case Populated_Installed_Selected - case Populated_Installed_Unselected - case Populated_Uninstalled - case Basic_Installed - case Basic_Installing - - var id: Preview2Name { self } -} - -var xcodeDict2: [Preview2Name: Xcode] = [ - .Populated_Installed_Selected: .init( - version: _versionNoMeta, - installState: .installed(Path(_path)!), - selected: true, - icon: NSWorkspace.shared.icon(forFile: _path), - requiredMacOSVersion: _requiredMacOSVersion, - releaseNotesURL: URL(string: "https://developer.apple.com/documentation/xcode-release-notes/xcode-12_3-release-notes/")!, - releaseDate: Date(), - sdks: _sdks, - compilers: _compilers, - downloadFileSize: _downloadFileSize - ), - .Populated_Installed_Unselected: .init( - version: _versionNoMeta, - installState: .installed(Path(_path)!), - selected: false, - icon: NSWorkspace.shared.icon(forFile: _path), - sdks: _sdks, - compilers: _compilers, - downloadFileSize: _downloadFileSize - ), - .Populated_Uninstalled: .init( - version: Version(major: 12, minor: 3, patch: 0), - installState: .notInstalled, - selected: false, - icon: nil, - sdks: _sdks, - compilers: _compilers, - downloadFileSize: _downloadFileSize - ), - .Basic_Installed: .init( - version: _versionWithMeta, - installState: .installed(Path(_path)!), - selected: false, - icon: nil, - sdks: nil, - compilers: nil - ), - .Basic_Installing: .init( - version: _versionWithMeta, - installState: .installing(.downloading( - progress: configure(Progress()) { - $0.kind = .file - $0.fileOperationKind = .downloading - $0.estimatedTimeRemaining = 123 - $0.totalUnitCount = 11_944_848_484 - $0.completedUnitCount = 848_444_920 - $0.throughput = 9_211_681 - } - )), - selected: false, - icon: nil, - sdks: nil, - compilers: nil - ), -] - -private let _versionNoMeta = Version(major: 12, minor: 3, patch: 0) -private let _versionWithMeta = Version(major: 12, minor: 3, patch: 1, buildMetadataIdentifiers: ["1234A"]) -private let _path = "/Applications/Xcode-12.3.0.app" -private let _requiredMacOSVersion = "10.15.4" -private let _sdks = SDKs( - macOS: .init(number: "11.1"), - iOS: .init(number: "14.3"), - watchOS: .init(number: "7.3"), - tvOS: .init(number: "14.3") -) -private let _compilers = Compilers( - gcc: .init(number: "4"), - llvm_gcc: .init(number: "213"), - llvm: .init(number: "2.3"), - clang: .init(number: "7.3"), - swift: .init(number: "5.3.2") -) -private let _downloadFileSize: Int64 = 242_342_424 diff --git a/Xcodes/Frontend/InfoPane/RuntimesView.swift b/Xcodes/Frontend/InfoPane/RuntimesView.swift deleted file mode 100644 index 5148c716..00000000 --- a/Xcodes/Frontend/InfoPane/RuntimesView.swift +++ /dev/null @@ -1,78 +0,0 @@ -// -// RuntimesView.swift -// Xcodes -// -// Created by Matt Kiazyk on 2023-11-23. -// Copyright © 2023 Robots and Pencils. All rights reserved. -// - -import SwiftUI -import XcodesKit - -struct RuntimesView: View { - @EnvironmentObject var appState: AppState - let xcode: Xcode - - var body: some View { - VStack(alignment: .leading) { - Text("Platforms") - .font(.headline) - .frame(maxWidth: .infinity, alignment: .leading) - - let builds = xcode.sdks?.allBuilds() - let runtimes = builds?.flatMap { sdkBuild in - appState.downloadableRuntimes.filter { - $0.sdkBuildUpdate == sdkBuild - } - } - - ForEach(runtimes ?? [], id: \.simulatorVersion.buildUpdate) { runtime in - VStack { - runtimeRow(runtime: runtime) - } - - } - } - } - - @ViewBuilder - func runtimeRow(runtime: DownloadableRuntime) -> some View { - HStack { - Text("\(runtime.visibleIdentifier)") - .font(.subheadline) - Spacer() - Text(runtime.downloadFileSizeString) - .font(.subheadline) - - switch runtime.installState { - case .installed, .notInstalled: - // it's installed if we have a path - if let path = appState.runtimeInstallPath(xcode: xcode, runtime: runtime) { - Button(action: { appState.reveal(path: path.string) }) { - Image(systemName: "arrow.right.circle.fill") - } - .buttonStyle(PlainButtonStyle()) - .help("RevealInFinder") - } else { - DownloadRuntimeButton(runtime: runtime) - } - case .installing(_): - CancelRuntimeInstallButton(runtime: runtime) - } - - } - - switch runtime.installState { - - case .installing(let installationStep): - RuntimeInstallationStepDetailView(installationStep: installationStep) - .fixedSize(horizontal: false, vertical: true) - default: - EmptyView() - } - } -} - -//#Preview { -// RuntimesView() -//} diff --git a/Xcodes/Frontend/MainWindow.swift b/Xcodes/Frontend/MainWindow.swift index f0a75e4d..cee42acb 100644 --- a/Xcodes/Frontend/MainWindow.swift +++ b/Xcodes/Frontend/MainWindow.swift @@ -37,7 +37,7 @@ struct MainWindow: View { } detail: { Group { if let xcode = xcode { - InfoPane2(xcode: xcode) + InfoPane(xcode: xcode) } else { UnselectedView() } diff --git a/Xcodes/Resources/Localizable.xcstrings b/Xcodes/Resources/Localizable.xcstrings index be5230fd..b7d3d62e 100644 --- a/Xcodes/Resources/Localizable.xcstrings +++ b/Xcodes/Resources/Localizable.xcstrings @@ -18443,6 +18443,9 @@ } } } + }, + "XCODES RULES!" : { + } }, "version" : "1.0"