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