improved refresh button in navbar

This commit is contained in:
Odweta
2024-12-22 12:05:34 +01:00
parent 377156a31c
commit f0fcad3491
3 changed files with 11 additions and 13 deletions
@@ -25,7 +25,6 @@ fun launchStart(ctx: Context) {
}
fun remoteLoad(ctx: Context) {
Log.d("debug", "remoteLoad called")
if (!global.isAPISetUp) {
CoroutineScope(Dispatchers.IO)
.launch {
@@ -40,7 +39,6 @@ fun remoteLoad(ctx: Context) {
)
}
} else {
Log.d("debug", "API set up, continuing")
CoroutineScope(Dispatchers.IO).launch {
launchContinue(
ctx,
@@ -85,8 +83,6 @@ fun launchContinue(
val lectureNotes = Util.fileToString(global.filePaths.lectureNotes)
Parsing.parseLectureNotes(lectureNotes)
Log.d("debug", "parsed the things")
// listen for internet availability in case of disconnection
if (!internetAwaitListenerRunning)
setOnInternetAvailListener(ctx)
@@ -102,9 +98,11 @@ fun launchContinue(
global.currentScreenElement = ScreenElement.Timetable
// show the full name of the user in the toolbar as a status
statusFactory.show(StatusType.NameRole)
Log.d("debug", "done and should show nameRole status")
if (Util.internetAvail(ctx)) {
statusFactory.show(StatusType.NameRole)
} else {
statusFactory.show(StatusType.NoInternet)
}
}
private fun setOnInternetAvailListener(ctx: Context) {
@@ -42,9 +42,11 @@ fun NavbarScreen() {
spacerModifier = 15.dp
Button(
onClick = {
remoteLoad(ctx)
statusFactory.show(StatusType.Loading)
refreshButtonContentColor.value = PastelYellow
if (Util.internetAvail(ctx)) {
remoteLoad(ctx)
statusFactory.show(StatusType.Loading)
refreshButtonContentColor.value = PastelYellow
}
},
colors = ButtonDefaults.buttonColors(
contentColor = refreshButtonContentColor.value,
@@ -63,7 +65,6 @@ fun NavbarScreen() {
Button(
onClick = {
isShowing = IsShowing.Timetable
timetableColor.value = PastelYellow
marksColor.value = Color.White
menuColor.value = Color.White
@@ -85,7 +86,6 @@ fun NavbarScreen() {
Button(
onClick = {
isShowing = IsShowing.Marks
timetableColor.value = Color.White
marksColor.value = PastelYellow
menuColor.value = Color.White
@@ -108,7 +108,6 @@ fun NavbarScreen() {
Button(
onClick = {
isShowing = IsShowing.Menu
timetableColor.value = Color.White
marksColor.value = Color.White
menuColor.value = PastelYellow
@@ -1,5 +1,6 @@
package com.odweta.solon
import android.util.Log
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height