144 lines
		
	
	
		
			4.6 KiB
		
	
	
	
		
			Kotlin
		
	
	
	
	
	
			
		
		
	
	
			144 lines
		
	
	
		
			4.6 KiB
		
	
	
	
		
			Kotlin
		
	
	
	
	
	
/*
 | 
						|
    Nama: Fadlan Rivaldi
 | 
						|
    NPM : 202310715280
 | 
						|
 */
 | 
						|
 | 
						|
package com.example.businesscard
 | 
						|
 | 
						|
import android.os.Bundle
 | 
						|
import androidx.activity.ComponentActivity
 | 
						|
import androidx.activity.compose.setContent
 | 
						|
import androidx.compose.foundation.Image
 | 
						|
import androidx.compose.foundation.background
 | 
						|
import androidx.compose.foundation.layout.*
 | 
						|
import androidx.compose.foundation.shape.CircleShape
 | 
						|
import androidx.compose.material.icons.Icons
 | 
						|
import androidx.compose.material.icons.filled.Call
 | 
						|
import androidx.compose.material.icons.filled.Email
 | 
						|
import androidx.compose.material.icons.filled.Share
 | 
						|
import androidx.compose.material3.*
 | 
						|
import androidx.compose.runtime.Composable
 | 
						|
import androidx.compose.ui.Alignment
 | 
						|
import androidx.compose.ui.Modifier
 | 
						|
import androidx.compose.ui.draw.clip
 | 
						|
import androidx.compose.ui.graphics.Color
 | 
						|
import androidx.compose.ui.layout.ContentScale
 | 
						|
import androidx.compose.ui.res.painterResource
 | 
						|
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.businesscard.ui.theme.BusinesscardTheme
 | 
						|
 | 
						|
class MainActivity : ComponentActivity() {
 | 
						|
    override fun onCreate(savedInstanceState: Bundle?) {
 | 
						|
        super.onCreate(savedInstanceState)
 | 
						|
        setContent {
 | 
						|
            BusinesscardTheme {
 | 
						|
                Surface(
 | 
						|
                    modifier = Modifier.fillMaxSize(),
 | 
						|
                    color = MaterialTheme.colorScheme.background
 | 
						|
                ) {
 | 
						|
                    ProfileCard()
 | 
						|
                }
 | 
						|
            }
 | 
						|
        }
 | 
						|
    }
 | 
						|
}
 | 
						|
 | 
						|
@Composable
 | 
						|
fun ProfileCard() {
 | 
						|
    // Box untuk menumpuk background + konten
 | 
						|
    Box(modifier = Modifier.fillMaxSize()) {
 | 
						|
 | 
						|
        // 🔹 Background gambar
 | 
						|
        Image(
 | 
						|
            painter = painterResource(id = R.drawable.gambar_background), // ganti dengan nama file gambar
 | 
						|
            contentDescription = null,
 | 
						|
            contentScale = ContentScale.Crop,
 | 
						|
            modifier = Modifier.fillMaxSize()
 | 
						|
        )
 | 
						|
 | 
						|
        // 🔹 Overlay semi-transparan agar teks tetap terbaca
 | 
						|
        Box(
 | 
						|
            modifier = Modifier
 | 
						|
                .fillMaxSize()
 | 
						|
                .background(Color.Black.copy(alpha = 0.2f))
 | 
						|
        )
 | 
						|
 | 
						|
        // 🔹 Konten utama
 | 
						|
        Column(
 | 
						|
            modifier = Modifier
 | 
						|
                .fillMaxSize()
 | 
						|
                .padding(24.dp),
 | 
						|
            verticalArrangement = Arrangement.SpaceBetween,
 | 
						|
            horizontalAlignment = Alignment.CenterHorizontally
 | 
						|
        ) {
 | 
						|
            // Bagian Tengah (foto, nama, jabatan)
 | 
						|
            Column(
 | 
						|
                horizontalAlignment = Alignment.CenterHorizontally,
 | 
						|
                verticalArrangement = Arrangement.Center,
 | 
						|
                modifier = Modifier.fillMaxHeight(0.7f)
 | 
						|
            ) {
 | 
						|
                Image(
 | 
						|
                    painter = painterResource(id = R.drawable.ronaldo_background), // ganti dengan nama file fotomu
 | 
						|
                    contentDescription = "Profile Picture",
 | 
						|
                    contentScale = ContentScale.Crop,
 | 
						|
                    modifier = Modifier
 | 
						|
                        .size(120.dp)
 | 
						|
                        .clip(CircleShape)
 | 
						|
                )
 | 
						|
 | 
						|
                Spacer(modifier = Modifier.height(16.dp))
 | 
						|
 | 
						|
                Text(
 | 
						|
                    text = "Jeremia Sebastian Marpaung",
 | 
						|
                    fontSize = 24.sp,
 | 
						|
                    fontWeight = FontWeight.Bold,
 | 
						|
                    color = Color.White
 | 
						|
                )
 | 
						|
 | 
						|
                Text(
 | 
						|
                    text = "Mahasiswa",
 | 
						|
                    fontSize = 20.sp,
 | 
						|
                    color = Color.White.copy(alpha = 0.8f)
 | 
						|
                )
 | 
						|
            }
 | 
						|
 | 
						|
            // Bagian Bawah (kontak)
 | 
						|
            Column(
 | 
						|
                horizontalAlignment = Alignment.Start,
 | 
						|
                verticalArrangement = Arrangement.Bottom
 | 
						|
            ) {
 | 
						|
                ContactItem(icon = Icons.Default.Call, info = "+6287785122540")
 | 
						|
                ContactItem(icon = Icons.Default.Share, info = "@jerisehatdankuat_")
 | 
						|
                ContactItem(icon = Icons.Default.Email, info = "202310715096@mhs.ubharajaya.ac.id")
 | 
						|
            }
 | 
						|
        }
 | 
						|
    }
 | 
						|
}
 | 
						|
 | 
						|
@Composable
 | 
						|
fun ContactItem(icon: androidx.compose.ui.graphics.vector.ImageVector, info: String) {
 | 
						|
    Row(
 | 
						|
        verticalAlignment = Alignment.CenterVertically,
 | 
						|
        modifier = Modifier.padding(vertical = 4.dp)
 | 
						|
    ) {
 | 
						|
        Icon(
 | 
						|
            imageVector = icon,
 | 
						|
            contentDescription = null,
 | 
						|
            tint = Color.White,
 | 
						|
            modifier = Modifier.size(18.dp)
 | 
						|
        )
 | 
						|
        Spacer(modifier = Modifier.width(8.dp))
 | 
						|
        Text(text = info, fontSize = 14.sp, color = Color.White)
 | 
						|
    }
 | 
						|
}
 | 
						|
 | 
						|
@Preview(showBackground = true)
 | 
						|
@Composable
 | 
						|
fun ProfileCardPreview() {
 | 
						|
    BusinesscardTheme {
 | 
						|
        ProfileCard()
 | 
						|
    }
 | 
						|
} |