Scope store and work with SwiftUIX got wrong UI size #2762
-
I'm trying to use the If I just using normal The other initializer: The reproduce project and detail description in here. If anyone has encountered a similar problem, please give me some advice. 🙏 I also create a issue at SwiftUIX. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
The issue seems to be in SwiftUIX. If you add extension PaginationView {
public init<Data, ID>(
axis: Axis = .horizontal,
transitionStyle: UIPageViewController.TransitionStyle = .scroll,
showsIndicators: Bool = true,
@ViewBuilder // 👈 This is important
content: () -> ForEach<Data, ID, Page>
) where Data.Element: Identifiable {
self.init(
content: .init(content()),
axis: axis,
transitionStyle: transitionStyle,
showsIndicators: showsIndicators
)
}
} Or if you don't want to use that extension you can be very explicit with your types: var body: some View {
PaginationView(
axis: .vertical,
showsIndicators: false
) { () -> ForEach<Array<StoreOf<Page>>, ObjectIdentifier, PageView> in
ForEach(Array(store.scope(state: \.pages, action: \.pages))) { store in
PageView(store: store)
}
}
} |
Beta Was this translation helpful? Give feedback.
The issue seems to be in SwiftUIX. If you add
@ViewBuilder
to thecontent
closure in the initializer you want, then it will work. You can either PR that to SwiftUIX, or you can drop this in your project:Or if you don't want to use t…