Skip to content

Commit

Permalink
refactored and fixed bugs.
Browse files Browse the repository at this point in the history
  • Loading branch information
2307vivek committed Aug 1, 2021
1 parent 80bc74c commit a98b676
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@
package com.example.androiddevchallenge.model

data class DogBreed(
val name: String
val name: String = "Affenpinscher"
)
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ fun AdoptyNavigation(splashScreenVisibleCondition: (SplashScreen.KeepOnScreenCon
HomeScreen(
viewModel = viewModel,
navController = navController,
navBackStackEntry = it,
)
}
composable(Screen.DogDetail.route) {
Expand All @@ -94,11 +93,6 @@ fun AdoptyNavigation(splashScreenVisibleCondition: (SplashScreen.KeepOnScreenCon
}
}

@Composable
fun CheckData() {
val context = LocalContext.current
}

@Composable
fun OfflineDialog(onRetry: () -> Unit) {
AlertDialog(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import androidx.navigation.NavBackStackEntry
import androidx.navigation.NavController
import coil.compose.rememberImagePainter
import com.example.androiddevchallenge.R
Expand All @@ -77,7 +76,6 @@ import com.example.androiddevchallenge.ui.screen.home.specialNeeds.DogSpecialNee
fun HomeScreen(
viewModel: HomeViewModel,
navController: NavController,
navBackStackEntry: NavBackStackEntry
) {
val viewState by viewModel.state.collectAsState()
val dogsSpecialNeedLazyListState = rememberLazyListState()
Expand All @@ -95,7 +93,6 @@ fun HomeScreen(
petState = viewState.petState,
specialNeedsDogsState = viewState.specialNeedsDogState,
lazyListState = dogsSpecialNeedLazyListState,
navBackStackEntry = navBackStackEntry,
onDogSelected = {
viewModel.onDogSelected(it)
navController.navigate(Screen.DogDetail.route)
Expand All @@ -115,7 +112,6 @@ fun DogContent(
specialNeedsDogsState: PetState<PetListResponse>,
lazyListState: LazyListState,
onDogSelected: (Pet) -> Unit,
navBackStackEntry: NavBackStackEntry
) {
if (dogBreeds.isNotEmpty() && selectedBreed != null) {
Column(modifier = modifier) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class HomeViewModel @Inject constructor(
private val petRepository: PetRepository
) : ViewModel() {

private val _selectedBreed = MutableStateFlow<DogBreed?>(null)
private val _selectedBreed = MutableStateFlow<DogBreed?>(DogBreed())
private val _petState = MutableStateFlow<PetState<PetListResponse>>(PetState())
private val _state = MutableStateFlow(HomeScreenViewState())
private val _specialNeedsDogsState =
Expand All @@ -59,7 +59,7 @@ class HomeViewModel @Inject constructor(
get() = _selectedDog

init {
onBreedSelected(DogBreed("Affenpinscher"))
onBreedSelected(DogBreed())
getSpecialNeedsDogs()

viewModelScope.launch {
Expand Down Expand Up @@ -112,6 +112,6 @@ class HomeViewModel @Inject constructor(
val petState: PetState<PetListResponse> = PetState(),
val specialNeedsDogState: PetState<PetListResponse> = PetState(),
val dogBreeds: List<DogBreed> = emptyList(),
val selectedBreed: DogBreed? = null
val selectedBreed: DogBreed? = DogBreed()
)
}

0 comments on commit a98b676

Please sign in to comment.