-
-
Notifications
You must be signed in to change notification settings - Fork 62
/
Copy pathMessagesView.swift
42 lines (37 loc) · 1.01 KB
/
MessagesView.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//
// MessagesView.swift
// Camel
//
// Created by Alex Rozanski on 26/03/2023.
//
import SwiftUI
struct MessagesView: View {
@ObservedObject var viewModel: MessagesViewModel
@State private var bannerHeight = Double(0)
var body: some View {
MessagesTableView(messages: viewModel.messages)
.frame(maxWidth: .infinity, maxHeight: .infinity)
.overlay {
if viewModel.isBuiltForDebug {
VStack {
DebugBuildBannerView()
.background(
GeometryReader { geometry in
Color.clear.preference(key: BannerHeightKey.self, value: geometry.size.height)
}
)
Spacer()
}
}
}
.onPreferenceChange(BannerHeightKey.self) { newHeight in
bannerHeight = newHeight
}
}
}
fileprivate struct BannerHeightKey: PreferenceKey {
static var defaultValue: CGFloat { 0 }
static func reduce(value: inout Value, nextValue: () -> Value) {
value = value + nextValue()
}
}