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

Ambiguous reference to member 'node' #68

Closed
tgdn opened this issue Mar 18, 2019 · 3 comments
Closed

Ambiguous reference to member 'node' #68

tgdn opened this issue Mar 18, 2019 · 3 comments

Comments

@tgdn
Copy link

tgdn commented Mar 18, 2019

Copied the example from the README using macOs TokamakAppKit (version 0.1).
macOS 10.14
Xcode 10.1

image

@MaxDesiatov
Copy link
Collaborator

MaxDesiatov commented Mar 18, 2019

Hi @tgdn! Thank you so much for reporting this and I'm so sorry for the example snippet in README not having working code. I will update it right away. Here's the version that should work:

struct Counter: LeafComponent {
  struct Props: Equatable {
    let countFrom: Int
  }

  static func render(props: Props, hooks: Hooks) -> AnyNode {
    let count = hooks.state(props.countFrom)

    return StackView.node(.init(
      Edges.equal(to: .parent),
      axis: .vertical,
      distribution: .fillEqually), [
        Button.node(Button.Props(
          onPress: Handler { count.set { $0 + 1 } },
          text: "Increment"
        )),
        Label.node(.init(alignment: .center, text: "\(count.value)"))
    ])
  }
}

Please bear in mind that macOS renderer supports only a few basic components (compared to iOS renderer, which allows building pretty complex apps), but I'm currently working on adding support for more components in the next version. Also, you'll need to create a view controller that renders your component:

import TokamakAppKit

final class ViewController: TokamakViewController {
  override var node: AnyNode {
    return View.node(
      .init(Style([
        Edges.equal(to: .parent),
        Width.equal(to: 200),
        Height.equal(to: 100),
      ])),
      Counter.node(.init(countFrom: 1))
    )
  }
}

The best way to try Tokamak on both iOS and macOS is to clone the repository and run pod install in the Example directory, which contains sample code for both platforms.

@MaxDesiatov
Copy link
Collaborator

I've just added detailed steps for running the Example project to README, please feel free to reopen the issue and report any other problems. Thanks again!

@tgdn
Copy link
Author

tgdn commented Mar 18, 2019

Thanks for the quick reply. That fixed the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants