// // AutoSlideCharacterBannerView.swift // SodaLive // // Created by klaus on 8/29/25. // import SwiftUI import Kingfisher struct AutoSlideCharacterBannerView: View { var items: [CharacterBannerResponse] = [] var onTap: (CharacterBannerResponse) -> Void = { _ in } @State private var currentIndex: Int = 0 @State private var height: CGFloat = 0 private let timer = Timer.publish(every: 4, on: .main, in: .common).autoconnect() var body: some View { VStack(spacing: 8) { TabView(selection: $currentIndex) { ForEach(0.. Void @State private var boundURL: URL? var body: some View { Group { if let boundURL { DownsampledKFImage( url: boundURL, size: CGSize(width: width, height: height) ).cornerRadius(12) } else { Color.clear .frame(width: width, height: height) .cornerRadius(12) } } .contentShape(Rectangle()) .onTapGesture { onTap(item) } .onAppear { let encoded = item.imageUrl.addingPercentEncoding( withAllowedCharacters: .urlQueryAllowed ) ?? item.imageUrl boundURL = URL(string: encoded) } .onDisappear { boundURL = nil } } }