fix(character-banner): indicator 위치 수정
This commit is contained in:
		@@ -12,12 +12,13 @@ struct AutoSlideCharacterBannerView: View {
 | 
			
		||||
    var items: [CharacterBannerResponse] = []
 | 
			
		||||
    var onTap: (CharacterBannerResponse) -> Void = { _ in }
 | 
			
		||||
    
 | 
			
		||||
    @State private var index: Int = 0
 | 
			
		||||
    @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 {
 | 
			
		||||
        TabView(selection: $index) {
 | 
			
		||||
        VStack(spacing: 8) {
 | 
			
		||||
            TabView(selection: $currentIndex) {
 | 
			
		||||
                ForEach(0..<items.count, id: \.self) { index in
 | 
			
		||||
                    let item = items[index]
 | 
			
		||||
                    KFImage(URL(string: item.imageUrl))
 | 
			
		||||
@@ -34,7 +35,7 @@ struct AutoSlideCharacterBannerView: View {
 | 
			
		||||
                        .onTapGesture { onTap(item) }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        .tabViewStyle(.page(indexDisplayMode: .automatic))
 | 
			
		||||
            .tabViewStyle(.page(indexDisplayMode: .never))
 | 
			
		||||
            .frame(maxWidth: .infinity)
 | 
			
		||||
            .frame(height: height)
 | 
			
		||||
            .onAppear {
 | 
			
		||||
@@ -45,7 +46,24 @@ struct AutoSlideCharacterBannerView: View {
 | 
			
		||||
            }
 | 
			
		||||
            .onReceive(timer) { _ in
 | 
			
		||||
                guard !items.isEmpty else { return }
 | 
			
		||||
            withAnimation { index = (index + 1) % items.count }
 | 
			
		||||
                withAnimation { currentIndex = (currentIndex + 1) % items.count }
 | 
			
		||||
            }
 | 
			
		||||
            
 | 
			
		||||
            HStack(spacing: 4) {
 | 
			
		||||
                ForEach(0..<items.count, id: \.self) { index in
 | 
			
		||||
                    Capsule()
 | 
			
		||||
                        .foregroundColor(
 | 
			
		||||
                            index == currentIndex
 | 
			
		||||
                            ? .button
 | 
			
		||||
                            : .gray90
 | 
			
		||||
                        )
 | 
			
		||||
                        .frame(
 | 
			
		||||
                            width: index == currentIndex ? 18 : 6,
 | 
			
		||||
                            height: 6
 | 
			
		||||
                        )
 | 
			
		||||
                        .tag(index)
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user