Skip to content

Commit

Permalink
#3 provide test resources
Browse files Browse the repository at this point in the history
  • Loading branch information
nastix123 committed Jul 14, 2024
1 parent 3746552 commit 79d7008
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package by.eapp.musicroom.screens.test

import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp

@Composable
fun TestScreen(
vm: TestViewModel
) {
val state by vm.state.collectAsState()

Text(text = state, fontSize = 45.sp, color = Color.Black)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package by.eapp.musicroom.screens.test

import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import by.eapp.musicroom.domain.repo.StatusRepository
import by.eapp.musicroom.network.RegistrationService
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.launch
import javax.inject.Inject

@HiltViewModel
class TestViewModel @Inject constructor(
private val statusRepository: StatusRepository
): ViewModel() {

private val _state = MutableStateFlow("")
val state: StateFlow<String> = _state.asStateFlow()

init {
getStatus()
}
private fun getStatus() {
viewModelScope.launch() {
_state.value = statusRepository.getStatus().toString() }
}
}

0 comments on commit 79d7008

Please sign in to comment.