Created
February 10, 2023 20:05
-
-
Save MamboBryan/c99730f31daa6e44275b3e96af51cb34 to your computer and use it in GitHub Desktop.
A small gist for compose camp
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
import androidx.compose.foundation.background | |
import androidx.compose.foundation.layout.* | |
import androidx.compose.material3.Button | |
import androidx.compose.material3.Text | |
import androidx.compose.runtime.* | |
import androidx.compose.ui.Alignment | |
import androidx.compose.ui.Modifier | |
import androidx.compose.ui.graphics.Color | |
import androidx.compose.ui.text.style.TextAlign | |
import androidx.compose.ui.tooling.preview.Preview | |
import androidx.compose.ui.unit.ExperimentalUnitApi | |
import androidx.compose.ui.unit.TextUnit | |
import androidx.compose.ui.unit.TextUnitType | |
import androidx.compose.ui.unit.dp | |
import kotlin.random.Random | |
/** | |
* @project ComposeGig | |
* @author mambobryan | |
* @email [email protected] | |
* Fri 10 Feb 2023 | |
*/ | |
@OptIn(ExperimentalUnitApi::class) | |
@Composable | |
fun ValentinoScreen() { | |
val list = mutableListOf<String>( | |
"I am Mambo \nI love Work Manager", | |
"I am Nayfill \nI love being the shawty for compose", | |
"I am Nana \nI love being the shawty for compose", | |
"I am Chikii \nI love being the shawty for compose", | |
) | |
var message by remember { mutableStateOf(list[Random.nextInt(0, 3)]) } | |
fun generate() { | |
message = list[Random.nextInt(0, 3)] | |
} | |
Column(modifier = Modifier.fillMaxSize(), horizontalAlignment = Alignment.CenterHorizontally) { | |
Column( | |
modifier = Modifier | |
.fillMaxWidth() | |
.weight(0.75f), | |
verticalArrangement = Arrangement.Center, | |
horizontalAlignment = Alignment.CenterHorizontally | |
) { | |
Text(text = "\uD83C\uDF39", fontSize = TextUnit(140f, TextUnitType.Sp)) | |
Text(modifier = Modifier.padding(top = 24.dp), text = "Android Crush", fontSize = TextUnit(36f, TextUnitType.Sp)) | |
} | |
Column( | |
modifier = Modifier | |
.width(450.dp) | |
.weight(0.5f), | |
verticalArrangement = Arrangement.Center, | |
horizontalAlignment = Alignment.CenterHorizontally | |
) { | |
Text(text = message, textAlign = TextAlign.Center,fontSize = TextUnit(20f, TextUnitType.Sp)) | |
} | |
Button(modifier = Modifier | |
.padding(32.dp) | |
.width(200.dp), | |
onClick = { generate() } | |
) { | |
Text(modifier = Modifier.padding(vertical = 8.dp), text = "Get Next") | |
} | |
Spacer(modifier = Modifier.weight(0.1f)) | |
} | |
} | |
@Preview | |
@Composable | |
fun ValentinoScreenPreview() { | |
ValentinoScreen() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@Raynafs check this out