forked from StanfordSpezi/SpeziAccount
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow to supply active account details with the AccountConfiguration …
…for previews (StanfordSpezi#46) # Allow to supply active account details with the AccountConfiguration for previews ## ♻️ Current situation & Problem As of right now the desired way to provide access to the `Account` object for previewing purposes with active account details, is by creating the `Account` instance yourself and putting it into the environment. With the introduction of the new `previewWith` modifier in Spezi `1.0`, we now have a framework-defined way of configuring modules for Previews. Therefore, this PR adds support to configure the `AccountConfiguration` for previewing purposes. ## ⚙️ Release Notes * Add `AccountConfiguration(building:active:configuration:)` initializer to easily preview Spezi Account using the new spezi `previewWith` modifier. ## 📚 Documentation Documentation was added. ## ✅ Testing _TBA_ ## 📝 Code of Conduct & Contributing Guidelines By submitting creating this pull request, you agree to follow our [Code of Conduct](https://github.com/StanfordSpezi/.github/blob/main/CODE_OF_CONDUCT.md) and [Contributing Guidelines](https://github.com/StanfordSpezi/.github/blob/main/CONTRIBUTING.md): - [x] I agree to follow the [Code of Conduct](https://github.com/StanfordSpezi/.github/blob/main/CODE_OF_CONDUCT.md) and [Contributing Guidelines](https://github.com/StanfordSpezi/.github/blob/main/CONTRIBUTING.md).
- Loading branch information
Showing
14 changed files
with
136 additions
and
63 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 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
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
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 |
---|---|---|
|
@@ -76,26 +76,24 @@ struct NameOverview_Previews: PreviewProvider { | |
static let detailsWithoutName = AccountDetails.Builder() | ||
.set(\.userId, value: "[email protected]") | ||
|
||
static let account = Account(building: details, active: MockUserIdPasswordAccountService()) | ||
static let accountWithoutName = Account(building: detailsWithoutName, active: MockUserIdPasswordAccountService()) | ||
|
||
// be aware, modifications won't be displayed due to declaration in PreviewProvider that do not trigger an UI update | ||
@State static var model = AccountOverviewFormViewModel(account: account) | ||
|
||
static var previews: some View { | ||
NavigationStack { | ||
if let details = account.details { | ||
NameOverview(model: model, details: details) | ||
AccountDetailsReader { account, details in | ||
NameOverview(model: AccountOverviewFormViewModel(account: account), details: details) | ||
} | ||
} | ||
.environment(account) | ||
.previewWith { | ||
AccountConfiguration(building: details, active: MockUserIdPasswordAccountService()) | ||
} | ||
|
||
NavigationStack { | ||
if let details = accountWithoutName.details { | ||
NameOverview(model: model, details: details) | ||
AccountDetailsReader { account, details in | ||
NameOverview(model: AccountOverviewFormViewModel(account: account), details: details) | ||
} | ||
} | ||
.environment(accountWithoutName) | ||
.previewWith { | ||
AccountConfiguration(building: detailsWithoutName, active: MockUserIdPasswordAccountService()) | ||
} | ||
} | ||
} | ||
#endif |
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
Oops, something went wrong.