Skip to content

Commit 48f1543

Browse files
committed
Make it better for cross-platform apps with SwiftUI
1 parent 5539fed commit 48f1543

File tree

1 file changed

+47
-26
lines changed

1 file changed

+47
-26
lines changed

Sources/TutorialAbout/View/AboutView.swift

Lines changed: 47 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -39,40 +39,61 @@ public struct AboutView: View {
3939
public init (react_items: [AboutModel]) {
4040
self.items = react_items
4141
}
42+
43+
// MARK: - COMPILER DIRECTIVE
44+
#if os(iOS)
45+
@Environment(\.horizontalSizeClass) var hsClass: UserInterfaceSizeClass?
46+
#endif
47+
4248
// MARK: - SOME SORT OF VIEW
4349
public var body: some View {
44-
NavigationView {
45-
VStack {
46-
AboutBackgroundView()
47-
.padding(.top, -15)
48-
49-
List {
50-
Section(
51-
header: Text(NSLocalizedString("IMPROVEMENT US", comment: "IMPROVEMENT US"))
52-
.font(.custom("Nunito-Regular", size: 25, relativeTo: .largeTitle))
53-
) {
54-
ForEach(improvementCase(items: items)) {
55-
AboutSectionView(aboutModel: $0)
56-
}
57-
}
50+
#if os(iOS)
51+
if hsClass == .compact {
52+
NavigationView {
53+
view
54+
}
55+
.accentColor(Color("AccentColor"))
56+
} else {
57+
view
58+
}
59+
#else
60+
view
61+
.frame(minWidth: 400, minHeight: 600)
62+
#endif
63+
}
5864

59-
Section(
60-
header: Text(NSLocalizedString("CONNECTING WITH US", comment: "CONNECTING WITH US"))
61-
.font(.custom("Nunito-Regular", size: 25, relativeTo: .largeTitle))
62-
) {
63-
ForEach(socialCase(items: items)) {
64-
AboutSectionView(aboutModel: $0)
65-
}
65+
@ViewBuilder
66+
private var view: some View {
67+
VStack {
68+
AboutBackgroundView()
69+
.padding(.top, -15)
70+
71+
List {
72+
Section(
73+
header: Text(NSLocalizedString("IMPROVEMENT US", comment: "IMPROVEMENT US"))
74+
.font(.custom("Nunito-Regular", size: 25, relativeTo: .largeTitle))
75+
) {
76+
ForEach(improvementCase(items: items)) {
77+
AboutSectionView(aboutModel: $0)
6678
}
6779
}
68-
.listStyle(.grouped)
69-
.padding(.top, -15)
7080

71-
Spacer()
81+
Section(
82+
header: Text(NSLocalizedString("CONNECTING WITH US", comment: "CONNECTING WITH US"))
83+
.font(.custom("Nunito-Regular", size: 25, relativeTo: .largeTitle))
84+
) {
85+
ForEach(socialCase(items: items)) {
86+
AboutSectionView(aboutModel: $0)
87+
}
88+
}
7289
}
73-
.navigationTitle(NSLocalizedString("About Us", comment: "About Us"))
74-
.navigationBarTitleDisplayMode(.automatic)
90+
.listStyle(.grouped)
91+
.padding(.top, -15)
92+
93+
Spacer()
7594
}
95+
.navigationTitle(NSLocalizedString("About Us", comment: "About Us"))
96+
.navigationBarTitleDisplayMode(.automatic)
7697
}
7798

7899
// MARK: - METHODS

0 commit comments

Comments
 (0)