Add first Main-screen

This commit is contained in:
BuildTools
2024-03-18 16:45:05 +01:00
parent 4eb6cfc4a7
commit 7ad42de5d3
2 changed files with 62 additions and 16 deletions

View File

@@ -3,13 +3,30 @@ package com.schoolapp.cleverclass
import android.os.Bundle import android.os.Bundle
import androidx.activity.ComponentActivity import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.MaterialTheme import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface import androidx.compose.material3.Surface
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.text.font.Font
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.sp
import com.schoolapp.cleverclass.ui.theme.CleverClassTheme import com.schoolapp.cleverclass.ui.theme.CleverClassTheme
class MainActivity : ComponentActivity() { class MainActivity : ComponentActivity() {
@@ -17,30 +34,59 @@ class MainActivity : ComponentActivity() {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContent { setContent {
CleverClassTheme { CleverClassTheme {
// A surface container using the 'background' color from the theme Surface(modifier = Modifier.fillMaxSize(),
Surface( color = MaterialTheme.colorScheme.background) {
modifier = Modifier.fillMaxSize(), Content()
color = MaterialTheme.colorScheme.background
) {
Greeting("Android")
} }
} }
} }
} }
} }
// Content of Main-screen
@OptIn(ExperimentalMaterial3Api::class)
@Composable @Composable
fun Greeting(name: String, modifier: Modifier = Modifier) { fun Content(){
Text( Column() {
text = "Hello $name!", TopAppBar(
modifier = modifier colors = TopAppBarDefaults.centerAlignedTopAppBarColors(MaterialTheme.colorScheme.background),
title = {
Text(text = "CleverClass",
fontFamily = FontFamily(Font(R.font.arlrdbd, FontWeight.Normal)))
},
modifier = Modifier.fillMaxWidth()
) )
}
@Preview(showBackground = true) Column(modifier = Modifier.verticalScroll(rememberScrollState())) {
@Composable Button(onClick = { /*TODO*/ }, color = Color(0xFFFF8A80), text = "Periodensystem")
fun GreetingPreview() { Button(onClick = { /*TODO*/ }, color = Color(0xFF8C9EFF), text = "Stundenplan")
CleverClassTheme { Button(onClick = { /*TODO*/ }, color = Color(0xFFEA80FC), text = "Noten")
Greeting("Android") Button(onClick = { /*TODO*/ }, color = Color(0xFF40C4FF), text = "Mebis")
Button(onClick = { /*TODO*/ }, color = Color(0xFFB2FF59), text = "DSBmobile")
Button(onClick = { /*TODO*/ }, color = Color(0xFF69F0AE), text = "...")
Button(onClick = { /*TODO*/ }, color = Color(0xFFFFD740), text = "...")
Button(onClick = { /*TODO*/ }, color = Color(0xFFE040FB), text = "...")
}
}
}
// Main-menu Buttons
@Composable
fun Button(onClick: () -> Unit, color : Color, text : String) {
Button(
onClick = { onClick() },
shape = RoundedCornerShape(40),
colors = ButtonDefaults.outlinedButtonColors(containerColor = color),
modifier = Modifier
.fillMaxWidth()
.height(128.dp)
.padding(start = 16.dp, end = 16.dp, top = 16.dp)
) {
Text(text,
color = MaterialTheme.colorScheme.background,
fontFamily = FontFamily(Font(R.font.arlrdbd, FontWeight.Normal)),
fontSize = 20.sp)
} }
} }

Binary file not shown.