feat(android): gate Focus tab behind focus_mode_enabled feature flag
This commit is contained in:
parent
39f8a70b6b
commit
b16a6614d4
@ -22,6 +22,9 @@ import com.chronomind.app.ui.screens.HistoryScreen
|
|||||||
import com.chronomind.app.ui.screens.SettingsScreen
|
import com.chronomind.app.ui.screens.SettingsScreen
|
||||||
import com.chronomind.app.ui.screens.TimelineScreen
|
import com.chronomind.app.ui.screens.TimelineScreen
|
||||||
import com.chronomind.app.ui.theme.CMColors
|
import com.chronomind.app.ui.theme.CMColors
|
||||||
|
import com.bytelyst.platform.BLFeatureFlagClient
|
||||||
|
import dagger.hilt.android.EntryPointAccessors
|
||||||
|
import androidx.compose.ui.platform.LocalContext
|
||||||
|
|
||||||
sealed class Screen(val route: String, val label: String, val icon: ImageVector) {
|
sealed class Screen(val route: String, val label: String, val icon: ImageVector) {
|
||||||
data object Timeline : Screen("timeline", "Timeline", Icons.Filled.Schedule)
|
data object Timeline : Screen("timeline", "Timeline", Icons.Filled.Schedule)
|
||||||
@ -32,9 +35,24 @@ sealed class Screen(val route: String, val label: String, val icon: ImageVector)
|
|||||||
|
|
||||||
val bottomNavItems = listOf(Screen.Timeline, Screen.Focus, Screen.History, Screen.Settings)
|
val bottomNavItems = listOf(Screen.Timeline, Screen.Focus, Screen.History, Screen.Settings)
|
||||||
|
|
||||||
|
@dagger.hilt.InstallIn(dagger.hilt.components.SingletonComponent::class)
|
||||||
|
@dagger.hilt.EntryPoint
|
||||||
|
interface NavFlagEntryPoint {
|
||||||
|
fun featureFlagClient(): BLFeatureFlagClient
|
||||||
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun ChronoMindNavHost() {
|
fun ChronoMindNavHost() {
|
||||||
val navController = rememberNavController()
|
val navController = rememberNavController()
|
||||||
|
val context = LocalContext.current
|
||||||
|
val entryPoint = EntryPointAccessors.fromApplication(context, NavFlagEntryPoint::class.java)
|
||||||
|
val flagClient = entryPoint.featureFlagClient()
|
||||||
|
val visibleNavItems = bottomNavItems.filter { screen ->
|
||||||
|
when (screen) {
|
||||||
|
is Screen.Focus -> flagClient.isEnabled("focus_mode_enabled")
|
||||||
|
else -> true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Scaffold(
|
Scaffold(
|
||||||
containerColor = CMColors.bg,
|
containerColor = CMColors.bg,
|
||||||
@ -46,7 +64,7 @@ fun ChronoMindNavHost() {
|
|||||||
val navBackStackEntry by navController.currentBackStackEntryAsState()
|
val navBackStackEntry by navController.currentBackStackEntryAsState()
|
||||||
val currentDestination = navBackStackEntry?.destination
|
val currentDestination = navBackStackEntry?.destination
|
||||||
|
|
||||||
bottomNavItems.forEach { screen ->
|
visibleNavItems.forEach { screen ->
|
||||||
val selected = currentDestination?.hierarchy?.any { it.route == screen.route } == true
|
val selected = currentDestination?.hierarchy?.any { it.route == screen.route } == true
|
||||||
NavigationBarItem(
|
NavigationBarItem(
|
||||||
icon = { Icon(screen.icon, contentDescription = screen.label) },
|
icon = { Icon(screen.icon, contentDescription = screen.label) },
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user