Skip to content

Commit

Permalink
Merge pull request #64 from PetJournal/feature/request-api-list-races…
Browse files Browse the repository at this point in the history
…-and-sizes

Requisição das listas de raça e porte
  • Loading branch information
JorgeTranin authored Jun 20, 2024
2 parents 26ba5ab + 93e5147 commit ba7f4c5
Show file tree
Hide file tree
Showing 33 changed files with 1,055 additions and 309 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import com.soujunior.domain.use_case.auth.SignUpUseCase
import com.soujunior.domain.use_case.guardian.GetGuardianNameUseCase
import com.soujunior.domain.use_case.guardian.GetPetRegistrationWentLive
import com.soujunior.domain.use_case.guardian.SetPetRegistrationWentLive
import com.soujunior.domain.use_case.pet.GetListPetRacesUseCase
import com.soujunior.domain.use_case.pet.GetListPetSizesUseCase
import com.soujunior.domain.use_case.pet.GetPetInformationUseCase
import com.soujunior.domain.use_case.pet.SavePetInformationUseCase
import com.soujunior.domain.use_case.pet.UpdatePetInformationUseCase
Expand Down Expand Up @@ -101,6 +103,8 @@ val mainModule = module {
factory { GetPetInformationUseCase(get()) }
factory { UpdatePetInformationUseCase(get()) }
factory { SavedStateHandle() }
factory { GetListPetSizesUseCase(get()) }
factory { GetListPetRacesUseCase(get()) }

single<AuthService> { get<Retrofit>().create(AuthService::class.java) }
single<GuardianService> { get<Retrofit>().create(GuardianService::class.java) }
Expand Down Expand Up @@ -151,5 +155,5 @@ val mainModule = module {
}

viewModel<BirthDateViewModel> { BirthDateViewModelImpl(get(), get(), get()) }
viewModel<ViewModelRaceSize> { ViewModelRaceSizeImpl(get(), get(), get()) }
viewModel<ViewModelRaceSize> { ViewModelRaceSizeImpl(get(), get(), get(), get(), get()) }
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.draw.drawBehind
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.focus.onFocusChanged
import androidx.compose.ui.focus.onFocusEvent
import androidx.compose.ui.geometry.CornerRadius
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.PathEffect
Expand All @@ -46,6 +44,7 @@ import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.soujunior.domain.model.request.PetRaceItemModel

@Composable
fun AutoCompleteDropDown(
Expand All @@ -55,7 +54,7 @@ fun AutoCompleteDropDown(
textValue: String,
isError: Boolean = false,
textError: List<String>? = null,
dropdownItems: List<String>? = null,
dropdownItems: List<PetRaceItemModel>? = null,
onEvent: (String) -> Unit,
onDropdownItemSelected: (String) -> Unit = {},
onFocusChange: (Boolean) -> Unit = {}
Expand Down Expand Up @@ -200,30 +199,29 @@ fun AutoCompleteDropDown(

if (textValue.isNotEmpty()) {
dropdownItems?.filter {
it.lowercase()
.contains(textValue.lowercase()) || it.lowercase()
it.name.lowercase()
.contains(textValue.lowercase()) || it.name.lowercase()
.contains("Outro")
}?.let { itemList ->
items(
itemList
.sorted()
) { itemFilter ->
CategoryItems(true, title = itemFilter) {
CategoryItems(true, title = itemFilter.name) {
expanded = false
onEvent(itemFilter)
onDropdownItemSelected(itemFilter)
onEvent(itemFilter.name)
onDropdownItemSelected(itemFilter.name)
}
}
}
} else {
if (dropdownItems != null) {
items(
dropdownItems.sorted()
dropdownItems
) { itemFilter ->
CategoryItems(false, title = itemFilter) {
CategoryItems(false, title = itemFilter.name) {
expanded = false
onEvent(itemFilter)
onDropdownItemSelected(itemFilter)
onEvent(itemFilter.name)
onDropdownItemSelected(itemFilter.name)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import androidx.compose.ui.graphics.drawscope.Stroke
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.soujunior.domain.model.request.PetSizeItemModel

@Composable
fun DropDown(
Expand All @@ -45,7 +46,7 @@ fun DropDown(
titleText: String = "Title",
isError: Boolean = false,
textError: List<String>? = null,
dropdownItems: List<String>? = null,
dropdownItems: List<PetSizeItemModel>? = null,
onEvent: (String) -> Unit,
textValue: String
) {
Expand Down Expand Up @@ -136,11 +137,11 @@ fun DropDown(
DropdownMenuItem(
onClick = {
isDropdownExpanded = false
onEvent(item)
onEvent(item.name)
}

) {
Text(text = item)
Text(text = item.name)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.soujunior.petjournal.ui.screens_app.screens_pets.petRaceAndSizeScreen

import com.soujunior.domain.model.request.PetRaceItemModel
import com.soujunior.domain.model.request.PetSizeItemModel

data class RaceSizeFormState(
val race: String = "",
val size: String = "",
Expand All @@ -11,7 +14,7 @@ data class RaceSizeFormState(
val idPetInformation : Long? = null,
val name: String = "",
val gender: String = "",
val listRace: List<String> = emptyList(),
val listSizes: List<String> = emptyList()
val listRace: List<PetRaceItemModel> = emptyList(),
val listSizes: List<PetSizeItemModel> = emptyList()
)

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package com.soujunior.petjournal.ui.screens_app.screens_pets.petRaceAndSizeScree

import androidx.lifecycle.ViewModel
import com.soujunior.domain.model.PetInformationModel
import com.soujunior.domain.model.request.PetRaceItemModel
import com.soujunior.domain.model.request.PetSizeItemModel
import com.soujunior.petjournal.ui.states.TaskState
import com.soujunior.petjournal.ui.util.ValidationEvent
import kotlinx.coroutines.channels.Channel
Expand All @@ -20,6 +22,8 @@ abstract class ViewModelRaceSize : ViewModel() {
get() = validationEventChannel.receiveAsFlow()

abstract fun success(petInformationModel: PetInformationModel)
abstract fun successGetPetSizes(listPetSizes: List<PetSizeItemModel>)
abstract fun successGetPetRaces(listPetRaces: List<PetRaceItemModel>)
abstract fun failed(exception: Throwable?)
abstract fun onEvent(event: RaceSizeFormEvent)
abstract fun enableButton(): Boolean
Expand All @@ -35,5 +39,6 @@ abstract class ViewModelRaceSize : ViewModel() {
abstract fun updatePetInformation()

abstract fun successPetUpdate(unit: Unit)
abstract fun getListRacePets()
abstract suspend fun requestGetListSizes()
abstract suspend fun requestGetListRaces()
}
Loading

0 comments on commit ba7f4c5

Please sign in to comment.