Skip to content

Commit

Permalink
[chore] #29 ktlint에 맞게 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
t1nm1ksun committed May 23, 2024
1 parent 1dfe868 commit 13b15b7
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,9 @@ import org.sopt.kream.util.base.BaseResponse

interface ProductRemoteDataSource {
suspend fun getSearchProduct(findName: String): BaseResponse<ResponseSearchProductDto>
suspend fun deleteScrap(memberId: Int, productId: Int): BaseResponse<Unit>

suspend fun deleteScrap(
memberId: Int,
productId: Int,
): BaseResponse<Unit>
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,9 @@ class ProductRemoteDataSourceImpl : ProductRemoteDataSource {
private val productService = ServicePool.productService

override suspend fun getSearchProduct(findName: String): BaseResponse<ResponseSearchProductDto> = productService.getSearchProduct(findName = findName)
override suspend fun deleteScrap(memberId: Int, productId: Int): BaseResponse<Unit> = productService.deleteScrap(memberId, RequestDeleteScrapDto(productId))

override suspend fun deleteScrap(
memberId: Int,
productId: Int,
): BaseResponse<Unit> = productService.deleteScrap(memberId, RequestDeleteScrapDto(productId))
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ class ProductRepositoryImpl(
productRemoteDataSource.getSearchProduct(findName = findName).data.toSearchProductModel()
}

override suspend fun deleteScrap(memberId: Int, productId: Int): Result<Unit> {
override suspend fun deleteScrap(
memberId: Int,
productId: Int,
): Result<Unit> {
return runCatching {
productRemoteDataSource.deleteScrap(memberId, productId)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import org.sopt.kream.data.model.response.ResponseReleaseProductDto
import org.sopt.kream.data.model.response.ResponseSearchProductDto
import org.sopt.kream.util.base.BaseResponse
import retrofit2.http.Body
import retrofit2.http.DELETE
import retrofit2.http.GET
import retrofit2.http.HTTP
import retrofit2.http.Header
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,9 @@ import org.sopt.kream.domain.model.SearchProductModel

interface ProductRepository {
suspend fun getSearchProduct(findName: String): Result<SearchProductModel>
suspend fun deleteScrap(memberId: Int, productId: Int): Result<Unit>

suspend fun deleteScrap(
memberId: Int,
productId: Int,
): Result<Unit>
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import org.sopt.kream.data.datasourceimpl.DummyRemoteDataSourceImpl
import org.sopt.kream.data.datasourceimpl.ProductRemoteDataSourceImpl
import org.sopt.kream.data.repository.DummyRepositoryImpl
import org.sopt.kream.data.repository.ProductRepositoryImpl
import org.sopt.kream.domain.repository.ProductRepository
import org.sopt.kream.presentation.ui.dummy.DummyViewModel
import org.sopt.kream.presentation.ui.main.home.release.ReleaseProductViewModel
import org.sopt.kream.presentation.ui.search.SearchViewModel
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.sopt.kream.presentation.ui.main.home.release

import android.os.Bundle
import android.util.Log
import android.view.View
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
Expand Down Expand Up @@ -68,7 +67,7 @@ import java.util.Calendar
import java.util.concurrent.TimeUnit

class ReleaseFragment : BindingFragment<FragmentReleaseBinding>({ FragmentReleaseBinding.inflate(it) }) {
private val viewModel : ReleaseProductViewModel by viewModels { ViewModelFactory() }
private val viewModel: ReleaseProductViewModel by viewModels { ViewModelFactory() }

override fun onViewCreated(
view: View,
Expand All @@ -87,23 +86,19 @@ class ReleaseFragment : BindingFragment<FragmentReleaseBinding>({ FragmentReleas
else -> Unit
}
}.launchIn(viewLifecycleOwner.lifecycleScope)




}
}

@Composable
fun UiStateISSuccess(
viewModel: ReleaseProductViewModel
viewModel: ReleaseProductViewModel,
) {
val advertisement by remember { mutableStateOf(viewModel.advertisements) }
Box(
modifier =
Modifier
.fillMaxSize()
.verticalScroll(rememberScrollState()),
Modifier
.fillMaxSize()
.verticalScroll(rememberScrollState()),
) {
Column(
modifier =
Expand Down Expand Up @@ -299,7 +294,11 @@ fun CustomMidNaviBar() {
}

@Composable
fun ShoesItem(releaseProductResponseDto: ResponseReleaseProductDto.ReleaseProductResponseDto,productIndex:Int,viewModel: ReleaseProductViewModel) {
fun ShoesItem(
releaseProductResponseDto: ResponseReleaseProductDto.ReleaseProductResponseDto,
productIndex: Int,
viewModel: ReleaseProductViewModel,
) {
var isIconChanged by remember { mutableStateOf(releaseProductResponseDto.isScrap) }
val iconResource =
if (isIconChanged) {
Expand Down Expand Up @@ -352,10 +351,10 @@ fun ShoesItem(releaseProductResponseDto: ResponseReleaseProductDto.ReleaseProduc
modifier =
Modifier.clickable {
isIconChanged = !isIconChanged
if (releaseProductResponseDto.isScrap){
viewModel.deleteScrap(productIndex)
}

if (releaseProductResponseDto.isScrap)
{
viewModel.deleteScrap(productIndex)
}
},
)
}
Expand All @@ -370,7 +369,7 @@ fun ShoesItem(releaseProductResponseDto: ResponseReleaseProductDto.ReleaseProduc
}

@Composable
fun ShoesList(viewModel:ReleaseProductViewModel) {
fun ShoesList(viewModel: ReleaseProductViewModel) {
val shoesList = viewModel.productList.collectAsState().value
Column {
val items = List(12) { it }
Expand All @@ -379,9 +378,9 @@ fun ShoesList(viewModel:ReleaseProductViewModel) {
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.SpaceEvenly,
) {
ShoesItem( shoesList[i],i+1, viewModel)
ShoesItem(shoesList[i], i + 1, viewModel)
if (i + 1 < items.size) {
ShoesItem(shoesList[i + 1],i+2,viewModel)
ShoesItem(shoesList[i + 1], i + 2, viewModel)
}
}
Spacer(modifier = Modifier.height(14.dp))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.launch
import org.sopt.kream.data.ServicePool
import org.sopt.kream.data.model.request.RequestDeleteScrapDto
import org.sopt.kream.data.model.response.ResponseReleaseProductDto
import org.sopt.kream.domain.repository.ProductRepository
import org.sopt.kream.util.base.BaseResponse
import org.sopt.kream.util.view.UiState

class ReleaseProductViewModel(
Expand All @@ -29,12 +27,10 @@ class ReleaseProductViewModel(
val getReleaseProductState get() = _getReleaseProductState.asStateFlow()
val deleteScrapState get() = _deleteScrapState.asStateFlow()

private val _productList = MutableStateFlow<List<ResponseReleaseProductDto.ReleaseProductResponseDto>>(listOf())
private val _productList = MutableStateFlow<List<ResponseReleaseProductDto.ReleaseProductResponseDto>>(listOf())

val productList get() = _productList.asStateFlow()



fun getReleaseProduct() {
viewModelScope.launch {
runCatching {
Expand All @@ -47,7 +43,8 @@ class ReleaseProductViewModel(
}
}
}
fun deleteScrap(productIndex:Int){

fun deleteScrap(productIndex: Int) {
Log.d("okhttp", "hi 1")
viewModelScope.launch {
repository.deleteScrap(2, productIndex)
Expand All @@ -61,7 +58,6 @@ class ReleaseProductViewModel(
}
}


private fun generateDummyAdvertisement(): List<Advertisement> {
return AdvertisementType.entries.mapIndexed { index, adEnum ->
Advertisement(
Expand Down

0 comments on commit 13b15b7

Please sign in to comment.