generated from StanfordBDHG/SwiftPackageTemplate
-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modifications: * replace `protocol` `OnboardingIdentifiableView` with simple conformance to `View & Identifiable` * create a new view modifier `.id(_:)` wrapping any `View` in a `struct OnboardingIdenfiableView` which is `View & Identifiable` and contains the specified `id` as a property * hoist `OnboardingStepIdentifier` overloaded intializers into different `OnboardingNavigationPath.append()` methods * remove `OnboardingIdentifiableTestViewDefault`
- Loading branch information
1 parent
5b3ff1a
commit 8edfc57
Showing
9 changed files
with
62 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
39 changes: 39 additions & 0 deletions
39
Sources/SpeziOnboarding/OnboardingIdentifiableViewModifier.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// | ||
// This source file is part of the Stanford Spezi open-source project | ||
// | ||
// SPDX-FileCopyrightText: 2024 Stanford University and the project authors (see CONTRIBUTORS.md) | ||
// | ||
// SPDX-License-Identifier: MIT | ||
// | ||
|
||
import SwiftUI | ||
|
||
/// Wrap `Content` `View` in an `Identifiable` `View`. | ||
public struct OnboardingIdentifiableView<Content>: View, Identifiable where Content: View { | ||
/// Unique identifier of the wrapped `View`. | ||
public let id: String | ||
/// Wrapped `View`. | ||
public var body: Content | ||
} | ||
|
||
struct OnboardingIdentifiableViewModifier: ViewModifier { | ||
let identifier: String | ||
|
||
func body(content: Content) -> some View { | ||
OnboardingIdentifiableView( | ||
id: self.identifier, | ||
body: content | ||
) | ||
} | ||
} | ||
|
||
|
||
extension View { | ||
/// `ViewModifier` assigning an identifier to the `View` it is applied to. | ||
/// When applying this modifier repeatedly, the outermost ``id(_:)`` counts. | ||
/// - Parameters: | ||
/// - identifier: The `String` identifier given to the view. | ||
public func id(_ identifier: String) -> some View { | ||
modifier(OnboardingIdentifiableViewModifier(identifier: identifier)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 0 additions & 39 deletions
39
Tests/UITests/TestApp/Views/OnboardingIdentifiableTestViewDefault.swift
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters