This file contains hidden or 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
| @Composable | |
| fun UserProfileScreen(viewModel: UserProfileViewModel) { | |
| val lifecycleOwner = LocalLifecycleOwner.current | |
| LaunchedEffect(Unit) { | |
| viewModel.events.flowWithLifecycle(lifecycleOwner.lifecycle) | |
| .onEach { event -> | |
| when (event) { | |
| UIEvent.NavigateToLogin -> { | |
| // This might never execute if config change happens |
This file contains hidden or 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
| // This sequence can lose events during configuration changes | |
| fun deleteAccount() { | |
| viewModelScope.launch { | |
| try { | |
| userRepository.deleteAccount() | |
| // 1. Event is sent | |
| _events.send(UIEvent.ShowToast("Account deleted successfully")) | |
| // 2. UI receives and schedules event | |
| // 3. Configuration change cancels collection | |
| // 4. Event is lost - user never sees confirmation! |
This file contains hidden or 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
| @Composable | |
| fun UserProfileScreen( | |
| viewModel: UserProfileViewModel = hiltViewModel() | |
| ) { | |
| val context = LocalContext.current | |
| val navController = LocalNavController.current | |
| // Collecting events from Channel | |
| val lifecycleOwner = LocalLifecycleOwner.current |
This file contains hidden or 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
| sealed class UIEvent { | |
| data class ShowToast(val message: String) : UIEvent() | |
| data class ShowError(val error: String) : UIEvent() | |
| data object NavigateToLogin : UIEvent() | |
| } | |
| class UserProfileViewModel( | |
| private val userRepository: UserRepository | |
| ) : ViewModel() { | |
This file contains hidden or 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
| package dev.euryperez.loginsample | |
| import androidx.compose.material.MaterialTheme | |
| import androidx.compose.material.Text | |
| import androidx.compose.runtime.Composable | |
| import org.jetbrains.compose.ui.tooling.preview.Preview | |
| @Composable | |
| @Preview | |
| fun App() { |
This file contains hidden or 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
| implementation(project.dependencies.platform(libs.firebase.bom)) | |
| implementation(libs.firebase.crashlyticsKtx) |
This file contains hidden or 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
| alias(libs.plugins.google.playServices) | |
| alias(libs.plugins.firebase.crashlytics) |
This file contains hidden or 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
| cocoapods { | |
| summary = "Some description for the Shared Module" | |
| homepage = "Link to the Shared Module homepage" | |
| version = "1.0" | |
| ios.deploymentTarget = "16.0" | |
| podfile = project.file("../iosApp/Podfile") | |
| framework { | |
| baseName = "composeApp" | |
| isStatic = true | |
| } |
This file contains hidden or 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
| sourceSets { | |
| commonMain.dependencies { | |
| implementation(compose.runtime) | |
| implementation(compose.foundation) | |
| implementation(compose.material) | |
| implementation(compose.ui) | |
| implementation(compose.components.resources) | |
| implementation(compose.components.uiToolingPreview) | |
| } | |
| commonTest.dependencies { |
This file contains hidden or 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
| plugins { | |
| alias(libs.plugins.kotlinMultiplatform) | |
| alias(libs.plugins.kotlinCocoapods) | |
| alias(libs.plugins.androidLibrary) | |
| alias(libs.plugins.jetbrainsCompose) | |
| } | |
| [...] |