From 76774d3d95a21b5aaa5471184b220bfb57dc907b Mon Sep 17 00:00:00 2001 From: Yu Sung Date: Fri, 17 Oct 2025 01:01:10 +0900 Subject: [PATCH] =?UTF-8?q?fix(creator-channel):=20=EB=82=B4=20=EC=B1=84?= =?UTF-8?q?=EB=84=90=20=EC=BB=A4=EB=AE=A4=EB=8B=88=ED=8B=B0=20=EC=95=84?= =?UTF-8?q?=EC=9D=B4=ED=85=9C=EC=9D=B4=20=EC=9C=84/=EC=95=84=EB=9E=98?= =?UTF-8?q?=EA=B0=80=20=EC=9E=98=EB=A6=AC=EB=8A=94=20=EB=B2=84=EA=B7=B8=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - HeightPreferenceKey를 사용해 아이템 사이즈 동적으로 갱신하여 LazyHStack의 사이즈를 현재 보이는 아이템의 사이즈로 설정하여 잘리는 버그 수정 --- .../Explorer/Profile/UserProfileView.swift | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) 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)