@@ -15,13 +15,13 @@ import androidx.browser.auth.AuthTabIntent
1515import androidx.compose.foundation.background
1616import androidx.compose.runtime.Composable
1717import androidx.compose.runtime.getValue
18- import androidx.compose.runtime.remember
1918import androidx.compose.ui.Modifier
2019import androidx.core.app.ActivityCompat
2120import androidx.core.os.LocaleListCompat
2221import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
2322import androidx.lifecycle.compose.collectAsStateWithLifecycle
2423import androidx.navigation.NavController
24+ import androidx.navigation.NavHostController
2525import androidx.navigation.compose.NavHost
2626import com.bitwarden.annotation.OmitFromCoverage
2727import com.bitwarden.ui.platform.base.util.EventsEffect
@@ -126,35 +126,13 @@ class MainActivity : AppCompatActivity() {
126126 SetupEventsEffect (navController = navController)
127127 val state by mainViewModel.stateFlow.collectAsStateWithLifecycle()
128128 updateScreenCapture(isScreenCaptureAllowed = state.isScreenCaptureAllowed)
129- LocalManagerProvider (
130- featureFlagsState = state.featureFlagsState ,
129+ MainActivityContent (
130+ state = state,
131131 authTabLaunchers = authTabLaunchers,
132- ) {
133- ObserveScreenDataEffect (
134- onDataUpdate = remember(mainViewModel) {
135- { mainViewModel.trySendAction(MainAction .ResumeScreenDataReceived (it)) }
136- },
137- )
138- BitwardenTheme (
139- theme = state.theme,
140- dynamicColor = state.isDynamicColorsEnabled,
141- ) {
142- NavHost (
143- navController = navController,
144- startDestination = OverlayNavRoute ,
145- modifier = Modifier
146- .background(color = BitwardenTheme .colorScheme.background.primary),
147- ) {
148- // The OverlayNav and Debug destinations are the only UIs that can be
149- // displayed here, everything else should be inside the OverlayNav.
150- overlayNavDestination { shouldShowSplashScreen = false }
151- debugMenuDestination(
152- onNavigateBack = { navController.popBackStack() },
153- onSplashScreenRemoved = { shouldShowSplashScreen = false },
154- )
155- }
156- }
157- }
132+ navController = navController,
133+ sendAction = mainViewModel::trySendAction,
134+ onSplashScreenRemoved = { shouldShowSplashScreen = false },
135+ )
158136 }
159137 }
160138
@@ -278,3 +256,38 @@ class MainActivity : AppCompatActivity() {
278256 }
279257 }
280258}
259+
260+ @OmitFromCoverage
261+ @Composable
262+ private fun MainActivityContent (
263+ state : MainState ,
264+ authTabLaunchers : AuthTabLaunchers ,
265+ navController : NavHostController ,
266+ sendAction : (MainAction ) -> Unit ,
267+ onSplashScreenRemoved : () -> Unit ,
268+ ) {
269+ LocalManagerProvider (
270+ featureFlagsState = state.featureFlagsState,
271+ authTabLaunchers = authTabLaunchers,
272+ ) {
273+ ObserveScreenDataEffect { sendAction(MainAction .ResumeScreenDataReceived (it)) }
274+ BitwardenTheme (
275+ theme = state.theme,
276+ dynamicColor = state.isDynamicColorsEnabled,
277+ ) {
278+ NavHost (
279+ navController = navController,
280+ startDestination = OverlayNavRoute ,
281+ modifier = Modifier .background(BitwardenTheme .colorScheme.background.primary),
282+ ) {
283+ // The OverlayNav and Debug destinations are the only UIs that can be
284+ // displayed here, everything else should be inside the OverlayNav.
285+ overlayNavDestination(onSplashScreenRemoved = onSplashScreenRemoved)
286+ debugMenuDestination(
287+ onNavigateBack = { navController.popBackStack() },
288+ onSplashScreenRemoved = onSplashScreenRemoved,
289+ )
290+ }
291+ }
292+ }
293+ }
0 commit comments