Skip to content

Commit

Permalink
[feat] #39 린트에 맞게 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
t1nm1ksun committed May 24, 2024
1 parent 086f362 commit aec3254
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 34 deletions.
6 changes: 3 additions & 3 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ dependencies {
implementation(libs.bundles.okhttp)
implementation(libs.bundles.retrofit)
implementation(libs.kotlin.serialization.json)
implementation (libs.androidx.foundation.v167)
implementation (libs.androidx.material)
implementation( libs.accompanist.pager.v0160)
implementation(libs.androidx.foundation.v167)
implementation(libs.androidx.material)
implementation(libs.accompanist.pager.v0160)

// Pager
implementation(libs.accompanist.pager.v02413rc)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package org.sopt.kream.presentation.ui.main.home.release

import android.annotation.SuppressLint
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.aspectRatio
Expand All @@ -12,6 +14,10 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.material.Tab
import androidx.compose.material.TabRow
import androidx.compose.material.TabRowDefaults
import androidx.compose.material.TabRowDefaults.tabIndicatorOffset
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
Expand All @@ -20,24 +26,17 @@ import androidx.compose.runtime.mutableLongStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.colorResource
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import com.google.accompanist.pager.ExperimentalPagerApi
import com.google.accompanist.pager.HorizontalPager
import com.google.accompanist.pager.rememberPagerState
import kotlinx.coroutines.delay
import org.sopt.kream.R
import org.sopt.kream.presentation.ui.model.Advertisement
import org.sopt.kream.theme.robotoBold
import java.util.concurrent.TimeUnit
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Column
import androidx.compose.material.Tab
import androidx.compose.material.TabRow
import androidx.compose.material.TabRowDefaults
import androidx.compose.material.TabRowDefaults.tabIndicatorOffset
import androidx.compose.ui.res.colorResource
import org.sopt.kream.R


@OptIn(ExperimentalPagerApi::class)
@Composable
Expand All @@ -59,45 +58,45 @@ fun ReleaseAdvertisementViewPager(
Advertisement(
imgResource = advertisement.imgResource,
modifier =
Modifier
.fillMaxSize()
.aspectRatio(1f),
Modifier
.fillMaxSize()
.aspectRatio(1f),
)
if (page == 0) {
CountdownTimer(targetTimeInMillis, textStyle = robotoBold)
}
}
}

Column (modifier = Modifier.fillMaxWidth()){
Column(modifier = Modifier.fillMaxWidth()) {
Spacer(modifier = Modifier.height(310.dp))

TabRow(
selectedTabIndex = pagerState.currentPage,
modifier = Modifier.height(2.dp).fillMaxWidth().padding(start = 14.dp).padding(end = 14.dp),

backgroundColor = colorResource(id = R.color.gray04),
indicator = { tabPositions ->
TabRowDefaults.Indicator(
Modifier
.tabIndicatorOffset(tabPositions[pagerState.currentPage])
.height(2.dp)
.background(colorResource(id = R.color.black01))
.background(colorResource(id = R.color.black01)),
)
},
divider = {}
){
divider = {},
) {
advertisements.forEachIndexed { index, _ ->
Tab(
selected = pagerState.currentPage == index,
onClick = { },
modifier = Modifier.height(2.dp) // Match the height of the indicator
modifier = Modifier.height(2.dp),
) {}
}
}
}
}
}

@SuppressLint("DefaultLocale")
@Composable
fun CountdownTimer(
Expand Down Expand Up @@ -125,9 +124,9 @@ fun CountdownTimer(

Row(
modifier =
Modifier
.fillMaxWidth()
.padding(top = 42.dp),
Modifier
.fillMaxWidth()
.padding(top = 42.dp),
horizontalArrangement = Arrangement.Center,
) {
Text(text = formattedDays, style = textStyle)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.colorResource
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.core.os.bundleOf
import androidx.fragment.app.viewModels
Expand Down Expand Up @@ -101,7 +100,6 @@ class ReleaseFragment : BindingFragment<FragmentReleaseBinding>({ FragmentReleas
}
}


@Composable
fun ReleaseView(
advertisements: List<Advertisement>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,19 @@ class ReleaseProductViewModel(
private val _postScrapState = MutableStateFlow<UiState<Int>>(UiState.Empty)
val postScrapState get() = _postScrapState.asStateFlow()

private val _deleteScrapState = MutableStateFlow<UiState<Int>>(UiState.Empty)

private val _productList = MutableStateFlow<List<ResponseReleaseProductDto.ReleaseProductResponseDto>>(listOf())
private val deleteScrapState =
MutableStateFlow<UiState<Int>>(UiState.Empty)

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

fun getReleaseProduct() {
viewModelScope.launch {
runCatching {
authService.getReleaseProduct(MEMBER_ID)
}.onSuccess {
_getReleaseProductState.value = UiState.Success(it.data.releaseProducts)
_productList.value = it.data.releaseProducts
productList.value = it.data.releaseProducts
}.onFailure { exception: Throwable ->
_getReleaseProductState.value = UiState.Error(exception.message)
}
Expand All @@ -60,11 +61,11 @@ class ReleaseProductViewModel(

fun deleteScrapProduct(productId: Int) {
viewModelScope.launch {
_deleteScrapState.value = UiState.Loading
deleteScrapState.value = UiState.Loading
productRepository.deleteScrap(productId = productId).onSuccess {
_deleteScrapState.value = UiState.Success(productId)
deleteScrapState.value = UiState.Success(productId)
}.onFailure { exception: Throwable ->
_deleteScrapState.value = UiState.Error(exception.message)
deleteScrapState.value = UiState.Error(exception.message)
}
}
}
Expand All @@ -77,4 +78,4 @@ class ReleaseProductViewModel(
)
}
}
}
}

0 comments on commit aec3254

Please sign in to comment.