From cc504c458efbcfe9ec42f0ca56cf6dd01259e5e8 Mon Sep 17 00:00:00 2001 From: Indris Alpasela <202310715200@mhs.ubharajaya.ac.id> Date: Thu, 30 Oct 2025 14:15:02 +0700 Subject: [PATCH] name-card --- .../com/example/helloworld2/MainActivity.kt | 94 +++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 app/src/main/java/com/example/helloworld2/MainActivity.kt diff --git a/app/src/main/java/com/example/helloworld2/MainActivity.kt b/app/src/main/java/com/example/helloworld2/MainActivity.kt new file mode 100644 index 0000000..1f98691 --- /dev/null +++ b/app/src/main/java/com/example/helloworld2/MainActivity.kt @@ -0,0 +1,94 @@ +package com.example.helloworld2 + +import android.os.Bundle +import androidx.activity.ComponentActivity +import androidx.activity.compose.setContent +import androidx.activity.enableEdgeToEdge +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.* +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material3.* +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Brush +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp +import com.example.helloworld2.ui.theme.HelloWorld2Theme + +class MainActivity : ComponentActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + enableEdgeToEdge() + setContent { + HelloWorld2Theme { + Surface( + modifier = Modifier.fillMaxSize(), + color = MaterialTheme.colorScheme.background + ) { + GreetingScreen(name = "Indris Alpasela") + } + } + } + } +} + +@Composable +fun GreetingScreen(name: String) { + // Background gradasi warna + Box( + modifier = Modifier + .fillMaxSize() + .background( + Brush.verticalGradient( + colors = listOf(Color(0xFF0D47A1), Color(0xFF1976D2), Color(0xFF42A5F5)) + ) + ), + contentAlignment = Alignment.Center + ) { + // Card di tengah + Card( + modifier = Modifier + .padding(20.dp) + .fillMaxWidth() + .wrapContentHeight(), + colors = CardDefaults.cardColors(containerColor = Color.White.copy(alpha = 0.95f)), + shape = RoundedCornerShape(24.dp), + elevation = CardDefaults.cardElevation(12.dp) + ) { + Column( + modifier = Modifier + .padding(24.dp) + .fillMaxWidth(), + horizontalAlignment = Alignment.CenterHorizontally + ) { + Text( + text = "Hello, $name 👋", + fontSize = 28.sp, + fontWeight = FontWeight.Bold, + color = Color(0xFF0D47A1), + textAlign = TextAlign.Center + ) + Spacer(modifier = Modifier.height(12.dp)) + Text( + text = "NPM : 202310715200", + fontSize = 16.sp, + color = Color.Gray, + textAlign = TextAlign.Center + ) + } + } + } +} + +@Preview(showBackground = true, showSystemUi = true) +@Composable +fun GreetingPreview() { + HelloWorld2Theme { + GreetingScreen("Android Dev") + } +}