diff --git a/Sources/SpeziOnboarding/ConsentView/ConsentDocument+ExportConfiguration.swift b/Sources/SpeziOnboarding/ConsentView/ConsentDocument+ExportConfiguration.swift index 8237d3e..a5794dd 100644 --- a/Sources/SpeziOnboarding/ConsentView/ConsentDocument+ExportConfiguration.swift +++ b/Sources/SpeziOnboarding/ConsentView/ConsentDocument+ExportConfiguration.swift @@ -69,23 +69,23 @@ extension ConsentDocument { /// - headerTitleFont: The font used for the header title. /// - headerExportTimeStampFont: The font used for the header timestamp. public init( - signatureNameFont: UIFont, - signaturePrefixFont: UIFont, - documentContentFont: UIFont, - headerTitleFont: UIFont, - headerExportTimeStampFont: UIFont - ) { - self.signatureNameFont = signatureNameFont - self.signaturePrefixFont = signaturePrefixFont - self.documentContentFont = documentContentFont - self.headerTitleFont = headerTitleFont - self.headerExportTimeStampFont = headerExportTimeStampFont - } + signatureNameFont: UIFont, + signaturePrefixFont: UIFont, + documentContentFont: UIFont, + headerTitleFont: UIFont, + headerExportTimeStampFont: UIFont + ) { + self.signatureNameFont = signatureNameFont + self.signaturePrefixFont = signaturePrefixFont + self.documentContentFont = documentContentFont + self.headerTitleFont = headerTitleFont + self.headerExportTimeStampFont = headerExportTimeStampFont + } } #else /// The ``FontSettings`` store configuration of the fonts used to render the exported /// consent document, i.e., fonts for the content, title and signature. - public struct FontSettings { + public struct FontSettings: @unchecked Sendable { /// The font of the name rendered below the signature line. public let signatureNameFont: NSFont /// The font of the prefix of the signature ("X" in most cases). @@ -107,18 +107,18 @@ extension ConsentDocument { /// - headerTitleFont: The font used for the header title. /// - headerExportTimeStampFont: The font used for the header timestamp. public init( - signatureNameFont: NSFont, - signaturePrefixFont: NSFont, - documentContentFont: NSFont, - headerTitleFont: NSFont, - headerExportTimeStampFont: NSFont - ) { - self.signatureNameFont = signatureNameFont - self.signaturePrefixFont = signaturePrefixFont - self.documentContentFont = documentContentFont - self.headerTitleFont = headerTitleFont - self.headerExportTimeStampFont = headerExportTimeStampFont - } + signatureNameFont: NSFont, + signaturePrefixFont: NSFont, + documentContentFont: NSFont, + headerTitleFont: NSFont, + headerExportTimeStampFont: NSFont + ) { + self.signatureNameFont = signatureNameFont + self.signaturePrefixFont = signaturePrefixFont + self.documentContentFont = documentContentFont + self.headerTitleFont = headerTitleFont + self.headerExportTimeStampFont = headerExportTimeStampFont + } } #endif @@ -126,8 +126,8 @@ extension ConsentDocument { let consentTitle: LocalizedStringResource let paperSize: PaperSize let includingTimestamp: Bool - let fontSettings: FontSettings - + nonisolated(unsafe) let fontSettings: FontSettings + /// Creates an `ExportConfiguration` specifying the properties of the exported consent form. /// - Parameters: diff --git a/Sources/SpeziOnboarding/ConsentView/ExportConfiguration+Defaults.swift b/Sources/SpeziOnboarding/ConsentView/ExportConfiguration+Defaults.swift index bac4249..b084a1b 100644 --- a/Sources/SpeziOnboarding/ConsentView/ExportConfiguration+Defaults.swift +++ b/Sources/SpeziOnboarding/ConsentView/ExportConfiguration+Defaults.swift @@ -9,55 +9,56 @@ import Foundation import SwiftUI + extension ConsentDocument.ExportConfiguration { /// Provides default values for fields related to the `ConsentDocumentExportConfiguration`. public enum Defaults { - #if !os(macOS) - /// Default export font settings with fixed font sizes, ensuring a consistent appearance across platforms. - /// - /// This configuration uses `systemFont` and `boldSystemFont` with absolute font sizes to achieve uniform font sizes - /// on different operating systems such as macOS, iOS, and visionOS. - public static let defaultExportFontSettings = FontSettings( - signatureNameFont: UIFont.systemFont(ofSize: 10), - signaturePrefixFont: UIFont.boldSystemFont(ofSize: 12), - documentContentFont: UIFont.systemFont(ofSize: 12), - headerTitleFont: UIFont.boldSystemFont(ofSize: 28), - headerExportTimeStampFont: UIFont.systemFont(ofSize: 8) - ) - - /// Default font based on system standards. In contrast to defaultExportFontSettings, - /// the font sizes might change according to the system settings, potentially leading to varying exported PDF documents - /// on devices with different system settings (e.g., larger default font size). - public static let defaultSystemDefaultFontSettings = FontSettings( - signatureNameFont: UIFont.preferredFont(forTextStyle: .subheadline), - signaturePrefixFont: UIFont.preferredFont(forTextStyle: .title2), - documentContentFont: UIFont.preferredFont(forTextStyle: .body), - headerTitleFont: UIFont.boldSystemFont(ofSize: UIFont.preferredFont(forTextStyle: .largeTitle).pointSize), - headerExportTimeStampFont: UIFont.preferredFont(forTextStyle: .caption1) - ) - #else - /// Default export font settings with fixed font sizes, ensuring a consistent appearance across platforms. - /// - /// This configuration uses `systemFont` and `boldSystemFont` with absolute font sizes to achieve uniform font sizes - /// on different operating systems such as macOS, iOS, and visionOS. - public static let defaultExportFontSettings = FontSettings( - signatureNameFont: NSFont.systemFont(ofSize: 10), - signaturePrefixFont: NSFont.boldSystemFont(ofSize: 12), - documentContentFont: NSFont.systemFont(ofSize: 12), - headerTitleFont: NSFont.boldSystemFont(ofSize: 28), - headerExportTimeStampFont: NSFont.systemFont(ofSize: 8) - ) - - /// Default font based on system standards. In contrast to defaultExportFontSettings, - /// the font sizes might change according to the system settings, potentially leading to varying exported PDF documents - /// on devices with different system settings (e.g., larger default font size). - public static let defaultSystemDefaultFontSettings = FontSettings( - signatureNameFont: NSFont.preferredFont(forTextStyle: .subheadline), - signaturePrefixFont: NSFont.preferredFont(forTextStyle: .title2), - documentContentFont: NSFont.preferredFont(forTextStyle: .body), - headerTitleFont: NSFont.boldSystemFont(ofSize: NSFont.preferredFont(forTextStyle: .largeTitle).pointSize), - headerExportTimeStampFont: NSFont.preferredFont(forTextStyle: .caption1) - ) - #endif - } + #if !os(macOS) + /// Default export font settings with fixed font sizes, ensuring a consistent appearance across platforms. + /// + /// This configuration uses `systemFont` and `boldSystemFont` with absolute font sizes to achieve uniform font sizes + /// on different operating systems such as macOS, iOS, and visionOS. + public static let defaultExportFontSettings = FontSettings( + signatureNameFont: UIFont.systemFont(ofSize: 10), + signaturePrefixFont: UIFont.boldSystemFont(ofSize: 12), + documentContentFont: UIFont.systemFont(ofSize: 12), + headerTitleFont: UIFont.boldSystemFont(ofSize: 28), + headerExportTimeStampFont: UIFont.systemFont(ofSize: 8) + ) + + /// Default font based on system standards. In contrast to defaultExportFontSettings, + /// the font sizes might change according to the system settings, potentially leading to varying exported PDF documents + /// on devices with different system settings (e.g., larger default font size). + public static let defaultSystemDefaultFontSettings = FontSettings( + signatureNameFont: UIFont.preferredFont(forTextStyle: .subheadline), + signaturePrefixFont: UIFont.preferredFont(forTextStyle: .title2), + documentContentFont: UIFont.preferredFont(forTextStyle: .body), + headerTitleFont: UIFont.boldSystemFont(ofSize: UIFont.preferredFont(forTextStyle: .largeTitle).pointSize), + headerExportTimeStampFont: UIFont.preferredFont(forTextStyle: .caption1) + ) + #else + /// Default export font settings with fixed font sizes, ensuring a consistent appearance across platforms. + /// + /// This configuration uses `systemFont` and `boldSystemFont` with absolute font sizes to achieve uniform font sizes + /// on different operating systems such as macOS, iOS, and visionOS. + public static let defaultExportFontSettings = FontSettings( + signatureNameFont: NSFont.systemFont(ofSize: 10), + signaturePrefixFont: NSFont.boldSystemFont(ofSize: 12), + documentContentFont: NSFont.systemFont(ofSize: 12), + headerTitleFont: NSFont.boldSystemFont(ofSize: 28), + headerExportTimeStampFont: NSFont.systemFont(ofSize: 8) + ) + + /// Default font based on system standards. In contrast to defaultExportFontSettings, + /// the font sizes might change according to the system settings, potentially leading to varying exported PDF documents + /// on devices with different system settings (e.g., larger default font size). + public static let defaultSystemDefaultFontSettings = FontSettings( + signatureNameFont: NSFont.preferredFont(forTextStyle: .subheadline), + signaturePrefixFont: NSFont.preferredFont(forTextStyle: .title2), + documentContentFont: NSFont.preferredFont(forTextStyle: .body), + headerTitleFont: NSFont.boldSystemFont(ofSize: NSFont.preferredFont(forTextStyle: .largeTitle).pointSize), + headerExportTimeStampFont: NSFont.preferredFont(forTextStyle: .caption1) + ) + #endif + } }