Skip to content

Commit

Permalink
update profile (api, impl, ui)
Browse files Browse the repository at this point in the history
show global success message after account change
  • Loading branch information
AkesiSeli committed Feb 9, 2025
1 parent 13b5e7e commit 4cfee0c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,7 @@ interface ProfileMviModel :
val hideNavigationBarWhileScrolling: Boolean = true,
)

sealed interface Effect
sealed interface Effect {
data object AccountChangeSuccess : Effect
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import androidx.compose.material3.rememberModalBottomSheetState
import androidx.compose.material3.rememberTopAppBarState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
Expand All @@ -47,9 +48,12 @@ import com.livefast.eattrash.raccoonforfriendica.core.commonui.components.Progre
import com.livefast.eattrash.raccoonforfriendica.core.commonui.content.CustomConfirmDialog
import com.livefast.eattrash.raccoonforfriendica.core.l10n.LocalStrings
import com.livefast.eattrash.raccoonforfriendica.core.navigation.di.getDrawerCoordinator
import com.livefast.eattrash.raccoonforfriendica.core.navigation.di.getNavigationCoordinator
import com.livefast.eattrash.raccoonforfriendica.domain.identity.data.AccountModel
import com.livefast.eattrash.raccoonforfriendica.feature.profile.loginintro.LoginIntroScreen
import com.livefast.eattrash.raccoonforfriendica.feature.profile.myaccount.MyAccountScreen
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launch

class ProfileScreen : Screen {
Expand All @@ -62,10 +66,22 @@ class ProfileScreen : Screen {
val scrollBehavior = TopAppBarDefaults.enterAlwaysScrollBehavior(topAppBarState)
val scope = rememberCoroutineScope()
val drawerCoordinator = remember { getDrawerCoordinator() }
val navigationCoordinator = remember { getNavigationCoordinator() }
val successMessage = LocalStrings.current.messageSuccess
var confirmLogoutDialogOpened by remember { mutableStateOf(false) }
var manageAccountsDialogOpened by remember { mutableStateOf(false) }
var confirmDeleteAccount by remember { mutableStateOf<AccountModel?>(null) }

LaunchedEffect(model) {
model.effects
.onEach { event ->
when (event) {
ProfileMviModel.Effect.AccountChangeSuccess ->
navigationCoordinator.showGlobalMessage(successMessage)
}
}.launchIn(this)
}

CompositionLocalProvider(
LocalProfileTopAppBarStateWrapper provides
object : ProfileTopAppBarStateWrapper {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ class ProfileViewModel(
it.copy(loading = true)
}
switchAccountUseCase(account)
emitEffect(ProfileMviModel.Effect.AccountChangeSuccess)
}
}

Expand Down

0 comments on commit 4cfee0c

Please sign in to comment.