Skip to content

Commit

Permalink
🔀 Merge branch 'hugo/feature/Update-Melody-with-localization'
Browse files Browse the repository at this point in the history
  • Loading branch information
ladislas committed Jan 24, 2024
2 parents f908f4e + a48061d commit 4b39314
Show file tree
Hide file tree
Showing 8 changed files with 110 additions and 104 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ sequence:
- instructions: Joue les notes de la même couleur que Leka
interface: melody
payload:
instructions:
text_music_selection: Sélection de la musique
text_button_play: Jouer
text_keyboard_partial: Clavier partiel
text_keyboard_full: Clavier entier
instrument: xylophone
songs:
- underTheMoonlight
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@
// Copyright APF France handicap
// SPDX-License-Identifier: Apache-2.0

// swiftlint:disable nesting
public enum MidiRecordingPlayer {
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)
self.instrument = try container.decode(String.self, forKey: .instrument)

let midiRecordingSongs = try container.decode([MidiRecording.Song].self, forKey: .songs)
Expand All @@ -18,57 +16,14 @@ public enum MidiRecordingPlayer {

// MARK: Public

public struct Instructions: Codable {
// MARK: Lifecycle

public init(
textMusicSelection: String, textButtonPlay: String, textKeyboardPartial: String,
textKeyboardFull: String
) {
self.textMusicSelection = textMusicSelection
self.textButtonPlay = textButtonPlay
self.textKeyboardPartial = textKeyboardPartial
self.textKeyboardFull = textKeyboardFull
}

public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)

self.textMusicSelection = try container.decode(String.self, forKey: .textMusicSelection)
self.textButtonPlay = try container.decode(String.self, forKey: .textButtonPlay)
self.textKeyboardPartial = try container.decode(String.self, forKey: .textKeyboardPartial)
self.textKeyboardFull = try container.decode(String.self, forKey: .textKeyboardFull)
}

// MARK: Public

public let textMusicSelection: String
public let textButtonPlay: String
public let textKeyboardPartial: String
public let textKeyboardFull: String

// MARK: Internal

enum CodingKeys: String, CodingKey {
case textMusicSelection = "text_music_selection"
case textButtonPlay = "text_button_play"
case textKeyboardPartial = "text_keyboard_partial"
case textKeyboardFull = "text_keyboard_full"
}
}

public let instructions: Instructions
public let instrument: String
public let songs: [MidiRecording]

// MARK: Internal

enum CodingKeys: String, CodingKey {
case instructions
case instrument
case songs
}
}
}

// swiftlint:enable nesting
72 changes: 72 additions & 0 deletions Modules/GameEngineKit/Resources/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,78 @@
}
}
}
},
"lekaapp.melody_view.keyboard_full" : {
"comment" : "MelodyView keyboard full keyboard label",
"extractionState" : "extracted_with_value",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "new",
"value" : "Full keyboard"
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
"value" : "Clavier entier"
}
}
}
},
"lekaapp.melody_view.keyboard_partial" : {
"comment" : "MelodyView partial keyboard label",
"extractionState" : "extracted_with_value",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "new",
"value" : "Partial keyboard"
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
"value" : "Clavier partiel"
}
}
}
},
"lekaapp.melody_view.play_button_label" : {
"comment" : "MelodyView play button label",
"extractionState" : "extracted_with_value",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "new",
"value" : "Play"
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
"value" : "Jouer"
}
}
}
},
"lekaapp.melody_view.song_selector_title" : {
"comment" : "MelodyView music selection title",
"extractionState" : "extracted_with_value",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "new",
"value" : "Music selection"
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
"value" : "Sélection de la musique"
}
}
}
}
},
"version" : "1.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

import ContentKit
import DesignKit
import LocalizationKit
import SwiftUI

