Is it possible to use Decompose with SwiftUI NavigationLink? #203
-
|
I was integrating Decompose into an iOS app and was wondering if it's possible to use the struct MainView: View {
private let component: TodoMain
@ObservedObject
private var models: ObservableValue<TodoMainModel>
init(_ component: TodoMain) {
self.component = component
self.models = ObservableValue(component.models)
}
var body: some View {
let model = models.value
return NavigationView {
VStack {
// how would the new component get to the destination parameter?
NavigationLink(destination: Text("View2").navigationBarTitle("Title View2", displayMode: .inline)) {
Text("NavigationLink")
}
ListView(
items: model.items,
onItemClicked: component.onItemClicked,
onDoneChanged: component.onItemDoneChanged
)
InputView(
textBinding: Binding(get: { model.text }, set: component.onInputTextChanged),
onAddClicked: component.onAddItemClicked
)
}.navigationBarTitle("Todo Sample", displayMode: .inline)
}
}
}Using the code above, I understand that the current Any help would be greatly appreciated or if there is a different way of achieving the native gesture without |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
|
First of all, I'm not quite familiar with SwiftUI. As far as I know,
But as far as I know, Also when I was playing with |
Beta Was this translation helpful? Give feedback.

First of all, I'm not quite familiar with SwiftUI. As far as I know,
NavgiationLinkshould be put around each item. I found the following links, which look useful:But as far as I know,
NavigationLinkis active component. It accepts aView, and SwiftUI displays it insideNavigationView. Looks like in this case the navigation is managed by SwiftUI, however ideally it should be managed by Decompose. It's like still using Fragments in Android. So if possible, I would avoid