you can now add notes to every lecture and they will automatically be saved locally
This commit is contained in:
@@ -138,7 +138,8 @@ var resetNav: Boolean = false
|
|||||||
|
|
||||||
var isAPISetUp: Boolean = false
|
var isAPISetUp: Boolean = false
|
||||||
|
|
||||||
var lectureNotes: HashMap<Int, String> = hashMapOf()
|
var lectureNotes: HashMap<Int, MutableState<String>> = hashMapOf()
|
||||||
|
var selectedLecture: Int = 0
|
||||||
|
|
||||||
var selectedDay: Int = 0
|
var selectedDay: Int = 0
|
||||||
var dayEndString: String = ""
|
var dayEndString: String = ""
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.odweta.solon
|
package com.odweta.solon
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
|
import android.util.Log
|
||||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
@@ -58,6 +59,8 @@ import java.time.LocalTime
|
|||||||
import java.time.format.DateTimeFormatter
|
import java.time.format.DateTimeFormatter
|
||||||
import kotlin.math.abs
|
import kotlin.math.abs
|
||||||
|
|
||||||
|
var showDetailDialog = mutableStateOf(false)
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun TimetableScreen() {
|
fun TimetableScreen() {
|
||||||
Box(
|
Box(
|
||||||
@@ -66,12 +69,60 @@ fun TimetableScreen() {
|
|||||||
contentAlignment = Alignment.BottomCenter
|
contentAlignment = Alignment.BottomCenter
|
||||||
) {
|
) {
|
||||||
DayPager()
|
DayPager()
|
||||||
//if (settings.showRefreshButton.checked.value) {
|
if (showDetailDialog.value) {
|
||||||
// RefreshButton()
|
DetailDialog()
|
||||||
//}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("UnrememberedMutableState")
|
||||||
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
|
@Composable
|
||||||
|
fun DetailDialog(modifier: Modifier = Modifier) {
|
||||||
|
Dialog(
|
||||||
|
onDismissRequest = { showDetailDialog.value = false }, // Close the dialog on dismiss
|
||||||
|
properties = DialogProperties(
|
||||||
|
dismissOnBackPress = true,
|
||||||
|
dismissOnClickOutside = true
|
||||||
|
),
|
||||||
|
content = {
|
||||||
|
Box(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(horizontal = 20.dp)
|
||||||
|
.background(
|
||||||
|
color = Color.Black,
|
||||||
|
shape = RoundedCornerShape(roundedCornerDimen)
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
if (lectureNotes[selectedLecture] == null) {
|
||||||
|
lectureNotes[selectedLecture] = mutableStateOf("")
|
||||||
|
}
|
||||||
|
|
||||||
|
TextField(
|
||||||
|
value = lectureNotes[selectedLecture]!!.value,
|
||||||
|
onValueChange = { newText: String ->
|
||||||
|
lectureNotes[selectedLecture]!!.value = newText
|
||||||
|
Util.saveLectureIds()
|
||||||
|
},
|
||||||
|
placeholder = { Text("Sem můžete napsat poznámky k\u00A0této hodině.") },
|
||||||
|
colors = TextFieldDefaults.textFieldColors(
|
||||||
|
focusedTextColor = Color.White,
|
||||||
|
containerColor = Color.Black,
|
||||||
|
selectionColors = TextSelectionColors(
|
||||||
|
handleColor = PastelYellow,
|
||||||
|
backgroundColor = PastelYellowTransparent
|
||||||
|
),
|
||||||
|
cursorColor = PastelYellow,
|
||||||
|
focusedIndicatorColor = PastelYellow,
|
||||||
|
unfocusedIndicatorColor = PastelYellowTransparent
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
@OptIn(ExperimentalFoundationApi::class)
|
@OptIn(ExperimentalFoundationApi::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun DayPager(modifier: Modifier = Modifier) {
|
fun DayPager(modifier: Modifier = Modifier) {
|
||||||
@@ -167,11 +218,9 @@ fun subjectModifier(d: Day, s: Subject, lectureNumber: Int): Modifier {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun DayScreen(day: Day) {
|
private fun DayScreen(day: Day) {
|
||||||
val scrollState = rememberScrollState()
|
val scrollState = rememberScrollState()
|
||||||
var showDetailDialog by remember { mutableStateOf(false) }
|
|
||||||
|
|
||||||
Column(modifier = Modifier.fillMaxSize()) {
|
Column(modifier = Modifier.fillMaxSize()) {
|
||||||
Row(
|
Row(
|
||||||
@@ -200,6 +249,7 @@ private fun DayScreen(day: Day) {
|
|||||||
.verticalScroll(scrollState)
|
.verticalScroll(scrollState)
|
||||||
) {
|
) {
|
||||||
for ((subjectIndex, subject) in day.subjects.withIndex()) {
|
for ((subjectIndex, subject) in day.subjects.withIndex()) {
|
||||||
|
val lectureId = Util.getLectureId(day.date, subjectIndex)
|
||||||
val amoledModifier = if (settings.useAmoledMode.checked.value) {
|
val amoledModifier = if (settings.useAmoledMode.checked.value) {
|
||||||
Modifier
|
Modifier
|
||||||
.width(50.dp)
|
.width(50.dp)
|
||||||
@@ -368,36 +418,13 @@ private fun DayScreen(day: Day) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Box(modifier = Modifier.fillMaxSize().zIndex(99f).clickable { showDetailDialog = true })
|
Box(modifier = Modifier
|
||||||
|
.fillMaxSize()
|
||||||
if (showDetailDialog) {
|
.zIndex(99f)
|
||||||
Dialog(
|
.clickable {
|
||||||
onDismissRequest = { showDetailDialog = false }, // Close the dialog on dismiss
|
selectedLecture = lectureId
|
||||||
properties = DialogProperties(
|
showDetailDialog.value = true
|
||||||
dismissOnBackPress = true,
|
})
|
||||||
dismissOnClickOutside = true
|
|
||||||
),
|
|
||||||
content = {
|
|
||||||
Box(
|
|
||||||
modifier = Modifier
|
|
||||||
.width(100.dp)
|
|
||||||
.height(100.dp)
|
|
||||||
.background(
|
|
||||||
color = Color.Black,
|
|
||||||
shape = RoundedCornerShape(roundedCornerDimen)
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
TextField(
|
|
||||||
value = lectureNotes[Util.getLectureId(day.date, subjectIndex)] ?: "",
|
|
||||||
onValueChange = { newText ->
|
|
||||||
lectureNotes[Util.getLectureId(day.date, subjectIndex)] = newText
|
|
||||||
Util.saveLectureIds()
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ import android.net.NetworkCapabilities
|
|||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.util.DisplayMetrics
|
import android.util.DisplayMetrics
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
|
import androidx.compose.runtime.MutableState
|
||||||
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.core.content.pm.PackageInfoCompat
|
import androidx.core.content.pm.PackageInfoCompat
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
@@ -266,8 +268,8 @@ class Util {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fun csvToHashMap(filePath: String): HashMap<Int, String> {
|
fun csvToHashMap(filePath: String): HashMap<Int, MutableState<String>> {
|
||||||
val hashMap = HashMap<Int, String>()
|
val hashMap = HashMap<Int, MutableState<String>>()
|
||||||
val lines = fileToString(filePath).lines()
|
val lines = fileToString(filePath).lines()
|
||||||
for (line in lines) {
|
for (line in lines) {
|
||||||
if (line.isBlank()) continue
|
if (line.isBlank()) continue
|
||||||
@@ -277,17 +279,18 @@ class Util {
|
|||||||
if (parts.size == 2) {
|
if (parts.size == 2) {
|
||||||
val key = parts[0].trim().toInt()
|
val key = parts[0].trim().toInt()
|
||||||
val value = parts[1].trim()
|
val value = parts[1].trim()
|
||||||
hashMap[key] = value
|
hashMap[key] = mutableStateOf("")
|
||||||
|
hashMap[key]!!.value = value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return hashMap
|
return hashMap
|
||||||
}
|
}
|
||||||
|
|
||||||
fun hashMapToCsv(hashMap: HashMap<Int, String>): String {
|
fun hashMapToCsv(hashMap: HashMap<Int, MutableState<String>>): String {
|
||||||
var result = ""
|
var result = ""
|
||||||
for ((key, value) in hashMap) {
|
for ((key, value) in hashMap) {
|
||||||
result += "$key,$value\n"
|
result += "$key,${value.value}\n"
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user