Skip to content

Instantly share code, notes, and snippets.

@Rohit-554
Created November 1, 2025 09:18
Show Gist options
  • Select an option

  • Save Rohit-554/cac8ff2bbb724acd1e0bbc2b325ab55b to your computer and use it in GitHub Desktop.

Select an option

Save Rohit-554/cac8ff2bbb724acd1e0bbc2b325ab55b to your computer and use it in GitHub Desktop.
Learn first jetpack compose ui
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.safeContentPadding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonColors
import androidx.compose.material3.MaterialTheme
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.TextStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import org.jetbrains.compose.resources.painterResource
import org.jetbrains.compose.ui.tooling.preview.Preview
import firstcmpproject.composeapp.generated.resources.Res
import firstcmpproject.composeapp.generated.resources.compose_multiplatform
import firstcmpproject.composeapp.generated.resources.yippy
@Composable
@Preview(showBackground = true)
fun App() {
MaterialTheme {
Column(
modifier = Modifier
.fillMaxSize()
.background(
color = Color(0xffffffff)
)
.padding(16.dp),
horizontalAlignment = Alignment.CenterHorizontally
) {
Image(
modifier = Modifier.size(300.dp),
painter = painterResource(resource = Res.drawable.yippy),
contentDescription = "This is a yippy"
)
Spacer(modifier = Modifier.height(48.dp))
Text(
"You guys are awesome",
style = TextStyle(
fontSize = 48.sp,
fontWeight = FontWeight.Black,
textAlign = TextAlign.Center
)
)
Spacer(modifier = Modifier.weight(1f))
Button(
modifier = Modifier.fillMaxWidth().height(56.dp),
onClick = {},
colors = ButtonColors(
containerColor = Color.Blue,
contentColor = Color.White,
disabledContainerColor = Color.Gray,
disabledContentColor = Color.Cyan
)
){
Text(
"Continue",
style = TextStyle(
fontSize = 24.sp,
fontWeight = FontWeight.Normal,
textAlign = TextAlign.Center
)
)
}
Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.SpaceBetween
) {
Row {
Box(
modifier = Modifier.size(24.dp).
background(
color = Color.Magenta,
shape = RoundedCornerShape(24.dp)
),
contentAlignment = Alignment.Center
) {
Text("1")
}
Text(
modifier = Modifier.padding(start = 12.dp),
text = "Hello"
)
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment