From fa6e7cea89892555ca6030a66cebbea62e7c5fa1 Mon Sep 17 00:00:00 2001 From: Ladislas de Toldi Date: Wed, 7 Feb 2024 11:22:51 +0100 Subject: [PATCH] :alembic: (ContentKit): Example - add real skills and get details --- .../ContentKitExample/Resources/activity.yml | 6 +++--- .../ContentKitExample/Sources/MainView.swift | 19 ++++++++++++++++++- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/Modules/ContentKit/Examples/ContentKitExample/Resources/activity.yml b/Modules/ContentKit/Examples/ContentKitExample/Resources/activity.yml index 4ae6eb7353..ce582ce4d7 100644 --- a/Modules/ContentKit/Examples/ContentKitExample/Resources/activity.yml +++ b/Modules/ContentKit/Examples/ContentKitExample/Resources/activity.yml @@ -12,9 +12,9 @@ authors: - aurore_kiesler skills: - - skill_one - - skill_two - - skill_three + - spatial_understanding + - recognition/animals + - communication/non_verbal_communication/gestures tags: - tag_one diff --git a/Modules/ContentKit/Examples/ContentKitExample/Sources/MainView.swift b/Modules/ContentKit/Examples/ContentKitExample/Sources/MainView.swift index 21bd13809e..fd38b4d0a0 100644 --- a/Modules/ContentKit/Examples/ContentKitExample/Sources/MainView.swift +++ b/Modules/ContentKit/Examples/ContentKitExample/Sources/MainView.swift @@ -71,7 +71,15 @@ struct MainView: View { DisclosureGroup("**Skills**") { ForEach(self.activity?.skills ?? [], id: \.self) { skill in - Text(skill) + let skill = Skills.skill(id: skill)! + HStack { + Text(skill.name) + Button { + self.selectedSkill = skill + } label: { + Image(systemName: "info.circle") + } + } } } @@ -93,6 +101,13 @@ struct MainView: View { .markdownTheme(.leka) } } + .sheet(item: self.$selectedSkill, onDismiss: { self.selectedSkill = nil }, content: { skill in + VStack(alignment: .leading) { + Text(skill.name) + .font(.headline) + Text(skill.description) + } + }) .onAppear { self.activity = ContentKit.decodeActivity("activity") print(self.activity ?? "not working") @@ -109,6 +124,8 @@ struct MainView: View { // MARK: Private + @State private var selectedSkill: Skill? + @State private var activity: Activity? }