Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

기프티콘 카테고리 별 사용 가능 기프티콘 및 유효기간 임박 표시 #84

Merged
merged 3 commits into from
May 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ internal fun BaseAppBar(buddyConAppBars: BuddyConAppBars) {
when (buddyConAppBars) {
is BuddyConAppBars.WithNotification -> {
Icon(
painter = painterResource(R.drawable.ic_notification_sel),
painter = painterResource(R.drawable.ic_notification),
contentDescription = buddyConAppBars.title,
modifier = Modifier
.size(AppbarIconSize)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ interface GiftiConService {

@GET("api/v1/gifticons/count")
suspend fun getGifticonCount(
@Query("used") used: Boolean
@Query("used") used: Boolean,
@Query("gifticonStoreCategory") gifticonStoreCategory: String? = null,
@Query("gifticonStore") gifticonStore: String? = null,
@Query("remainingDays") remainingDays: Int? = null
): GifticonCountResponse

/** 기프티콘 상세 정보 수정 */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,19 @@ class GifticonRepositoryImpl @Inject constructor(
).flow
}

override fun getGifticonCount(used: Boolean): Flow<Int> = flow {
override fun getGifticonCount(
used: Boolean,
gifticonStoreCategory: GifticonStoreCategory?,
gifticonStore: GifticonStore?,
remainingDays: Int?
): Flow<Int> = flow {
emit(
giftiConService.getGifticonCount(used)
.body
.count
giftiConService.getGifticonCount(
used = used,
gifticonStoreCategory = gifticonStoreCategory?.name,
gifticonStore = gifticonStore?.code,
remainingDays = remainingDays
).body.count
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ enum class GifticonStore(val value: String, val code: String?) {
MACDONALD("맥도날드", "MACDONALD"),
GS25("GS25", "GS25"),
CU("CU", "CU"),
OTHERS("기타", "OTHERS'"),
OTHERS("기타", "OTHERS"),
NONE("", "")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ interface GifticonRepository {
fun fetchUnavailableGifticon(): Flow<PagingData<UnavailableGifticon.UnavailableGifticonInfo>>

fun getGifticonCount(
used: Boolean
used: Boolean,
gifticonStoreCategory: GifticonStoreCategory? = null,
gifticonStore: GifticonStore? = null,
remainingDays: Int? = null
): Flow<Int>

fun editGifticonDetail(
Expand Down
1 change: 1 addition & 0 deletions feature/gifticon/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ dependencies {
implementation project(":core:utility")

implementation libs.hilt.android
implementation libs.androidx.constraintlayout
kapt libs.hilt.compiler
implementation libs.accompanist.systemuicontroller

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.graphics.ColorMatrix
import androidx.compose.ui.input.pointer.pointerInteropFilter
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
Expand All @@ -48,6 +50,7 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.viewinterop.AndroidView
import androidx.constraintlayout.compose.ConstraintLayout
import androidx.constraintlayout.compose.Dimension
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import coil.compose.AsyncImage
Expand Down Expand Up @@ -349,6 +352,7 @@ private fun GifticonDetailInfoRow(
}
}

@OptIn(ExperimentalComposeUiApi::class)
@Composable
private fun GifticonMap(
mapLocation: MapLocation = MapLocation(),
Expand Down Expand Up @@ -378,9 +382,13 @@ private fun GifticonMap(
.fillMaxWidth()
.height(166.dp)
.clip(RoundedCornerShape(20.dp))
.pointerInteropFilter {
(store == GifticonStore.OTHERS || !isGrantedPermission) // 기타 및 권한 없을 시 Map Touch 이벤트 막기
}
) {
AndroidView(
modifier = Modifier.fillMaxSize(),
modifier = Modifier
.fillMaxSize(),
factory = { context ->
MapView(context)
},
Expand Down Expand Up @@ -411,7 +419,7 @@ private fun GifticonMap(
)
}
)
if (isGrantedPermission.not()) {
if (store == GifticonStore.OTHERS) {
Spacer(
modifier = Modifier
.fillMaxSize()
Expand All @@ -421,27 +429,22 @@ private fun GifticonMap(
modifier = Modifier
.align(Alignment.Center)
.background(BuddyConTheme.colors.background, RoundedCornerShape((22.5).dp))
.padding(horizontal = 20.dp, vertical = 14.dp)
.clickable {
navigateToSetting(
context = context,
packageName = context.packageName
)
},
.padding(horizontal = 20.dp, vertical = 14.dp),
contentAlignment = Alignment.Center
) {
Text(
text = buildAnnotatedString {
append("해당 기프티콘 브랜드는 ")
withStyle(style = SpanStyle(Color.Red)) {
append("위치 정보 이용")
append("지도 기능")
}
append("에 동의해야 사용할 수 있어요.")
append("이 제한되어 있어요.")
},
style = BuddyConTheme.typography.body04.copy(color = Grey70)
)
}
} else {
if (store == GifticonStore.OTHERS) {
if (isGrantedPermission.not()) {
Spacer(
modifier = Modifier
.fillMaxSize()
Expand All @@ -451,16 +454,21 @@ private fun GifticonMap(
modifier = Modifier
.align(Alignment.Center)
.background(BuddyConTheme.colors.background, RoundedCornerShape((22.5).dp))
.padding(horizontal = 20.dp, vertical = 14.dp),
.padding(horizontal = 20.dp, vertical = 14.dp)
.clickable {
navigateToSetting(
context = context,
packageName = context.packageName
)
},
contentAlignment = Alignment.Center
) {
Text(
text = buildAnnotatedString {
append("해당 기프티콘 브랜드는 ")
withStyle(style = SpanStyle(Color.Red)) {
append("지도 기능")
append("위치 정보 이용")
}
append("이 제한되어 있어요.")
append("에 동의해야 사용할 수 있어요.")
},
style = BuddyConTheme.typography.body04.copy(color = Grey70)
)
Expand Down
29 changes: 23 additions & 6 deletions feature/map/src/main/java/com/yapp/buddycon/map/MapViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class MapViewModel @Inject constructor(

init {
getGifticonCount()
getDeadLineCount()
}

fun fetchAvailableGifticon() {
Expand All @@ -58,12 +59,26 @@ class MapViewModel @Inject constructor(
}

private fun getGifticonCount() {
gifticonRepository.getGifticonCount(used = false)
.onEach {
_mapUiState.value = _mapUiState.value.copy(
totalCount = it
)
}.launchIn(viewModelScope)
gifticonRepository.getGifticonCount(
used = false,
gifticonStore = mapUiState.value.store
).onEach {
_mapUiState.value = _mapUiState.value.copy(
totalCount = it
)
}.launchIn(viewModelScope)
}

private fun getDeadLineCount() {
gifticonRepository.getGifticonCount(
used = false,
gifticonStore = mapUiState.value.store,
remainingDays = 14
).onEach {
_mapUiState.value = _mapUiState.value.copy(
deadLineCount = it
)
}.launchIn(viewModelScope)
}

fun searchPlacesByKeyword(
Expand Down Expand Up @@ -97,6 +112,8 @@ class MapViewModel @Inject constructor(
store = store
)
fetchAvailableGifticon()
getGifticonCount()
getDeadLineCount()
}

fun changeBottomSheetValue(sheetValue: BottomSheetValue) {
Expand Down
1 change: 1 addition & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ androidx-compose-ui-tooling = { group = "androidx.compose.ui", name = "ui-toolin
androidx-compose-ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" }
appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }
material = { group = "com.google.android.material", name = "material", version.ref = "material" }
androidx-constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version = "2.1.4" }

[bundles]
androidx-compose = ["androidx-compose-ui", "androidx-compose-ui-tooling", "androidx-compose-ui-tooling-preview", "androidx-activity-compose", "androidx-compose-material3", "androidx-navigation-compose", "androidx-lifecycle-compose", "androidx-hilt-navigation-compose"]
Expand Down
Loading