HomeScreenViewModel
ViewModel for the Home screen, responsible for fetching and exposing the signed-in subscriber's verified profile, basic user info, account holder status, and account balance from the MTN MOMO API.
All four calls run through a single ordered pipeline in loadHomeData rather than concurrently:
Verified profile (
userinfo, consent) — fetched first because it identifies the subscriber; its phone number becomes the account holder used by the next two calls.Basic user info — for the account holder derived from step 1.
Account holder status — for the same account holder.
Account balance — independent of the others.
Because the pipeline is a single coroutine, showProgressBar is set to true once at the start and back to false in a finally block only after every step has completed — the spinner never hides while any request is still in flight, and later steps can wait on earlier steps' data.
One-off UI events (snackbar messages) are emitted via snackBarStateFlow, a SharedFlow that the composable collects inside a LaunchedEffect.
The whole pipeline is guarded by a single check on CredentialStorage.getAccessToken: if no valid token is present the load is skipped and an error snackbar is shown. In normal operation the access token is provisioned by io.rekast.sdk.sample.views.main.MainViewModel on first launch and refreshed automatically by TokenAuthenticator on 401.
Constructors
Properties
Holds the fetched AccountBalance for the account; null until the API responds.
Holds the fetched AccountHolderStatus for the account; null until the API responds.
Holds the fetched BasicUserInfo for the authenticated user; null until the API responds.
Controls whether the circular progress indicator is shown instead of the screen content.
Flow of SnackBarComponentConfiguration events to be displayed as snack bars.
Holds the fetched consent-granted UserInfoWithConsent profile; null until the API responds.