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

[Fix] 주변 상점 UI 웹, ios와 동기화 #411

Open
wants to merge 11 commits into
base: develop
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ enum class OnboardingType(
DINING_IMAGE(R.string.dining_image_tooltip),
DINING_NOTIFICATION(0),
DINING_SHARE(0),
ARTICLE_KEYWORD(R.string.article_keyword_tooltip)
ARTICLE_KEYWORD(R.string.article_keyword_tooltip),
REVIEW_SORTING(R.string.store_review_sorting_tooltip)
}
1 change: 1 addition & 0 deletions core/onboarding/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
<string name="dining_image_tooltip">식단 사진을 확인해보세요!</string>
<string name="dining_share_tooltip">식단이 마음에 들었다면 공유하기!</string>
<string name="article_keyword_tooltip">키워드를 추가하고 맞춤 알림을 받아보세요!</string>
<string name="store_review_sorting_tooltip">지금 리뷰가 가장 많은 상점을 확인해보세요!</string>
</resources>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions core/src/main/res/drawable/left_event_arrow.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="17dp"
android:height="16dp"
android:viewportWidth="17"
android:viewportHeight="16">
<group>
<clip-path
android:pathData="M0.5,0h16v16h-16z"/>
<path
android:pathData="M7.7,8L10.3,10.6C10.422,10.722 10.483,10.878 10.483,11.066C10.483,11.255 10.422,11.411 10.3,11.533C10.177,11.655 10.022,11.717 9.833,11.717C9.644,11.717 9.488,11.655 9.366,11.533L6.3,8.467C6.233,8.4 6.186,8.328 6.158,8.25C6.13,8.172 6.116,8.089 6.116,8C6.116,7.911 6.13,7.828 6.158,7.75C6.186,7.672 6.233,7.6 6.3,7.533L9.366,4.467C9.488,4.344 9.644,4.283 9.833,4.283C10.022,4.283 10.177,4.344 10.3,4.467C10.422,4.589 10.483,4.744 10.483,4.933C10.483,5.122 10.422,5.278 10.3,5.4L7.7,8Z"
android:fillColor="#FAFAFA"/>
</group>
</vector>
13 changes: 13 additions & 0 deletions core/src/main/res/drawable/right_event_arrow.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="17dp"
android:height="16dp"
android:viewportWidth="17"
android:viewportHeight="16">
<group>
<clip-path
android:pathData="M16.5,16l-16,-0l-0,-16l16,-0z"/>
<path
android:pathData="M9.3,8L6.7,5.4C6.578,5.278 6.517,5.122 6.517,4.933C6.517,4.745 6.578,4.589 6.7,4.467C6.823,4.345 6.978,4.283 7.167,4.283C7.356,4.283 7.512,4.345 7.634,4.467L10.7,7.533C10.767,7.6 10.814,7.672 10.842,7.75C10.87,7.828 10.884,7.911 10.884,8C10.884,8.089 10.87,8.172 10.842,8.25C10.814,8.328 10.767,8.4 10.7,8.467L7.634,11.533C7.512,11.656 7.356,11.717 7.167,11.717C6.978,11.717 6.823,11.656 6.7,11.533C6.578,11.411 6.517,11.256 6.517,11.067C6.517,10.878 6.578,10.722 6.7,10.6L9.3,8Z"
android:fillColor="#FAFAFA"/>
</group>
</vector>
6 changes: 6 additions & 0 deletions core/src/main/res/drawable/rounded_corners_black.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/black" />
<corners android:radius="5dp" />
</shape>
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,8 @@ interface UserAuthApi {

@POST("abtest/assign")
suspend fun postABTestAssign(@Body abTestRequest: ABTestRequest): ABTestResponse

@POST(URLConstant.SHOPS.SHOPS + "/{storeId}/call-notification")
suspend fun postReviewPromptNotification(@Path("storeId") storeId: Int)

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ fun String.toSubscribesType(): SubscribesType = when (this) {
Subscribes.DINING_SOLD_OUT -> SubscribesType.DINING_SOLD_OUT
Subscribes.DINING_IMAGE_UPLOAD -> SubscribesType.DINING_IMAGE_UPLOAD
Subscribes.ARTICLE_KEYWORD -> SubscribesType.ARTICLE_KEYWORD
Subscribes.REVIEW_PROMPT -> SubscribesType.REVIEW_PROMPT
else -> SubscribesType.NOTHING
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import `in`.koreatech.koin.domain.model.store.StoreReview
import `in`.koreatech.koin.domain.model.store.StoreReviewContent
import `in`.koreatech.koin.domain.model.store.StoreReviewStatistics
import `in`.koreatech.koin.domain.model.store.StoreWithMenu
import `in`.koreatech.koin.domain.model.store.toStoreCategory
import `in`.koreatech.koin.domain.util.ext.localDayOfWeekName

fun StoreItemResponse.toStore(): Store = Store(
Expand All @@ -61,7 +60,7 @@ fun StoreItemResponse.toStore(): Store = Store(
closeTime = it.closeTime ?: ""
)
}.orEmpty().getOrElse(0) { Store.OpenData(localDayOfWeekName, false, "00:00", "00:00") },
categoryIds = categoryIds?.map { it.toStoreCategory() }.orEmpty()
categoryIds = categoryIds
)

fun StoreEventItemReponse.toStoreEvent(): StoreEvent = StoreEvent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ class NotificationRepositoryImpl @Inject constructor(
return notificationRemoteDataSource.getPermissionInfo().toNotificationPermissionInfo()
}

override suspend fun postReviewPromptNotification(storeId: Int) {
notificationRemoteDataSource.postReviewPromptNotification(storeId)
}

override suspend fun updateSubscription(type: SubscribesType) {
notificationRemoteDataSource.updateSubscription(type.toString())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ data class StoreItemResponse(
@SerializedName("pay_card") val isCardOk: Boolean?,
@SerializedName("pay_bank") val isBankOk: Boolean?,
@SerializedName("open") val open: List<OpenResponseDTO>?,
@SerializedName("category_ids") val categoryIds: List<Int>?,
@SerializedName("category_ids") val categoryIds: List<Int>,
@SerializedName("is_event") val isEvent: Boolean?,
@SerializedName("is_open") val isOpen: Boolean?,
@SerializedName("average_rate") val averageRate : Double,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ class NotificationRemoteDataSource @Inject constructor(
suspend fun getPermissionInfo(): NotificationPermissionInfoResponse =
userAuthApi.getNotificationPermissionInfo()

suspend fun postReviewPromptNotification(storeId: Int) {
userAuthApi.postReviewPromptNotification(storeId)
}

suspend fun updateSubscription(type: String) {
userAuthApi.updateSubscription(type)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ data class Subscribes(
const val DINING_SOLD_OUT = "DINING_SOLD_OUT"
const val DINING_IMAGE_UPLOAD = "DINING_IMAGE_UPLOAD"
const val ARTICLE_KEYWORD = "ARTICLE_KEYWORD"
const val REVIEW_PROMPT = "REVIEW_PROMPT"
}
}

Expand All @@ -30,7 +31,7 @@ data class SubscribesDetail(
}

enum class SubscribesType {
SHOP_EVENT, DINING_SOLD_OUT, DINING_IMAGE_UPLOAD, NOTHING, ARTICLE_KEYWORD
SHOP_EVENT, DINING_SOLD_OUT, DINING_IMAGE_UPLOAD, NOTHING, ARTICLE_KEYWORD, REVIEW_PROMPT
}

enum class SubscribesDetailType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ data class Store(
val averageRate : Double,
val reviewCount : Int,
val open: OpenData,
val categoryIds: List<StoreCategory?>
val categoryIds: List<Int>
) {
data class OpenData(
val dayOfWeek: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,3 @@ sealed class StoreCategory(val code: Int) {
object BeautySalon : StoreCategory(9)
object Etc : StoreCategory(10)
}

fun Int.toStoreCategory() = when (this) {
1 -> StoreCategory.All
2 -> StoreCategory.Chicken
3 -> StoreCategory.Pizza
4 -> StoreCategory.DOSIRAK
5 -> StoreCategory.PorkFeet
6 -> StoreCategory.Chinese
7 -> StoreCategory.NormalFood
8 -> StoreCategory.Cafe
9 -> StoreCategory.BeautySalon
10 -> StoreCategory.Etc
else -> null
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import `in`.koreatech.koin.domain.model.notification.SubscribesType

interface NotificationRepository {
suspend fun getPermissionInfo(): NotificationPermissionInfo
suspend fun postReviewPromptNotification(storeId: Int)
suspend fun updateSubscription(type: SubscribesType)
suspend fun updateSubscriptionDetail(type: SubscribesDetailType)
suspend fun deleteSubscription(type: SubscribesType)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package `in`.koreatech.koin.domain.usecase.business

import `in`.koreatech.koin.domain.model.store.Store
import `in`.koreatech.koin.domain.model.store.StoreCategory
import `in`.koreatech.koin.domain.repository.StoreRepository
import `in`.koreatech.koin.domain.util.ext.sortedOpenStore
import `in`.koreatech.koin.domain.util.match
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package `in`.koreatech.koin.domain.usecase.store

import `in`.koreatech.koin.domain.constant.STORE_RECOMMEND_STORES
import `in`.koreatech.koin.domain.model.store.Store
import `in`.koreatech.koin.domain.model.store.StoreCategory
import `in`.koreatech.koin.domain.model.store.StoreWithMenu
import `in`.koreatech.koin.domain.repository.StoreRepository
import `in`.koreatech.koin.domain.util.ext.sortedOpenStore
Expand All @@ -17,11 +16,11 @@ class GetRecommendStoresUseCase @Inject constructor(
return storeRepository.getStores()
.filter {
val shopRandomCategoryId =
store.shopCategories?.filter { it.id != StoreCategory.All.code }
store.shopCategories?.filter { it.id != 0 }
?.randomOrNull()?.id
it.categoryIds.find {
it?.code == shopRandomCategoryId
}?.code == shopRandomCategoryId && !it.open.closed && it.uid != store.uid
it == shopRandomCategoryId
} == shopRandomCategoryId && !it.open.closed && it.uid != store.uid
}
.shuffled()
.take(STORE_RECOMMEND_STORES)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
package `in`.koreatech.koin.domain.usecase.store

import `in`.koreatech.koin.domain.model.store.Store
import `in`.koreatech.koin.domain.model.store.StoreCategory
import `in`.koreatech.koin.domain.model.store.StoreCategories
import `in`.koreatech.koin.domain.model.store.StoreSorter
import `in`.koreatech.koin.domain.repository.StoreRepository
import `in`.koreatech.koin.domain.util.ext.sortedOpenStore
import `in`.koreatech.koin.domain.util.match
import javax.inject.Inject

class GetStoresUseCase @Inject constructor(
private val storeRepository: StoreRepository,
) {
suspend operator fun invoke(
category: StoreCategory? = null,
category: StoreCategories? = null,
storeSorter: StoreSorter? = StoreSorter.NONE,
isOperating: Boolean? = null,
isDelivery: Boolean? = null
Expand All @@ -23,7 +21,7 @@ class GetStoresUseCase @Inject constructor(
isDelivery = isDelivery
)
.filter {
category in it.categoryIds
category?.id in it.categoryIds
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package `in`.koreatech.koin.domain.usecase.store

import `in`.koreatech.koin.domain.error.user.UserErrorHandler
import `in`.koreatech.koin.domain.model.error.ErrorHandler
import `in`.koreatech.koin.domain.repository.NotificationRepository
import javax.inject.Inject

class ReviewPromptUscCase @Inject constructor(
private val notificationRepository: NotificationRepository,
private val userErrorHandler: UserErrorHandler,
) {
suspend operator fun invoke(storeId: Int): Pair<Unit?, ErrorHandler?> {
return try {
notificationRepository.postReviewPromptNotification(storeId)
Unit to null
} catch (e: Exception) {
null to userErrorHandler.handleUserError(e)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package `in`.koreatech.koin.domain.usecase.store

import `in`.koreatech.koin.domain.model.store.Store
import `in`.koreatech.koin.domain.model.store.StoreCategory
import `in`.koreatech.koin.domain.model.store.StoreCategories
import `in`.koreatech.koin.domain.model.store.StoreSorter
import `in`.koreatech.koin.domain.repository.StoreRepository
import kotlinx.coroutines.CoroutineDispatcher
Expand All @@ -13,7 +13,7 @@ class SearchStoreUseCase constructor(
) {
suspend operator fun invoke(
search: String = "",
category: StoreCategory? = null,
category: StoreCategories? = null,
storeSorter: StoreSorter? = null,
isOperating: Boolean? = null,
isDelivery: Boolean? = null
Expand All @@ -26,7 +26,7 @@ class SearchStoreUseCase constructor(
isDelivery = isDelivery
)
.filter {
if (search == "") category in it.categoryIds else it.name.contains(search)
if (search == "") category?.id in it.categoryIds else it.name.contains(search)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class NotificationActivity : ActivityBase() {
textViewNotificationSetting.isVisible = false
notificationDiningSoldOut.isEnabled = true
notificationShopEvent.isEnabled = true
notificationReviewPrompt.isEnabled = true
notificationDiningImageUpload.isEnabled = true
}
}
Expand All @@ -81,6 +82,7 @@ class NotificationActivity : ActivityBase() {
textViewNotificationSetting.isVisible = true
notificationDiningSoldOut.disableAll()
notificationShopEvent.disableAll()
notificationReviewPrompt.disableAll()
notificationDiningImageUpload.disableAll()
}
}
Expand Down Expand Up @@ -115,6 +117,13 @@ class NotificationActivity : ActivityBase() {
}
}

SubscribesType.REVIEW_PROMPT -> with(binding.notificationReviewPrompt) {
if (isChecked != it.isPermit) {
fakeChecked = it.isPermit
isChecked = it.isPermit
}
}

SubscribesType.NOTHING -> Unit
else -> Unit
}
Expand Down Expand Up @@ -176,6 +185,11 @@ class NotificationActivity : ActivityBase() {
binding.notificationShopEvent.setOnSwitchClickListener { isChecked ->
handleSubscription(isChecked, SubscribesType.SHOP_EVENT)
}

binding.notificationReviewPrompt.setOnSwitchClickListener { isChecked ->
handleSubscription(isChecked, SubscribesType.REVIEW_PROMPT)
}

binding.notificationDiningImageUpload.setOnSwitchClickListener { isChecked ->
EventLogger.logClickEvent(
EventAction.CAMPUS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ class NotificationViewModel @Inject constructor(
}

sealed class NotificationUiState {
data class Success(val notificationPermissionInfo: NotificationPermissionInfo) :
NotificationUiState()
data class Success(val notificationPermissionInfo: NotificationPermissionInfo) : NotificationUiState()

data object Failed : NotificationUiState()
data object Nothing : NotificationUiState()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,18 @@ import androidx.activity.viewModels
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
import dagger.hilt.android.AndroidEntryPoint
import `in`.koreatech.koin.R
import `in`.koreatech.koin.core.activity.ActivityBase
import `in`.koreatech.koin.core.analytics.EventAction
import `in`.koreatech.koin.core.analytics.EventExtra
import `in`.koreatech.koin.core.analytics.EventLogger
import `in`.koreatech.koin.core.appbar.AppBarBase
import `in`.koreatech.koin.core.constant.AnalyticsConstant
import `in`.koreatech.koin.core.util.dataBinding
import `in`.koreatech.koin.core.viewpager.HorizontalMarginItemDecoration
import `in`.koreatech.koin.databinding.ActivityCallBenefitStoreMainBinding
import `in`.koreatech.koin.domain.model.store.StoreCategory
import `in`.koreatech.koin.domain.model.store.StoreSorter
import `in`.koreatech.koin.ui.navigation.KoinNavigationDrawerTimeActivity
import `in`.koreatech.koin.ui.navigation.KoinNavigationDrawerActivity
import `in`.koreatech.koin.ui.navigation.state.MenuState
import `in`.koreatech.koin.ui.store.adapter.StoreBenefitRecyclerAdapter
import `in`.koreatech.koin.ui.store.adapter.StoreEventPagerAdapter
Expand Down Expand Up @@ -62,7 +57,7 @@ class CallBenefitStoreActivity : KoinNavigationDrawerTimeActivity() {
EventExtra(AnalyticsConstant.CURRENT_PAGE, it.name),
EventExtra(AnalyticsConstant.DURATION_TIME, getElapsedTimeAndReset().toString())
)
storeDetailContract.launch(Triple(it.uid, getStoreCategoryName(StoreCategory.All), true))
storeDetailContract.launch(Triple(it.uid, viewModel.category.value?.name, true))
}
}
private val storeEventPagerAdapter = StoreEventPagerAdapter().apply {
Expand All @@ -75,7 +70,7 @@ class CallBenefitStoreActivity : KoinNavigationDrawerTimeActivity() {
storeDetailContract.launch(
Triple(
it.shopId,
getStoreCategoryName(viewModel.category.value),
viewModel.category.value?.name,
false
)
)
Expand Down Expand Up @@ -198,21 +193,6 @@ class CallBenefitStoreActivity : KoinNavigationDrawerTimeActivity() {
viewModel.settingStoreSorter(StoreSorter.NONE)
}

private fun getStoreCategoryName(category: StoreCategory?): String {
return when (category) {
StoreCategory.Chicken -> getString(R.string.chicken)
StoreCategory.Pizza -> getString(R.string.pizza)
StoreCategory.DOSIRAK -> getString(R.string.dorisak)
StoreCategory.PorkFeet -> getString(R.string.pork_feet)
StoreCategory.Chinese -> getString(R.string.chinese)
StoreCategory.NormalFood -> getString(R.string.normal_food)
StoreCategory.Cafe -> getString(R.string.cafe)
StoreCategory.BeautySalon -> getString(R.string.beauty_salon)
StoreCategory.Etc -> getString(R.string.etc)
StoreCategory.All, null -> getString(R.string.see_all)
}
}

private fun initOnRefreshDiningList() {
binding.storeSwiperefreshlayout.setOnRefreshListener {
viewModel.refreshStores()
Expand Down
Loading