Started StundenplanActivity
began with the implementation of sharedPreferences added LessonStoreManager added TimeTableSetupActivity (-> + entries in the AndroidManifest.xml & strings.xml) committed version of "Stundenplan" is unfinished and malfunctional (switching to Laptop for holidays)
This commit is contained in:
@@ -1,11 +1,15 @@
|
||||
package com.schoolapp.cleverclass
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.activity.compose.setContent
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.ArrowBack
|
||||
@@ -18,19 +22,47 @@ import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TopAppBar
|
||||
import androidx.compose.material3.TopAppBarDefaults
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.schoolapp.cleverclass.LessonStoreManager.getLessons
|
||||
import com.schoolapp.cleverclass.ui.theme.CleverClassTheme
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
private val listOfDays = listOf("mon", "tue", "wed", "thu", "fri", "sat", "sun")
|
||||
private val lessonGrabberIndex = 0
|
||||
|
||||
class StundenplanActivity : ComponentActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
val sharedPreferences = this.getSharedPreferences("TimeTable", Context.MODE_PRIVATE)
|
||||
val maxLessons = sharedPreferences.getString("maxLessons", "").toString()
|
||||
val lessonLength = sharedPreferences.getString("lessonLength", "").toString()
|
||||
|
||||
setContent {
|
||||
CleverClassTheme {
|
||||
Surface(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
color = MaterialTheme.colorScheme.background
|
||||
) {
|
||||
println(maxLessons)
|
||||
//println(lessonLength)
|
||||
if (maxLessons.isEmpty() || lessonLength.isEmpty()) {
|
||||
val intent = Intent(this@StundenplanActivity, TimeTableSetupActivity::class.java).apply {
|
||||
putExtra(TimeTableSetupActivity.TYPE_KEY, "FirstSetup")
|
||||
}
|
||||
startActivity(intent)
|
||||
}
|
||||
|
||||
StundenplanContent(activity = this)
|
||||
}
|
||||
}
|
||||
@@ -64,7 +96,46 @@ fun StundenplanContent(activity: ComponentActivity){
|
||||
)
|
||||
|
||||
Column() {
|
||||
|
||||
listOfDays.forEach() {currentDay ->
|
||||
Day(currentDay)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
data class LessonData(
|
||||
val subject: String,
|
||||
val teacher: String,
|
||||
val room: String
|
||||
)
|
||||
|
||||
@Composable
|
||||
fun Day(day: String) {
|
||||
var lessons = emptyList<LessonData>()
|
||||
val context = LocalContext.current
|
||||
Column {
|
||||
LaunchedEffect(lessons, context) {
|
||||
getLessons(context, day).collect { savedLessons ->
|
||||
lessons = savedLessons.toMutableList()
|
||||
}
|
||||
}
|
||||
lessons.forEach() {
|
||||
Lesson(subject = it.subject, teacher = it.teacher, room = it.room)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun Lesson(subject: String, teacher: String, room: String) {
|
||||
Box(modifier = Modifier
|
||||
.size(200.dp, 100.dp)
|
||||
.padding(3.dp)
|
||||
) {
|
||||
Text(modifier = Modifier.align(Alignment.Center),
|
||||
text = "$subject\n@$room\n/w$teacher")
|
||||
}
|
||||
}
|
||||
|
||||
fun currentDay(): String {
|
||||
return "hi"
|
||||
}
|
||||
Reference in New Issue
Block a user