fix(creator-channel): 내 채널 커뮤니티 아이템이 위/아래가 잘리는 버그 수정
- HeightPreferenceKey를 사용해 아이템 사이즈 동적으로 갱신하여 LazyHStack의 사이즈를 현재 보이는 아이템의 사이즈로 설정하여 잘리는 버그 수정
This commit is contained in:
@@ -20,6 +20,8 @@ struct UserProfileView: View {
|
|||||||
@State private var isShowRouletteSettings: Bool = false
|
@State private var isShowRouletteSettings: Bool = false
|
||||||
@State private var isShowMenuSettings: Bool = false
|
@State private var isShowMenuSettings: Bool = false
|
||||||
|
|
||||||
|
@State private var maxCommunityPostHeight: CGFloat? = nil
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
GeometryReader { proxy in
|
GeometryReader { proxy in
|
||||||
BaseView(isLoading: $viewModel.isLoading) {
|
BaseView(isLoading: $viewModel.isLoading) {
|
||||||
@@ -95,6 +97,12 @@ struct UserProfileView: View {
|
|||||||
step: .creatorCommunityAll(creatorId: userId)
|
step: .creatorCommunityAll(creatorId: userId)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
.background(
|
||||||
|
GeometryReader { geo in
|
||||||
|
Color.clear
|
||||||
|
.preference(key: HeightPreferenceKey.self, value: geo.size.height)
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
CreatorCommunityMoreItemView {
|
CreatorCommunityMoreItemView {
|
||||||
@@ -105,8 +113,15 @@ struct UserProfileView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.padding(.horizontal, 13.3)
|
.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)
|
.padding(.top, 26.7)
|
||||||
} else {
|
} else {
|
||||||
if UserDefaults.int(forKey: .userId) == creatorProfile.creator.creatorId {
|
if UserDefaults.int(forKey: .userId) == creatorProfile.creator.creatorId {
|
||||||
@@ -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 {
|
struct UserProfileView_Previews: PreviewProvider {
|
||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
UserProfileView(userId: 0)
|
UserProfileView(userId: 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user