From b6ba6264f78e62b7be53106c2d0dde995ad3b013 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Sat, 24 Jan 2026 16:46:38 -0600 Subject: [PATCH] Signed-off-by: Matt Bruce --- .../Views/Table/CompactHandView.swift | 54 +++++++++++-------- 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/Baccarat/Baccarat/Views/Table/CompactHandView.swift b/Baccarat/Baccarat/Views/Table/CompactHandView.swift index 485ee17..cf55e2a 100644 --- a/Baccarat/Baccarat/Views/Table/CompactHandView.swift +++ b/Baccarat/Baccarat/Views/Table/CompactHandView.swift @@ -92,32 +92,40 @@ struct CompactHandView: View { GeometryReader { geometry in let availableWidth = geometry.size.width - ScrollViewReader { proxy in - ScrollView(.horizontal, showsIndicators: false) { - cardsContent - .padding(.horizontal, Design.Spacing.medium) - .frame(minWidth: availableWidth, alignment: .center) - .id("cards_container") - } - .scrollDisabled(cards.count < 3) - .scrollClipDisabled(true) // Prevent clipping during deal animations - .background(Color.clear) - .onChange(of: cards.count) { _, newCount in - // When 3rd card is dealt, wait for animation then scroll - if newCount == 3 { - let lastIndex = isBottom ? 4 : 5 - DispatchQueue.main.asyncAfter(deadline: .now() + 0.8) { - withAnimation(.spring(duration: 0.5)) { - proxy.scrollTo(lastIndex, anchor: .center) + if isLargeScreen { + // iPad: Simple centered layout - no scrolling needed + cardsContent + .padding(.horizontal, Design.Spacing.medium) + .frame(width: availableWidth, alignment: .center) + } else { + // iPhone: Use ScrollView for 3rd card + ScrollViewReader { proxy in + ScrollView(.horizontal, showsIndicators: false) { + cardsContent + .padding(.horizontal, Design.Spacing.medium) + .frame(minWidth: availableWidth, alignment: .center) + .id("cards_container") + } + .scrollDisabled(cards.count < 3) + .scrollClipDisabled(true) // Prevent clipping during deal animations + .background(Color.clear) + .onChange(of: cards.count) { _, newCount in + // When 3rd card is dealt, wait for animation then scroll + if newCount == 3 { + let lastIndex = isBottom ? 4 : 5 + DispatchQueue.main.asyncAfter(deadline: .now() + 0.8) { + withAnimation(.spring(duration: 0.5)) { + proxy.scrollTo(lastIndex, anchor: .center) + } } } } - } - .onChange(of: currentRevealIndex) { _, newIndex in - // Scroll to the active card during interaction - if newIndex >= 4 { - withAnimation(.spring(duration: 0.5)) { - proxy.scrollTo(newIndex, anchor: .center) + .onChange(of: currentRevealIndex) { _, newIndex in + // Scroll to the active card during interaction + if newIndex >= 4 { + withAnimation(.spring(duration: 0.5)) { + proxy.scrollTo(newIndex, anchor: .center) + } } } }