extension MelodyView {
struct KeyboardModeView: View {
// MARK: Lifecycle

init(keyboard: Binding<KeyboardType>, instructions: MidiRecordingPlayer.Payload.Instructions) {
init(keyboard: Binding<KeyboardType>) {
self._keyboard = keyboard
self.instructions = instructions
}

// MARK: Internal
Expand All @@ -23,7 +23,7 @@ extension MelodyView {
GameEngineKitAsset.Exercises.Melody.iconKeyboardPartial.swiftUIImage
.resizable()
.scaledToFit()
Text(self.instructions.textKeyboardPartial)
Text(l10n.MelodyView.partialKeyboardLabel)
.foregroundStyle(self.keyboard == .partial ? .black : .gray.opacity(0.4))
}
.onTapGesture {
Expand All @@ -36,7 +36,7 @@ extension MelodyView {
GameEngineKitAsset.Exercises.Melody.iconKeyboardFull.swiftUIImage
.resizable()
.scaledToFit()
Text(self.instructions.textKeyboardFull)
Text(l10n.MelodyView.fullKeyboardLabel)
.foregroundStyle(self.keyboard == .full ? .black : .gray.opacity(0.4))
}
.onTapGesture {
Expand All @@ -52,7 +52,6 @@ extension MelodyView {
// MARK: Private

@Binding private var keyboard: KeyboardType
private let instructions: MidiRecordingPlayer.Payload.Instructions
}
}

Expand All @@ -63,15 +62,8 @@ extension MelodyView {
MidiRecording(.twinkleTwinkleLittleStar),
MidiRecording(.underTheMoonlight),
]
let instructions = MidiRecordingPlayer.Payload.Instructions(
textMusicSelection: "Sélection de la musique",
textButtonPlay: "Jouer",
textKeyboardPartial: "Clavier partiel",
textKeyboardFull: "Clavier entier"
)

return MelodyView.KeyboardModeView(
keyboard: .constant(.partial),
instructions: instructions
keyboard: .constant(.partial)
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// SPDX-License-Identifier: Apache-2.0

import ContentKit
import LocalizationKit
import SwiftUI

extension MelodyView {
Expand All @@ -11,7 +12,6 @@ extension MelodyView {
@Binding var mode: Stage
@Binding var keyboard: KeyboardType
let songs: [MidiRecording]
let instructions: MidiRecordingPlayer.Payload.Instructions

var body: some View {
VStack(spacing: 100) {
Expand All @@ -22,20 +22,17 @@ extension MelodyView {
.padding(.trailing, 50)

VStack(spacing: 0) {
KeyboardModeView(keyboard: self.$keyboard, instructions: self.instructions)
KeyboardModeView(keyboard: self.$keyboard)

SongSelectorView(
songs: self.songs, selectedMidiRecording: self.$selectedSong,
textMusicSelection: self.instructions.textMusicSelection
)
SongSelectorView(songs: self.songs, selectedMidiRecording: self.$selectedSong)
}
}
.padding(.horizontal, 100)

Button {
self.mode = .selectionConfirmed
} label: {
ButtonLabel(self.instructions.textButtonPlay, color: .cyan)
ButtonLabel(String(l10n.MelodyView.playButtonLabel.characters), color: .cyan)
}
}
}
Expand All @@ -51,18 +48,11 @@ extension MelodyView {
MidiRecording(.ohTheCrocodiles),
MidiRecording(.happyBirthday),
]
let instructions = MidiRecordingPlayer.Payload.Instructions(
textMusicSelection: "Sélection de la musique",
textButtonPlay: "Jouer",
textKeyboardPartial: "Clavier partiel",
textKeyboardFull: "Clavier entier"
)

return MelodyView.LauncherView(
selectedSong: .constant(MidiRecording(.underTheMoonlight)),
mode: .constant(.waitingForSelection),
keyboard: .constant(.partial),
songs: songs,
instructions: instructions
songs: songs
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,22 @@

import ContentKit
import DesignKit
import LocalizationKit
import SwiftUI

extension MelodyView {
struct SongSelectorView: View {
// MARK: Lifecycle

init(songs: [MidiRecording], selectedMidiRecording: Binding<MidiRecording>, textMusicSelection: String) {
init(songs: [MidiRecording], selectedMidiRecording: Binding<MidiRecording>) {
self.songs = songs
self._selectedMidiRecording = selectedMidiRecording
self.textMusicSelection = textMusicSelection
}

// MARK: Internal

@Binding var selectedMidiRecording: MidiRecording
let songs: [MidiRecording]
let textMusicSelection: String

let columns = [
GridItem(.flexible()),
Expand All @@ -29,7 +28,7 @@ extension MelodyView {

var body: some View {
VStack(alignment: .leading) {
Text(self.textMusicSelection)
Text(l10n.MelodyView.musicSelectionTitle)
// TODO: (@ui/ux) - Design System - replace with Leka font
.font(.headline)

Expand Down Expand Up @@ -68,16 +67,9 @@ extension MelodyView {
MidiRecording(.twinkleTwinkleLittleStar),
MidiRecording(.underTheMoonlight),
]
let instructions = MidiRecordingPlayer.Payload.Instructions(
textMusicSelection: "Sélection de la musique",
textButtonPlay: "Jouer",
textKeyboardPartial: "Clavier partiel",
textKeyboardFull: "Clavier entier"
)

return MelodyView.SongSelectorView(
songs: songs,
selectedMidiRecording: .constant(MidiRecording(.underTheMoonlight)),
textMusicSelection: instructions.textMusicSelection
selectedMidiRecording: .constant(MidiRecording(.underTheMoonlight))
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Leka - iOS Monorepo
// Copyright APF France handicap
// SPDX-License-Identifier: Apache-2.0

import LocalizationKit

// swiftlint:disable line_length

extension l10n {
enum MelodyView {
static let musicSelectionTitle = LocalizedString("lekaapp.melody_view.song_selector_title", value: "Music selection", comment: "MelodyView music selection title")

static let playButtonLabel = LocalizedString("lekaapp.melody_view.play_button_label", value: "Play", comment: "MelodyView play button label")

static let partialKeyboardLabel = LocalizedString("lekaapp.melody_view.keyboard_partial", value: "Partial keyboard", comment: "MelodyView partial keyboard label")

static let fullKeyboardLabel = LocalizedString("lekaapp.melody_view.keyboard_full", value: "Full keyboard", comment: "MelodyView keyboard full keyboard label")
}
}

// swiftlint:enable line_length
Loading

0 comments on commit 4b39314

Please sign in to comment.