Skip to content

Commit

Permalink
Added some changes in clean code impl
Browse files Browse the repository at this point in the history
  • Loading branch information
myofficework000 committed May 7, 2024
1 parent f32a5ec commit cf304c4
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.example.jetpack_compose_all_in_one.android_architectures.clean_code.data.dto

data class DogEntityCleanCode(
val message: String,
val dogUrl: String,
val status: String
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import com.example.jetpack_compose_all_in_one.android_architectures.clean_code.d

object DogMapperCleanCode: Mapper<DogEntityCleanCode, DogResponseCleanCode> {
override fun mapFromEntity(type: DogEntityCleanCode) = DogResponseCleanCode(
message = type.message,
message = type.dogUrl,
status = type.status
)

override fun mapToEntity(type: DogResponseCleanCode) = DogEntityCleanCode(
message = type.message,
dogUrl = type.message,
status = type.status
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.example.jetpack_compose_all_in_one.android_architectures.clean_code.
import com.example.jetpack_compose_all_in_one.android_architectures.clean_code.domain.repositories.DogRepositoryCleanCode
import javax.inject.Inject

class GetDogUsecase @Inject constructor(
class GetDogUseCase @Inject constructor(
private val repo: DogRepositoryCleanCode
) {
suspend operator fun invoke() = repo.getRandomDog()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.size
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
Expand Down Expand Up @@ -50,7 +49,7 @@ fun DogApiMainPage(
}

GlideImage(
model = it.message,
model = it.dogUrl,
contentDescription = "woof",
modifier = Modifier.size(400.dp)
) { it2 ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,15 @@ import androidx.compose.runtime.setValue
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.example.jetpack_compose_all_in_one.android_architectures.clean_code.data.dto.DogEntityCleanCode
import com.example.jetpack_compose_all_in_one.android_architectures.clean_code.data.dto.DogResponseCleanCode
import com.example.jetpack_compose_all_in_one.android_architectures.clean_code.domain.repositories.DogRepositoryCleanCode
import com.example.jetpack_compose_all_in_one.android_architectures.clean_code.domain.usecases.GetDogUsecase
import com.example.jetpack_compose_all_in_one.android_architectures.clean_code.domain.usecases.GetDogUseCase
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import javax.inject.Inject

@HiltViewModel
class DogViewModelCleanCode @Inject constructor(
private val getRandomDogUsecase: GetDogUsecase
private val getRandomDogUseCase: GetDogUseCase
): ViewModel() {
init { getRandomDog() }

Expand All @@ -25,7 +23,7 @@ class DogViewModelCleanCode @Inject constructor(

fun getRandomDog() {
viewModelScope.launch(Dispatchers.IO) {
dogResponse = getRandomDogUsecase()
dogResponse = getRandomDogUseCase()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ import com.example.jetpack_compose_all_in_one.utils.showLongToast
import com.example.jetpack_compose_all_in_one.R

@Composable
fun RandomDogView(
) {
fun RandomDogView() {

val viewModel: RandomDogViewModel = hiltViewModel()
val state by viewModel.viewState.collectAsState()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ private val DarkColorScheme = darkColorScheme(
secondary = PurpleGrey80,
tertiary = Pink80,
surface = LightBlue,
onSurface = Color.White
onSurface = Color.White,
onSecondary = Color.Gray
)

private val LightColorScheme = lightColorScheme(
Expand All @@ -33,7 +34,8 @@ private val LightColorScheme = lightColorScheme(
secondary = PurpleGrey40,
tertiary = Pink40,
surface = Color(0xFF154C79),
onSurface = Color.White
onSurface = Color.White,
onSecondary = Color.White

/* Other default colors to override
background = Color(0xFFFFFBFE),
Expand Down

0 comments on commit cf304c4

Please sign in to comment.