Skip to content

Commit fee5249

Browse files
committed
Fix style bug
1 parent 3c39d6a commit fee5249

File tree

2 files changed

+43
-13
lines changed

2 files changed

+43
-13
lines changed

RELEASE_NOTES.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ OnboardingKit honors semver.
44

55

66

7+
## 7.0.1
8+
9+
### 🐛 Bug Fixes
10+
11+
* The custom onboarding page view style is now applied on appear, instead of as a task.
12+
13+
14+
715
## 7.0
816

917
This version drastically simplifies the library and bumps the platform deployment targets to more modern platform versions.

Sources/OnboardingKit/Views/OnboardingPageView.swift

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,14 @@ import SwiftUI
1212
import UIKit
1313
#endif
1414

15-
/**
16-
This view can be used to render a collection of pages, that
17-
can be swiped through horizontally.
18-
19-
This will use a regular `TabView` on iOS, and a custom page
20-
view on other platforms.
21-
22-
Apply the `.onboardingPageViewStyle(...)` modifier to style
23-
this view.
24-
*/
15+
/// This view can be used to show a collection of pages that
16+
/// can be swiped through horizontally.
17+
///
18+
/// This view uses a regular SwiftUI `TabView` on iOS, and a
19+
/// custom page view implementation on other platforms.
20+
///
21+
/// Apply an ``SwiftUI/View/onboardingPageViewStyle(_:)`` to
22+
/// your view to customize its style.
2523
public struct OnboardingPageView<Page, PageItemView: View>: View {
2624

2725
/// Create a tutorial page view.
@@ -51,7 +49,7 @@ public struct OnboardingPageView<Page, PageItemView: View>: View {
5149

5250
public var body: some View {
5351
bodyContent
54-
.task { setupAppearance() }
52+
.onAppear { setupAppearance() }
5553
}
5654
}
5755

@@ -72,7 +70,7 @@ private extension OnboardingPageView {
7270
.tag($0.offset)
7371
}
7472
}
75-
.tabViewStyle(.page)
73+
.tabViewStyle(.page(indexDisplayMode: .always))
7674
#else
7775
PageView(
7876
pages: Array(pages.enumerated()),
@@ -99,8 +97,32 @@ private extension OnboardingPageView {
9997
func setupAppearance() {
10098
#if os(iOS)
10199
let appearance = UIPageControl.appearance()
102-
appearance.currentPageIndicatorTintColor = UIColor(style.currentPageIndicatorTintColor)
103100
appearance.pageIndicatorTintColor = UIColor(style.pageIndicatorTintColor)
101+
appearance.currentPageIndicatorTintColor = UIColor(style.currentPageIndicatorTintColor)
104102
#endif
105103
}
106104
}
105+
106+
#Preview {
107+
108+
struct Preview: View {
109+
110+
@State
111+
private var index = 0
112+
113+
var body: some View {
114+
OnboardingPageView(pages: Array(0...10), pageIndex: $index) { index, info in
115+
Text("Page \(index)/\(info.totalPageCount)")
116+
}
117+
.onboardingPageViewStyle(
118+
.init(
119+
pageIndicatorTintColor: .red,
120+
currentPageIndicatorTintColor: .gray
121+
)
122+
)
123+
.background(Color.blue)
124+
}
125+
}
126+
127+
return Preview()
128+
}

0 commit comments

Comments
 (0)