Skip to content

Commit

Permalink
♻️ (GEK): Update tileWidth and way to display Xylo
Browse files Browse the repository at this point in the history
  • Loading branch information
HPezz committed Dec 4, 2023
1 parent 7f74080 commit 46f45ff
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Leka - iOS Monorepo
# Copyright 2023 APF France handicap
# SPDX-License-Identifier: Apache-2.0

id: 7fe97b08432f4ec0a1556f6f8734a99e
name: Xylophone Octatonic
description: L'objectif est de jouer de la musique à l'aide du xylophone
image: activity_color_recognition_1
sequence:
- exercises:
- instructions: Joue du xylophone avec Leka
interface: musicalInstruments
payload:
instrument: xylophone
scale: majorOctatonic
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ let kActivities: [Activity] = [
ContentKit.decodeActivity("activity-hideAndSeek"),
ContentKit.decodeActivity("activity-xylophone-pentatonic"),
ContentKit.decodeActivity("activity-xylophone-heptatonic"),
ContentKit.decodeActivity("activity-xylophone-octatonic"),
]

struct GEKNewSystemView: View {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ public struct MelodyView: View {
tile.color.screen
}
.buttonStyle(
MusicalInstrumentView.XylophoneView.TileButtonStyle(index: tile.id, tileNumber: tileNumber)
MusicalInstrumentView.XylophoneView.TileButtonStyle(
index: tile.id, tileNumber: tileNumber, tileWidth: 130)
)
.compositingGroup()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ extension MusicalInstrumentView.XylophoneView {
let xyloAttachColor = Color(red: 0.87, green: 0.65, blue: 0.54)
let defaultMaxTileHeight: Int = 500
let defaultTileHeightGap: Int = 250
let defaultTileWidth: CGFloat = 130
let defaultTilesScaleFeedback: CGFloat = 0.98
let defaultTilesRotationFeedback: CGFloat = -1

let index: Int
let tileNumber: Int
let tileWidth: CGFloat

func makeBody(configuration: Self.Configuration) -> some View {
configuration.label
Expand Down Expand Up @@ -47,7 +47,7 @@ extension MusicalInstrumentView.XylophoneView {
.stroke(.black.opacity(configuration.isPressed ? 0.3 : 0), lineWidth: 20)
}
.clipShape(RoundedRectangle(cornerRadius: 7, style: .circular))
.frame(width: defaultTileWidth, height: setSizeFromIndex())
.frame(width: tileWidth, height: setSizeFromIndex())
.scaleEffect(
configuration.isPressed ? defaultTilesScaleFeedback : 1,
anchor: .center
Expand Down Expand Up @@ -78,5 +78,5 @@ extension MusicalInstrumentView.XylophoneView {
} label: {
Color(.red)
}
.buttonStyle(MusicalInstrumentView.XylophoneView.TileButtonStyle(index: 0, tileNumber: 1))
.buttonStyle(MusicalInstrumentView.XylophoneView.TileButtonStyle(index: 0, tileNumber: 1, tileWidth: 130))
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ extension MusicalInstrumentView {
@ObservedObject var xyloPlayer: MIDIPlayer
let tilesSpacing: CGFloat
let tileNumber: Int
let tileColors: [Robot.Color] = [.pink, .red, .orange, .yellow, .green, .blue, .purple]
let tileColors: [Robot.Color] = [.pink, .red, .orange, .yellow, .green, .lightBlue, .blue, .purple]
let scale: MIDIScale

init(midiPlayer: MIDIPlayer, scale: MIDIScale) {
self.xyloPlayer = midiPlayer
self.scale = scale
self.tileNumber = scale.notes.count
self.tilesSpacing = scale.self == .majorPentatonic ? 40 : 16
self.tilesSpacing = scale.self == .majorPentatonic ? 40 : 20
}

var body: some View {
Expand All @@ -31,7 +31,10 @@ extension MusicalInstrumentView {
} label: {
tileColors[index].screen
}
.buttonStyle(TileButtonStyle(index: index, tileNumber: tileNumber))
.buttonStyle(
TileButtonStyle(
index: index, tileNumber: tileNumber, tileWidth: scale.self == .majorPentatonic ? 130 : 100)
)
.compositingGroup()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@ import AudioKit
enum MIDIScale: String {
case majorPentatonic
case majorHeptatonic
case majorOctatonic

var notes: [MIDINoteNumber] {
switch self {
case .majorPentatonic:
return [24, 26, 28, 31, 33]
case .majorHeptatonic:
return [24, 26, 28, 29, 31, 33, 35]
case .majorOctatonic:
return [24, 26, 28, 29, 31, 33, 35, 36]
}
}
}

0 comments on commit 46f45ff

Please sign in to comment.