nachonavarro / Pages

📖 A lightweight, paging view solution for SwiftUI

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

setCurrentItem: positionIndex in ModalPages

csdal opened this issue · comments

For example, we open a book, stopped reading at page number 33. The book resumes at page 1 and we have to flip page by page until page number 33. If the book resumes at page 33, it would be great.

I agree, let me look at how I can include it and I'll come back to you on this.

Hey,

I added the feature that will solve this problem. Now the user has the ability to maintain the state of the current page themselves to do whatever they want with the state:

import Pages

struct ContentView: View {

    @State var index: Int = 0

    var body: some View {
        Pages(currentPage: $index) {
            Text("Page 1")
            Button(action: {
                self.index = 3
            }) {
                Text("This button will go to page 4")
            }
            Text("Page 3")
            Text("Page 4")
        }
        
    }

}