From 552e58d3cf45c1ed942cc617f891f5d7be67cd3e Mon Sep 17 00:00:00 2001 From: Ladislas de Toldi Date: Sat, 20 Jan 2024 15:01:07 +0100 Subject: [PATCH 1/9] :recycle: (ContentKit): Refactor to enum instead of class --- Modules/ContentKit/Sources/ContentKit.swift | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/Modules/ContentKit/Sources/ContentKit.swift b/Modules/ContentKit/Sources/ContentKit.swift index f875e75a2..098329ee1 100644 --- a/Modules/ContentKit/Sources/ContentKit.swift +++ b/Modules/ContentKit/Sources/ContentKit.swift @@ -8,16 +8,4 @@ let log = LogKit.createLoggerFor(module: "ContentKit") // MARK: - ContentKit -public class ContentKit { - // MARK: Lifecycle - - private init() { - // nothing to do - } - - // MARK: Public - - public var shared: ContentKit { - ContentKit() - } -} +public enum ContentKit {} From 219a542c17d9592c034cd2fa1c7b1b91abf58c5c Mon Sep 17 00:00:00 2001 From: Ladislas de Toldi Date: Mon, 12 Feb 2024 17:31:55 +0100 Subject: [PATCH 2/9] :truck: (tools): Rename hooks to check yaml definitions (vs data) --- .pre-commit-config.yaml | 12 ++++++------ ..._authors.py => check_yaml_definitions_authors.py} | 0 ...ions.py => check_yaml_definitions_professions.py} | 0 ...ta_skills.py => check_yaml_definitions_skills.py} | 0 4 files changed, 6 insertions(+), 6 deletions(-) rename Tools/Hooks/{check_yaml_data_authors.py => check_yaml_definitions_authors.py} (100%) rename Tools/Hooks/{check_yaml_data_professions.py => check_yaml_definitions_professions.py} (100%) rename Tools/Hooks/{check_yaml_data_skills.py => check_yaml_definitions_skills.py} (100%) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 21f1173f0..9446de116 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -55,38 +55,38 @@ repos: language: script files: '.*\.xcstrings' - - id: check_yaml_data_professions + - id: check_yaml_definitions_professions name: Check professions.yml description: | This hook checks professions.yml for: - non unique ids - jtd schema validation It also formats the file and sorts the entries - entry: python3 Tools/Hooks/check_yaml_data_professions.py + entry: python3 Tools/Hooks/check_yaml_definitions_professions.py language: python additional_dependencies: ["ruamel.yaml"] files: professions.yml - - id: check_yaml_data_authors + - id: check_yaml_definitions_authors name: Check authors.yml description: | This hook checks authors.yml for: - non unique ids - jtd schema validation It also formats the file and sorts the entries - entry: python3 Tools/Hooks/check_yaml_data_authors.py + entry: python3 Tools/Hooks/check_yaml_definitions_authors.py language: python additional_dependencies: ["ruamel.yaml"] files: authors.yml - - id: check_yaml_data_skills + - id: check_yaml_definitions_skills name: Check skills.yml description: | This hook checks skills.yml for: - non unique ids - jtd schema validation It also formats the file and sorts the entries - entry: python3 Tools/Hooks/check_yaml_data_skills.py + entry: python3 Tools/Hooks/check_yaml_definitions_skills.py language: python additional_dependencies: ["ruamel.yaml"] files: skills.yml diff --git a/Tools/Hooks/check_yaml_data_authors.py b/Tools/Hooks/check_yaml_definitions_authors.py similarity index 100% rename from Tools/Hooks/check_yaml_data_authors.py rename to Tools/Hooks/check_yaml_definitions_authors.py diff --git a/Tools/Hooks/check_yaml_data_professions.py b/Tools/Hooks/check_yaml_definitions_professions.py similarity index 100% rename from Tools/Hooks/check_yaml_data_professions.py rename to Tools/Hooks/check_yaml_definitions_professions.py diff --git a/Tools/Hooks/check_yaml_data_skills.py b/Tools/Hooks/check_yaml_definitions_skills.py similarity index 100% rename from Tools/Hooks/check_yaml_data_skills.py rename to Tools/Hooks/check_yaml_definitions_skills.py From 39dcc7c92d50e1ad93d137c9e98d89884c68ddcf Mon Sep 17 00:00:00 2001 From: Ladislas de Toldi Date: Mon, 12 Feb 2024 18:25:10 +0100 Subject: [PATCH 3/9] :monocle_face: (specs): Activity JTD - Make payload empty to accept any data --- Specs/jtd/activity.jtd.json | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/Specs/jtd/activity.jtd.json b/Specs/jtd/activity.jtd.json index c7c790bc0..b5169a2aa 100644 --- a/Specs/jtd/activity.jtd.json +++ b/Specs/jtd/activity.jtd.json @@ -57,11 +57,7 @@ }, "definitions": { "$author": { - "enum": [ - "leka_at_apf_france_handicap", - "aurore_kiesler", - "julie_tuil" - ] + "enum": ["leka", "aurore_kiesler", "julie_tuil"] }, "$hmi": { "enum": ["robot", "tablet", "magic_cards", "tablet_robot"] @@ -160,8 +156,6 @@ "$exercise/gameplay": { "enum": ["findTheRightAnswers", "associateCategories"] }, - "$exercise/payload": { - "type": "string" - } + "$exercise/payload": {} } } From 12cad804221e78f1440c6bae786c3f7e2bd29fff Mon Sep 17 00:00:00 2001 From: Ladislas de Toldi Date: Thu, 15 Feb 2024 09:35:08 +0100 Subject: [PATCH 4/9] :recycle: (specs): JTD - add version, update interfaces, fix instructions --- Specs/jtd/activity.jtd.json | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/Specs/jtd/activity.jtd.json b/Specs/jtd/activity.jtd.json index b5169a2aa..b9323af99 100644 --- a/Specs/jtd/activity.jtd.json +++ b/Specs/jtd/activity.jtd.json @@ -1,5 +1,8 @@ { "properties": { + "version": { + "type": "string" + }, "uuid": { "type": "string" }, @@ -93,7 +96,8 @@ "type": "string" }, "instructions": { - "type": "string" + "type": "string", + "nullable": true } } }, @@ -115,13 +119,17 @@ "$exercise": { "properties": { "instructions": { - "ref": "$exercise/instructions" + "ref": "$exercise/instructions", + "nullable": true }, "interface": { "ref": "$exercise/interface" - }, + } + }, + "optionalProperties": { "gameplay": { - "ref": "$exercise/gameplay" + "ref": "$exercise/gameplay", + "nullable": true }, "payload": { "ref": "$exercise/payload" @@ -150,7 +158,11 @@ "dragAndDropToAssociate", "danceFreeze", "remoteStandard", - "remoteArrow" + "remoteArrow", + "hideAndSeek", + "musicalInstruments", + "melody", + "pairing" ] }, "$exercise/gameplay": { From 6e4d31ba34fcadcc95179d8b909792030f515fd4 Mon Sep 17 00:00:00 2001 From: Ladislas de Toldi Date: Thu, 15 Feb 2024 10:00:21 +0100 Subject: [PATCH 5/9] :technologist: (hooks): Add activity content check hook, script --- .pre-commit-config.yaml | 12 ++++ Tools/Hooks/check_yaml_content_activities.py | 73 ++++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100755 Tools/Hooks/check_yaml_content_activities.py diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9446de116..07223c24d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -90,3 +90,15 @@ repos: language: python additional_dependencies: ["ruamel.yaml"] files: skills.yml + + - id: check_yaml_content_activities + name: Check activity.yml files + description: | + This hook checks activity.yml files for: + - uuid and filename consistency + - jtd schema validation + entry: python3 Tools/Hooks/check_yaml_content_activities.py + language: python + additional_dependencies: ["ruamel.yaml"] + files: .*\.activity\.yml + types: [yaml] diff --git a/Tools/Hooks/check_yaml_content_activities.py b/Tools/Hooks/check_yaml_content_activities.py new file mode 100755 index 000000000..5379411be --- /dev/null +++ b/Tools/Hooks/check_yaml_content_activities.py @@ -0,0 +1,73 @@ +#!/usr/bin/python3 + +# Leka - LekaOS +# Copyright 2020 APF France handicap +# SPDX-License-Identifier: Apache-2.0 + +import os +import subprocess +import uuid +import ruamel.yaml +import sys + + +JTD_SCHEMA = "Specs/jtd/activity.jtd.json" + + +# +# Mark: - Main +# + + +# ? Check if a file was specified +if len(sys.argv) > 1: + FILENAME = sys.argv[1] +else: + print("❌ No file specified") + exit(1) + +# ? Create a YAML object +yaml = ruamel.yaml.YAML(typ='rt') +yaml.indent(mapping=2, sequence=4, offset=2) + +# ? Load the YAML file +with open(FILENAME, 'r') as file: + data = yaml.load(file) + +# ? Check uuid is the same as the filename +filename_uuid = os.path.basename(FILENAME).split("-")[0] +if data['uuid'] != filename_uuid: + print(f"❌ The id in {FILENAME} is not the same as the filename") + print(f"uuid: {data['uuid']}") + print(f"filename: {filename_uuid}") + exit(1) + +# ? Check uuid is valid +try: + uuid.UUID(data['uuid']) +except ValueError: + print(f"❌ The id in {FILENAME} is not valid") + print(f"uuid: {data['uuid']}") + exit(1) + +# ? Check schema validation with ajv +os.environ['FORCE_COLOR'] = 'true' +cmd = f"ajv validate --verbose --all-errors --spec=jtd -s {JTD_SCHEMA} -d {FILENAME}" +result = subprocess.run(cmd, shell=True, capture_output=True) + +if result.returncode != 0: + error = result.stderr.decode('utf-8') + print(f"❌ File does not match the schema {JTD_SCHEMA}") + print(error) + exit(1) + +# ? Check name is the same as filename +filename_name = os.path.basename(FILENAME).split('-')[-1].split('.activity.yml')[0] +if data['name'] != filename_name: + print(f"❌ The name in {FILENAME} is not the same as the filename") + print(f"name: {data['name']}") + print(f"filename: {filename_name}") + exit(1) + + +exit(0) From 91ee5ebd21d040f4dc6dadaedf2366f45417335a Mon Sep 17 00:00:00 2001 From: Ladislas de Toldi Date: Sat, 20 Jan 2024 14:58:10 +0100 Subject: [PATCH 6/9] :bento: (ContentKit): Add sample activities --- ...497F87B32A390119DB98-sample_6.activity.yml | 212 ++++++++++++++++++ ...4A6AA11AB39D64D63990-sample_1.activity.yml | 212 ++++++++++++++++++ ...423482E243BCBC7F8CA8-sample_2.activity.yml | 212 ++++++++++++++++++ ...4D84A45AA20385F389F1-sample_5.activity.yml | 212 ++++++++++++++++++ ...42ADB5B03B409462923E-sample_4.activity.yml | 212 ++++++++++++++++++ ...49AF96CD77A9DF90833B-sample_3.activity.yml | 212 ++++++++++++++++++ 6 files changed, 1272 insertions(+) create mode 100644 Modules/ContentKit/Resources/Content/activities/examples/2FE0B8BDD1B0497F87B32A390119DB98-sample_6.activity.yml create mode 100644 Modules/ContentKit/Resources/Content/activities/examples/5A670B59EB214A6AA11AB39D64D63990-sample_1.activity.yml create mode 100644 Modules/ContentKit/Resources/Content/activities/examples/6102794F02D3423482E243BCBC7F8CA8-sample_2.activity.yml create mode 100644 Modules/ContentKit/Resources/Content/activities/examples/725853C4DC7B4D84A45AA20385F389F1-sample_5.activity.yml create mode 100644 Modules/ContentKit/Resources/Content/activities/examples/81F6617499FE42ADB5B03B409462923E-sample_4.activity.yml create mode 100644 Modules/ContentKit/Resources/Content/activities/examples/E7EE9CA4B13B49AF96CD77A9DF90833B-sample_3.activity.yml diff --git a/Modules/ContentKit/Resources/Content/activities/examples/2FE0B8BDD1B0497F87B32A390119DB98-sample_6.activity.yml b/Modules/ContentKit/Resources/Content/activities/examples/2FE0B8BDD1B0497F87B32A390119DB98-sample_6.activity.yml new file mode 100644 index 000000000..f77e5299c --- /dev/null +++ b/Modules/ContentKit/Resources/Content/activities/examples/2FE0B8BDD1B0497F87B32A390119DB98-sample_6.activity.yml @@ -0,0 +1,212 @@ +# Leka - iOS Monorepo +# Copyright APF France handicap +# SPDX-License-Identifier: Apache-2.0 + +version: 1.0.0 + +uuid: 2FE0B8BDD1B0497F87B32A390119DB98 +name: sample_6 + +status: published + +authors: + - leka + - aurore_kiesler + - julie_tuil + +skills: + - spatial_understanding + - recognition/animals + - communication/non_verbal_communication/gestures + +tags: + - tag_one + - tag_two + - tag_three + +hmi: + - robot + - magic_cards + - tablet_robot + +locales: + - en_US + - fr_FR + +l10n: + - locale: fr_FR + details: + icon: name_of_the_activity-icon-fr_FR.svg + + title: Activité d'exemple + subtitle: pour le développement + + description: | + Activité d'exemple utilisée pour le développement de l'application + + instructions: | + ## Longues instructions en markdown plus complexe si on veut + + Lorem markdownum recepta avidum, missa de quam patientia, antris: cum defuit, + Titan repetemus nomine, ignare. Quod ad aura, et non quod vidisse utque ulla: + + - Pro inposuit tibi orsa tum artes ferox + - Acmon plausu qua agrestum situs virgo in + - Vacuus a pendens rostro non si pharetrae + - Haeremusque quos auxiliaris coniunx + - Repulsa impediunt munera teneri fallebat + - Bracchia frustra telo Iovis faucibus casus + + - locale: en_US + details: + icon: name_of_the_activity-icon-en_US.svg + + title: Sample activity + subtitle: for development + + description: | + Sample activity used for the development of the application + + instructions: | + ## Long instructions in markdown more complex if we want + + Lorem markdownum recepta avidum, missa de quam patientia, antris: cum defuit, + Titan repetemus nomine, ignare. Quod ad aura, et non quod vidisse utque ulla: + + - Pro inposuit tibi orsa tum artes ferox + - Acmon plausu qua agrestum situs virgo in + - Vacuus a pendens rostro non si pharetrae + - Haeremusque quos auxiliaris coniunx + - Repulsa impediunt munera teneri fallebat + - Bracchia frustra telo Iovis faucibus casus + +gameengine: + shuffle_exercises: true + shuffle_sequences: true + +exercises: + - group: + - instructions: + - locale: fr_FR + value: Touch le rond jaune + - locale: en_US + value: Touch the yellow circle + interface: touchToSelect + gameplay: findTheRightAnswers + payload: + choices: + - value: yellow + type: color + isRightAnswer: true + - value: red + type: color + - value: green + type: color + - value: blue + type: color + + - instructions: + - locale: fr_FR + value: Touch la pastèque + - locale: en_US + value: Touch the watermelon + interface: touchToSelect + gameplay: findTheRightAnswers + payload: + choices: + - value: 🍉 + type: emoji + isRightAnswer: true + - value: 🍌 + type: emoji + - value: 🍒 + type: emoji + - value: 🥝 + type: emoji + + - instructions: + - locale: fr_FR + value: Touch le carré + - locale: en_US + value: Touch the square + interface: touchToSelect + gameplay: findTheRightAnswers + payload: + choices: + - value: circle + type: sfsymbol + - value: square + type: sfsymbol + isRightAnswer: true + - value: triangle + type: sfsymbol + - value: rhombus + type: sfsymbol + + - group: + - instructions: + - locale: fr_FR + value: Contrôle Leka avec la télécommande et fais le changer de couleur + - locale: en_US + value: Control Leka with the remote and make it change color + interface: remoteArrow + + - instructions: + - locale: fr_FR + value: Contrôle Leka avec la télécommande et fais le changer de couleur + - locale: en_US + value: Control Leka with the remote and make it change color + interface: remoteArrow + + - group: + - instructions: + - locale: fr_FR + value: Joue du xylophone avec Leka + - locale: en_US + value: Play the xylophone with Leka + interface: musicalInstruments + payload: + instrument: xylophone + scale: majorHeptatonic + + - instructions: + - locale: fr_FR + value: Joue du xylophone avec Leka + - locale: en_US + value: Play the xylophone with Leka + interface: musicalInstruments + payload: + instrument: xylophone + scale: majorPentatonic + + - group: + - instructions: null + interface: danceFreeze + payload: + songs: + - earlyBird + - emptyPage + - gigglySquirrel + - handsOn + - happyDays + - inTheGame + - littleByLittle + + - instructions: null + interface: hideAndSeek + + - instructions: + - locale: fr_FR + value: Joue les notes de la même couleur que Leka + - locale: en_US + value: Play the notes of the same color as Leka + interface: melody + payload: + instrument: xylophone + songs: + - underTheMoonlight + - aGreenMouse + - twinkleTwinkleLittleStar + - londonBridgeIsFallingDown + - ohTheCrocodiles + - happyBirthday diff --git a/Modules/ContentKit/Resources/Content/activities/examples/5A670B59EB214A6AA11AB39D64D63990-sample_1.activity.yml b/Modules/ContentKit/Resources/Content/activities/examples/5A670B59EB214A6AA11AB39D64D63990-sample_1.activity.yml new file mode 100644 index 000000000..a6353318b --- /dev/null +++ b/Modules/ContentKit/Resources/Content/activities/examples/5A670B59EB214A6AA11AB39D64D63990-sample_1.activity.yml @@ -0,0 +1,212 @@ +# Leka - iOS Monorepo +# Copyright APF France handicap +# SPDX-License-Identifier: Apache-2.0 + +version: 1.0.0 + +uuid: 5A670B59EB214A6AA11AB39D64D63990 +name: sample_1 + +status: published + +authors: + - leka + - aurore_kiesler + - julie_tuil + +skills: + - spatial_understanding + - recognition/animals + - communication/non_verbal_communication/gestures + +tags: + - tag_one + - tag_two + - tag_three + +hmi: + - robot + - magic_cards + - tablet_robot + +locales: + - en_US + - fr_FR + +l10n: + - locale: fr_FR + details: + icon: name_of_the_activity-icon-fr_FR.svg + + title: Activité d'exemple + subtitle: pour le développement + + description: | + Activité d'exemple utilisée pour le développement de l'application + + instructions: | + ## Longues instructions en markdown plus complexe si on veut + + Lorem markdownum recepta avidum, missa de quam patientia, antris: cum defuit, + Titan repetemus nomine, ignare. Quod ad aura, et non quod vidisse utque ulla: + + - Pro inposuit tibi orsa tum artes ferox + - Acmon plausu qua agrestum situs virgo in + - Vacuus a pendens rostro non si pharetrae + - Haeremusque quos auxiliaris coniunx + - Repulsa impediunt munera teneri fallebat + - Bracchia frustra telo Iovis faucibus casus + + - locale: en_US + details: + icon: name_of_the_activity-icon-en_US.svg + + title: Sample activity + subtitle: for development + + description: | + Sample activity used for the development of the application + + instructions: | + ## Long instructions in markdown more complex if we want + + Lorem markdownum recepta avidum, missa de quam patientia, antris: cum defuit, + Titan repetemus nomine, ignare. Quod ad aura, et non quod vidisse utque ulla: + + - Pro inposuit tibi orsa tum artes ferox + - Acmon plausu qua agrestum situs virgo in + - Vacuus a pendens rostro non si pharetrae + - Haeremusque quos auxiliaris coniunx + - Repulsa impediunt munera teneri fallebat + - Bracchia frustra telo Iovis faucibus casus + +gameengine: + shuffle_exercises: true + shuffle_sequences: true + +exercises: + - group: + - instructions: + - locale: fr_FR + value: Touch le rond jaune + - locale: en_US + value: Touch the yellow circle + interface: touchToSelect + gameplay: findTheRightAnswers + payload: + choices: + - value: yellow + type: color + isRightAnswer: true + - value: red + type: color + - value: green + type: color + - value: blue + type: color + + - instructions: + - locale: fr_FR + value: Touch la pastèque + - locale: en_US + value: Touch the watermelon + interface: touchToSelect + gameplay: findTheRightAnswers + payload: + choices: + - value: 🍉 + type: emoji + isRightAnswer: true + - value: 🍌 + type: emoji + - value: 🍒 + type: emoji + - value: 🥝 + type: emoji + + - instructions: + - locale: fr_FR + value: Touch le carré + - locale: en_US + value: Touch the square + interface: touchToSelect + gameplay: findTheRightAnswers + payload: + choices: + - value: circle + type: sfsymbol + - value: square + type: sfsymbol + isRightAnswer: true + - value: triangle + type: sfsymbol + - value: rhombus + type: sfsymbol + + - group: + - instructions: + - locale: fr_FR + value: Contrôle Leka avec la télécommande et fais le changer de couleur + - locale: en_US + value: Control Leka with the remote and make it change color + interface: remoteArrow + + - instructions: + - locale: fr_FR + value: Contrôle Leka avec la télécommande et fais le changer de couleur + - locale: en_US + value: Control Leka with the remote and make it change color + interface: remoteArrow + + - group: + - instructions: + - locale: fr_FR + value: Joue du xylophone avec Leka + - locale: en_US + value: Play the xylophone with Leka + interface: musicalInstruments + payload: + instrument: xylophone + scale: majorHeptatonic + + - instructions: + - locale: fr_FR + value: Joue du xylophone avec Leka + - locale: en_US + value: Play the xylophone with Leka + interface: musicalInstruments + payload: + instrument: xylophone + scale: majorPentatonic + + - group: + - instructions: + interface: danceFreeze + payload: + songs: + - earlyBird + - emptyPage + - gigglySquirrel + - handsOn + - happyDays + - inTheGame + - littleByLittle + + - instructions: + interface: hideAndSeek + + - instructions: + - locale: fr_FR + value: Joue les notes de la même couleur que Leka + - locale: en_US + value: Play the notes of the same color as Leka + interface: melody + payload: + instrument: xylophone + songs: + - underTheMoonlight + - aGreenMouse + - twinkleTwinkleLittleStar + - londonBridgeIsFallingDown + - ohTheCrocodiles + - happyBirthday diff --git a/Modules/ContentKit/Resources/Content/activities/examples/6102794F02D3423482E243BCBC7F8CA8-sample_2.activity.yml b/Modules/ContentKit/Resources/Content/activities/examples/6102794F02D3423482E243BCBC7F8CA8-sample_2.activity.yml new file mode 100644 index 000000000..b9dec965b --- /dev/null +++ b/Modules/ContentKit/Resources/Content/activities/examples/6102794F02D3423482E243BCBC7F8CA8-sample_2.activity.yml @@ -0,0 +1,212 @@ +# Leka - iOS Monorepo +# Copyright APF France handicap +# SPDX-License-Identifier: Apache-2.0 + +version: 1.0.0 + +uuid: 6102794F02D3423482E243BCBC7F8CA8 +name: sample_2 + +status: published + +authors: + - leka + - aurore_kiesler + - julie_tuil + +skills: + - spatial_understanding + - recognition/animals + - communication/non_verbal_communication/gestures + +tags: + - tag_one + - tag_two + - tag_three + +hmi: + - robot + - magic_cards + - tablet_robot + +locales: + - en_US + - fr_FR + +l10n: + - locale: fr_FR + details: + icon: name_of_the_activity-icon-fr_FR.svg + + title: Activité d'exemple + subtitle: pour le développement + + description: | + Activité d'exemple utilisée pour le développement de l'application + + instructions: | + ## Longues instructions en markdown plus complexe si on veut + + Lorem markdownum recepta avidum, missa de quam patientia, antris: cum defuit, + Titan repetemus nomine, ignare. Quod ad aura, et non quod vidisse utque ulla: + + - Pro inposuit tibi orsa tum artes ferox + - Acmon plausu qua agrestum situs virgo in + - Vacuus a pendens rostro non si pharetrae + - Haeremusque quos auxiliaris coniunx + - Repulsa impediunt munera teneri fallebat + - Bracchia frustra telo Iovis faucibus casus + + - locale: en_US + details: + icon: name_of_the_activity-icon-en_US.svg + + title: Sample activity + subtitle: for development + + description: | + Sample activity used for the development of the application + + instructions: | + ## Long instructions in markdown more complex if we want + + Lorem markdownum recepta avidum, missa de quam patientia, antris: cum defuit, + Titan repetemus nomine, ignare. Quod ad aura, et non quod vidisse utque ulla: + + - Pro inposuit tibi orsa tum artes ferox + - Acmon plausu qua agrestum situs virgo in + - Vacuus a pendens rostro non si pharetrae + - Haeremusque quos auxiliaris coniunx + - Repulsa impediunt munera teneri fallebat + - Bracchia frustra telo Iovis faucibus casus + +gameengine: + shuffle_exercises: true + shuffle_sequences: true + +exercises: + - group: + - instructions: + - locale: fr_FR + value: Touch le rond jaune + - locale: en_US + value: Touch the yellow circle + interface: touchToSelect + gameplay: findTheRightAnswers + payload: + choices: + - value: yellow + type: color + isRightAnswer: true + - value: red + type: color + - value: green + type: color + - value: blue + type: color + + - instructions: + - locale: fr_FR + value: Touch la pastèque + - locale: en_US + value: Touch the watermelon + interface: touchToSelect + gameplay: findTheRightAnswers + payload: + choices: + - value: 🍉 + type: emoji + isRightAnswer: true + - value: 🍌 + type: emoji + - value: 🍒 + type: emoji + - value: 🥝 + type: emoji + + - instructions: + - locale: fr_FR + value: Touch le carré + - locale: en_US + value: Touch the square + interface: touchToSelect + gameplay: findTheRightAnswers + payload: + choices: + - value: circle + type: sfsymbol + - value: square + type: sfsymbol + isRightAnswer: true + - value: triangle + type: sfsymbol + - value: rhombus + type: sfsymbol + + - group: + - instructions: + - locale: fr_FR + value: Contrôle Leka avec la télécommande et fais le changer de couleur + - locale: en_US + value: Control Leka with the remote and make it change color + interface: remoteArrow + + - instructions: + - locale: fr_FR + value: Contrôle Leka avec la télécommande et fais le changer de couleur + - locale: en_US + value: Control Leka with the remote and make it change color + interface: remoteArrow + + - group: + - instructions: + - locale: fr_FR + value: Joue du xylophone avec Leka + - locale: en_US + value: Play the xylophone with Leka + interface: musicalInstruments + payload: + instrument: xylophone + scale: majorHeptatonic + + - instructions: + - locale: fr_FR + value: Joue du xylophone avec Leka + - locale: en_US + value: Play the xylophone with Leka + interface: musicalInstruments + payload: + instrument: xylophone + scale: majorPentatonic + + - group: + - instructions: + interface: danceFreeze + payload: + songs: + - earlyBird + - emptyPage + - gigglySquirrel + - handsOn + - happyDays + - inTheGame + - littleByLittle + + - instructions: + interface: hideAndSeek + + - instructions: + - locale: fr_FR + value: Joue les notes de la même couleur que Leka + - locale: en_US + value: Play the notes of the same color as Leka + interface: melody + payload: + instrument: xylophone + songs: + - underTheMoonlight + - aGreenMouse + - twinkleTwinkleLittleStar + - londonBridgeIsFallingDown + - ohTheCrocodiles + - happyBirthday diff --git a/Modules/ContentKit/Resources/Content/activities/examples/725853C4DC7B4D84A45AA20385F389F1-sample_5.activity.yml b/Modules/ContentKit/Resources/Content/activities/examples/725853C4DC7B4D84A45AA20385F389F1-sample_5.activity.yml new file mode 100644 index 000000000..14485f85f --- /dev/null +++ b/Modules/ContentKit/Resources/Content/activities/examples/725853C4DC7B4D84A45AA20385F389F1-sample_5.activity.yml @@ -0,0 +1,212 @@ +# Leka - iOS Monorepo +# Copyright APF France handicap +# SPDX-License-Identifier: Apache-2.0 + +version: 1.0.0 + +uuid: 725853C4DC7B4D84A45AA20385F389F1 +name: sample_5 + +status: published + +authors: + - leka + - aurore_kiesler + - julie_tuil + +skills: + - spatial_understanding + - recognition/animals + - communication/non_verbal_communication/gestures + +tags: + - tag_one + - tag_two + - tag_three + +hmi: + - robot + - magic_cards + - tablet_robot + +locales: + - en_US + - fr_FR + +l10n: + - locale: fr_FR + details: + icon: name_of_the_activity-icon-fr_FR.svg + + title: Activité d'exemple + subtitle: pour le développement + + description: | + Activité d'exemple utilisée pour le développement de l'application + + instructions: | + ## Longues instructions en markdown plus complexe si on veut + + Lorem markdownum recepta avidum, missa de quam patientia, antris: cum defuit, + Titan repetemus nomine, ignare. Quod ad aura, et non quod vidisse utque ulla: + + - Pro inposuit tibi orsa tum artes ferox + - Acmon plausu qua agrestum situs virgo in + - Vacuus a pendens rostro non si pharetrae + - Haeremusque quos auxiliaris coniunx + - Repulsa impediunt munera teneri fallebat + - Bracchia frustra telo Iovis faucibus casus + + - locale: en_US + details: + icon: name_of_the_activity-icon-en_US.svg + + title: Sample activity + subtitle: for development + + description: | + Sample activity used for the development of the application + + instructions: | + ## Long instructions in markdown more complex if we want + + Lorem markdownum recepta avidum, missa de quam patientia, antris: cum defuit, + Titan repetemus nomine, ignare. Quod ad aura, et non quod vidisse utque ulla: + + - Pro inposuit tibi orsa tum artes ferox + - Acmon plausu qua agrestum situs virgo in + - Vacuus a pendens rostro non si pharetrae + - Haeremusque quos auxiliaris coniunx + - Repulsa impediunt munera teneri fallebat + - Bracchia frustra telo Iovis faucibus casus + +gameengine: + shuffle_exercises: true + shuffle_sequences: true + +exercises: + - group: + - instructions: + - locale: fr_FR + value: Touch le rond jaune + - locale: en_US + value: Touch the yellow circle + interface: touchToSelect + gameplay: findTheRightAnswers + payload: + choices: + - value: yellow + type: color + isRightAnswer: true + - value: red + type: color + - value: green + type: color + - value: blue + type: color + + - instructions: + - locale: fr_FR + value: Touch la pastèque + - locale: en_US + value: Touch the watermelon + interface: touchToSelect + gameplay: findTheRightAnswers + payload: + choices: + - value: 🍉 + type: emoji + isRightAnswer: true + - value: 🍌 + type: emoji + - value: 🍒 + type: emoji + - value: 🥝 + type: emoji + + - instructions: + - locale: fr_FR + value: Touch le carré + - locale: en_US + value: Touch the square + interface: touchToSelect + gameplay: findTheRightAnswers + payload: + choices: + - value: circle + type: sfsymbol + - value: square + type: sfsymbol + isRightAnswer: true + - value: triangle + type: sfsymbol + - value: rhombus + type: sfsymbol + + - group: + - instructions: + - locale: fr_FR + value: Contrôle Leka avec la télécommande et fais le changer de couleur + - locale: en_US + value: Control Leka with the remote and make it change color + interface: remoteArrow + + - instructions: + - locale: fr_FR + value: Contrôle Leka avec la télécommande et fais le changer de couleur + - locale: en_US + value: Control Leka with the remote and make it change color + interface: remoteArrow + + - group: + - instructions: + - locale: fr_FR + value: Joue du xylophone avec Leka + - locale: en_US + value: Play the xylophone with Leka + interface: musicalInstruments + payload: + instrument: xylophone + scale: majorHeptatonic + + - instructions: + - locale: fr_FR + value: Joue du xylophone avec Leka + - locale: en_US + value: Play the xylophone with Leka + interface: musicalInstruments + payload: + instrument: xylophone + scale: majorPentatonic + + - group: + - instructions: + interface: danceFreeze + payload: + songs: + - earlyBird + - emptyPage + - gigglySquirrel + - handsOn + - happyDays + - inTheGame + - littleByLittle + + - instructions: + interface: hideAndSeek + + - instructions: + - locale: fr_FR + value: Joue les notes de la même couleur que Leka + - locale: en_US + value: Play the notes of the same color as Leka + interface: melody + payload: + instrument: xylophone + songs: + - underTheMoonlight + - aGreenMouse + - twinkleTwinkleLittleStar + - londonBridgeIsFallingDown + - ohTheCrocodiles + - happyBirthday diff --git a/Modules/ContentKit/Resources/Content/activities/examples/81F6617499FE42ADB5B03B409462923E-sample_4.activity.yml b/Modules/ContentKit/Resources/Content/activities/examples/81F6617499FE42ADB5B03B409462923E-sample_4.activity.yml new file mode 100644 index 000000000..9f609a24b --- /dev/null +++ b/Modules/ContentKit/Resources/Content/activities/examples/81F6617499FE42ADB5B03B409462923E-sample_4.activity.yml @@ -0,0 +1,212 @@ +# Leka - iOS Monorepo +# Copyright APF France handicap +# SPDX-License-Identifier: Apache-2.0 + +version: 1.0.0 + +uuid: 81F6617499FE42ADB5B03B409462923E +name: sample_4 + +status: published + +authors: + - leka + - aurore_kiesler + - julie_tuil + +skills: + - spatial_understanding + - recognition/animals + - communication/non_verbal_communication/gestures + +tags: + - tag_one + - tag_two + - tag_three + +hmi: + - robot + - magic_cards + - tablet_robot + +locales: + - en_US + - fr_FR + +l10n: + - locale: fr_FR + details: + icon: name_of_the_activity-icon-fr_FR.svg + + title: Activité d'exemple + subtitle: pour le développement + + description: | + Activité d'exemple utilisée pour le développement de l'application + + instructions: | + ## Longues instructions en markdown plus complexe si on veut + + Lorem markdownum recepta avidum, missa de quam patientia, antris: cum defuit, + Titan repetemus nomine, ignare. Quod ad aura, et non quod vidisse utque ulla: + + - Pro inposuit tibi orsa tum artes ferox + - Acmon plausu qua agrestum situs virgo in + - Vacuus a pendens rostro non si pharetrae + - Haeremusque quos auxiliaris coniunx + - Repulsa impediunt munera teneri fallebat + - Bracchia frustra telo Iovis faucibus casus + + - locale: en_US + details: + icon: name_of_the_activity-icon-en_US.svg + + title: Sample activity + subtitle: for development + + description: | + Sample activity used for the development of the application + + instructions: | + ## Long instructions in markdown more complex if we want + + Lorem markdownum recepta avidum, missa de quam patientia, antris: cum defuit, + Titan repetemus nomine, ignare. Quod ad aura, et non quod vidisse utque ulla: + + - Pro inposuit tibi orsa tum artes ferox + - Acmon plausu qua agrestum situs virgo in + - Vacuus a pendens rostro non si pharetrae + - Haeremusque quos auxiliaris coniunx + - Repulsa impediunt munera teneri fallebat + - Bracchia frustra telo Iovis faucibus casus + +gameengine: + shuffle_exercises: true + shuffle_sequences: true + +exercises: + - group: + - instructions: + - locale: fr_FR + value: Touch le rond jaune + - locale: en_US + value: Touch the yellow circle + interface: touchToSelect + gameplay: findTheRightAnswers + payload: + choices: + - value: yellow + type: color + isRightAnswer: true + - value: red + type: color + - value: green + type: color + - value: blue + type: color + + - instructions: + - locale: fr_FR + value: Touch la pastèque + - locale: en_US + value: Touch the watermelon + interface: touchToSelect + gameplay: findTheRightAnswers + payload: + choices: + - value: 🍉 + type: emoji + isRightAnswer: true + - value: 🍌 + type: emoji + - value: 🍒 + type: emoji + - value: 🥝 + type: emoji + + - instructions: + - locale: fr_FR + value: Touch le carré + - locale: en_US + value: Touch the square + interface: touchToSelect + gameplay: findTheRightAnswers + payload: + choices: + - value: circle + type: sfsymbol + - value: square + type: sfsymbol + isRightAnswer: true + - value: triangle + type: sfsymbol + - value: rhombus + type: sfsymbol + + - group: + - instructions: + - locale: fr_FR + value: Contrôle Leka avec la télécommande et fais le changer de couleur + - locale: en_US + value: Control Leka with the remote and make it change color + interface: remoteArrow + + - instructions: + - locale: fr_FR + value: Contrôle Leka avec la télécommande et fais le changer de couleur + - locale: en_US + value: Control Leka with the remote and make it change color + interface: remoteArrow + + - group: + - instructions: + - locale: fr_FR + value: Joue du xylophone avec Leka + - locale: en_US + value: Play the xylophone with Leka + interface: musicalInstruments + payload: + instrument: xylophone + scale: majorHeptatonic + + - instructions: + - locale: fr_FR + value: Joue du xylophone avec Leka + - locale: en_US + value: Play the xylophone with Leka + interface: musicalInstruments + payload: + instrument: xylophone + scale: majorPentatonic + + - group: + - instructions: + interface: danceFreeze + payload: + songs: + - earlyBird + - emptyPage + - gigglySquirrel + - handsOn + - happyDays + - inTheGame + - littleByLittle + + - instructions: + interface: hideAndSeek + + - instructions: + - locale: fr_FR + value: Joue les notes de la même couleur que Leka + - locale: en_US + value: Play the notes of the same color as Leka + interface: melody + payload: + instrument: xylophone + songs: + - underTheMoonlight + - aGreenMouse + - twinkleTwinkleLittleStar + - londonBridgeIsFallingDown + - ohTheCrocodiles + - happyBirthday diff --git a/Modules/ContentKit/Resources/Content/activities/examples/E7EE9CA4B13B49AF96CD77A9DF90833B-sample_3.activity.yml b/Modules/ContentKit/Resources/Content/activities/examples/E7EE9CA4B13B49AF96CD77A9DF90833B-sample_3.activity.yml new file mode 100644 index 000000000..fe5884d97 --- /dev/null +++ b/Modules/ContentKit/Resources/Content/activities/examples/E7EE9CA4B13B49AF96CD77A9DF90833B-sample_3.activity.yml @@ -0,0 +1,212 @@ +# Leka - iOS Monorepo +# Copyright APF France handicap +# SPDX-License-Identifier: Apache-2.0 + +version: 1.0.0 + +uuid: E7EE9CA4B13B49AF96CD77A9DF90833B +name: sample_3 + +status: published + +authors: + - leka + - aurore_kiesler + - julie_tuil + +skills: + - spatial_understanding + - recognition/animals + - communication/non_verbal_communication/gestures + +tags: + - tag_one + - tag_two + - tag_three + +hmi: + - robot + - magic_cards + - tablet_robot + +locales: + - en_US + - fr_FR + +l10n: + - locale: fr_FR + details: + icon: name_of_the_activity-icon-fr_FR.svg + + title: Activité d'exemple + subtitle: pour le développement + + description: | + Activité d'exemple utilisée pour le développement de l'application + + instructions: | + ## Longues instructions en markdown plus complexe si on veut + + Lorem markdownum recepta avidum, missa de quam patientia, antris: cum defuit, + Titan repetemus nomine, ignare. Quod ad aura, et non quod vidisse utque ulla: + + - Pro inposuit tibi orsa tum artes ferox + - Acmon plausu qua agrestum situs virgo in + - Vacuus a pendens rostro non si pharetrae + - Haeremusque quos auxiliaris coniunx + - Repulsa impediunt munera teneri fallebat + - Bracchia frustra telo Iovis faucibus casus + + - locale: en_US + details: + icon: name_of_the_activity-icon-en_US.svg + + title: Sample activity + subtitle: for development + + description: | + Sample activity used for the development of the application + + instructions: | + ## Long instructions in markdown more complex if we want + + Lorem markdownum recepta avidum, missa de quam patientia, antris: cum defuit, + Titan repetemus nomine, ignare. Quod ad aura, et non quod vidisse utque ulla: + + - Pro inposuit tibi orsa tum artes ferox + - Acmon plausu qua agrestum situs virgo in + - Vacuus a pendens rostro non si pharetrae + - Haeremusque quos auxiliaris coniunx + - Repulsa impediunt munera teneri fallebat + - Bracchia frustra telo Iovis faucibus casus + +gameengine: + shuffle_exercises: true + shuffle_sequences: true + +exercises: + - group: + - instructions: + - locale: fr_FR + value: Touch le rond jaune + - locale: en_US + value: Touch the yellow circle + interface: touchToSelect + gameplay: findTheRightAnswers + payload: + choices: + - value: yellow + type: color + isRightAnswer: true + - value: red + type: color + - value: green + type: color + - value: blue + type: color + + - instructions: + - locale: fr_FR + value: Touch la pastèque + - locale: en_US + value: Touch the watermelon + interface: touchToSelect + gameplay: findTheRightAnswers + payload: + choices: + - value: 🍉 + type: emoji + isRightAnswer: true + - value: 🍌 + type: emoji + - value: 🍒 + type: emoji + - value: 🥝 + type: emoji + + - instructions: + - locale: fr_FR + value: Touch le carré + - locale: en_US + value: Touch the square + interface: touchToSelect + gameplay: findTheRightAnswers + payload: + choices: + - value: circle + type: sfsymbol + - value: square + type: sfsymbol + isRightAnswer: true + - value: triangle + type: sfsymbol + - value: rhombus + type: sfsymbol + + - group: + - instructions: + - locale: fr_FR + value: Contrôle Leka avec la télécommande et fais le changer de couleur + - locale: en_US + value: Control Leka with the remote and make it change color + interface: remoteArrow + + - instructions: + - locale: fr_FR + value: Contrôle Leka avec la télécommande et fais le changer de couleur + - locale: en_US + value: Control Leka with the remote and make it change color + interface: remoteArrow + + - group: + - instructions: + - locale: fr_FR + value: Joue du xylophone avec Leka + - locale: en_US + value: Play the xylophone with Leka + interface: musicalInstruments + payload: + instrument: xylophone + scale: majorHeptatonic + + - instructions: + - locale: fr_FR + value: Joue du xylophone avec Leka + - locale: en_US + value: Play the xylophone with Leka + interface: musicalInstruments + payload: + instrument: xylophone + scale: majorPentatonic + + - group: + - instructions: + interface: danceFreeze + payload: + songs: + - earlyBird + - emptyPage + - gigglySquirrel + - handsOn + - happyDays + - inTheGame + - littleByLittle + + - instructions: + interface: hideAndSeek + + - instructions: + - locale: fr_FR + value: Joue les notes de la même couleur que Leka + - locale: en_US + value: Play the notes of the same color as Leka + interface: melody + payload: + instrument: xylophone + songs: + - underTheMoonlight + - aGreenMouse + - twinkleTwinkleLittleStar + - londonBridgeIsFallingDown + - ohTheCrocodiles + - happyBirthday From e933e6166c643286ef215fe8cae8d5630577087a Mon Sep 17 00:00:00 2001 From: Ladislas de Toldi Date: Thu, 15 Feb 2024 13:07:01 +0100 Subject: [PATCH 7/9] :clown_face: (ContentKit): Activity - add mock --- .../Sources/Mocks/Activity+Mock.swift | 120 ++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 Modules/ContentKit/Sources/Mocks/Activity+Mock.swift diff --git a/Modules/ContentKit/Sources/Mocks/Activity+Mock.swift b/Modules/ContentKit/Sources/Mocks/Activity+Mock.swift new file mode 100644 index 000000000..2dece2979 --- /dev/null +++ b/Modules/ContentKit/Sources/Mocks/Activity+Mock.swift @@ -0,0 +1,120 @@ +// Leka - iOS Monorepo +// Copyright APF France handicap +// SPDX-License-Identifier: Apache-2.0 + +import Yams + +public extension Activity { + static var mock: Activity { + let data = mockActivityYaml.data(using: .utf8)! + let activity = try! YAMLDecoder().decode(Activity.self, from: data) // swiftlint:disable:this force_try + return activity + } + + // swiftformat:disable all + private static let mockActivityYaml = """ + version: 1.0.0 + + uuid: E7EE9CA4B13B49AF96CD77A9DF90833B + name: mock_activity + + status: published + + authors: + - leka + - aurore_kiesler + - julie_tuil + + skills: + - spatial_understanding + - recognition/animals + - communication/non_verbal_communication/gestures + + tags: + - tag_one + - tag_two + - tag_three + + hmi: + - robot + - magic_cards + - tablet_robot + + locales: + - en_US + - fr_FR + + l10n: + - locale: fr_FR + details: + icon: name_of_the_activity-icon-fr_FR.svg + + title: Activité d'exemple + subtitle: pour le développement + + description: | + Activité d'exemple utilisée pour le développement de l'application + + instructions: | + ## Longues instructions en markdown plus complexe si on veut + + Lorem markdownum recepta avidum, missa de quam patientia, antris: cum defuit, + Titan repetemus nomine, ignare. Quod ad aura, et non quod vidisse utque ulla: + + - Pro inposuit tibi orsa tum artes ferox + - Acmon plausu qua agrestum situs virgo in + - Vacuus a pendens rostro non si pharetrae + - Haeremusque quos auxiliaris coniunx + - Repulsa impediunt munera teneri fallebat + - Bracchia frustra telo Iovis faucibus casus + + - locale: en_US + details: + icon: name_of_the_activity-icon-en_US.svg + + title: Sample activity + subtitle: for development + + description: | + Sample activity used for the development of the application + + instructions: | + ## Long instructions in markdown more complex if we want + + Lorem markdownum recepta avidum, missa de quam patientia, antris: cum defuit, + Titan repetemus nomine, ignare. Quod ad aura, et non quod vidisse utque ulla: + + - Pro inposuit tibi orsa tum artes ferox + - Acmon plausu qua agrestum situs virgo in + - Vacuus a pendens rostro non si pharetrae + - Haeremusque quos auxiliaris coniunx + - Repulsa impediunt munera teneri fallebat + - Bracchia frustra telo Iovis faucibus casus + + gameengine: + shuffle_exercises: true + shuffle_sequences: true + + exercises: + - group: + - instructions: + - locale: fr_FR + value: Touch le rond jaune + - locale: en_US + value: Touch the yellow circle + interface: touchToSelect + gameplay: findTheRightAnswers + payload: + choices: + - value: yellow + type: color + isRightAnswer: true + - value: red + type: color + - value: green + type: color + - value: blue + type: color + """ + // swiftformat:enable all +} From 885be4aaaf23aa12082be4366e2ca85db15979b2 Mon Sep 17 00:00:00 2001 From: Ladislas de Toldi Date: Thu, 15 Feb 2024 13:07:37 +0100 Subject: [PATCH 8/9] :sparkles: (ContentKit): List sample activities --- Modules/ContentKit/Sources/ContentKit.swift | 31 ++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/Modules/ContentKit/Sources/ContentKit.swift b/Modules/ContentKit/Sources/ContentKit.swift index 098329ee1..766cd879d 100644 --- a/Modules/ContentKit/Sources/ContentKit.swift +++ b/Modules/ContentKit/Sources/ContentKit.swift @@ -2,10 +2,39 @@ // Copyright APF France handicap // SPDX-License-Identifier: Apache-2.0 +import Foundation import LogKit +import Yams let log = LogKit.createLoggerFor(module: "ContentKit") // MARK: - ContentKit -public enum ContentKit {} +public enum ContentKit { + public static func listSampleActivities() -> [Activity]? { + let bundle = Bundle.module + let files = bundle.paths(forResourcesOfType: "activity.yml", inDirectory: nil) + + var activities: [Activity] = [] + + for file in files { + let data = try? String(contentsOfFile: file, encoding: .utf8) + + guard let data else { + log.error("Error reading file: \(file)") + continue + } + + let activity = try? YAMLDecoder().decode(Activity.self, from: data) + + guard let activity else { + log.error("Error decoding file: \(file)") + continue + } + + activities.append(activity) + } + + return activities.sorted { $0.name < $1.name } + } +} From c1d2ac4a2065a3563b1611e6bcb5cf450ba4d5ec Mon Sep 17 00:00:00 2001 From: Ladislas de Toldi Date: Thu, 15 Feb 2024 13:07:54 +0100 Subject: [PATCH 9/9] :alembic: (ContentKitExample): List sample activities, show details --- ...inView.swift => ActivityDetailsView.swift} | 76 ++++++------------- .../Sources/ActivityListView.swift | 55 ++++++++++++++ .../ContentKitExample/Sources/MainApp.swift | 4 +- 3 files changed, 80 insertions(+), 55 deletions(-) rename Modules/ContentKit/Examples/ContentKitExample/Sources/{MainView.swift => ActivityDetailsView.swift} (63%) create mode 100644 Modules/ContentKit/Examples/ContentKitExample/Sources/ActivityListView.swift diff --git a/Modules/ContentKit/Examples/ContentKitExample/Sources/MainView.swift b/Modules/ContentKit/Examples/ContentKitExample/Sources/ActivityDetailsView.swift similarity index 63% rename from Modules/ContentKit/Examples/ContentKitExample/Sources/MainView.swift rename to Modules/ContentKit/Examples/ContentKitExample/Sources/ActivityDetailsView.swift index db0d52238..8519802a2 100644 --- a/Modules/ContentKit/Examples/ContentKitExample/Sources/MainView.swift +++ b/Modules/ContentKit/Examples/ContentKitExample/Sources/ActivityDetailsView.swift @@ -7,13 +7,6 @@ import LocalizationKit import MarkdownUI import SwiftUI -extension Theme { - static let leka: Theme = .gitHub - .text { - BackgroundColor(.clear) - } -} - // MARK: - RowView struct RowView: View { @@ -44,21 +37,23 @@ struct RowView: View { } } -// MARK: - MainView +// MARK: - ActivityDetailsView -struct MainView: View { +struct ActivityDetailsView: View { // MARK: Internal + let activity: Activity + var body: some View { List { Section("Information") { - RowView(label: "UUID", value: self.activity?.id ?? "nil") - RowView(label: "Name", value: self.activity?.name ?? "nil") + RowView(label: "UUID", value: self.activity.id) + RowView(label: "Name", value: self.activity.name) - RowView(label: "Status", value: self.activity?.status == .published ? "published" : "draft") + RowView(label: "Status", value: self.activity.status == .published ? "published" : "draft") DisclosureGroup("**Authors**") { - ForEach(self.activity?.authors ?? [], id: \.self) { author in + ForEach(self.activity.authors, id: \.self) { author in let author = Authors.hmi(id: author)! HStack { Text(author.name) @@ -79,13 +74,13 @@ struct MainView: View { }) DisclosureGroup("**Available languages**") { - ForEach(self.activity?.languages ?? [], id: \.self) { lang in + ForEach(self.activity.languages, id: \.self) { lang in Text(lang.identifier) } } DisclosureGroup("**Skills**") { - ForEach(self.activity?.skills ?? [], id: \.self) { skill in + ForEach(self.activity.skills, id: \.self) { skill in let skill = Skills.skill(id: skill)! HStack { Text(skill.name) @@ -106,7 +101,7 @@ struct MainView: View { }) DisclosureGroup("**HMI**") { - ForEach(self.activity?.hmi ?? [], id: \.self) { hmi in + ForEach(self.activity.hmi, id: \.self) { hmi in let hmi = HMI.hmi(id: hmi)! HStack { Text(hmi.name) @@ -127,51 +122,24 @@ struct MainView: View { }) DisclosureGroup("**Tags**") { - ForEach(self.activity?.tags ?? [], id: \.self) { skill in + ForEach(self.activity.tags, id: \.self) { skill in Text(skill) } } } Section("Details (in: \(l10n.language.identifier))") { - Text(self.activity?.details.title ?? "nil") + Text(self.activity.details.title) .font(.title) - Text(self.activity?.details.subtitle ?? "nil") + Text(self.activity.details.subtitle) .font(.title2) - Markdown(self.activity?.details.description ?? "nil") - .markdownTheme(.leka) - Markdown(self.activity?.details.instructions ?? "nil") - .markdownTheme(.leka) - } - } - .onAppear { - self.activity = ContentKit.decodeActivity("activity") - print(self.activity ?? "not working") - - let skills = Skills.list - for (index, skill) in skills.enumerated() { - print("skill \(index + 1)") - print("id: \(skill.id)") - print("name: \(skill.name)") - print("description: \(skill.description)") - } - - let hmis = HMI.list - for (index, hmi) in hmis.enumerated() { - print("hmi \(index + 1)") - print("id: \(hmi.id)") - print("name: \(hmi.name)") - print("description: \(hmi.description)") - } - - let authors = Authors.list - for (index, author) in authors.enumerated() { - print("author \(index + 1)") - print("id: \(author.id)") - print("name: \(author.name)") - print("description: \(author.description)") + Markdown(self.activity.details.description) + .markdownTheme(.gitHub) + Markdown(self.activity.details.instructions) + .markdownTheme(.gitHub) } } + .navigationTitle(self.activity.name) } // MARK: Private @@ -179,10 +147,10 @@ struct MainView: View { @State private var selectedSkill: Skill? @State private var selectedHMI: HMIDetails? @State private var selectedAuthor: Author? - - @State private var activity: Activity? } #Preview { - MainView() + NavigationStack { + ActivityDetailsView(activity: Activity.mock) + } } diff --git a/Modules/ContentKit/Examples/ContentKitExample/Sources/ActivityListView.swift b/Modules/ContentKit/Examples/ContentKitExample/Sources/ActivityListView.swift new file mode 100644 index 000000000..1c9425e4c --- /dev/null +++ b/Modules/ContentKit/Examples/ContentKitExample/Sources/ActivityListView.swift @@ -0,0 +1,55 @@ +// Leka - iOS Monorepo +// Copyright APF France handicap +// SPDX-License-Identifier: Apache-2.0 + +import ContentKit +import MarkdownUI +import SwiftUI + +// MARK: - ActivityListView + +struct ActivityListView: View { + let activities: [Activity] = ContentKit.listSampleActivities() ?? [] + + var body: some View { + List { + ForEach(self.activities) { activity in + NavigationLink(destination: ActivityDetailsView(activity: activity)) { + Text(activity.name) + } + } + } + .navigationTitle("Activities") + .onAppear { + let skills = Skills.list + for (index, skill) in skills.enumerated() { + print("skill \(index + 1)") + print("id: \(skill.id)") + print("name: \(skill.name)") + print("description: \(skill.description)") + } + + let hmis = HMI.list + for (index, hmi) in hmis.enumerated() { + print("hmi \(index + 1)") + print("id: \(hmi.id)") + print("name: \(hmi.name)") + print("description: \(hmi.description)") + } + + let authors = Authors.list + for (index, author) in authors.enumerated() { + print("author \(index + 1)") + print("id: \(author.id)") + print("name: \(author.name)") + print("description: \(author.description)") + } + } + } +} + +#Preview { + NavigationStack { + ActivityListView() + } +} diff --git a/Modules/ContentKit/Examples/ContentKitExample/Sources/MainApp.swift b/Modules/ContentKit/Examples/ContentKitExample/Sources/MainApp.swift index 7f59470fa..31c5ef3e0 100644 --- a/Modules/ContentKit/Examples/ContentKitExample/Sources/MainApp.swift +++ b/Modules/ContentKit/Examples/ContentKitExample/Sources/MainApp.swift @@ -9,7 +9,9 @@ import SwiftUI struct ContentKitExample: App { var body: some Scene { WindowGroup { - MainView() + NavigationStack { + ActivityListView() + } } } }