Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CarouselStack inside List #78

Open
kkotar opened this issue Nov 23, 2023 · 0 comments
Open

CarouselStack inside List #78

kkotar opened this issue Nov 23, 2023 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@kkotar
Copy link

kkotar commented Nov 23, 2023

Describe the bug
If CarouselStack is used within a List, and when swiping a card to the right, the card jumps back to the center, but after the animation is complete, the correct card is selected.

To Reproduce
Minimum amount of code to reproduce:

import SwiftUI
import Combine
import ShuffleIt

struct CarouselStackDemoView: View {
    @Environment(\.dismiss) var dismiss
    @State private var sneaker: Sneaker?
    @State private var isShowItems: Bool = false
    let carouselPublisher = PassthroughSubject<CarouselDirection, Never>()
    let timer = Timer.publish(every: 10, tolerance: 0.1, on: .main, in: .default).autoconnect()
    @Environment(\.horizontalSizeClass) var horizontalSizeClass
    let columns: [GridItem] = .init(repeating: GridItem(.flexible(), spacing: 20, alignment: .leading), count: 2)
    let sneakers: [Sneaker] = .sneakers()
    
    var body: some View {
        List {
            CarouselStack(sneakers, initialIndex: 0) { sneaker, translation in
                SneakerCard(sneaker: sneaker, translation: translation)
            }
            .carouselScale(0.7)
            .carouselPadding(horizontalSizeClass == .compact ? 20 : 40)
            .carouselSpacing(horizontalSizeClass == .compact ? 10 : 30)
            .carouselStyle(.finiteScroll)
        }
        .listStyle(.plain)

        .overlay(alignment: .topTrailing) {
            Button(action: {
                dismiss()
            }) {
                Image(systemName: "xmark.circle.fill")
                    .font(.largeTitle)
                    .foregroundStyle(.white)
                    .background {
                        Circle()
                            .foregroundColor(.black.opacity(0.4))
                            .padding(4)
                    }
            }
            .buttonStyle(.plain)
            .padding(.horizontal, 20)
        }
    }
}

Steps to reproduce the behavior:

  1. Go to 'CaraouselStackDemoView' and replace view with code from above.
  2. Swipe card left or right.
  3. See card jumps back after swipe.

Expected behavior
If card is swiped to the right, the next card should be displayed in the centre.

Screenshots
If applicable, add screenshots to help explain your problem.

Device information (please complete the following information):

  • Device: iPhone/Simulator
  • OS: iOS 17.0
  • Xcode version: Xcode 15

Additional context
Add any other context about the problem here.

@kkotar kkotar added the bug Something isn't working label Nov 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants