diff --git a/Modules/GameEngineKit/Sources/OldSystem/Exercises/Specialized/ColorMusicPad/ColorMusicPad.swift b/Modules/GameEngineKit/Sources/OldSystem/Exercises/Specialized/ColorMusicPad/ColorMusicPad.swift new file mode 100644 index 000000000..cf393b42e --- /dev/null +++ b/Modules/GameEngineKit/Sources/OldSystem/Exercises/Specialized/ColorMusicPad/ColorMusicPad.swift @@ -0,0 +1,41 @@ +// Leka - iOS Monorepo +// Copyright APF France handicap +// SPDX-License-Identifier: Apache-2.0 + +import AudioKit +import DesignKit +import RobotKit +import SwiftUI + +struct ColorMusicPad: View { + // MARK: Internal + + @StateObject var midiPlayer: MIDIPlayer = .init(instrument: MIDIInstrument.xylophone) + + var body: some View { + LazyVGrid(columns: self.columns, spacing: self.kHorizontalSpacing) { + ForEach(0..<10) { index in + Rectangle() + .fill(self.colors[index].screen) + .onTapGesture { + Robot.shared.shine(.all(in: self.colors[index])) + self.midiPlayer.noteOn(number: self.scale.notes[index]) + } + .frame(width: self.kTileWidth, height: self.kTileHeight) + } + } + } + + // MARK: Private + + private let scale: MIDIScale = .majorPentatonicDoubleOctave + private let colors: [Robot.Color] = [.lightPink, .red, .orange, .yellow, .green, .mint, .lightBlue, .blue, .purple, .pink] + private let columns = Array(repeating: GridItem(), count: 5) + private let kHorizontalSpacing: CGFloat = 0 + private let kTileWidth: CGFloat = 220 + private let kTileHeight: CGFloat = 600 +} + +#Preview { + ColorMusicPad() +} diff --git a/Modules/GameEngineKit/Sources/OldSystem/Views/Activity/ActivityView.swift b/Modules/GameEngineKit/Sources/OldSystem/Views/Activity/ActivityView.swift index df7d19fd7..1b8034cad 100644 --- a/Modules/GameEngineKit/Sources/OldSystem/Views/Activity/ActivityView.swift +++ b/Modules/GameEngineKit/Sources/OldSystem/Views/Activity/ActivityView.swift @@ -387,6 +387,9 @@ public struct ActivityView: View { exercise: self.viewModel.currentExercise, data: self.viewModel.currentExerciseSharedData ) + + case .colorMusicPad: + ColorMusicPad() } }