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.WindowInsets
|
|
|
|
|
import androidx.compose.foundation.layout.fillMaxHeight
|
|
|
|
|
import androidx.compose.foundation.layout.fillMaxWidth
|
|
|
|
|
import androidx.compose.foundation.layout.padding
|
|
|
|
|
import androidx.compose.foundation.layout.windowInsetsPadding
|
|
|
|
|
import androidx.compose.foundation.layout.wrapContentHeight
|
|
|
|
|
import androidx.compose.foundation.layout.wrapContentWidth
|
|
|
|
|
import androidx.compose.foundation.shape.CircleShape
|
|
|
|
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
|
|
|
import androidx.compose.material.Button
|
|
|
|
|
import androidx.compose.material.ButtonDefaults
|
|
|
|
|
import androidx.compose.material.Icon
|
|
|
|
|
import androidx.compose.material.MaterialTheme
|
|
|
|
|
import androidx.compose.material.icons.Icons
|
|
|
|
|
import androidx.compose.material.icons.filled.ArrowBackIosNew
|
|
|
|
|
import androidx.compose.runtime.Composable
|
|
|
|
|
import androidx.compose.ui.Modifier
|
|
|
|
|
import androidx.compose.ui.draw.shadow
|
|
|
|
|
import androidx.compose.ui.graphics.Color
|
|
|
|
|
import androidx.compose.ui.unit.dp
|
2024-10-28 00:46:18 +00:00
|
|
|
import androidx.constraintlayout.compose.ConstrainedLayoutReference
|
2024-10-26 18:07:40 +00:00
|
|
|
import androidx.constraintlayout.compose.ConstraintLayout
|
2024-10-28 00:46:18 +00:00
|
|
|
import androidx.constraintlayout.compose.ConstraintLayoutScope
|
2024-10-26 18:07:40 +00:00
|
|
|
import androidx.constraintlayout.compose.Dimension
|
|
|
|
|
import cafe.adriel.voyager.navigator.LocalNavigator
|
|
|
|
|
import cafe.adriel.voyager.navigator.currentOrThrow
|
2024-10-28 00:46:18 +00:00
|
|
|
import transparentButton
|
|
|
|
|
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
|
|
|
|
|
|
|
|
Profiles.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) {
|
|
|
|
|
Profiles.createProfile(Modifier.constrainAs(createProfile) {
|
|
|
|
|
linkTo(parent.top, parent.bottom)
|
|
|
|
|
end.linkTo(parent.end)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}p
|
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
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|