This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (showNoteNames) { | |
Row { | |
repeat(7) { noteIndex -> | |
Container( | |
LayoutPadding(right = 1.dp) + LayoutSize(16.dp, 62.dp), | |
alignment = Alignment.BottomCenter | |
) { | |
val noteName = formatNoteName(startFromF, noteIndex, octave) | |
Text(text = noteName, style = TextStyle(fontSize = 8.sp)) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
private fun AccidentalPianoKey(leftSpacing: Dp) { | |
Spacer(modifier = LayoutWidth(leftSpacing)) | |
ColoredRect( | |
color = Color.Black, | |
height = 40.dp, | |
width = 13.dp | |
) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Row { | |
if (startFromF) { | |
AccidentalPianoKey(10.dp) | |
AccidentalPianoKey(5.dp) | |
AccidentalPianoKey(4.dp) | |
AccidentalPianoKey(21.dp) | |
AccidentalPianoKey(4.dp) | |
} else { | |
AccidentalPianoKey(10.dp) | |
AccidentalPianoKey(5.dp) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
private fun PianoKey() { | |
ColoredRect( | |
modifier = LayoutPadding(right = 1.dp), | |
color = Color.White, | |
height = 64.dp, | |
width = 16.dp | |
) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Row { | |
repeat(7) { | |
PianoKey() | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun PianoRollOctave(startFromF: Boolean = false, showNoteNames: Boolean = false, octave: Int? = 0) { | |
Stack { | |
Row { | |
repeat(7) { | |
PianoKey() | |
} | |
} | |
Row { | |
if (startFromF) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun PianoRoll(from: PianoKey, to: PianoKey) { | |
val startsAtF = from.note >= F | |
Row { | |
for (octave in from.octave..to.octave) { | |
PianoRollOctave(startsAtF, true, octave) | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
@Preview | |
fun PianoRollPreview() { | |
PianoRoll(PianoKey(F, 0), PianoKey(C, 1)) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val onCardSaved = { | |
runBlocking { | |
repository.saveCard(state.card) | |
goto(Destination.HomeScreen) | |
} | |
} | |
MemsetMainTemplate { | |
when (state.loadingState) { | |
LoadingState.Loaded -> CardEditorContent(state, onCardSaved) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun <T> observe(observable: () -> LiveData<T>, result: (T) -> Unit) { | |
val thing = stateFor<T?> { null } | |
onActive { | |
val observer = | |
Observer<T> { | |
thing.value = it | |
result(it) | |
} | |
with(observable()) { |