From 1144adbabb1ecef475d4bd3657c893dcd7951488 Mon Sep 17 00:00:00 2001 From: 202310715002 RAFI FATTAN FITRIARDI <202310715002@mhs.ubharajaya.ac.id> Date: Mon, 22 Sep 2025 18:23:33 +0700 Subject: [PATCH] Upload files to "/" Tugas 1 "Create Your First App" dari developer.android.com --- MainActivity.kt | 65 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 MainActivity.kt diff --git a/MainActivity.kt b/MainActivity.kt new file mode 100644 index 0000000..754d397 --- /dev/null +++ b/MainActivity.kt @@ -0,0 +1,65 @@ +package com.example.helloworld + +import android.os.Bundle +import androidx.activity.ComponentActivity +import androidx.activity.compose.setContent +import androidx.activity.enableEdgeToEdge +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.material3.Scaffold +import androidx.compose.material3.Surface +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.tooling.preview.Preview +import com.example.helloworld.ui.theme.HelloWorldTheme +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.unit.dp +import androidx.compose.foundation.layout.padding +import androidx.compose.ui.text.style.TextAlign + +class MainActivity : ComponentActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + enableEdgeToEdge() + setContent { + HelloWorldTheme { + Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding -> + Greeting( + name = "Android", + modifier = Modifier.padding(innerPadding) + ) + } + } + } + } +} + +@Composable +fun Greeting(name: String, modifier: Modifier = Modifier) { + Surface(color = Color.Green) { + androidx.compose.foundation.layout.Column( + modifier = modifier.padding(24.dp) + ) { + Text( + text = "Hello, $name!", + textAlign = TextAlign.Justify + ) + Text( + text = "Mobile Programming 25/26.", + textAlign = TextAlign.Justify + ) + } + } +} + + +@Preview(showBackground = true) +@Composable +fun GreetingPreview() { + HelloWorldTheme { + Greeting("Rafi Fattan") + } +} \ No newline at end of file