created TempScreen for on-demand recompositions of the whole app.
enhanced UI
This commit is contained in:
-6
@@ -13,12 +13,6 @@
|
|||||||
</DropdownSelection>
|
</DropdownSelection>
|
||||||
<DialogSelection />
|
<DialogSelection />
|
||||||
</SelectionState>
|
</SelectionState>
|
||||||
<SelectionState runConfigName="TimetablePreview">
|
|
||||||
<option name="selectionMode" value="DROPDOWN" />
|
|
||||||
</SelectionState>
|
|
||||||
<SelectionState runConfigName="RBPreview">
|
|
||||||
<option name="selectionMode" value="DROPDOWN" />
|
|
||||||
</SelectionState>
|
|
||||||
</selectionStates>
|
</selectionStates>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
@@ -63,7 +63,10 @@ object BackButtonFactory: BackButtonFactoryInterface {
|
|||||||
@Composable
|
@Composable
|
||||||
override fun get(type: BackButtonType): @Composable () -> Unit {
|
override fun get(type: BackButtonType): @Composable () -> Unit {
|
||||||
return when (type) {
|
return when (type) {
|
||||||
BackButtonType.Menu -> { { BackButton { global.currentScreenElement = ScreenElement.Menu } } }
|
BackButtonType.Menu -> { { BackButton {
|
||||||
|
global.currentScreenElement = ScreenElement.Menu
|
||||||
|
global.currentScreen = Screen.Main
|
||||||
|
} } }
|
||||||
BackButtonType.MarksAll -> { { BackButton {
|
BackButtonType.MarksAll -> { { BackButton {
|
||||||
global.currentScreenElement = ScreenElement.Marks
|
global.currentScreenElement = ScreenElement.Marks
|
||||||
global.marksDepthLevel = MarksDepthLevel.All
|
global.marksDepthLevel = MarksDepthLevel.All
|
||||||
|
|||||||
@@ -15,12 +15,16 @@ import androidx.compose.foundation.layout.height
|
|||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
import androidx.compose.runtime.MutableState
|
import androidx.compose.runtime.MutableState
|
||||||
import androidx.compose.runtime.RecomposeScope
|
import androidx.compose.runtime.RecomposeScope
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
|
import androidx.compose.runtime.key
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.platform.LocalViewConfiguration
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
import com.odweta.solon.ui.theme.PastelYellow
|
import com.odweta.solon.ui.theme.PastelYellow
|
||||||
@@ -32,7 +36,9 @@ import java.util.concurrent.Callable
|
|||||||
enum class Screen {
|
enum class Screen {
|
||||||
Main,
|
Main,
|
||||||
Splash,
|
Splash,
|
||||||
SignIn
|
SignIn,
|
||||||
|
Settings,
|
||||||
|
Temp
|
||||||
}
|
}
|
||||||
|
|
||||||
// default settings (will get overwritten by the saved settings)
|
// default settings (will get overwritten by the saved settings)
|
||||||
@@ -187,7 +193,6 @@ enum class ScreenElement {
|
|||||||
FinalMarks,
|
FinalMarks,
|
||||||
Menu,
|
Menu,
|
||||||
About,
|
About,
|
||||||
Settings,
|
|
||||||
SignOut
|
SignOut
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -217,11 +222,13 @@ class Global {
|
|||||||
var selectedLecture: Int = 0
|
var selectedLecture: Int = 0
|
||||||
var currentLectureNumber: Int = 0
|
var currentLectureNumber: Int = 0
|
||||||
|
|
||||||
|
var tempScreen by mutableStateOf(Screen.Settings)
|
||||||
var currentScreen by mutableStateOf(Screen.Main)
|
var currentScreen by mutableStateOf(Screen.Main)
|
||||||
var currentScreenElement by mutableStateOf(ScreenElement.Timetable)
|
var currentScreenElement by mutableStateOf(ScreenElement.Timetable)
|
||||||
|
|
||||||
var status by mutableStateOf("")
|
var status by mutableStateOf("")
|
||||||
|
|
||||||
|
var returnToTempScreen by mutableStateOf(false)
|
||||||
var isAPISetUp by mutableStateOf(false)
|
var isAPISetUp by mutableStateOf(false)
|
||||||
var launched by mutableStateOf(false)
|
var launched by mutableStateOf(false)
|
||||||
var refreshed by mutableStateOf(false)
|
var refreshed by mutableStateOf(false)
|
||||||
@@ -273,9 +280,16 @@ val global = Global()
|
|||||||
|
|
||||||
var settings = SettingsData()
|
var settings = SettingsData()
|
||||||
|
|
||||||
|
private fun <T> changeAndRevert(variable: T, newValue: T, revert: (T) -> Unit) {
|
||||||
|
val orig = variable
|
||||||
|
revert(newValue)
|
||||||
|
revert(orig)
|
||||||
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun <T> Animate(targetState: T, content: @Composable (target: T) -> Unit) {
|
fun <T> Animate(targetState: T, content: @Composable (target: T) -> Unit) {
|
||||||
if (settings.useAnimations.checked.value == true) {
|
if (settings.useAnimations.checked.value == true) {
|
||||||
|
// When animations are enabled, apply AnimatedContent
|
||||||
AnimatedContent(
|
AnimatedContent(
|
||||||
targetState = targetState,
|
targetState = targetState,
|
||||||
transitionSpec = {
|
transitionSpec = {
|
||||||
@@ -283,11 +297,16 @@ fun <T> Animate(targetState: T, content: @Composable (target: T) -> Unit) {
|
|||||||
slideOutVertically(targetOffsetY = { it }) + fadeOut()
|
slideOutVertically(targetOffsetY = { it }) + fadeOut()
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
modifier = Modifier.fillMaxSize(), label = "animated content"
|
modifier = Modifier.fillMaxSize(),
|
||||||
|
label = "animated content"
|
||||||
) { target ->
|
) { target ->
|
||||||
content(target)
|
content(target)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
// When animations are disabled, just show content without animation
|
||||||
content(targetState)
|
content(targetState)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -43,6 +43,9 @@ class MainActivity : ComponentActivity() {
|
|||||||
Screen.Main -> if (global.launched) MainScreen()
|
Screen.Main -> if (global.launched) MainScreen()
|
||||||
Screen.Splash -> SplashScreen()
|
Screen.Splash -> SplashScreen()
|
||||||
Screen.SignIn -> SignInScreen()
|
Screen.SignIn -> SignInScreen()
|
||||||
|
Screen.Settings -> SettingsScreen()
|
||||||
|
Screen.Temp -> TempScreen()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -76,7 +79,6 @@ class MainActivity : ComponentActivity() {
|
|||||||
ScreenElement.FinalMarks -> FinalMarksScreen()
|
ScreenElement.FinalMarks -> FinalMarksScreen()
|
||||||
ScreenElement.Menu -> MenuScreen()
|
ScreenElement.Menu -> MenuScreen()
|
||||||
ScreenElement.About -> AboutScreen()
|
ScreenElement.About -> AboutScreen()
|
||||||
ScreenElement.Settings -> SettingsScreen()
|
|
||||||
ScreenElement.SignOut -> SignOutScreen()
|
ScreenElement.SignOut -> SignOutScreen()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -90,4 +92,3 @@ class MainActivity : ComponentActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
@@ -86,7 +86,7 @@ fun MenuScreen() {
|
|||||||
Spacer(modifier = Modifier.width(menuSeparatorDimen))
|
Spacer(modifier = Modifier.width(menuSeparatorDimen))
|
||||||
|
|
||||||
MenuButton(
|
MenuButton(
|
||||||
{ global.currentScreenElement = ScreenElement.Settings },
|
{ global.currentScreen = Screen.Settings },
|
||||||
Icons.Default.Settings,
|
Icons.Default.Settings,
|
||||||
"Nastavení"
|
"Nastavení"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ class Parsing {
|
|||||||
subj.getJSONArray("teachers")
|
subj.getJSONArray("teachers")
|
||||||
.getJSONObject(0).getString("name") + " " +
|
.getJSONObject(0).getString("name") + " " +
|
||||||
subj.getJSONArray("teachers")
|
subj.getJSONArray("teachers")
|
||||||
.getJSONObject(0).getString("name")
|
.getJSONObject(0).getString("surname")
|
||||||
} else {
|
} else {
|
||||||
""
|
""
|
||||||
}
|
}
|
||||||
@@ -199,15 +199,13 @@ class Parsing {
|
|||||||
|
|
||||||
val detailHours = subj.getJSONArray("detailHours")
|
val detailHours = subj.getJSONArray("detailHours")
|
||||||
newSubject.number =
|
newSubject.number =
|
||||||
detailHours.getJSONObject(i).get("id").toString()
|
detailHours.getJSONObject(i).getString("id")
|
||||||
newSubject.start =
|
newSubject.start =
|
||||||
detailHours.getJSONObject(i).get("timeFrom")
|
detailHours.getJSONObject(i).getString("timeFrom")
|
||||||
.toString()
|
|
||||||
newSubject.start =
|
newSubject.start =
|
||||||
newSubject.start.slice(0..newSubject.start.length - 4)
|
newSubject.start.slice(0..newSubject.start.length - 4)
|
||||||
newSubject.end =
|
newSubject.end =
|
||||||
detailHours.getJSONObject(i).get("timeto")
|
detailHours.getJSONObject(i).getString("timeto")
|
||||||
.toString()
|
|
||||||
newSubject.end =
|
newSubject.end =
|
||||||
newSubject.end.slice(0..newSubject.end.length - 4)
|
newSubject.end.slice(0..newSubject.end.length - 4)
|
||||||
subjects.add(newSubject)
|
subjects.add(newSubject)
|
||||||
@@ -217,7 +215,7 @@ class Parsing {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val sCopy = subjects.toList()
|
val sCopy = subjects.toList()
|
||||||
for (s in 0 until sCopy.size) {
|
for (s in sCopy.indices) {
|
||||||
if ("-" in subjects[s].number) {
|
if ("-" in subjects[s].number) {
|
||||||
subjects[s].number = "1"
|
subjects[s].number = "1"
|
||||||
subjects[s].start = "08:00"
|
subjects[s].start = "08:00"
|
||||||
@@ -226,26 +224,6 @@ class Parsing {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
// rust pseudocode
|
|
||||||
|
|
||||||
let mut res: Vec<i32> = vec![];
|
|
||||||
for i in 0..v.len()-1 {
|
|
||||||
if v[i] == v[i+1]-1 {
|
|
||||||
res.push(v[i]);
|
|
||||||
} else {
|
|
||||||
res.push(v[i]);
|
|
||||||
|
|
||||||
while res[res.len()-1]+1 != v[i+1] {
|
|
||||||
res.push(res[res.len()-1]+1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
res.push(v[v.len()-1]);
|
|
||||||
|
|
||||||
res
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (subjects.size > 1) {
|
if (subjects.size > 1) {
|
||||||
for (i in 0..<subjects.size - 1) {
|
for (i in 0..<subjects.size - 1) {
|
||||||
if (subjects[i].number == ((subjects[i + 1].number.toInt() - 1).toString())) {
|
if (subjects[i].number == ((subjects[i + 1].number.toInt() - 1).toString())) {
|
||||||
|
|||||||
@@ -38,7 +38,10 @@ import kotlinx.coroutines.launch
|
|||||||
@Composable
|
@Composable
|
||||||
fun SettingsScreen() {
|
fun SettingsScreen() {
|
||||||
// handle the back gesture (back swipe form side or back button on bottom android navbar)
|
// handle the back gesture (back swipe form side or back button on bottom android navbar)
|
||||||
BackHandler { global.currentScreenElement = ScreenElement.Menu }
|
BackHandler {
|
||||||
|
global.currentScreenElement = ScreenElement.Menu
|
||||||
|
global.currentScreen = Screen.Main
|
||||||
|
}
|
||||||
|
|
||||||
// load the settings dat every time the settings screen is opened,
|
// load the settings dat every time the settings screen is opened,
|
||||||
// maybe i can add a flag that determines if the settings are up to date?
|
// maybe i can add a flag that determines if the settings are up to date?
|
||||||
@@ -87,6 +90,7 @@ fun SettingsTableRow(setting: Setting) {
|
|||||||
checked = setting.checked.value == true,
|
checked = setting.checked.value == true,
|
||||||
onCheckedChange = {
|
onCheckedChange = {
|
||||||
setting.checked.value = it
|
setting.checked.value = it
|
||||||
|
showTempScreen(Screen.Settings)
|
||||||
Util.saveStringToFile(global.filePaths.settings, settings.toString())
|
Util.saveStringToFile(global.filePaths.settings, settings.toString())
|
||||||
},
|
},
|
||||||
colors = SwitchColors(
|
colors = SwitchColors(
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package com.odweta.solon
|
||||||
|
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
|
||||||
|
// temporary screens to artificially trigger recompositions basically at the root level
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun TempScreen() {
|
||||||
|
when (global.tempScreen) {
|
||||||
|
Screen.Main -> MainScreen()
|
||||||
|
Screen.Splash -> SplashScreen()
|
||||||
|
Screen.SignIn -> SignInScreen()
|
||||||
|
Screen.Settings -> SettingsScreen()
|
||||||
|
Screen.Temp -> {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun showTempScreen(screen: Screen) {
|
||||||
|
global.returnToTempScreen = true
|
||||||
|
global.tempScreen = screen
|
||||||
|
global.currentScreen = Screen.Temp
|
||||||
|
}
|
||||||
@@ -49,6 +49,7 @@ import androidx.compose.ui.focus.focusModifier
|
|||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.res.painterResource
|
import androidx.compose.ui.res.painterResource
|
||||||
|
import androidx.compose.ui.text.TextStyle
|
||||||
import androidx.compose.ui.text.font.FontStyle
|
import androidx.compose.ui.text.font.FontStyle
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
import androidx.compose.ui.text.style.TextAlign
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
@@ -440,8 +441,9 @@ private fun DayScreen(day: Day) {
|
|||||||
|
|
||||||
Text(
|
Text(
|
||||||
text = " supl ",
|
text = " supl ",
|
||||||
color = Color.Black,
|
color = Color.White,
|
||||||
modifier = Modifier.background(color = Color.White)
|
fontStyle = FontStyle.Italic,
|
||||||
|
modifier = Modifier.background(color = PastelRedTransparent)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -486,8 +488,7 @@ private fun DayScreen(day: Day) {
|
|||||||
) {
|
) {
|
||||||
if (settings.useSvobodaMode.checked.value == true) {
|
if (settings.useSvobodaMode.checked.value == true) {
|
||||||
if (
|
if (
|
||||||
subject.teacher == "Jindřich Svoboda" &&
|
subject.teacher == "Jindřich Svoboda"
|
||||||
global.studentClass == "5. G"
|
|
||||||
) {
|
) {
|
||||||
Image(
|
Image(
|
||||||
painter = painterResource(R.drawable.spock),
|
painter = painterResource(R.drawable.spock),
|
||||||
|
|||||||
Reference in New Issue
Block a user