Closed rb090 closed 1 year ago
I solved this problem I had by building a PageControl
element like @esikmalazman did it in SwiftUI-UIPageControl
And this element I put now below the Pager { ... }
, so my code looks in the end like this:
VStack {
// 'currentPage' is a '@StateObject' defined outside the `var body: some View { }` -> `@StateObject var currentPage = Page.withIndex(0)`
Pager(page: currentPage, data: items, id: \.self) { item in
MyView(item: item)
}
.sensitivity(.high)
.preferredItemSize(CGSize(width: CONST_FOR_WIDTH, height: CONST_FOR_HEIGHT))
.itemSpacing(12)
// Pager element to have the page indicator
PageControl(currentPageIndex: currentPage.index, numberOfPages: items.count).padding(.bottom, 20)
}
My colleague @sebbu gave me this tip, by moving my thoughts to UIPageControl
. This UIKit element is used for UIKit pager elements and can be easily rebuild into SwiftUI.
But is there a way to please integrate the PageControl to this library and be able to enable it by a ViewModifier
I think a PageControl
is out of the scope of the library. I leave this to the user to implement if desired
Is your feature request related to a problem? Please describe.
I started using SwiftUIPager. I like it a lot. I want to use it, because I want to show a pager where the end of the previous element and the begging of the next element in the pager is visible:
There is only one thing I am missing atm. This is a page indicator about the current page index like SwiftUI has for the
TabView
element. When I useTabView
I am settingtabViewStyle
topage
and there I can specify thePageTabViewStyle.IndexDisplayMode
:This results in:
Describe the solution you'd like
It would be nice to please have a
ViewModifier
for thePager
element to enable displaying those index indicator dots at the bottom.But maybe there is already sth like this provided by this library and I did not find it yet? 😬
Describe alternatives you've considered
I considered to implement an own Indicator dots element similar to this:
But with this I do not achieve this nice effect of dots getting "fade out" on many elements, which fe. standard on SwiftUI when using
indexDisplayMode
:Plus on many elements I end up in weird behaviors, like the
ForEach
overgrow theHStack
container:When I add
.clipping()
after the.frame(...)
on theHStack
theForEach
is in the bounds ofHStack
, but the 1st element of theForEach
is not visible and so on. So I run in one problem after the other.And with this I have not this "fading and shrinking" out of the page indicator view like with
TabView
Additional context
/