Skip to content

Commit 2fdc060

Browse files
committed
fix SDKView logic, hide the view when the content is empty
1 parent 2f7d45c commit 2fdc060

1 file changed

Lines changed: 16 additions & 6 deletions

File tree

Xcodes/Frontend/InfoPane/SDKsView.swift

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,28 @@ import SwiftUI
1010
import struct XCModel.SDKs
1111

1212
struct SDKsView: View {
13-
let sdks: SDKs?
13+
let content: String
1414

1515
var body: some View {
16-
if let sdks = sdks {
16+
if content.isEmpty {
17+
EmptyView()
18+
} else {
1719
VStack(alignment: .leading) {
1820
Text("SDKs").font(.headline)
19-
Text(Self.content(from: sdks)).font(.subheadline)
21+
Text(content).font(.subheadline)
2022
}
21-
} else {
22-
EmptyView()
2323
}
2424
}
2525

26+
init(sdks: SDKs?) {
27+
guard let sdks = sdks else {
28+
self.content = ""
29+
return
30+
}
31+
let content = Self.content(from: sdks)
32+
self.content = content
33+
}
34+
2635
static private func content(from sdks: SDKs) -> String {
2736
let content: String = [
2837
("macOS", sdks.macOS),
@@ -41,6 +50,7 @@ struct SDKsView: View {
4150
// description for each type of compilers
4251
return "\($0.0): \(numbers.joined(separator: ", "))"
4352
}.joined(separator: "\n")
53+
.trimmingCharacters(in: .whitespaces)
4454

4555
return content
4656
}
@@ -68,7 +78,7 @@ private struct WrapperView: View {
6878
SDKsView(sdks: sdks).border(.red)
6979
Spacer()
7080
Toggle(isOn: $isNil) {
71-
Text("Is Nil?")
81+
Text("Empty Content?")
7282
}
7383
}
7484
.frame(width: 200, height: 100)

0 commit comments

Comments
 (0)