Upload files to "/"
Tugas 3 Kartu Nama
This commit is contained in:
		
						commit
						d9f5816eed
					
				
							
								
								
									
										141
									
								
								MainActivity.kt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										141
									
								
								MainActivity.kt
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,141 @@
 | 
			
		||||
//Nuryudha Maulana Fahmi
 | 
			
		||||
//202310715038
 | 
			
		||||
package com.example.kartunamayuda
 | 
			
		||||
 | 
			
		||||
import android.os.Bundle
 | 
			
		||||
import androidx.activity.ComponentActivity
 | 
			
		||||
import androidx.activity.compose.setContent
 | 
			
		||||
import androidx.activity.enableEdgeToEdge
 | 
			
		||||
import androidx.compose.foundation.Image
 | 
			
		||||
import androidx.compose.foundation.background
 | 
			
		||||
import androidx.compose.foundation.layout.*
 | 
			
		||||
import androidx.compose.foundation.shape.CircleShape
 | 
			
		||||
import androidx.compose.material3.*
 | 
			
		||||
import androidx.compose.runtime.Composable
 | 
			
		||||
import androidx.compose.ui.Alignment
 | 
			
		||||
import androidx.compose.ui.Modifier
 | 
			
		||||
import androidx.compose.ui.graphics.Color
 | 
			
		||||
import androidx.compose.ui.layout.ContentScale
 | 
			
		||||
import androidx.compose.ui.res.painterResource
 | 
			
		||||
import androidx.compose.ui.text.font.FontFamily
 | 
			
		||||
import androidx.compose.ui.text.font.FontWeight
 | 
			
		||||
import androidx.compose.ui.tooling.preview.Preview
 | 
			
		||||
import androidx.compose.ui.unit.dp
 | 
			
		||||
import androidx.compose.ui.unit.sp
 | 
			
		||||
import com.example.kartunamayuda.ui.theme.KartuNamaYudaTheme
 | 
			
		||||
 | 
			
		||||
class MainActivity : ComponentActivity() {
 | 
			
