diff --git a/Xcodes.xcodeproj/project.pbxproj b/Xcodes.xcodeproj/project.pbxproj index 701b465..da34e5f 100644 --- a/Xcodes.xcodeproj/project.pbxproj +++ b/Xcodes.xcodeproj/project.pbxproj @@ -14,6 +14,7 @@ 53CBAB2C263DCC9100410495 /* XcodesAlert.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53CBAB2B263DCC9100410495 /* XcodesAlert.swift */; }; 63EAA4EB259944450046AB8F /* ProgressButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63EAA4EA259944450046AB8F /* ProgressButton.swift */; }; B0403CF02AD92D7B00137C09 /* ReleaseNotesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0403CEF2AD92D7B00137C09 /* ReleaseNotesView.swift */; }; + B0403CF22AD934B600137C09 /* CompatibilityView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0403CF12AD934B600137C09 /* CompatibilityView.swift */; }; B0C6AD042AD6E65700E64698 /* ReleaseDateView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0C6AD032AD6E65700E64698 /* ReleaseDateView.swift */; }; B0C6AD0B2AD9178E00E64698 /* IdenticalBuildView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0C6AD0A2AD9178E00E64698 /* IdenticalBuildView.swift */; }; B0C6AD0D2AD91D7900E64698 /* IconView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0C6AD0C2AD91D7900E64698 /* IconView.swift */; }; @@ -197,6 +198,7 @@ AAB037D32839BD4700017680 /* ko */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ko; path = ko.lproj/Localizable.strings; sourceTree = ""; }; AB4EB0DE28541FA000FF3B1D /* ja */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ja; path = ja.lproj/Localizable.strings; sourceTree = ""; }; B0403CEF2AD92D7B00137C09 /* ReleaseNotesView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReleaseNotesView.swift; sourceTree = ""; }; + B0403CF12AD934B600137C09 /* CompatibilityView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CompatibilityView.swift; sourceTree = ""; }; B0C6AD032AD6E65700E64698 /* ReleaseDateView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReleaseDateView.swift; sourceTree = ""; }; B0C6AD0A2AD9178E00E64698 /* IdenticalBuildView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IdenticalBuildView.swift; sourceTree = ""; }; B0C6AD0C2AD91D7900E64698 /* IconView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IconView.swift; sourceTree = ""; }; @@ -624,6 +626,7 @@ isa = PBXGroup; children = ( B0403CEF2AD92D7B00137C09 /* ReleaseNotesView.swift */, + B0403CF12AD934B600137C09 /* CompatibilityView.swift */, CAFBDC67259A308B003DCC5A /* InfoPane.swift */, E8E98A9525D863D700EC89A0 /* InstallationStepDetailView.swift */, B0C6AD032AD6E65700E64698 /* ReleaseDateView.swift */, @@ -875,6 +878,7 @@ CABFA9CD2592EEEA00380FEE /* Foundation.swift in Sources */, 36741BFF291E50F500A85AAE /* FileError.swift in Sources */, CA9FF8872595607900E47BAF /* InstalledXcode.swift in Sources */, + B0403CF22AD934B600137C09 /* CompatibilityView.swift in Sources */, 53CBAB2C263DCC9100410495 /* XcodesAlert.swift in Sources */, CA42DD6E25AEA8B200BC0B0C /* Logger.swift in Sources */, CA61A6E0259835580008926E /* Xcode.swift in Sources */, diff --git a/Xcodes/Frontend/InfoPane/CompatibilityView.swift b/Xcodes/Frontend/InfoPane/CompatibilityView.swift new file mode 100644 index 0000000..9e23e35 --- /dev/null +++ b/Xcodes/Frontend/InfoPane/CompatibilityView.swift @@ -0,0 +1,57 @@ +// +// CompatibilityView.swift +// Xcodes +// +// Created by Duong Thai on 13/10/2023. +// Copyright © 2023 Robots and Pencils. All rights reserved. +// + +import SwiftUI + +struct CompatibilityView: View { + let requiredMacOSVersion: String? + + var body: some View { + if let requiredMacOSVersion = requiredMacOSVersion { + VStack(alignment: .leading) { + Text("Compatibility") + .font(.headline) + Text(String(format: localizeString("MacOSRequirement"), requiredMacOSVersion)) + .font(.subheadline) + } + } else { + EmptyView() + } + } +} + +struct CompatibilityView_Preview: PreviewProvider { + static var previews: some View { + WrapperView() + } +} + +private struct WrapperView: View { + @State var isNil = false + var requiredMacOSVersion: String? { + isNil + ? nil + : "10.15.4" + } + + var body: some View { + VStack { + HStack { + CompatibilityView(requiredMacOSVersion: requiredMacOSVersion) + .border(.red) + } + Spacer() + Toggle(isOn: $isNil) { + Text("Is Nil?") + } + } + .animation(.default) + .frame(width: 200, height: 100) + .padding() + } +} diff --git a/Xcodes/Frontend/InfoPane/InfoPane.swift b/Xcodes/Frontend/InfoPane/InfoPane.swift index 293d804..26e1c47 100644 --- a/Xcodes/Frontend/InfoPane/InfoPane.swift +++ b/Xcodes/Frontend/InfoPane/InfoPane.swift @@ -58,7 +58,7 @@ struct InfoPane: View { ReleaseDateView(date: xcode.releaseDate) .frame(maxWidth: .infinity, alignment: .leading) IdenticalBuildsView(builds: xcode.identicalBuilds) - compatibility(for: xcode) + CompatibilityView(requiredMacOSVersion: xcode.requiredMacOSVersion) sdks(for: xcode) compilers(for: xcode) } @@ -74,22 +74,6 @@ struct InfoPane: View { } } - @ViewBuilder - private func compatibility(for xcode: Xcode) -> some View { - if let requiredMacOSVersion = xcode.requiredMacOSVersion { - VStack(alignment: .leading) { - Text("Compatibility") - .font(.headline) - .frame(maxWidth: .infinity, alignment: .leading) - Text(String(format: localizeString("MacOSRequirement"), requiredMacOSVersion)) - .font(.subheadline) - .frame(maxWidth: .infinity, alignment: .leading) - } - } else { - EmptyView() - } - } - @ViewBuilder private func sdks(for xcode: Xcode) -> some View { if let sdks = xcode.sdks {