import SwiftUI
struct ContentView: View {
@Environment(\.horizontalSizeClass) var horizontalClass
var body: some View {
Group {
if horizontalClass == .compact {
VStack(spacing: 0) {
HeaderView(isCompact: true)
BodyView()
}
} else {
HStack(spacing: 0) {
HeaderView(isCompact: false)
BodyView()
}
}
}.ignoresSafeArea()
}
}
struct HeaderView: View {
let isCompact: Bool
var body: some View {
Text("Food Menu")
.frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: isCompact ? 150 : .infinity)
.background(Color.yellow)
}
}
struct BodyView: View {
var body: some View {
Text("Content Title")
.frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity)
.background(Color.gray)
}
}
'SwiftUI' 카테고리의 다른 글
PreferenceKey Protocol (0) | 2023.12.19 |
---|---|
GeometryReader (0) | 2023.12.19 |
Tab View, badge (0) | 2023.12.19 |
Confirmation Dialog - 하단 메뉴 (0) | 2023.12.19 |
Alert View (0) | 2023.12.19 |