1

I've tried everything I can think of but I can't get this button to fire consistently when nested inside a ScrollView. If I change the ScrollView to a List, it works fine, but I don't want the UI of a list on the Watch, I would prefer to use a ScrollView. I think it's related to the system detecting taps to scroll and taps on the button but not sure how to fix or any workarounds?

struct WatchWorkoutSummaryView: View {
    
    @EnvironmentObject var workoutManager:  WorkoutManager
    
    
    var body: some View {
        ScrollView {
            EffortLevelRingViewForWatch(workoutState: WatchWorkoutState.After)
            Divider()
                .padding(.horizontal)
            IntensityViewForWatch()
            Divider()
                .padding(.horizontal)
            HeartRateZonesViewForWatch(workoutState: WatchWorkoutState.After)
            Divider()
                .padding(.horizontal)
            AerobicAnaerobicWatchMasterView()
            Divider()
                .padding(.horizontal)
            VStack {
                SummaryView().environmentObject(workoutManager)
                Button(action: {
                    print("button is tapped")
                    workoutManager.dismissLiveWorkoutTabViewSheet()
                    workoutManager.resetWorkoutManager()
                }, label: {
                    Text("Done")
                        .foregroundColor(.white)
                    
                })
                    .background(
                        
                        Color.buttonColor
                            .cornerRadius(10)
                            
                    )
                   
                    .buttonStyle(BorderedButtonStyle(tint: .clear))
                    .padding(.horizontal)
                    .animation(nil)
            }
            .padding(.vertical)
        }
        //This doesn't work.
        .animation(nil) 
    }
}
GarySabo
  • 5,806
  • 5
  • 49
  • 124
  • 2
    Provided code is not testable. Try to remove everything and keep only a button for testing, then remove all modifiers, then add by one simple views... and you'll find the origin. I don't think it is due to ScrollView. – Asperi Jun 10 '22 at 18:45
  • @Asperi thanks you are right, a button inside a Scrollview by itself works, but I still am unable to isolate what might be the cause – GarySabo Jun 10 '22 at 21:36
  • As mentioned, the code cannot be tested, but you could try adding a `VStack`, such as: `ScrollView { VStack {...}}` – workingdog support Ukraine Jun 11 '22 at 01:57

0 Answers0