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