라이브방 - 메뉴판 사이즈
- 높이가 500보다 작으면 메뉴의 길이만큼 표시되도록 수정 - 최대 높이 500
This commit is contained in:
parent
88055c47c3
commit
5b55c9d2e3
|
@ -15,6 +15,7 @@ struct LiveRoomViewV2: View {
|
|||
@StateObject var viewModel = LiveRoomViewModel()
|
||||
|
||||
@State private var textHeight: CGFloat = .zero
|
||||
@State private var menuTextHeight: CGFloat = .zero
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
|
@ -341,11 +342,18 @@ struct LiveRoomViewV2: View {
|
|||
.foregroundColor(.white)
|
||||
.lineSpacing(4)
|
||||
}
|
||||
.background(GeometryReader { geometry in
|
||||
Color.clear.preference(key: TextViewHeightKey.self, value: geometry.size.height)
|
||||
})
|
||||
}
|
||||
.padding(8)
|
||||
.background(Color.gray33)
|
||||
.padding(.horizontal, 60)
|
||||
.padding(.bottom, 120)
|
||||
.frame(maxWidth: 350)
|
||||
.frame(height: menuTextHeight > 500 ? 500 : menuTextHeight, alignment: .topLeading)
|
||||
.onPreferenceChange(TextViewHeightKey.self) { value in
|
||||
menuTextHeight = value + 15
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -759,6 +767,13 @@ struct LiveRoomViewV2: View {
|
|||
value += nextValue()
|
||||
}
|
||||
}
|
||||
|
||||
struct TextViewHeightKey: PreferenceKey {
|
||||
static var defaultValue: CGFloat = .zero
|
||||
static func reduce(value: inout CGFloat, nextValue: () -> CGFloat) {
|
||||
value = nextValue()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct LiveRoomViewV2_Previews: PreviewProvider {
|
||||
|
|
Loading…
Reference in New Issue