From b00378b780565a52424d318b5d42419be9bbddb2 Mon Sep 17 00:00:00 2001 From: Hugo Pezziardi Date: Wed, 13 Dec 2023 16:51:45 +0100 Subject: [PATCH] :sparkles: (ContentKitxUIExplorer): Add Pairing activity --- .../activities/activity-pairing.yml | 22 ++++++ .../GEKNewSystem/GEKNewSystemView.swift | 1 + .../Sources/Exercise/Exercise+Interface.swift | 1 + .../Sources/Exercise/Exercise+Pairing.swift | 73 +++++++++++++++++++ .../Sources/Exercise/Exercise+Payload.swift | 4 + .../Sources/Exercise/Exercise.swift | 3 + 6 files changed, 104 insertions(+) create mode 100644 Apps/LekaActivityUIExplorer/Resources/GEKNewSystem/activities/activity-pairing.yml create mode 100644 Modules/ContentKit/Sources/Exercise/Exercise+Pairing.swift diff --git a/Apps/LekaActivityUIExplorer/Resources/GEKNewSystem/activities/activity-pairing.yml b/Apps/LekaActivityUIExplorer/Resources/GEKNewSystem/activities/activity-pairing.yml new file mode 100644 index 0000000000..313826213b --- /dev/null +++ b/Apps/LekaActivityUIExplorer/Resources/GEKNewSystem/activities/activity-pairing.yml @@ -0,0 +1,22 @@ +# Leka - iOS Monorepo +# Copyright 2023 APF France handicap +# SPDX-License-Identifier: Apache-2.0 + +id: 834779ede3324f44a38163159edc15c0 +name: Pairing +description: L'objectif est de découvrir Leka et s'habituer à ses réactions +image: activity_color_recognition_1 +sequence: + - exercises: + - instructions: Observe Leka + interface: pairing + payload: + instructions: + text_main_instructions: | + Le mode Pairing permet à la personne accompagnée de se familiariser à Leka + avant même d'entrer dans les apprentissages des Activités et des Parcours. + Le robot va s'animer en faisant des pauses afin que la personne accompagnée puisse + apprivoiser son nouveau compagnon ! + text_button_play: Jouer + text_button_pause: Pause + text_button_stop: Stop diff --git a/Apps/LekaActivityUIExplorer/Sources/GEKNewSystem/GEKNewSystemView.swift b/Apps/LekaActivityUIExplorer/Sources/GEKNewSystem/GEKNewSystemView.swift index a99dc488e0..2c17e8af23 100644 --- a/Apps/LekaActivityUIExplorer/Sources/GEKNewSystem/GEKNewSystemView.swift +++ b/Apps/LekaActivityUIExplorer/Sources/GEKNewSystem/GEKNewSystemView.swift @@ -41,6 +41,7 @@ let kActivities: [Activity] = [ ContentKit.decodeActivity("activity-xylophone-pentatonic"), ContentKit.decodeActivity("activity-xylophone-heptatonic"), ContentKit.decodeActivity("activity-melody"), + ContentKit.decodeActivity("activity-pairing"), ] // MARK: - GEKNewSystemView diff --git a/Modules/ContentKit/Sources/Exercise/Exercise+Interface.swift b/Modules/ContentKit/Sources/Exercise/Exercise+Interface.swift index f7f7ae9b17..fa53f52abb 100644 --- a/Modules/ContentKit/Sources/Exercise/Exercise+Interface.swift +++ b/Modules/ContentKit/Sources/Exercise/Exercise+Interface.swift @@ -18,5 +18,6 @@ public extension Exercise { case hideAndSeek case musicalInstruments case melody + case pairing } } diff --git a/Modules/ContentKit/Sources/Exercise/Exercise+Pairing.swift b/Modules/ContentKit/Sources/Exercise/Exercise+Pairing.swift new file mode 100644 index 0000000000..cfa6ddef7c --- /dev/null +++ b/Modules/ContentKit/Sources/Exercise/Exercise+Pairing.swift @@ -0,0 +1,73 @@ +// Leka - iOS Monorepo +// Copyright 2023 APF France handicap +// SPDX-License-Identifier: Apache-2.0 + +// MARK: - Pairing + +// swiftlint:disable nesting + +public enum Pairing { + public struct Payload: Codable { + // MARK: Lifecycle + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + self.instructions = try container.decode(Instructions.self, forKey: .instructions) + } + + // MARK: Public + + public let instructions: Instructions + + // MARK: Internal + + enum CodingKeys: String, CodingKey { + case instructions + } + } +} + +// MARK: - Pairing.Payload.Instructions + +public extension Pairing.Payload { + struct Instructions: Codable { + // MARK: Lifecycle + + public init( + textMainInstructions: String, textButtonPlay: String, textButtonPause: String, + textButtonStop: String + ) { + self.textMainInstructions = textMainInstructions + self.textButtonPlay = textButtonPlay + self.textButtonPause = textButtonPause + self.textButtonStop = textButtonStop + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.textMainInstructions = try container.decode(String.self, forKey: .textMainInstructions) + self.textButtonPlay = try container.decode(String.self, forKey: .textButtonPlay) + self.textButtonPause = try container.decode(String.self, forKey: .textButtonPause) + self.textButtonStop = try container.decode(String.self, forKey: .textButtonStop) + } + + // MARK: Public + + public let textMainInstructions: String + public let textButtonPlay: String + public let textButtonPause: String + public let textButtonStop: String + + // MARK: Internal + + enum CodingKeys: String, CodingKey { + case textMainInstructions = "text_main_instructions" + case textButtonPlay = "text_button_play" + case textButtonPause = "text_button_pause" + case textButtonStop = "text_button_stop" + } + } +} + +// swiftlint:enable nesting diff --git a/Modules/ContentKit/Sources/Exercise/Exercise+Payload.swift b/Modules/ContentKit/Sources/Exercise/Exercise+Payload.swift index 831040074e..55b9243cfc 100644 --- a/Modules/ContentKit/Sources/Exercise/Exercise+Payload.swift +++ b/Modules/ContentKit/Sources/Exercise/Exercise+Payload.swift @@ -35,3 +35,7 @@ extension MusicalInstrument.Payload: ExercisePayloadProtocol {} // MARK: - DanceFreeze.Payload + ExercisePayloadProtocol extension DanceFreeze.Payload: ExercisePayloadProtocol {} + +// MARK: - Pairing.Payload + ExercisePayloadProtocol + +extension Pairing.Payload: ExercisePayloadProtocol {} diff --git a/Modules/ContentKit/Sources/Exercise/Exercise.swift b/Modules/ContentKit/Sources/Exercise/Exercise.swift index 4028d564dd..2f87a63798 100644 --- a/Modules/ContentKit/Sources/Exercise/Exercise.swift +++ b/Modules/ContentKit/Sources/Exercise/Exercise.swift @@ -39,6 +39,9 @@ public struct Exercise: Codable { case (.melody, .none): self.payload = try container.decode(MidiRecordingPlayer.Payload.self, forKey: .payload) + case (.pairing, .none): + self.payload = try container.decode(Pairing.Payload.self, forKey: .payload) + case (.remoteStandard, .none), (.remoteArrow, .none): self.payload = nil