Skip to content

Commit

Permalink
Update to Spezi Views 0.4.0 (StanfordSpezi#12)
Browse files Browse the repository at this point in the history
# Update to Spezi Views 0.4.0

## ♻️ Current situation & Problem
- The current version of Spezi Account relies von Spezi Views 0.3.0
while all other packages have moved over to Spezi Views 0.4.0. This
mismatch stops us from updating the Template to Spezi 0.7.0.

## 💡 Proposed solution
- While this will be eventually addressed with StanfordSpezi#7, we want to update the
Spezi Template App to Spezi 0.7.0 before that to get it up to speed with
the ecosystem and to ensure that the diff in merging in changes implied
in StanfordSpezi#7 are minimal for the Template App but also other applications
updating to 0.7.0 before Spezi Account gets a new major release.

## ⚙️ Release Notes 
- Updates to Spezi Views 0.4.0


### 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
PSchmiedmayer authored and NikolaiMadlener committed Aug 12, 2023
1 parent 83a3130 commit 9b59476
Show file tree
Hide file tree
Showing 19 changed files with 218 additions and 355 deletions.
14 changes: 6 additions & 8 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# This source file is part of the Spezi open source project
# This source file is part of the Stanford Spezi open-source project
#
# SPDX-FileCopyrightText: 2022 Stanford University and the project authors (see CONTRIBUTORS.md)
#
Expand Down Expand Up @@ -141,8 +141,6 @@ only_rules:
- implicitly_unwrapped_optional
# Identifiers should use inclusive language that avoids discrimination against groups of people based on race, gender, or socioeconomic status
- inclusive_language
# If defer is at the end of its parent scope, it will be executed right where it is anyway.
- inert_defer
# Prefer using Set.isDisjoint(with:) over Set.intersection(_:).isEmpty.
- is_disjoint
# Discouraged explicit usage of the default separator.
Expand Down Expand Up @@ -329,8 +327,6 @@ only_rules:
- unowned_variable_capture
# Catch statements should not declare error variables without type casting.
- untyped_error_in_catch
# Unused reference in a capture list should be removed.
- unused_capture_list
# Unused parameter in a closure should be replaced with _.
- unused_closure_parameter
# Unused control flow label should be removed.
Expand Down Expand Up @@ -371,16 +367,18 @@ only_rules:
# The variable should be placed on the left, the constant on the right of a comparison operator.
- yoda_condition

attributes:
attributes_with_arguments_always_on_line_above: false

deployment_target: # Availability checks or attributes shouldn’t be using older versions that are satisfied by the deployment target.
iOSApplicationExtension_deployment_target: 16.0
iOS_deployment_target: 16.0

attributes:
attributes_with_arguments_always_on_line_above: false

excluded: # paths to ignore during linting. Takes precedence over `included`.
- .build
- .swiftpm
- .derivedData
- Tests/UITests/.derivedData

closure_body_length: # Closure bodies should not span too many lines.
- 35 # warning - default: 20
Expand Down
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.7
// swift-tools-version:5.8

//
// This source file is part of the Spezi open source project
Expand All @@ -22,7 +22,7 @@ let package = Package(
],
dependencies: [
.package(url: "https://github.com/StanfordSpezi/Spezi", .upToNextMinor(from: "0.7.0")),
.package(url: "https://github.com/StanfordSpezi/SpeziViews", .upToNextMinor(from: "0.3.0"))
.package(url: "https://github.com/StanfordSpezi/SpeziViews", .upToNextMinor(from: "0.4.0"))
],
targets: [
.target(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ open class EmailPasswordAccountService: UsernamePasswordAccountService {
}

override open var localization: Localization {
let usernameField = FieldLocalization(
title: String(moduleLocalized: "EAP_LOGIN_USERNAME_TITLE"),
placeholder: String(moduleLocalized: "EAP_LOGIN_USERNAME_PLACEHOLDER")
let usernameField = FieldLocalizationResource(
title: LocalizedStringResource("EAP_LOGIN_USERNAME_TITLE", bundle: .atURL(from: .module)),
placeholder: LocalizedStringResource("EAP_LOGIN_USERNAME_PLACEHOLDER", bundle: .atURL(from: .module))
)
return Localization(
login: .init(buttonTitle: String(moduleLocalized: "EAP_LOGIN_BUTTON_TITLE"), username: usernameField),
signUp: .init(buttonTitle: String(moduleLocalized: "EAP_SIGNUP_BUTTON_TITLE"), username: usernameField),
login: .init(buttonTitle: LocalizedStringResource("EAP_LOGIN_BUTTON_TITLE", bundle: .atURL(from: .module)), username: usernameField),
signUp: .init(buttonTitle: LocalizedStringResource("EAP_SIGNUP_BUTTON_TITLE", bundle: .atURL(from: .module)), username: usernameField),
resetPassword: .init(username: usernameField)
)
}
Expand Down Expand Up @@ -76,7 +76,7 @@ open class EmailPasswordAccountService: UsernamePasswordAccountService {
}


override open func button<V: View>(_ title: String, destination: V) -> AnyView {
override open func button<V: View>(_ title: LocalizedStringResource, destination: V) -> AnyView {
AnyView(
NavigationLink {
destination
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// SPDX-License-Identifier: MIT
//

import Foundation
import SpeziViews


Expand All @@ -28,58 +29,58 @@ extension Localization {
public struct Login: Codable {
/// A default configuration for providing localized text to login views.
public static let `default` = Login(
buttonTitle: String(moduleLocalized: "UAP_LOGIN_BUTTON_TITLE"),
navigationTitle: String(moduleLocalized: "UAP_LOGIN_NAVIGATION_TITLE"),
username: FieldLocalization(
title: String(moduleLocalized: "UAP_LOGIN_USERNAME_TITLE"),
placeholder: String(moduleLocalized: "UAP_LOGIN_USERNAME_PLACEHOLDER")
buttonTitle: LocalizedStringResource("UAP_LOGIN_BUTTON_TITLE", bundle: .atURL(from: .module)),
navigationTitle: LocalizedStringResource("UAP_LOGIN_NAVIGATION_TITLE", bundle: .atURL(from: .module)),
username: FieldLocalizationResource(
title: LocalizedStringResource("UAP_LOGIN_USERNAME_TITLE", bundle: .atURL(from: .module)),
placeholder: LocalizedStringResource("UAP_LOGIN_USERNAME_PLACEHOLDER", bundle: .atURL(from: .module))
),
password: FieldLocalization(
title: String(moduleLocalized: "UAP_LOGIN_PASSWORD_TITLE"),
placeholder: String(moduleLocalized: "UAP_LOGIN_PASSWORD_PLACEHOLDER")
password: FieldLocalizationResource(
title: LocalizedStringResource("UAP_LOGIN_PASSWORD_TITLE", bundle: .atURL(from: .module)),
placeholder: LocalizedStringResource("UAP_LOGIN_PASSWORD_PLACEHOLDER", bundle: .atURL(from: .module))
),
loginActionButtonTitle: String(moduleLocalized: "UAP_LOGIN_ACTION_BUTTON_TITLE"),
defaultLoginFailedError: String(moduleLocalized: "UAP_LOGIN_FAILED_DEFAULT_ERROR")
loginActionButtonTitle: LocalizedStringResource("UAP_LOGIN_ACTION_BUTTON_TITLE", bundle: .atURL(from: .module)),
defaultLoginFailedError: LocalizedStringResource("UAP_LOGIN_FAILED_DEFAULT_ERROR", bundle: .atURL(from: .module))
)


/// A localized `String` to display on the login button.
public let buttonTitle: String
/// A localized `String` for login view's navigation title.
public let navigationTitle: String
/// A localized `LocalizedStringResource` to display on the login button.
public let buttonTitle: LocalizedStringResource
/// A localized `LocalizedStringResource` for login view's navigation title.
public let navigationTitle: LocalizedStringResource
/// A `FieldLocalization` instance containing the localized title and placeholder text for the username field.
public let username: FieldLocalization
public let username: FieldLocalizationResource
/// A `FieldLocalization` instance containing the localized title and placeholder text for the password field.
public let password: FieldLocalization
/// A localized `String` to display on the login action button.
public let loginActionButtonTitle: String
/// A localized`String` error message to be displayed when login fails.
public let defaultLoginFailedError: String
public let password: FieldLocalizationResource
/// A localized `LocalizedStringResource` to display on the login action button.
public let loginActionButtonTitle: LocalizedStringResource
/// A localized`LocalizedStringResource` error message to be displayed when login fails.
public let defaultLoginFailedError: LocalizedStringResource


/// Creates a localization configuration for login views.
///
/// - Parameters:
/// - buttonTitle: A localized `String` to display on the login button.
/// - navigationTitle: A localized `String` for the login view's navigation title.
/// - buttonTitle: A localized `LocalizedStringResource` to display on the login button.
/// - navigationTitle: A localized `LocalizedStringResource` for the login view's navigation title.
/// - username: A `FieldLocalization` instance containing the localized title and placeholder text for the username field.
/// - password: A `FieldLocalization` instance containing the localized title and placeholder text for the password field.
/// - loginActionButtonTitle: A localized `String` to display on the login action button.
/// - defaultLoginFailedError: A localized `String` error message to be displayed when login fails.
/// - loginActionButtonTitle: A localized `LocalizedStringResource` to display on the login action button.
/// - defaultLoginFailedError: A localized `LocalizedStringResource` error message to be displayed when login fails.
public init(
buttonTitle: String = Login.default.buttonTitle,
navigationTitle: String = Login.default.navigationTitle,
username: FieldLocalization = Login.default.username,
password: FieldLocalization = Login.default.password,
loginActionButtonTitle: String = Login.default.loginActionButtonTitle,
defaultLoginFailedError: String = Login.default.defaultLoginFailedError
buttonTitle: LocalizedStringResource = Login.default.buttonTitle,
navigationTitle: LocalizedStringResource = Login.default.navigationTitle,
username: FieldLocalizationResource = Login.default.username,
password: FieldLocalizationResource = Login.default.password,
loginActionButtonTitle: LocalizedStringResource = Login.default.loginActionButtonTitle,
defaultLoginFailedError: LocalizedStringResource = Login.default.defaultLoginFailedError
) {
self.buttonTitle = buttonTitle.localized
self.navigationTitle = navigationTitle.localized
self.buttonTitle = buttonTitle
self.navigationTitle = navigationTitle
self.username = username
self.password = password
self.loginActionButtonTitle = loginActionButtonTitle.localized
self.defaultLoginFailedError = defaultLoginFailedError.localized
self.loginActionButtonTitle = loginActionButtonTitle
self.defaultLoginFailedError = defaultLoginFailedError
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// SPDX-License-Identifier: MIT
//

import Foundation
import SpeziViews


Expand All @@ -19,7 +20,7 @@ extension Localization {
/// ```swift
/// ResetPassword(
/// navigationTitle: "CUSTOM_NAVIGATION_TITLE",
/// username: FieldLocalization(
/// username: FieldLocalizationResource(
/// title: "CUSTOM_USERNAME",
/// placeholder: "CUSTOM_USERNAME_PLACEHOLDER"
/// )
Expand All @@ -28,55 +29,55 @@ extension Localization {
public struct ResetPassword: Codable {
/// A default configuration for providing localized text to reset password views
public static let `default` = ResetPassword(
buttonTitle: String(moduleLocalized: "UAP_RESET_PASSWORD_BUTTON_TITLE"),
navigationTitle: String(moduleLocalized: "UAP_RESET_PASSWORD_NAVIGATION_TITLE"),
username: FieldLocalization(
title: String(moduleLocalized: "UAP_RESET_PASSWORD_USERNAME_TITLE"),
placeholder: String(moduleLocalized: "UAP_RESET_PASSWORD_USERNAME_PLACEHOLDER")
buttonTitle: LocalizedStringResource("UAP_RESET_PASSWORD_BUTTON_TITLE", bundle: .atURL(from: .module)),
navigationTitle: LocalizedStringResource("UAP_RESET_PASSWORD_NAVIGATION_TITLE", bundle: .atURL(from: .module)),
username: FieldLocalizationResource(
title: LocalizedStringResource("UAP_RESET_PASSWORD_USERNAME_TITLE", bundle: .atURL(from: .module)),
placeholder: LocalizedStringResource("UAP_RESET_PASSWORD_USERNAME_PLACEHOLDER", bundle: .atURL(from: .module))
),
resetPasswordActionButtonTitle: String(moduleLocalized: "UAP_RESET_PASSWORD_ACTION_BUTTON_TITLE"),
processSuccessfulLabel: String(moduleLocalized: "UAP_RESET_PASSWORD_PROCESS_SUCCESSFUL_LABEL"),
defaultResetPasswordFailedError: String(moduleLocalized: "UAP_RESET_PASSWORD_FAILED_DEFAULT_ERROR")
resetPasswordActionButtonTitle: LocalizedStringResource("UAP_RESET_PASSWORD_ACTION_BUTTON_TITLE", bundle: .atURL(from: .module)),
processSuccessfulLabel: LocalizedStringResource("UAP_RESET_PASSWORD_PROCESS_SUCCESSFUL_LABEL", bundle: .atURL(from: .module)),
defaultResetPasswordFailedError: LocalizedStringResource("UAP_RESET_PASSWORD_FAILED_DEFAULT_ERROR", bundle: .atURL(from: .module))
)


/// A localized `String` to display on the reset password button.
public let buttonTitle: String
/// A localized `String` for the reset password view's navigation title.
public let navigationTitle: String
/// A `FieldLocalization` instance containing the localized title and placeholder text for the username field.
public let username: FieldLocalization
/// A localized `String` to display on the reset password action button.
public let resetPasswordActionButtonTitle: String
/// A localized `String` to display when the reset password process has been successful.
public let processSuccessfulLabel: String
/// A localized `String` to display when the reset password process has failed.
public let defaultResetPasswordFailedError: String
/// A localized `LocalizedStringResource` to display on the reset password button.
public let buttonTitle: LocalizedStringResource
/// A localized `LocalizedStringResource` for the reset password view's navigation title.
public let navigationTitle: LocalizedStringResource
/// A `FieldLocalizationResource` instance containing the localized title and placeholder text for the username field.
public let username: FieldLocalizationResource
/// A localized `LocalizedStringResource` to display on the reset password action button.
public let resetPasswordActionButtonTitle: LocalizedStringResource
/// A localized `LocalizedStringResource` to display when the reset password process has been successful.
public let processSuccessfulLabel: LocalizedStringResource
/// A localized `LocalizedStringResource` to display when the reset password process has failed.
public let defaultResetPasswordFailedError: LocalizedStringResource


/// Creates a localization configuration for reset password views.
///
/// - Parameters:
/// - buttonTitle: A localized `String` title for the reset password button.
/// - navigationTitle: A localized `String` for the reset password view's navigation title.
/// - username: A `FieldLocalization` instance containing the localized title and placeholder text for the username field.
/// - resetPasswordActionbuttonTitle: A localized `String` to display on the reset password action button.
/// - processSuccessfulLabel: A localized `String` to display when the reset password process has been successful.
/// - defaultResetPasswordFailedError: A localized `String` to display when the reset password process has failed.
/// - buttonTitle: A localized `LocalizedStringResource` title for the reset password button.
/// - navigationTitle: A localized `LocalizedStringResource` for the reset password view's navigation title.
/// - username: A `FieldLocalizationResource` instance containing the localized title and placeholder text for the username field.
/// - resetPasswordActionbuttonTitle: A localized `LocalizedStringResource` to display on the reset password action button.
/// - processSuccessfulLabel: A localized `LocalizedStringResource` to display when the reset password process has been successful.
/// - defaultResetPasswordFailedError: A localized `LocalizedStringResource` to display when the reset password process has failed.
public init(
buttonTitle: String = ResetPassword.default.buttonTitle,
navigationTitle: String = ResetPassword.default.navigationTitle,
username: FieldLocalization = ResetPassword.default.username,
resetPasswordActionButtonTitle: String = ResetPassword.default.resetPasswordActionButtonTitle,
processSuccessfulLabel: String = ResetPassword.default.processSuccessfulLabel,
defaultResetPasswordFailedError: String = ResetPassword.default.defaultResetPasswordFailedError
buttonTitle: LocalizedStringResource = ResetPassword.default.buttonTitle,
navigationTitle: LocalizedStringResource = ResetPassword.default.navigationTitle,
username: FieldLocalizationResource = ResetPassword.default.username,
resetPasswordActionButtonTitle: LocalizedStringResource = ResetPassword.default.resetPasswordActionButtonTitle,
processSuccessfulLabel: LocalizedStringResource = ResetPassword.default.processSuccessfulLabel,
defaultResetPasswordFailedError: LocalizedStringResource = ResetPassword.default.defaultResetPasswordFailedError
) {
self.buttonTitle = buttonTitle.localized
self.navigationTitle = navigationTitle.localized
self.buttonTitle = buttonTitle
self.navigationTitle = navigationTitle
self.username = username
self.resetPasswordActionButtonTitle = resetPasswordActionButtonTitle.localized
self.processSuccessfulLabel = processSuccessfulLabel.localized
self.defaultResetPasswordFailedError = defaultResetPasswordFailedError.localized
self.resetPasswordActionButtonTitle = resetPasswordActionButtonTitle
self.processSuccessfulLabel = processSuccessfulLabel
self.defaultResetPasswordFailedError = defaultResetPasswordFailedError
}
}
}
Loading

0 comments on commit 9b59476

Please sign in to comment.