diff --git a/SodaLive/Sources/Explorer/Profile/UserProfileView.swift b/SodaLive/Sources/Explorer/Profile/UserProfileView.swift index 290301b..2afc57c 100644 --- a/SodaLive/Sources/Explorer/Profile/UserProfileView.swift +++ b/SodaLive/Sources/Explorer/Profile/UserProfileView.swift @@ -20,6 +20,8 @@ struct UserProfileView: View { @State private var isShowRouletteSettings: Bool = false @State private var isShowMenuSettings: Bool = false + @State private var maxCommunityPostHeight: CGFloat? = nil + var body: some View { GeometryReader { proxy in BaseView(isLoading: $viewModel.isLoading) { @@ -95,6 +97,12 @@ struct UserProfileView: View { step: .creatorCommunityAll(creatorId: userId) ) } + .background( + GeometryReader { geo in + Color.clear + .preference(key: HeightPreferenceKey.self, value: geo.size.height) + } + ) } CreatorCommunityMoreItemView { @@ -105,8 +113,15 @@ struct UserProfileView: View { } } .padding(.horizontal, 13.3) + .frame(height: maxCommunityPostHeight) + .onPreferenceChange(HeightPreferenceKey.self) { value in + if let current = maxCommunityPostHeight { + maxCommunityPostHeight = max(current, value) + } else { + maxCommunityPostHeight = value + } + } } - .frame(minHeight: 146) .padding(.top, 26.7) } else { if UserDefaults.int(forKey: .userId) == creatorProfile.creator.creatorId { @@ -211,7 +226,7 @@ struct UserProfileView: View { .padding(.top, 26.7) } } - + UserProfileFanTalkView( userId: userId, cheers: creatorProfile.cheers, @@ -399,6 +414,13 @@ struct UserProfileView: View { } } +struct HeightPreferenceKey: PreferenceKey { + static var defaultValue: CGFloat = 0 + static func reduce(value: inout CGFloat, nextValue: () -> CGFloat) { + value = max(value, nextValue()) // 가장 큰 height로 갱신 + } +} + struct UserProfileView_Previews: PreviewProvider { static var previews: some View { UserProfileView(userId: 0)