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
class MainActivity : AppCompatActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContent { | |
onActive { | |
// TODO something special | |
onDispose { | |
// TODO clean up the special stuff |
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
class MyViewModel : BaseViewModel() { | |
val data: LiveData<String> = MutableLiveData() | |
fun load() { | |
data.forceValue("Hello, World") | |
} | |
private fun <T> LiveData<T>.forceValue(value: T) { | |
(this as MutableLiveData<T>).value = value | |
} |
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
class MyViewModel : BaseViewModel() { | |
val _data = MutableLiveData<String>() | |
val data: LiveData<String> | |
get() = _data | |
fun load() { | |
_data.value = "Hello, World" | |
} | |
} |
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
class MyViewModel : BaseViewModel() { | |
val data: LiveData<String> = MutableLiveData() | |
fun load() { | |
data.value = "Hello, World" | |
} | |
} | |
class MyActivity : AppCompatActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { |
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 GuitarString(modifier: Modifier, thickness: Dp = 3.dp) { | |
Container(modifier = modifier, alignment = Alignment.CenterRight) { | |
ColoredRect( | |
modifier = modifier + Border( | |
RoundedCornerShape(1.dp), | |
1.dp, | |
Color.Black | |
) + LayoutHeight(thickness), brush = SolidColor(Color.LightGray) | |
) |
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 Fretwire(modifier: Modifier, scale: Float = 1.5f) { | |
Container(modifier = modifier, alignment = Alignment.CenterRight) { | |
ColoredRect( | |
modifier = Border( | |
RoundedCornerShape(1.dp), | |
1.dp, | |
Color.Black | |
) + LayoutSize(width = (BASE_FRETWIRE_WIDTH * scale).dp, height = (BASE_FRETBOARD_HEIGHT * scale).dp), | |
brush = SolidColor(Color.Gray) |
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 FretMarkerLayer( | |
fromFret: Int, | |
toFret: Int, | |
markers: List<Marker>, | |
scale: Float = 1.5f | |
) { | |
val fretRange = toFret - fromFret | |
Table(columns = fretRange) { |
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 Fretboard() { | |
Column { | |
Container { | |
Stack { | |
Row(modifier = LayoutWidth.Fill) { | |
// Fretwire + Nut layer | |
} | |
Column(modifier = LayoutWidth.Fill) { | |
// String layer |
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, | |
highlightedKeys: List<PianoKey>? = null | |
) { | |
Stack { | |
WhiteNotes(startFromF, octave, highlightedKeys) | |
BlackNotes(startFromF, octave, highlightedKeys) |
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 PianoChord(chord: List<PianoKey>) { | |
val lower = chord.lowerKey() | |
val upper = chord.upperKey() | |
PianoRoll(lower, upper, true, chord) | |
} |