1
votes

I'm trying to make a horizontal scrollview that has multiple lists embedded inside of it, thing is that even implementing the delete method i can scroll the lists or the scrollviews but i can't use the delete action.

I wonder if is there any way i can overcome this problem, maybe by making the scrollview non-scrollable when the finger is on the cell or if there's a smarter option.

Here's the code:

 var body: some View {
    ScrollView(.horizontal, showsIndicators: true){
        HStack(alignment: .top, spacing: 60){
            ForEach(data.trips[0].days){ day in
                    List{
                        Section{
                            Text(String((day as Day).date))
                            ForEach(day.stops){ stop in
                                Text((stop as Stop).title)
                            }.onDelete(perform: self.delete)
                        }
                    }
                .listStyle(GroupedListStyle())
            }
        }.frame(width:800)
    }.background(Color.clear)
}

func delete(at offsets: IndexSet){
    print(offsets)
}

Of course it slides left/right through the scrollview and up/down through the list

1
You can consider adding EditButton/EditMode explicitly. - Asperi

1 Answers

0
votes

You're using a bunch of built-in conveniences like ScrollView and List, and I don't think there's any way to override their behaviours selectively by making only part of the field scrollable.

And even if you did hack that together, I think it would be really unintuitive for the user. It would mix the UI swipe metaphors in a way that isn't obvious at all.

You'll have to either implement your own scroll widget for the HStack, or add a delete interface.