		||||
    override fun onCreate(saved: Bundle?) {
 | 
			
		||||
        super.onCreate(saved)
 | 
			
		||||
        enableEdgeToEdge()
 | 
			
		||||
        setContent {
 | 
			
		||||
            KartuNamaYudaTheme {
 | 
			
		||||
                Surface(
 | 
			
		||||
                    modifier = Modifier.fillMaxSize(),
 | 
			
		||||
                    color = MaterialTheme.colorScheme.background
 | 
			
		||||
                ) {
 | 
			
		||||
                    KartuNamaScreen()
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@Composable
 | 
			
		||||
fun KartuNamaScreen() {
 | 
			
		||||
    // Hacker Theme Colors
 | 
			
		||||
    val neonGreen = Color(0xFF00FF41) // Bright neon green
 | 
			
		||||
    val darkCardBackground = Color(0xFF1A1A1A) // Dark gray for card
 | 
			
		||||
    val mainText = Color.White // White/Light gray text
 | 
			
		||||
 | 
			
		||||
    Box(
 | 
			
		||||
        modifier = Modifier
 | 
			
		||||
            .fillMaxSize()
 | 
			
		||||
            .background(Color.Black), // Main background is black
 | 
			
		||||
        contentAlignment = Alignment.Center
 | 
			
		||||
    ) {
 | 
			
		||||
        Card(
 | 
			
		||||
            modifier = Modifier
 | 
			
		||||
                .padding(24.dp)
 | 
			
		||||
                .fillMaxWidth(),
 | 
			
		||||
            // Set card colors for hacker theme
 | 
			
		||||
            colors = CardDefaults.cardColors(
 | 
			
		||||
                containerColor = darkCardBackground
 | 
			
		||||
            ),
 | 
			
		||||
            shape = MaterialTheme.shapes.medium
 | 
			
		||||
        ) {
 | 
			
		||||
            Column(
 | 
			
		||||
                modifier = Modifier
 | 
			
		||||
                    .background(darkCardBackground)
 | 
			
		||||
                    .padding(24.dp),
 | 
			
		||||
                horizontalAlignment = Alignment.CenterHorizontally
 | 
			
		||||
            ) {
 | 
			
		||||
                // Foto profil
 | 
			
		||||
                Image(
 | 
			
		||||
                    // NOTE: R.drawable.yuda must exist in your drawable folder!
 | 
			
		||||
                    painter = painterResource(id = R.drawable.yuda),
 | 
			
		||||
                    contentDescription = "Foto Profil",
 | 
			
		||||
                    modifier = Modifier
 | 
			
		||||
                        .size(100.dp)
 | 
			
		||||
                        .padding(2.dp), // Reduce padding to make the green border thin
 | 
			
		||||
                    contentScale = ContentScale.Crop
 | 
			
		||||
                )
 | 
			
		||||
 | 
			
		||||
                Spacer(modifier = Modifier.height(16.dp))
 | 
			
		||||
 | 
			
		||||
                Text(
 | 
			
		||||
                    text = "Nuryudha Maulana Fahmi",
 | 
			
		||||
                    fontSize = 22.sp,
 | 
			
		||||
                    fontWeight = FontWeight.Bold,
 | 
			
		||||
                    fontFamily = FontFamily.Monospace, // Use Monospace font
 | 
			
		||||
                    color = neonGreen // Main name in neon green
 | 
			
		||||
                )
 | 
			
		||||
 | 
			
		||||
                Text(
 | 
			
		||||
                    text = "Mahasiswa",
 | 
			
		||||
                    fontSize = 16.sp,
 | 
			
		||||
                    fontFamily = FontFamily.Monospace,
 | 
			
		||||
                    color = mainText // Role in white
 | 
			
		||||
                )
 | 
			
		||||
 | 
			
		||||
                Spacer(modifier = Modifier.height(16.dp))
 | 
			
		||||
 | 
			
		||||
                Divider(color = neonGreen, thickness = 1.dp) // Neon green divider
 | 
			
		||||
 | 
			
		||||
                Spacer(modifier = Modifier.height(16.dp))
 | 
			
		||||
 | 
			
		||||
                ContactItem(label = "Telepon", value = "+62 812-3456-7890", mainText = mainText, highlightColor = neonGreen)
 | 
			
		||||
                ContactItem(label = "Email", value = "202310715038@mhs.ubharajaya.ac.id", mainText = mainText, highlightColor = neonGreen)
 | 
			
		||||
                ContactItem(label = "Instagram", value = "Yudha", mainText = mainText, highlightColor = neonGreen)
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@Composable
 | 
			
		||||
fun ContactItem(label: String, value: String, mainText: Color, highlightColor: Color) {
 | 
			
		||||
    Column(horizontalAlignment = Alignment.CenterHorizontally) {
 | 
			
		||||
        Text(
 | 
			
		||||
            text = label,
 | 
			
		||||
            fontSize = 14.sp,
 | 
			
		||||
            fontFamily = FontFamily.Monospace,
 | 
			
		||||
            color = highlightColor.copy(alpha = 0.7f) // Label in dimmer neon green
 | 
			
		||||
        )
 | 
			
		||||
        Text(
 | 
			
		||||
            text = value,
 | 
			
		||||
            fontSize = 16.sp,
 | 
			
		||||
            fontWeight = FontWeight.Medium,
 | 
			
		||||
            fontFamily = FontFamily.Monospace,
 | 
			
		||||
            color = mainText // Value in white
 | 
			
		||||
        )
 | 
			
		||||
        Spacer(modifier = Modifier.height(8.dp))
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@Preview(showBackground = true)
 | 
			
		||||
@Composable
 | 
			
		||||
fun PreviewKartuNama() {
 | 
			
		||||
    KartuNamaYudaTheme {
 | 
			
		||||
        KartuNamaScreen()
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user