|
@@ -4,6 +4,7 @@ import android.app.Activity
|
|
|
import android.content.res.Configuration
|
|
|
import android.util.Log
|
|
|
import androidx.activity.ComponentActivity
|
|
|
+import androidx.compose.animation.AnimatedVisibility
|
|
|
import androidx.compose.foundation.layout.Box
|
|
|
import androidx.compose.foundation.layout.Column
|
|
|
import androidx.compose.foundation.layout.RowScope
|
|
@@ -22,6 +23,7 @@ import androidx.compose.material3.MaterialTheme
|
|
|
import androidx.compose.material3.Scaffold
|
|
|
import androidx.compose.material3.Text
|
|
|
import androidx.compose.runtime.Composable
|
|
|
+import androidx.compose.runtime.LaunchedEffect
|
|
|
import androidx.compose.runtime.getValue
|
|
|
import androidx.compose.runtime.mutableStateOf
|
|
|
import androidx.compose.runtime.remember
|
|
@@ -41,6 +43,7 @@ import androidx.navigation.compose.currentBackStackEntryAsState
|
|
|
import androidx.navigation.compose.rememberNavController
|
|
|
import com.vpn.fastestvpnservice.R
|
|
|
import com.vpn.fastestvpnservice.navigation.BottomBarNavGraph
|
|
|
+import com.vpn.fastestvpnservice.navigation.navigationAnimation
|
|
|
import com.vpn.fastestvpnservice.sealedClass.BottomBarScreen
|
|
|
import com.vpn.fastestvpnservice.ui.theme.customTypography2
|
|
|
|
|
@@ -109,8 +112,30 @@ fun RowScope.AddItem(
|
|
|
currentDestination: NavDestination?,
|
|
|
navHostController: NavHostController
|
|
|
) {
|
|
|
+ var isClicked by remember { mutableStateOf(false) }
|
|
|
val route = currentRoute(navController = navHostController)
|
|
|
Log.d("currentRoute -> ", route.toString())
|
|
|
+
|
|
|
+ if (isClicked) {
|
|
|
+ if (currentDestination?.route != screen.route) {
|
|
|
+ Log.d("test_bottom_navbar",
|
|
|
+ "currentDestination -> " + currentDestination?.route
|
|
|
+ + "Screen Clicked -> " + screen.route
|
|
|
+ )
|
|
|
+
|
|
|
+ LaunchedEffect(Unit) {
|
|
|
+ navHostController.navigate(screen.route) {
|
|
|
+ popUpTo(
|
|
|
+ navHostController.graph
|
|
|
+ .findStartDestination().id) {
|
|
|
+ saveState = true
|
|
|
+ }
|
|
|
+ launchSingleTop = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ isClicked = false
|
|
|
+ }
|
|
|
BottomNavigationItem(
|
|
|
label = {
|
|
|
if (currentDestination?.route == screen.route) {
|
|
@@ -132,24 +157,10 @@ fun RowScope.AddItem(
|
|
|
it.route == screen.route
|
|
|
} == true,
|
|
|
onClick = {
|
|
|
+ isClicked = true
|
|
|
|
|
|
/* First time currentDestination is different when on BottomBar Item */
|
|
|
|
|
|
- if (currentDestination?.route != screen.route) {
|
|
|
- Log.d("test_bottom_navbar",
|
|
|
- "currentDestination -> " + currentDestination?.route
|
|
|
- + "Screen Clicked -> " + screen.route
|
|
|
- )
|
|
|
-
|
|
|
- navHostController.navigate(screen.route) {
|
|
|
- popUpTo(
|
|
|
- navHostController.graph
|
|
|
- .findStartDestination().id) {
|
|
|
- saveState = true
|
|
|
- }
|
|
|
- launchSingleTop = true
|
|
|
- }
|
|
|
- }
|
|
|
},
|
|
|
icon = {
|
|
|
if (currentDestination?.route == screen.route) {
|