Skip to content

Commit

Permalink
Review supereg
Browse files Browse the repository at this point in the history
Modifications:

* add links in DocC
* remove superflous type `OnboardingIdentifiableView`
  • Loading branch information
felixschlegel committed Apr 22, 2024
1 parent bdb41b6 commit 74aaecb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 18 deletions.
4 changes: 2 additions & 2 deletions Sources/SpeziOnboarding/OnboardingFlow/OnboardingStack.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ import SwiftUI
///
/// ### Identifying Onboarding Views
///
/// Apply the `onboardingIdentifier(_:)` modifier to clearly identify a view in the `OnboardingStack`.
/// Apply the ``SwiftUI/View/onboardingIdentifier(_:)`` modifier to clearly identify a view in the `OnboardingStack`.
/// This is particularly useful in scenarios where multiple instances of the same view type might appear in the stack.
///
/// ```swift
Expand All @@ -69,7 +69,7 @@ import SwiftUI
/// }
/// ```
///
/// - Note: When the `onboardingIdentifier(_:)` modifier is applied multiple times to the same view, the most recently applied identifier takes precedence.
/// - Note: When the ``SwiftUI/View/onboardingIdentifier(_:)`` modifier is applied multiple times to the same view, the outermost identifier takes precedence.
public struct OnboardingStack: View {
@State var onboardingNavigationPath: OnboardingNavigationPath
private let collection: _OnboardingFlowViewCollection
Expand Down
21 changes: 5 additions & 16 deletions Sources/SpeziOnboarding/OnboardingIdentifiableViewModifier.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,17 @@

import SwiftUI

/// Wrap `Content` `View` in an `Identifiable` `View`.
private struct OnboardingIdentifiableView<Content, ID>: View, Identifiable where Content: View, ID: Hashable {
/// Unique identifier of the wrapped `View`.
let id: ID
/// Wrapped `View`.
let body: Content
}

private struct OnboardingIdentifiableViewModifier<ID>: ViewModifier, Identifiable where ID: Hashable {
let id: ID

func body(content: Content) -> some View {
OnboardingIdentifiableView(
id: self.id,
body: content
)
}
func body(content: Content) -> some View { content }
}

extension View {
/// `ViewModifier` assigning an identifier to the `View` it is applied to.
/// When applying this modifier repeatedly, the outermost ``onboardingIdentifier(_:)`` counts.
/// Assign a unique identifier to a ``SwiftUI/View`` appearing in an ``OnboardingStack``.
///
/// A `ViewModifier` assigning an identifier to the `View` it is applied to.
/// When applying this modifier repeatedly, the outermost ``SwiftUI/View/onboardingIdentifier(_:)`` counts.
///
/// - Note: This `ViewModifier` should only be used to identify `View`s of the same type within an ``OnboardingStack``.
///
Expand Down

0 comments on commit 74aaecb

Please sign in to comment.