Skip to content

Commit

Permalink
✨ (GEKExample): Add MagicCardExercises
Browse files Browse the repository at this point in the history
  • Loading branch information
HPezz committed Jan 10, 2025
1 parent fb047d2 commit 59c5fd0
Show file tree
Hide file tree
Showing 2 changed files with 157 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
// SPDX-License-Identifier: Apache-2.0

import GameEngineKit
import RobotKit
import SwiftUI

struct ContentView: View {
@State var selection: Int = 0
@State var isConnectionSheetPresented: Bool = false

var body: some View {
NavigationStack {
Expand All @@ -19,6 +21,8 @@ struct ContentView: View {
.frame(maxWidth: .infinity)
.padding()

MagicCardExercises()

TTSExercises()

ActionThenTTSExercises()
Expand Down Expand Up @@ -56,6 +60,20 @@ struct ContentView: View {
}
.tag(1)
}
.toolbar {
ToolbarItem(placement: .topBarTrailing) {
Button("Connect to a Robot") {
self.isConnectionSheetPresented = true
}
}
}
}
.sheet(isPresented: self.$isConnectionSheetPresented) {
NavigationStack {
RobotConnectionView(viewModel: RobotConnectionViewModel())
.logEventScreenView(screenName: "robot_connection", context: .sheet)
.navigationBarTitleDisplayMode(.inline)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
// Leka - iOS Monorepo
// Copyright APF France handicap
// SPDX-License-Identifier: Apache-2.0

import ContentKit
import GameEngineKit
import RobotKit
import SwiftUI

// TODO: (@ladislas) to remove in the future, replaced by actual data

Check warning on line 10 in Modules/GameEngineKit/Examples/GameEngineKitExample/Sources/App/Exercises/MagicCardExercises.swift

View workflow job for this annotation

GitHub Actions / swiftlint

TODOs should be resolved ((@ladislas) to remove in the f...) (todo)
extension ExerciseData {
static let MagicCardxFindTheRightAnswersxEmotions: [MagicCardCoordinatorFindTheRightAnswersChoiceModel] = [
.init(value: MagicCard.emotion_disgust_leka, isRightAnswer: true),
.init(value: MagicCard.emotion_fear_leka),
.init(value: MagicCard.emotion_joy_leka),
.init(value: MagicCard.emotion_sadness_leka),
.init(value: MagicCard.emotion_anger_leka),
]

static let MagicCardxFindTheRightAnswersxNumbers: [MagicCardCoordinatorFindTheRightAnswersChoiceModel] = [
.init(value: MagicCard.number_0),
.init(value: MagicCard.number_1),
.init(value: MagicCard.number_2),
.init(value: MagicCard.number_3),
.init(value: MagicCard.number_4),
.init(value: MagicCard.number_5, isRightAnswer: true),
.init(value: MagicCard.number_6),
]

static let MagicCardxFindTheRightAnswersxColors: [MagicCardCoordinatorFindTheRightAnswersChoiceModel] = [
.init(value: MagicCard.color_red),
.init(value: MagicCard.color_blue),
.init(value: MagicCard.color_yellow),
.init(value: MagicCard.color_green),
.init(value: MagicCard.color_orange, isRightAnswer: true),
.init(value: MagicCard.color_purple),
]
}

// MARK: - MagicCardExercises

struct MagicCardExercises: View {
var body: some View {
Text("MagicCard")
.font(.title)
.padding()
ScrollView(.horizontal) {
HStack(spacing: 20) {
NavigationLink {
let coordinator = MagicCardCoordinatorFindTheRightAnswers(
choices: ExerciseData.MagicCardxFindTheRightAnswersxNumbers,
action: Exercise.Action.robot(type: .image("magicCardNumbers5Five"))
)
let viewModel = MagicCardViewViewModel(coordinator: coordinator)

MagicCardView(viewModel: viewModel)
.navigationTitle("Number Recognition")
.navigationBarTitleDisplayMode(.large)
} label: {
ExerciseNavigationButtonLabel(text: "Number Recognition", color: .purple)
}

NavigationLink {
let coordinator = MagicCardCoordinatorFindTheRightAnswers(
choices: ExerciseData.MagicCardxFindTheRightAnswersxColors,
action: Exercise.Action.robot(type: .image("magicCardColorsOrangePaint"))
)
let viewModel = MagicCardViewViewModel(coordinator: coordinator)

MagicCardView(viewModel: viewModel)
.navigationTitle("Screen Color Recognition")
.navigationBarTitleDisplayMode(.large)
} label: {
ExerciseNavigationButtonLabel(text: "Screen Color Recognition", color: .purple)
}

NavigationLink {
let coordinator = MagicCardCoordinatorFindTheRightAnswers(
choices: ExerciseData.MagicCardxFindTheRightAnswersxColors,
action: Exercise.Action.robot(type: .image("magicCardColorsOrangePaint"))
)
let viewModel = MagicCardViewViewModel(coordinator: coordinator)

MagicCardView(viewModel: viewModel)
.navigationTitle("LED Color Recognition")
.navigationBarTitleDisplayMode(.large)
} label: {
ExerciseNavigationButtonLabel(text: "LED Color Recognition", color: .purple)
}

NavigationLink {
let coordinator = MagicCardCoordinatorFindTheRightAnswers(
choices: ExerciseData.MagicCardxFindTheRightAnswersxEmotions,
action: Exercise.Action.robot(type: .image("robotFaceDisgusted"))
)
let viewModel = MagicCardViewViewModel(coordinator: coordinator)

MagicCardView(viewModel: viewModel)
.navigationTitle("Emotion Recognition")
.navigationBarTitleDisplayMode(.large)
} label: {
ExerciseNavigationButtonLabel(text: "Emotion Recognition", color: .purple)
}

NavigationLink {
let coordinator = MagicCardCoordinatorFindTheRightAnswers(
choices: ExerciseData.MagicCardxFindTheRightAnswersxNumbers,
action: Exercise.Action.robot(type: .spots(5))
)
let viewModel = MagicCardViewViewModel(coordinator: coordinator)

MagicCardView(viewModel: viewModel)
.navigationTitle("Spot Counting")
.navigationBarTitleDisplayMode(.large)
} label: {
ExerciseNavigationButtonLabel(text: "Spot Counting", color: .purple)
}

NavigationLink {
let coordinator = MagicCardCoordinatorFindTheRightAnswers(
choices: ExerciseData.MagicCardxFindTheRightAnswersxNumbers,
action: Exercise.Action.robot(type: .flash(5))
)
let viewModel = MagicCardViewViewModel(coordinator: coordinator)

MagicCardView(viewModel: viewModel)
.navigationTitle("Flash Counting")
.navigationBarTitleDisplayMode(.large)
} label: {
ExerciseNavigationButtonLabel(text: "Flash Counting", color: .purple)
}
}
}
}
}

#Preview {
MagicCardExercises()
}

0 comments on commit 59c5fd0

Please sign in to comment.