HomeScreenViewModel

class HomeScreenViewModel(defaultRepository: ERROR CLASS: Symbol not found for DefaultRepository, credentialStorage: CredentialStorage, settings: ERROR CLASS: Symbol not found for Settings, dispatchers: DispatcherProvider, sampleConfig: SampleConfig) : BaseScreenViewModel

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:

  1. Verified profile (userinfo, consent) — fetched first because it identifies the subscriber; its phone number becomes the account holder used by the next two calls.

  2. Basic user info — for the account holder derived from step 1.

  3. Account holder status — for the same account holder.

  4. 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

Link copied to clipboard
constructor(defaultRepository: ERROR CLASS: Symbol not found for DefaultRepository, credentialStorage: CredentialStorage, settings: ERROR CLASS: Symbol not found for Settings, dispatchers: DispatcherProvider, sampleConfig: SampleConfig)

Properties

Link copied to clipboard
var accountBalance: ERROR CLASS: Symbol not found for MutableLiveData<ERROR CLASS: Symbol not found for AccountBalance?>

Holds the fetched AccountBalance for the account; null until the API responds.

Link copied to clipboard
var accountHolderStatus: ERROR CLASS: Symbol not found for MutableLiveData<ERROR CLASS: Symbol not found for AccountHolderStatus?>

Holds the fetched AccountHolderStatus for the account; null until the API responds.

Link copied to clipboard
var basicUserInfo: ERROR CLASS: Symbol not found for MutableLiveData<ERROR CLASS: Symbol not found for BasicUserInfo?>

Holds the fetched BasicUserInfo for the authenticated user; null until the API responds.

Link copied to clipboard
val showProgressBar: ERROR CLASS: Unresolved name: MutableLiveData

Controls whether the circular progress indicator is shown instead of the screen content.

Link copied to clipboard
val snackBarStateFlow: ERROR CLASS: Symbol not found for SharedFlow<io/rekast/sdk/sample/utils/SnackBarComponentConfiguration>

Flow of SnackBarComponentConfiguration events to be displayed as snack bars.

Link copied to clipboard
var userInfoWithConsent: ERROR CLASS: Symbol not found for MutableLiveData<ERROR CLASS: Symbol not found for UserInfoWithConsent?>

Holds the fetched consent-granted UserInfoWithConsent profile; null until the API responds.

Functions

Link copied to clipboard

Loads all Home screen data in a single ordered pipeline. Shows the progress bar for the whole batch, fetches each resource in sequence — so a step can wait on the previous step's data — and hides the progress bar only once every step has finished (success or failure).