fix(banner): 이미지가 2장씩 넘어가는 버그 수정

This commit is contained in:
Yu Sung
2025-11-20 18:08:54 +09:00
parent 001f161fc5
commit 90b6dfb498
5 changed files with 5 additions and 51 deletions

View File

@@ -79,11 +79,10 @@ private struct AutoSlideCharacterBannerPage: View {
let width: CGFloat let width: CGFloat
let height: CGFloat let height: CGFloat
let onTap: (CharacterBannerResponse) -> Void let onTap: (CharacterBannerResponse) -> Void
@State private var boundURL: URL?
var body: some View { var body: some View {
Group { Group {
if let boundURL { if let boundURL = URL(string: item.imageUrl.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) ?? item.imageUrl){
DownsampledKFImage( DownsampledKFImage(
url: boundURL, url: boundURL,
size: CGSize(width: width, height: height) size: CGSize(width: width, height: height)
@@ -96,14 +95,5 @@ private struct AutoSlideCharacterBannerPage: View {
} }
.contentShape(Rectangle()) .contentShape(Rectangle())
.onTapGesture { onTap(item) } .onTapGesture { onTap(item) }
.onAppear {
let encoded = item.imageUrl.addingPercentEncoding(
withAllowedCharacters: .urlQueryAllowed
) ?? item.imageUrl
boundURL = URL(string: encoded)
}
.onDisappear {
boundURL = nil
}
} }
} }

View File

@@ -82,11 +82,10 @@ private struct ContentMainBannerPage: View {
let item: GetAudioContentBannerResponse let item: GetAudioContentBannerResponse
let width: CGFloat let width: CGFloat
let height: CGFloat let height: CGFloat
@State private var boundURL: URL?
var body: some View { var body: some View {
Group { Group {
if let boundURL { if let boundURL = URL(string: item.thumbnailImageUrl.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) ?? item.thumbnailImageUrl) {
KFImage(boundURL) KFImage(boundURL)
.cancelOnDisappear(true) .cancelOnDisappear(true)
.downsampling(size: CGSize(width: width, height: height)) .downsampling(size: CGSize(width: width, height: height))
@@ -118,15 +117,6 @@ private struct ContentMainBannerPage: View {
} }
} }
} }
.onAppear {
let urlString = item.thumbnailImageUrl.addingPercentEncoding(
withAllowedCharacters: .urlQueryAllowed
) ?? item.thumbnailImageUrl
boundURL = URL(string: urlString)
}
.onDisappear {
boundURL = nil
}
} }
} }

View File

@@ -107,11 +107,10 @@ struct ContentMainBannerImageView: View {
let width: CGFloat let width: CGFloat
let height: CGFloat let height: CGFloat
let item: GetAudioContentBannerResponse let item: GetAudioContentBannerResponse
@State private var boundURL: URL?
var body: some View { var body: some View {
Group { Group {
if let boundURL { if let boundURL = URL(string: url.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) ?? url) {
DownsampledKFImage( DownsampledKFImage(
url: boundURL, url: boundURL,
size: CGSize(width: width, height: height) size: CGSize(width: width, height: height)
@@ -138,12 +137,5 @@ struct ContentMainBannerImageView: View {
} }
} }
} }
.onAppear {
let encoded = url.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) ?? url
boundURL = URL(string: encoded)
}
.onDisappear {
boundURL = nil
}
} }
} }

View File

@@ -80,11 +80,10 @@ struct SeriesMainHomeBannerImageView: View {
let url: String let url: String
let width: CGFloat let width: CGFloat
let height: CGFloat let height: CGFloat
@State private var boundURL: URL?
var body: some View { var body: some View {
Group { Group {
if let boundURL { if let boundURL = URL(string: url.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) ?? url) {
DownsampledKFImage( DownsampledKFImage(
url: boundURL, url: boundURL,
size: CGSize(width: width, height: height) size: CGSize(width: width, height: height)
@@ -97,13 +96,6 @@ struct SeriesMainHomeBannerImageView: View {
} }
} }
.contentShape(Rectangle()) .contentShape(Rectangle())
.onAppear {
let encoded = url.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) ?? url
boundURL = URL(string: encoded)
}
.onDisappear {
boundURL = nil
}
} }
} }

View File

@@ -77,11 +77,10 @@ private struct SectionEventBannerPage: View {
let width: CGFloat let width: CGFloat
let height: CGFloat let height: CGFloat
let token: String let token: String
@State private var boundURL: URL?
var body: some View { var body: some View {
Group { Group {
if let boundURL { if let boundURL = URL(string: item.thumbnailImageUrl.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) ?? item.thumbnailImageUrl) {
KFImage(boundURL) KFImage(boundURL)
.cancelOnDisappear(true) .cancelOnDisappear(true)
.downsampling(size: CGSize(width: width, height: height)) .downsampling(size: CGSize(width: width, height: height))
@@ -108,14 +107,5 @@ private struct SectionEventBannerPage: View {
AppState.shared.setAppStep(step: .login) AppState.shared.setAppStep(step: .login)
} }
} }
.onAppear {
let urlString = item.thumbnailImageUrl.addingPercentEncoding(
withAllowedCharacters: .urlQueryAllowed
) ?? item.thumbnailImageUrl
boundURL = URL(string: urlString)
}
.onDisappear {
boundURL = nil
}
} }
} }