Skip to content

Commit

Permalink
✨ (ContentKitxUIExplorer): Add Pairing activity
Browse files Browse the repository at this point in the history
  • Loading branch information
HPezz committed Dec 21, 2023
1 parent 09084cb commit b00378b
Show file tree
Hide file tree
Showing 6 changed files with 104 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ public extension Exercise {
case hideAndSeek
case musicalInstruments
case melody
case pairing
}
}
73 changes: 73 additions & 0 deletions Modules/ContentKit/Sources/Exercise/Exercise+Pairing.swift
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions Modules/ContentKit/Sources/Exercise/Exercise+Payload.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,7 @@ extension MusicalInstrument.Payload: ExercisePayloadProtocol {}
// MARK: - DanceFreeze.Payload + ExercisePayloadProtocol

extension DanceFreeze.Payload: ExercisePayloadProtocol {}

// MARK: - Pairing.Payload + ExercisePayloadProtocol

extension Pairing.Payload: ExercisePayloadProtocol {}
3 changes: 3 additions & 0 deletions Modules/ContentKit/Sources/Exercise/Exercise.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b00378b

Please sign in to comment.