This file contains 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
************************************************************************************************************************************** | |
Sort without sort function | |
************************************************************************************************************************************** | |
val numbers = mutableListOf(4, 8, 32, 2, 5, 8) | |
var temp: Int | |
for (i in 0 until numbers.size) { | |
for (j in i + 1 until numbers.size) { | |
if (numbers[i] > numbers[j]) { | |
temp = numbers[i] |
This file contains 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
****************************************************************************************************************************************** | |
ex-1 | |
statement = here, we want to test that, from 3 tabs, whatever value is set for current screen so according that same tab should selected. | |
****************************************************************************************************************************************** | |
passed case) | |
@get:Rule | |
val composeTestRule = createComposeRule() | |
@Test | |
fun rallyTopAppBarTest() { |
This file contains 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
********************************************************************************************************************************* | |
AnimatedVisibility - without params | |
********************************************************************************************************************************* | |
@Preview(showSystemUi = true) | |
@Composable | |
fun SimpleAnimatedVisibility() { | |
var visibility by remember { mutableStateOf(true) } | |
Column( | |
modifier = Modifier.fillMaxSize(), |
This file contains 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
********************************************************************************************************************************* | |
Image | |
********************************************************************************************************************************* | |
Usage: | |
painter = painterResource(id = OwlTheme.images.lockupLogo) | |
--------------------------------------------------------------------------------- | |
data class: | |
@Immutable | |
data class Images(@DrawableRes val lockupLogo: Int) |
This file contains 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
values/themes.xml | |
<resources> | |
<style name="Theme.ComposeTheming" parent="Theme.Material.DayNight.NoActionBar"> | |
<item name="android:statusBarColor">@color/status_bar</item> | |
</style> | |
<style name="Theme.Material.DayNight.NoActionBar" parent="@android:style/Theme.Material.Light.NoActionBar" /> | |
</resources> | |
-------------------------------------------------------------------------------------------------------------------------- |
This file contains 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
@Preview(showSystemUi = true) | |
@Composable | |
fun ConstraintLayoutContentPreview() { | |
ComposeTheme { | |
ConstraintLayoutContent() | |
} | |
} | |
//(1)----------------------------------Basic------------------------------------ | |
@Composable | |
fun ConstraintLayoutContent() { |
This file contains 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
//implement custom column | |
@Composable | |
fun MyOwnColumn( | |
modifier: Modifier = Modifier, | |
content: @Composable () -> Unit | |
) { | |
Layout( | |
modifier = modifier, | |
content = content | |
) { measurables, constraints -> |
This file contains 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
fun Modifier.baseLineToTop(firstBaselineToTop: Dp): Modifier { | |
return this.then( | |
layout { measurable, constraints -> | |
val placeable = measurable.measure(constraints = constraints) | |
// Check the composable has a first baseline | |
check(placeable[FirstBaseline] != AlignmentLine.Unspecified) | |
val firstBaseline = placeable[FirstBaseline] |
This file contains 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
FloatingActionButton(onClick = { }, backgroundColor = MaterialTheme.colors.secondary) { | |
Icon( | |
painter = painterResource(id = R.drawable.ic_baseline_arrow_upward_24), | |
contentDescription = "Go Up" | |
) |
This file contains 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
@Preview | |
@Composable | |
private fun columnRecyclerView(names: List<String> = List(1000) { "$it" }) { | |
val context = LocalContext.current | |
Column( | |
modifier = Modifier.fillMaxSize(), verticalArrangement = Arrangement.Center, | |
horizontalAlignment = Alignment.CenterHorizontally | |
) { | |
LazyColumn(modifier = Modifier.padding(vertical = 4.dp)) { | |
items(names) { name -> |