Skip to content

Commit

Permalink
✨ (GEK): Add ColorMusicPad activity
Browse files Browse the repository at this point in the history
  • Loading branch information
HPezz committed Dec 6, 2024
1 parent 6b74c25 commit 35a1f59
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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()
}
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,9 @@ public struct ActivityView: View {
exercise: self.viewModel.currentExercise,
data: self.viewModel.currentExerciseSharedData
)

case .colorMusicPad:
ColorMusicPad()
}
}

Expand Down

0 comments on commit 35a1f59

Please sign in to comment.