Spezi 入门引导

Build and Test codecov DOI

提供用于入门引导和同意书的 UI 组件。

概述

Spezi Onboarding 模块提供用户界面组件,用于引导用户入门应用程序,包括获取参与研究的同意书的可能性。

Screenshot displaying the onboarding view. Screenshot displaying the onboarding view. Screenshot displaying the sequential onboarding view. Screenshot displaying the sequential onboarding view. Screenshot displaying the consent view. Screenshot displaying the consent view.
OnboardingView(入门引导视图) SequentialOnboardingView(顺序入门引导视图) OnboardingConsentView(入门引导同意书视图)

设置

添加 Spezi Onboarding 作为依赖项

您需要在 Xcode 中的应用程序Swift 包中添加 Spezi Onboarding Swift 包作为依赖项。

示例

入门引导视图

OnboardingView 允许您将信息分隔到屏幕上的不同区域,每个区域都有标题、描述和图标。

import SpeziOnboarding
import SwiftUI


struct OnboardingViewExample: View {
    var body: some View {
        OnboardingView(
            title: "Welcome",
            subtitle: "This is an example onboarding view",
            areas: [
                .init(
                    icon: Image(systemName: "tortoise.fill"), 
                    title: "Tortoise", 
                    description: "A Tortoise!"
                ),
                .init(
                    icon: {
                        Image(systemName: "lizard.fill")
                            .foregroundColor(.green)
                    },
                    title: "Lizard", 
                    description: "A Lizard!"
                ),
                .init(
                    icon: {
                        Circle().fill(.orange)
                    }, 
                    title: "Circle", 
                    description: "A Circle!"
                )
            ],
            actionText: "Learn More",
            action: {
                // Action to perform when the user taps the action button.
            }
        )
    }
}

顺序入门引导视图

SequentialOnboardingView 允许您逐步显示信息,并在用户点击 Continue(继续)按钮时显示每个附加区域。

import SpeziOnboarding
import SwiftUI


struct SequentialOnboardingViewExample: View {
    var body: some View {
        SequentialOnboardingView(
            title: "Things to know",
            subtitle: "And you should pay close attention ...",
            content: [
                .init(
                    title: "A thing to know", 
                    description: "This is a first thing that you should know; read carefully!"
                ),
                .init(
                    title: "Second thing to know", 
                    description: "This is a second thing that you should know; read carefully!"
                ),
                .init(
                    title: "Third thing to know", 
                    description: "This is a third thing that you should know; read carefully!"
                )
            ],
            actionText: "Continue"
        ) {
            // Action to perform when the user has viewed all the steps
        }
    }
}

入门引导同意书视图

OnboardingConsentView 可用于允许您的用户阅读并同意文档,例如,研究的同意书或应用程序的条款和条件文档。 该文档可以使用姓氏和名字以及手绘签名进行签名。 然后,可以将签署的同意书导出并共享为 PDF 文件。

以下示例演示了如何通过提供编码为 UTF8 Data 实例(可以异步提供)的 Markdown 内容,在给予同意后应执行的操作(接收导出的 PDF 格式的同意书),以及定义导出同意书属性的配置来构建上面显示的 OnboardingConsentView

import SpeziOnboarding
import SwiftUI


struct ConsentViewExample: View {
    var body: some View {
        OnboardingConsentView(
            markdown: {
                Data("This is a *markdown* **example**".utf8)
            },
            action: { exportedConsentPdf in
                // Action to perform once the user has given their consent.
                // Closure receives the exported consent PDF to persist or upload it.
            },
            exportConfiguration: .init(paperSize: .usLetter),    // Configure the properties of the exported consent form
            currentDateInSignature: true   // Indicates if the consent signature should include the current date.
        )
    }
}

有关更多信息,请参阅 API 文档

Spezi 模板应用程序

Spezi 模板应用程序 提供了一个很好的起点和使用 SpeziOnboarding 模块的示例。

在本地运行测试

如果您想克隆此存储库并在本地运行单元和 UI 测试,请注意您需要配置 git lfs(大文件存储)。单元测试在运行时加载一些二进制数据(例如,PDF 文件),这些数据作为 git lfs 标签存储在 测试资源中。要安装 git lfs,请参阅 官方文档。之后,通过执行以下命令为您的用户设置 git lfs

git lfs install

现在,您可以克隆存储库,并且应该正确检出二进制文件。

贡献

欢迎对此项目进行贡献。请务必首先阅读 贡献指南贡献者盟约行为准则

许可证

此项目已获得 MIT 许可证的许可。 有关更多信息,请参见 许可证

Spezi Footer Spezi Footer