This file contains hidden or 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
class ProductViewModel : ViewModel() { | |
val products = MutableLiveData<List<Product>>() | |
val loading = MutableLiveData<Boolean>() | |
val error = MutableLiveData<String>() | |
fun loadProducts() { | |
loading.value = true | |
viewModelScope.launch { | |
try { | |
val response = RetrofitClient.api.getProducts() |
This file contains hidden or 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
@Composable | |
fun UserListScreen(users: List<User>) { | |
var searchQuery by remember { mutableStateOf("") } | |
Column { | |
TextField( | |
value = searchQuery, | |
onValueChange = { searchQuery = it }, | |
placeholder = { Text("Search users") } | |
) |