diff --git a/SodaLive/Sources/Live/Room/V2/LiveRoomViewV2.swift b/SodaLive/Sources/Live/Room/V2/LiveRoomViewV2.swift index cd59726..7b38a03 100644 --- a/SodaLive/Sources/Live/Room/V2/LiveRoomViewV2.swift +++ b/SodaLive/Sources/Live/Room/V2/LiveRoomViewV2.swift @@ -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 {