Skip to content

Commit 77ca8a2

Browse files
committed
move the compatibility view to CompatibilityView.swift
1 parent f1fea63 commit 77ca8a2

3 files changed

Lines changed: 62 additions & 17 deletions

File tree

Xcodes.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
53CBAB2C263DCC9100410495 /* XcodesAlert.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53CBAB2B263DCC9100410495 /* XcodesAlert.swift */; };
1515
63EAA4EB259944450046AB8F /* ProgressButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63EAA4EA259944450046AB8F /* ProgressButton.swift */; };
1616
B0403CF02AD92D7B00137C09 /* ReleaseNotesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0403CEF2AD92D7B00137C09 /* ReleaseNotesView.swift */; };
17+
B0403CF22AD934B600137C09 /* CompatibilityView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0403CF12AD934B600137C09 /* CompatibilityView.swift */; };
1718
B0C6AD042AD6E65700E64698 /* ReleaseDateView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0C6AD032AD6E65700E64698 /* ReleaseDateView.swift */; };
1819
B0C6AD0B2AD9178E00E64698 /* IdenticalBuildView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0C6AD0A2AD9178E00E64698 /* IdenticalBuildView.swift */; };
1920
B0C6AD0D2AD91D7900E64698 /* IconView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0C6AD0C2AD91D7900E64698 /* IconView.swift */; };
@@ -197,6 +198,7 @@
197198
AAB037D32839BD4700017680 /* ko */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ko; path = ko.lproj/Localizable.strings; sourceTree = "<group>"; };
198199
AB4EB0DE28541FA000FF3B1D /* ja */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ja; path = ja.lproj/Localizable.strings; sourceTree = "<group>"; };
199200
B0403CEF2AD92D7B00137C09 /* ReleaseNotesView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReleaseNotesView.swift; sourceTree = "<group>"; };
201+
B0403CF12AD934B600137C09 /* CompatibilityView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CompatibilityView.swift; sourceTree = "<group>"; };
200202
B0C6AD032AD6E65700E64698 /* ReleaseDateView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReleaseDateView.swift; sourceTree = "<group>"; };
201203
B0C6AD0A2AD9178E00E64698 /* IdenticalBuildView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IdenticalBuildView.swift; sourceTree = "<group>"; };
202204
B0C6AD0C2AD91D7900E64698 /* IconView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IconView.swift; sourceTree = "<group>"; };
@@ -624,6 +626,7 @@
624626
isa = PBXGroup;
625627
children = (
626628
B0403CEF2AD92D7B00137C09 /* ReleaseNotesView.swift */,
629+
B0403CF12AD934B600137C09 /* CompatibilityView.swift */,
627630
CAFBDC67259A308B003DCC5A /* InfoPane.swift */,
628631
E8E98A9525D863D700EC89A0 /* InstallationStepDetailView.swift */,
629632
B0C6AD032AD6E65700E64698 /* ReleaseDateView.swift */,
@@ -875,6 +878,7 @@
875878
CABFA9CD2592EEEA00380FEE /* Foundation.swift in Sources */,
876879
36741BFF291E50F500A85AAE /* FileError.swift in Sources */,
877880
CA9FF8872595607900E47BAF /* InstalledXcode.swift in Sources */,
881+
B0403CF22AD934B600137C09 /* CompatibilityView.swift in Sources */,
878882
53CBAB2C263DCC9100410495 /* XcodesAlert.swift in Sources */,
879883
CA42DD6E25AEA8B200BC0B0C /* Logger.swift in Sources */,
880884
CA61A6E0259835580008926E /* Xcode.swift in Sources */,
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
//
2+
// CompatibilityView.swift
3+
// Xcodes
4+
//
5+
// Created by Duong Thai on 13/10/2023.
6+
// Copyright © 2023 Robots and Pencils. All rights reserved.
7+
//
8+
9+
import SwiftUI
10+
11+
struct CompatibilityView: View {
12+
let requiredMacOSVersion: String?
13+
14+
var body: some View {
15+
if let requiredMacOSVersion = requiredMacOSVersion {
16+
VStack(alignment: .leading) {
17+
Text("Compatibility")
18+
.font(.headline)
19+
Text(String(format: localizeString("MacOSRequirement"), requiredMacOSVersion))
20+
.font(.subheadline)
21+
}
22+
} else {
23+
EmptyView()
24+
}
25+
}
26+
}
27+
28+
struct CompatibilityView_Preview: PreviewProvider {
29+
static var previews: some View {
30+
WrapperView()
31+
}
32+
}
33+
34+
private struct WrapperView: View {
35+
@State var isNil = false
36+
var requiredMacOSVersion: String? {
37+
isNil
38+
? nil
39+
: "10.15.4"
40+
}
41+
42+
var body: some View {
43+
VStack {
44+
HStack {
45+
CompatibilityView(requiredMacOSVersion: requiredMacOSVersion)
46+
.border(.red)
47+
}
48+
Spacer()
49+
Toggle(isOn: $isNil) {
50+
Text("Is Nil?")
51+
}
52+
}
53+
.animation(.default)
54+
.frame(width: 200, height: 100)
55+
.padding()
56+
}
57+
}

Xcodes/Frontend/InfoPane/InfoPane.swift

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ struct InfoPane: View {
5858
ReleaseDateView(date: xcode.releaseDate)
5959
.frame(maxWidth: .infinity, alignment: .leading)
6060
IdenticalBuildsView(builds: xcode.identicalBuilds)
61-
compatibility(for: xcode)
61+
CompatibilityView(requiredMacOSVersion: xcode.requiredMacOSVersion)
6262
sdks(for: xcode)
6363
compilers(for: xcode)
6464
}
@@ -74,22 +74,6 @@ struct InfoPane: View {
7474
}
7575
}
7676

77-
@ViewBuilder
78-
private func compatibility(for xcode: Xcode) -> some View {
79-
if let requiredMacOSVersion = xcode.requiredMacOSVersion {
80-
VStack(alignment: .leading) {
81-
Text("Compatibility")
82-
.font(.headline)
83-
.frame(maxWidth: .infinity, alignment: .leading)
84-
Text(String(format: localizeString("MacOSRequirement"), requiredMacOSVersion))
85-
.font(.subheadline)
86-
.frame(maxWidth: .infinity, alignment: .leading)
87-
}
88-
} else {
89-
EmptyView()
90-
}
91-
}
92-
9377
@ViewBuilder
9478
private func sdks(for xcode: Xcode) -> some View {
9579
if let sdks = xcode.sdks {

0 commit comments

Comments
 (0)