You've already forked RekomenciMobile
feat: added bootom nav
This commit is contained in:
+15
-29
@@ -44,18 +44,20 @@ fun TBottomNavigation(modifier: Modifier = Modifier, selectedPage: Int, onSelect
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
|
||||
val firstIconPos = remember { mutableFloatStateOf(0f) }
|
||||
val secondIconPos = remember { mutableFloatStateOf(0f) }
|
||||
val thirdIconPos = remember { mutableFloatStateOf(0f) }
|
||||
val homeIconPos = remember { mutableFloatStateOf(0f) }
|
||||
val profileIconPos = remember { mutableFloatStateOf(0f) }
|
||||
|
||||
val indicatorOffset =
|
||||
with(LocalDensity.current) {
|
||||
when (selectedPage) {
|
||||
0 -> firstIconPos.floatValue - secondIconPos.floatValue
|
||||
1 -> 0f
|
||||
2 -> thirdIconPos.floatValue - secondIconPos.floatValue
|
||||
val hasPositions = homeIconPos.floatValue != 0f || profileIconPos.floatValue != 0f
|
||||
if (!hasPositions) return@with null
|
||||
val center = (homeIconPos.floatValue + profileIconPos.floatValue) / 2f
|
||||
val target = when (selectedPage) {
|
||||
1 -> homeIconPos.floatValue
|
||||
2 -> profileIconPos.floatValue
|
||||
else -> null
|
||||
}?.toDp()
|
||||
}
|
||||
target?.let { (it - center).toDp() }
|
||||
}
|
||||
AnimatedVisibility(indicatorOffset != null) {
|
||||
indicatorOffset?.let {
|
||||
@@ -76,28 +78,12 @@ fun TBottomNavigation(modifier: Modifier = Modifier, selectedPage: Int, onSelect
|
||||
.size(30.dp)
|
||||
.onGloballyPositioned {
|
||||
it.parentCoordinates?.positionInParent()?.let {
|
||||
firstIconPos.floatValue = it.x
|
||||
homeIconPos.floatValue = it.x
|
||||
}
|
||||
}
|
||||
.noRippleClickable {
|
||||
onSelect(0)
|
||||
},
|
||||
painter = painterResource(R.drawable.ic_trips),
|
||||
tint = animateColorAsState(if (selectedPage == 0) MaterialTheme.colorScheme.surfaceVariant else MaterialTheme.colorScheme.onSurfaceVariant).value,
|
||||
contentDescription = "open trips list screen"
|
||||
)
|
||||
|
||||
Icon(
|
||||
modifier = Modifier
|
||||
.size(30.dp)
|
||||
.onGloballyPositioned {
|
||||
it.parentCoordinates?.positionInParent()?.let {
|
||||
secondIconPos.floatValue = it.x
|
||||
}
|
||||
}
|
||||
.noRippleClickable {
|
||||
onSelect(1)
|
||||
},
|
||||
painter = painterResource(R.drawable.ic_home),
|
||||
tint = animateColorAsState(if (selectedPage == 1) MaterialTheme.colorScheme.surfaceVariant else MaterialTheme.colorScheme.onSurfaceVariant).value,
|
||||
contentDescription = "open tasks screen"
|
||||
@@ -108,15 +94,15 @@ fun TBottomNavigation(modifier: Modifier = Modifier, selectedPage: Int, onSelect
|
||||
.size(30.dp)
|
||||
.onGloballyPositioned {
|
||||
it.parentCoordinates?.positionInParent()?.let {
|
||||
thirdIconPos.floatValue = it.x
|
||||
profileIconPos.floatValue = it.x
|
||||
}
|
||||
}
|
||||
.noRippleClickable {
|
||||
onSelect(2)
|
||||
onSelect(1)
|
||||
},
|
||||
painter = painterResource(R.drawable.ic_profile),
|
||||
tint = animateColorAsState(if (selectedPage == 2) MaterialTheme.colorScheme.surfaceVariant else MaterialTheme.colorScheme.onSurfaceVariant).value,
|
||||
contentDescription = "open tasks screen"
|
||||
contentDescription = "open profile screen"
|
||||
)
|
||||
}
|
||||
|
||||
@@ -135,4 +121,4 @@ fun TBottomNavigationPreview() {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,14 +72,10 @@ fun TTasksApp(
|
||||
) { newPage ->
|
||||
when (newPage) {
|
||||
0 -> {
|
||||
TODO()
|
||||
}
|
||||
|
||||
1 -> {
|
||||
appState.navController.navigate(AppDestination.Main.route)
|
||||
}
|
||||
|
||||
2 -> {
|
||||
1 -> {
|
||||
appState.navController.navigate(AppDestination.Profile.route)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import androidx.navigation.compose.composable
|
||||
import com.prodhack.moscow2025.presentation.screens.main.MainScreen
|
||||
import com.prodhack.moscow2025.domain.utils.NetworkError
|
||||
import com.prodhack.moscow2025.presentation.screens.login.LoginScreen
|
||||
import com.prodhack.moscow2025.presentation.screens.profile.ProfileScreen
|
||||
import com.prodhack.moscow2025.presentation.screens.register.RegisterScreen
|
||||
import com.prodhack.moscow2025.presentation.utils.ErrorCallbacks
|
||||
import com.prodhack.moscow2025.presentation.utils.ErrorCollectorScope
|
||||
@@ -75,6 +76,11 @@ fun TTasksNavHost(
|
||||
composable(AppDestination.Main.route) {
|
||||
MainScreen()
|
||||
}
|
||||
|
||||
composable(AppDestination.Profile.route)
|
||||
{
|
||||
ProfileScreen()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
package com.prodhack.moscow2025.presentation.screens.profile
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
|
||||
@Composable
|
||||
fun ProfileScreen(modifier: Modifier = Modifier) {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user