-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
android/app/src/main/java/by/eapp/musicroom/screens/test/TestScreen.kt
This file contains 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
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) | ||
} |
30 changes: 30 additions & 0 deletions
30
android/app/src/main/java/by/eapp/musicroom/screens/test/TestViewModel.kt
This file contains 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
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() } | ||
} | ||
} |