fermoya / SwiftUIPager

Native Pager in SwiftUI
MIT License
1.29k stars 172 forks source link

[FEAT] Where is itemTappable option mentioned in the Medium article? #131

Closed dinotrnka closed 4 years ago

dinotrnka commented 4 years ago

Is your feature request related to a problem? Please describe.

Hi! In the Medium article I saw a mention of a feature: itemTappable - makes the pages clickable. But I can't find it in the library itself. Can someone please clarify?

Also, I'd like to know whether this feature enables the user to tap on non-focused page in order to switch to that page, because I could really make use of that functionality.

Thanks.

fermoya commented 4 years ago

Hi @dinotrnka , I published that article long ago, with the first version of the framework. I decided to remove it as it’s something that can very easily be achieved by using onTapGesture and setting the page index and it’s very specific to certain users. As the library aims to be of general purpose, this went away. It was creating trouble to some users too as gesture management is not quite well defined yet in SwiftUI.

I don’t think it’s worth bringing it back but I’m happy to share code to do so if needed

dinotrnka commented 4 years ago

Hi @fermoya, thanks for your response. If you could share the code for that specific case then I'd be very grateful. Thanks!

fermoya commented 4 years ago

So you need to do:

Pager(page: $pageIndex, 
           data: myData) { index in
    MyPage(index: index)
        .onTapGesture {
            withAnimation {
                pageIndex = index
            }
     }
}
dinotrnka commented 4 years ago

Thanks, works like a charm!