2024-10-26 18:07:40 +00:00
|
|
|
package ui
|
|
|
|
|
|
|
|
|
|
import androidx.compose.foundation.background
|
|
|
|
|
import androidx.compose.foundation.layout.Box
|
|
|
|
|
import androidx.compose.foundation.layout.fillMaxWidth
|
|
|
|
|
import androidx.compose.foundation.layout.padding
|
|
|
|
|
import androidx.compose.foundation.shape.CircleShape
|
|
|
|
|
import androidx.compose.material.MaterialTheme
|
|
|
|
|
import androidx.compose.material.icons.Icons
|
|
|
|
|
import androidx.compose.material.icons.filled.ArrowBackIosNew
|
2024-10-28 23:23:32 +00:00
|
|
|
import androidx.compose.material.icons.filled.Settings
|
2024-10-26 18:07:40 +00:00
|
|
|
import androidx.compose.runtime.Composable
|
|
|
|
|
import androidx.compose.ui.Modifier
|
|
|
|
|
import androidx.compose.ui.unit.dp
|
|
|
|
|
import androidx.constraintlayout.compose.ConstraintLayout
|
|
|
|
|
import cafe.adriel.voyager.navigator.LocalNavigator
|
|
|
|
|
import cafe.adriel.voyager.navigator.currentOrThrow
|
2024-10-28 00:46:18 +00:00
|
|
|
import transparentButton
|
2024-10-28 23:23:32 +00:00
|
|
|
import ui.Profiles.Companion.Buttons.Companion.createProfile
|
|
|
|
|
import ui.Profiles.Companion.Buttons.Companion.currentProfile
|
2024-10-28 00:46:18 +00:00
|
|
|
import ui.screens.ProfilesManager
|
2024-10-26 18:07:40 +00:00
|
|
|
import ui.screens.Settings
|
|
|
|
|
|
|
|
|
|
class Bars {
|
|
|
|
|
companion object {
|
|
|
|
|
@Composable
|
|
|
|
|
fun topBar(screenCount: Int) {
|
|
|
|
|
ConstraintLayout(
|
2024-10-28 00:46:18 +00:00
|
|
|
modifier = Modifier
|
2024-10-26 18:07:40 +00:00
|
|
|
.padding(10.dp)
|
2024-10-28 00:46:18 +00:00
|
|
|
.fillMaxWidth()
|
2024-10-26 18:07:40 +00:00
|
|
|
) {
|
|
|
|
|
val (back, capture) = createRefs()
|
|
|
|
|
|
|
|
|
|
if (screenCount > 1) {
|
|
|
|
|
backButton(Modifier.constrainAs(back) {
|
|
|
|
|
linkTo(parent.top, parent.bottom)
|
|
|
|
|
start.linkTo(parent.start, margin = 5.dp)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
}
|
2024-10-28 00:46:18 +00:00
|
|
|
|
2024-10-26 18:07:40 +00:00
|
|
|
Capture.captureContext(Modifier.constrainAs(capture) {
|
|
|
|
|
linkTo(parent.top, parent.bottom)
|
|
|
|
|
linkTo(parent.start, parent.end)
|
|
|
|
|
centerVerticallyTo(parent)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
|
fun bottomBar() {
|
|
|
|
|
ConstraintLayout(
|
2024-10-28 00:46:18 +00:00
|
|
|
modifier = Modifier
|
2024-10-26 18:07:40 +00:00
|
|
|
.padding(5.dp)
|
|
|
|
|
.fillMaxWidth()
|
|
|
|
|
) {
|
2024-10-28 00:46:18 +00:00
|
|
|
val (currentProfile, createProfile) = createRefs()
|
2024-10-26 18:07:40 +00:00
|
|
|
|
2024-10-28 23:23:32 +00:00
|
|
|
currentProfile(Modifier.constrainAs(currentProfile) {
|
2024-10-28 00:46:18 +00:00
|
|
|
linkTo(parent.top, parent.bottom)
|
2024-10-26 18:07:40 +00:00
|
|
|
start.linkTo(parent.start)
|
|
|
|
|
})
|
|
|
|
|
|
2024-10-28 00:46:18 +00:00
|
|
|
if (LocalNavigator.currentOrThrow.lastItem is ProfilesManager) {
|
2024-10-28 23:23:32 +00:00
|
|
|
createProfile(Modifier.constrainAs(createProfile) {
|
2024-10-28 00:46:18 +00:00
|
|
|
linkTo(parent.top, parent.bottom)
|
|
|
|
|
end.linkTo(parent.end)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-10-28 23:23:32 +00:00
|
|
|
}
|
2024-10-26 18:07:40 +00:00
|
|
|
@Composable
|
|
|
|
|
fun backButton(modifier: Modifier) {
|
|
|
|
|
val navigator = LocalNavigator.currentOrThrow
|
2024-10-28 00:46:18 +00:00
|
|
|
|
2024-10-26 18:07:40 +00:00
|
|
|
Box(
|
|
|
|
|
modifier = modifier
|
|
|
|
|
.background(MaterialTheme.colors.primary, CircleShape)
|
|
|
|
|
) {
|
2024-10-28 00:46:18 +00:00
|
|
|
transparentButton(
|
|
|
|
|
modifier = Modifier,
|
|
|
|
|
icon = Icons.Filled.ArrowBackIosNew,
|
|
|
|
|
contentDescription = "Go Back",
|
|
|
|
|
onClick = { navigator.pop() },
|
|
|
|
|
)
|
2024-10-26 18:07:40 +00:00
|
|
|
}
|
|
|
|
|
}
|
2024-10-28 23:23:32 +00:00
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
|
fun settingsButton(modifier: Modifier) {
|
|
|
|
|
val navigator = LocalNavigator.currentOrThrow
|
|
|
|
|
|
|
|
|
|
transparentButton(
|
|
|
|
|
modifier = modifier,
|
|
|
|
|
icon = Icons.Filled.Settings,
|
|
|
|
|
contentDescription = "Settings",
|
|
|
|
|
onClick = {
|
|
|
|
|
if (navigator.lastItem !is Settings) {
|
|
|
|
|
navigator.push(Settings())
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
}
|
2024-10-26 18:07:40 +00:00
|
|
|
}
|
|
|
|
|
}
|