File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,19 +10,28 @@ import SwiftUI
1010import struct XCModel. SDKs
1111
1212struct 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 )
You can’t perform that action at this time.
0 commit comments