96 lines
3.4 KiB
Kotlin
96 lines
3.4 KiB
Kotlin
|
|
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
|
||
|
|
import androidx.constraintlayout.compose.ConstraintLayout
|
||
|
|
import androidx.constraintlayout.compose.Dimension
|
||
|
|
import cafe.adriel.voyager.navigator.LocalNavigator
|
||
|
|
import cafe.adriel.voyager.navigator.currentOrThrow
|
||
|
|
import ui.screens.Settings
|
||
|
|
|
||
|
|
class Bars {
|
||
|
|
companion object {
|
||
|
|
@Composable
|
||
|
|
fun topBar(screenCount: Int) {
|
||
|
|
ConstraintLayout(
|
||
|
|
Modifier
|
||
|
|
.fillMaxWidth()
|
||
|
|
.padding(10.dp)
|
||
|
|
) {
|
||
|
|
val (back, capture) = createRefs()
|
||
|
|
|
||
|
|
if (screenCount > 1) {
|
||
|
|
backButton(Modifier.constrainAs(back) {
|
||
|
|
linkTo(parent.top, parent.bottom)
|
||
|
|
start.linkTo(parent.start, margin = 5.dp)
|
||
|
|
})
|
||
|
|
|
||
|
|
}
|
||
|
|
Capture.captureContext(Modifier.constrainAs(capture) {
|
||
|
|
linkTo(parent.top, parent.bottom)
|
||
|
|
linkTo(parent.start, parent.end)
|
||
|
|
centerVerticallyTo(parent)
|
||
|
|
})
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
@Composable
|
||
|
|
fun bottomBar() {
|
||
|
|
ConstraintLayout(
|
||
|
|
Modifier
|
||
|
|
.padding(5.dp)
|
||
|
|
.fillMaxWidth()
|
||
|
|
) {
|
||
|
|
val currentProfile = createRef()
|
||
|
|
|
||
|
|
Profiles.currentProfile(Modifier.constrainAs(currentProfile) {
|
||
|
|
bottom.linkTo(parent.bottom)
|
||
|
|
start.linkTo(parent.start)
|
||
|
|
})
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
@Composable
|
||
|
|
fun backButton(modifier: Modifier) {
|
||
|
|
val navigator = LocalNavigator.currentOrThrow
|
||
|
|
Box(
|
||
|
|
modifier = modifier
|
||
|
|
.background(MaterialTheme.colors.primary, CircleShape)
|
||
|
|
) {
|
||
|
|
Button(
|
||
|
|
shape = CircleShape,
|
||
|
|
colors = ButtonDefaults.buttonColors(backgroundColor = Color.Transparent, contentColor = MaterialTheme.colors.onPrimary),
|
||
|
|
elevation = ButtonDefaults.elevation(0.dp),
|
||
|
|
onClick = {
|
||
|
|
navigator.pop()
|
||
|
|
}) {
|
||
|
|
Icon(
|
||
|
|
imageVector = Icons.Filled.ArrowBackIosNew,
|
||
|
|
contentDescription = "Go Back"
|
||
|
|
)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|