Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customised views cannot be passed in iPages Initializer #4

Closed
neptunezxn opened this issue Oct 21, 2020 · 2 comments
Closed

Customised views cannot be passed in iPages Initializer #4

neptunezxn opened this issue Oct 21, 2020 · 2 comments

Comments

@neptunezxn
Copy link

I'm trying out iPages however I encountered the following issue.

It's a very basic usage - one master view initializes iPages and two subviews A and B.

MasterView.swift

import SwiftUI
import iPages

struct MasterView: View {
    @State var currentPage: Int = 0
    var body: some View {
        iPages([SubViewA(), SubViewB()], currentPage: $currentPage)
    }
}

SubViewA.swift

import SwiftUI

struct SubViewA: View {
    var body: some View {
        Text("this is subview A")
    }
}

SubViewB.swift

import SwiftUI

struct SubViewB: View {
    var body: some View {
        Text("this is subview B")
    }
}

The above code does not compile with the unhelpful error as follows.
image

Environment
XCode: Version 12.0.1
macOS: Catalina 10.15.7

Please can anyone suggest if I'm doing anything incorrect or there is a bug somewhere in the library? Thanks in advance!

@blsage
Copy link
Owner

blsage commented Oct 21, 2020

I know what's going on. Will push a fix in a bit.

@blsage
Copy link
Owner

blsage commented Oct 21, 2020

Fixed bug, and updating the documentation now. One thing to be aware of, iPages now takes a trailing view builder closure of ordered views as pages, just like VStack or ZStack:

import SwiftUI
import iPages

struct ContentView: View {
    @State var currentPage: Int = 0

    var body: some View {
        iPages(currentPage: $currentPage) {
            Color.red
            Text("iPages")
        }
    }
}

Let me know if you have any questions or find any more bugs.

@blsage blsage closed this as completed Oct 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants