Tugas 3 PPB I
TUGAS 3 - MEMBUAT APLIKASI mengucapkan "happy birthday" sederhana
Nama: Muhammad Ghani Taufiqurrahman Atmaja
NRP : 5025201110
Kelas: PPB - I
Pada tugas ini, saya mengembangkan aplikasi android sederhana untuk mengucapkan "Happy Birthday" menggunakan Jetpack Compose melalui Android Studio. Berikut adalah kode program dan hasil pengerjaannya.
Source Code: Repo
Code:
package com.example.tugas3ppbimport android.os.Bundleimport androidx.activity.ComponentActivityimport androidx.activity.compose.setContentimport androidx.compose.foundation.layout.Arrangementimport androidx.compose.foundation.layout.Columnimport androidx.compose.foundation.layout.fillMaxSizeimport androidx.compose.foundation.layout.paddingimport androidx.compose.material3.MaterialThemeimport androidx.compose.material3.Surfaceimport androidx.compose.material3.Textimport androidx.compose.runtime.Composableimport androidx.compose.ui.Alignmentimport androidx.compose.ui.Modifierimport androidx.compose.ui.text.style.TextAlignimport androidx.compose.ui.tooling.preview.Previewimport androidx.compose.ui.unit.dpimport androidx.compose.ui.unit.spimport com.example.tugas3ppb.ui.theme.Tugas3PPBThemeclass MainActivity : ComponentActivity() {override fun onCreate(savedInstanceState: Bundle?) {super.onCreate(savedInstanceState)setContent {Tugas3PPBTheme {// A surface container using the 'background' color from the themeSurface(modifier = Modifier.fillMaxSize(),color = MaterialTheme.colorScheme.background) {GreetingText(message = "Feliz CumpleaƱos Samuel!",from = "From Isabella",Modifier.padding(8.dp))}}}}}@Composablefun GreetingText(message:String,from:String, modifier: Modifier= Modifier){Column(verticalArrangement = Arrangement.Center,modifier = modifier.padding(8.dp)){Text(text = message,fontSize = 63.sp,lineHeight = 80.sp,textAlign = TextAlign.Center)Text(text = from,fontSize = 36.sp,modifier = Modifier.padding(16.dp).align(alignment = Alignment.End))}}@Preview(showBackground = true)@Composablefun BirthdayCardPreview() {Tugas3PPBTheme {GreetingText(message = "Feliz CumpleaƱos Samuel!", from = "From Isabella")}}
Hasil:
Comments
Post a Comment