Skip to content

Commit

Permalink
get selected product in SelectedProduct view and show it
Browse files Browse the repository at this point in the history
  • Loading branch information
MiguelRom3ro committed Apr 4, 2024
1 parent 1d54f7f commit 081a3d2
Show file tree
Hide file tree
Showing 15 changed files with 57 additions and 38 deletions.

This file was deleted.

10 changes: 0 additions & 10 deletions app/src/main/java/com/miguelrr/capsshop/domain/GetCapIdUseCase.kt

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.miguelrr.capsshop.domain.usecases

class AddItemSCUseCase {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.miguelrr.capsshop.domain.usecases

import com.miguelrr.capsshop.data.CapRepository
import com.miguelrr.capsshop.data.database.entity.toDatabase
import com.miguelrr.capsshop.domain.model.Cap
import javax.inject.Inject

class GetCapIdUseCase @Inject constructor(
private val capRepository: CapRepository
){

suspend operator fun invoke(id : Int) : Cap{
return capRepository.getCapByID(id)
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.miguelrr.capsshop.domain.usecases

class LogInUseCase {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.miguelrr.capsshop.domain.usecases

class LogOutUseCase {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.miguelrr.capsshop.domain.usecases

class RemoveItemSCUseCase {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.miguelrr.capsshop.domain.usecases

class SignUpUseCase {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.miguelrr.capsshop.domain.usecases

class UpdateItemSCUseCase {
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,24 @@ package com.miguelrr.capsshop.ui.selectedproduct
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.miguelrr.capsshop.domain.model.Cap
import com.miguelrr.capsshop.domain.usecases.GetCapIdUseCase
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.launch
import javax.inject.Inject

class SelectedProductViewModel : ViewModel() {
@HiltViewModel
class SelectedProductViewModel @Inject constructor(
private val getCapIdUseCase: GetCapIdUseCase
): ViewModel(){

private val _text = MutableLiveData<String>().apply {
value = "This is dashboard Fragment"
private var _cap = MutableLiveData<Cap>()
val cap : LiveData<Cap> get() = _cap

fun onCreate(idCap : Int){
viewModelScope.launch {
_cap.postValue(getCapIdUseCase(idCap))
}
}
val text: LiveData<String> = _text
}

0 comments on commit 081a3d2

Please sign in to comment.