-
-
Save saqib-github-commits/4e0844dda9a03568b4e571102de9ad71 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@OptIn(ExperimentalMaterial3Api::class) | |
@Composable | |
fun NetworkConnectivityScreen( | |
viewModel: NetworkConnectivityViewModel = viewModel(), | |
snackbarHostState: SnackbarHostState = SnackbarHostState() | |
) { | |
val networkStatus = viewModel.networkStatus.collectAsStateWithLifecycle() | |
if (networkStatus.value == NetworkStatus.Disconnected) { | |
LaunchedEffect(networkStatus) { | |
snackbarHostState.showSnackbar("you are offline") | |
} | |
} | |
Scaffold( | |
snackbarHost = { SnackbarHost(hostState = snackbarHostState) } | |
) { paddingValues -> | |
Box( | |
modifier = Modifier.fillMaxSize().padding(paddingValues), | |
contentAlignment = Alignment.Center | |
) { | |
Text(text = "Connectivity Service") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment