Skip to content

Commit

Permalink
refactor(mapview): Rename MapViewModel to MapViewViewModel and ad…
Browse files Browse the repository at this point in the history
…just empty list logic

The `MapViewModel` class has been renamed to `MapViewViewModel`. Also, the condition for returning an empty list in `MapPlaceRepo` has been changed from `random > 5` to `random > 2`.
  • Loading branch information
ImaginativeShohag committed Dec 27, 2024
1 parent 7664af4 commit e057918
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ object MapPlaceRepo {
// Note: It randomly send empty list to demonstrate empty view.
val random = Random.nextInt(10)

if (random > 5) {
if (random > 2) {
return places
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ import org.imaginativeworld.whynotcompose.ui.screens.tutorial.selectimageandcrop
import org.imaginativeworld.whynotcompose.ui.screens.ui.index.UiIndexScreen
import org.imaginativeworld.whynotcompose.ui.screens.ui.mapview.MapScreen
import org.imaginativeworld.whynotcompose.ui.screens.ui.mapview.MapViewDetailsScreen
import org.imaginativeworld.whynotcompose.ui.screens.ui.mapview.MapViewModel
import org.imaginativeworld.whynotcompose.ui.screens.ui.mapview.MapViewViewModel
import org.imaginativeworld.whynotcompose.ui.screens.ui.otpcodeverify.OtpCodeVerifyScreen
import org.imaginativeworld.whynotcompose.ui.screens.ui.otpcodeverify.OtpCodeVerifyViewModel
import org.imaginativeworld.whynotcompose.ui.screens.ui.pager.UiPagerScreen
Expand Down Expand Up @@ -692,7 +692,7 @@ private fun NavGraphBuilder.addUiScreens(
}

composable(UIsScreen.UiMapView.route) {
val viewModel: MapViewModel = hiltViewModel()
val viewModel: MapViewViewModel = hiltViewModel()

MapScreen(
viewModel = viewModel,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ import timber.log.Timber
@Suppress("ktlint:compose:modifier-missing-check")
@Composable
fun MapScreen(
viewModel: MapViewModel,
viewModel: MapViewViewModel,
goBack: () -> Unit,
gotoDetailsScreen: (MapPlace) -> Unit
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ import org.imaginativeworld.whynotcompose.repositories.MapPlaceRepo
import timber.log.Timber

@HiltViewModel
class MapViewModel @Inject constructor() : ViewModel() {
class MapViewViewModel @Inject constructor() : ViewModel() {
private val eventShowLoading = MutableStateFlow(false)
private val eventShowEmpty = MutableStateFlow(false)
private val eventShowMessage = MutableStateFlow<Event<String>?>(null)
Expand Down Expand Up @@ -113,7 +113,7 @@ class MapViewModel @Inject constructor() : ViewModel() {

previousResult = places

this@MapViewModel.places.value = places
this@MapViewViewModel.places.value = places

eventShowEmpty.value = places.isEmpty()

Expand Down

0 comments on commit e057918

Please sign in to comment.