diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 1fe096b91..ee5e04316 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -30,8 +30,8 @@ android { applicationId = "com.eatssu.android" minSdk = 28 targetSdk = 37 - versionCode = 73 - versionName = "3.2.18" + versionCode = 76 + versionName = "3.2.19" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } diff --git a/app/src/androidTest/java/com/eatssu/android/presentation/favorite/MenuFavoriteSearchUiTest.kt b/app/src/androidTest/java/com/eatssu/android/presentation/favorite/MenuFavoriteSearchUiTest.kt index eb924161c..348bf1e94 100644 --- a/app/src/androidTest/java/com/eatssu/android/presentation/favorite/MenuFavoriteSearchUiTest.kt +++ b/app/src/androidTest/java/com/eatssu/android/presentation/favorite/MenuFavoriteSearchUiTest.kt @@ -7,12 +7,16 @@ import android.os.Bundle import android.os.SystemClock import android.view.KeyEvent import android.view.MotionEvent +import android.view.WindowManager import android.view.accessibility.AccessibilityNodeInfo import androidx.activity.ComponentActivity import androidx.activity.compose.setContent import androidx.activity.enableEdgeToEdge import androidx.compose.runtime.Composable import androidx.compose.runtime.mutableStateOf +import androidx.core.view.ViewCompat +import androidx.core.view.WindowCompat +import androidx.core.view.WindowInsetsCompat import androidx.test.core.app.ActivityScenario import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.platform.app.InstrumentationRegistry @@ -36,6 +40,49 @@ class MenuFavoriteSearchUiTest { private val instrumentation = InstrumentationRegistry.getInstrumentation() private val context = instrumentation.targetContext + @Test + fun shortSearchWarningMovesFromSearchFieldToBottomWhenImeCloses() { + val state = mutableStateOf(FavoriteState(favoriteMenuLoadState = MenuFavoriteLoadState.Success)) + val feedback = mutableStateOf(null) + launch { + FavoriteScreen( + uiState = UiState.Success(state.value), + onStoreTypeSelected = {}, + onPartnershipClick = {}, + onMenuSearchFocusChanged = { focused -> + if (focused) state.value = state.value.copy(isMenuSearchMode = true) + }, + onMenuSearchQueryChanged = { state.value = state.value.copy(menuSearchQuery = it) }, + onMenuSearchSubmit = { + if (state.value.normalizedMenuSearchQuery.length == 1) { + feedback.value = FavoriteMenuSnackbarEvent(R.string.favorite_menu_search_too_short, true) + } + }, + menuSnackbarEvent = feedback.value, + ) + }.use { scenario -> + val isField: (AccessibilityNodeInfo) -> Boolean = { it.className == "android.widget.EditText" } + tap(awaitNode(isField)) + awaitIme(scenario, visible = true) + setQuery("a") + submitSearch() + val warning = context.getString(R.string.favorite_menu_search_too_short) + val field = Rect().also { awaitNode(isField).getBoundsInScreen(it) } + val keyboardOpen = Rect().also { awaitText(warning).getBoundsInScreen(it) } + assertTrue("Warning should be directly below the field", keyboardOpen.top >= field.bottom) + assertTrue(keyboardOpen.top - field.bottom <= 24 * context.resources.displayMetrics.density) + + scenario.onActivity { activity -> + WindowCompat.getInsetsController(activity.window, activity.window.decorView) + .hide(WindowInsetsCompat.Type.ime()) + } + awaitIme(scenario, visible = false) + val keyboardClosed = Rect().also { awaitText(warning).getBoundsInScreen(it) } + assertTrue("The same warning should move down after dismissal", keyboardClosed.top > keyboardOpen.bottom) + assertEquals("a", state.value.menuSearchQuery) + } + } + @Test fun focusTypingEnterFeedbackAndClose() { val requests = AtomicInteger() @@ -142,6 +189,38 @@ class MenuFavoriteSearchUiTest { } } + @Test + fun menuAndRestaurantAreSeparateLinesAndEmptyStateKeepsTodayAccordion() { + val favorite = FavoriteMenu(42L, "QA geometry menu", Restaurant.HAKSIK, false) + val state = mutableStateOf(FavoriteState( + favoriteMenus = listOf(favorite), + favoriteMenuLoadState = MenuFavoriteLoadState.Success, + )) + launch { + FavoriteScreen( + uiState = UiState.Success(state.value), + onStoreTypeSelected = {}, + onPartnershipClick = {}, + ) + }.use { + val menuBounds = Rect().also { awaitText(favorite.menuName).getBoundsInScreen(it) } + val restaurantBounds = Rect().also { + awaitText(context.getString(Restaurant.HAKSIK.displayNameResId)).getBoundsInScreen(it) + } + assertTrue("Restaurant label must be below the menu", restaurantBounds.top >= menuBounds.bottom) + assertTrue("Restaurant label must be smaller", restaurantBounds.height() < menuBounds.height()) + instrumentation.runOnMainSync { state.value = state.value.copy(favoriteMenus = emptyList()) } + val accordionBounds = Rect().also { + awaitText(context.getString(R.string.today_favorite_title)).getBoundsInScreen(it) + } + val emptyBounds = Rect().also { + awaitText(context.getString(R.string.favorite_menu_empty_title)).getBoundsInScreen(it) + } + assertTrue("Empty message must not overlap the retained accordion", emptyBounds.top >= accordionBounds.bottom) + screenshot("favorite-empty-responsive") + } + } + @Test fun alreadySavedMenusDoNotAccumulateInNextSelectionAndSaveDisablesAgain() { val names = listOf("맑은미역국", "배추김치", "연탄불맛돈불고기", "양배추찜") @@ -201,9 +280,26 @@ class MenuFavoriteSearchUiTest { private fun launch(content: @Composable () -> Unit): ActivityScenario = ActivityScenario.launch(ComponentActivity::class.java).also { scenario -> - scenario.onActivity { activity -> activity.enableEdgeToEdge(); activity.setContent { EatssuTheme { content() } } } + scenario.onActivity { activity -> + activity.enableEdgeToEdge() + activity.window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE) + activity.setContent { EatssuTheme { content() } } + } } + private fun awaitIme(scenario: ActivityScenario, visible: Boolean) { + repeat(40) { + var matches = false + scenario.onActivity { activity -> + matches = ViewCompat.getRootWindowInsets(activity.window.decorView) + ?.isVisible(WindowInsetsCompat.Type.ime()) == visible + } + if (matches) return + Thread.sleep(100) + } + error("Expected keyboard visibility: $visible") + } + private fun setQuery(query: String) { val field = awaitNode { it.className?.toString() == "android.widget.EditText" } assertTrue(field.performAction(AccessibilityNodeInfo.ACTION_SET_TEXT, Bundle().apply { diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 5480536a4..660b7d527 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -287,7 +287,8 @@ + android:exported="true" + android:windowSoftInputMode="adjustResize"> diff --git a/app/src/main/java/com/eatssu/android/presentation/MainActivity.kt b/app/src/main/java/com/eatssu/android/presentation/MainActivity.kt index 9a04897c6..49471fb94 100644 --- a/app/src/main/java/com/eatssu/android/presentation/MainActivity.kt +++ b/app/src/main/java/com/eatssu/android/presentation/MainActivity.kt @@ -54,6 +54,8 @@ class MainActivity : BaseActivity( ActivityMainBinding::inflate, ScreenId.HOME_MAIN ) { + override val dispatchContentInsets: Boolean = true + companion object { const val EXTRA_OPEN_MENU_FAVORITES = "open_menu_favorites" const val EXTRA_SHOW_NOTIFICATION_ENABLED_TOAST = "show_notification_enabled_toast" @@ -318,6 +320,7 @@ class MainActivity : BaseActivity( title = getString(R.string.dialog_notification_pre_permission_title), description = getString(R.string.dialog_notification_pre_permission_description), ) { + notificationDesign = true cancelText = getString(R.string.button_later) confirmText = getString(R.string.button_allow_notification) cancellable = true diff --git a/app/src/main/java/com/eatssu/android/presentation/base/BaseActivity.kt b/app/src/main/java/com/eatssu/android/presentation/base/BaseActivity.kt index a8dba0928..76a532894 100644 --- a/app/src/main/java/com/eatssu/android/presentation/base/BaseActivity.kt +++ b/app/src/main/java/com/eatssu/android/presentation/base/BaseActivity.kt @@ -80,6 +80,8 @@ abstract class BaseActivity( } + protected open val dispatchContentInsets: Boolean = false + private fun setContainerInset() { // Toolbar: topInset만 적용 val toolbar = findViewById(R.id.toolbar) @@ -104,8 +106,12 @@ abstract class BaseActivity( /* bottom = */ systemInsets.bottom ) - // 소비된 인셋을 반환하여 자식 뷰가 다시 받지 않도록 함 - WindowInsetsCompat.CONSUMED + // Forward remaining insets (such as the IME) without applying system bar padding twice. + if (dispatchContentInsets) { + insets.inset(systemInsets.left, systemInsets.top, systemInsets.right, systemInsets.bottom) + } else { + WindowInsetsCompat.CONSUMED + } } } diff --git a/app/src/main/java/com/eatssu/android/presentation/cafeteria/review/ReviewComposeActivity.kt b/app/src/main/java/com/eatssu/android/presentation/cafeteria/review/ReviewComposeActivity.kt index 6baee8eec..c800237cc 100644 --- a/app/src/main/java/com/eatssu/android/presentation/cafeteria/review/ReviewComposeActivity.kt +++ b/app/src/main/java/com/eatssu/android/presentation/cafeteria/review/ReviewComposeActivity.kt @@ -154,6 +154,7 @@ class ReviewComposeActivity : AppCompatActivity() { title = getString(R.string.review_menu_notification_title), description = getString(R.string.review_menu_notification_description), ) { + notificationDesign = true confirmText = getString(R.string.button_allow_notification) onConfirm { dialog -> dialog.dismiss() diff --git a/app/src/main/java/com/eatssu/android/presentation/favorite/FavoriteDetailScreen.kt b/app/src/main/java/com/eatssu/android/presentation/favorite/FavoriteDetailScreen.kt index 20fbe7a95..d2485a457 100644 --- a/app/src/main/java/com/eatssu/android/presentation/favorite/FavoriteDetailScreen.kt +++ b/app/src/main/java/com/eatssu/android/presentation/favorite/FavoriteDetailScreen.kt @@ -30,6 +30,7 @@ import com.eatssu.android.R import com.eatssu.android.domain.model.PartnershipRestaurant import com.eatssu.android.presentation.map.MapExternalNavigator import com.eatssu.android.presentation.map.MapProvider +import com.eatssu.android.presentation.map.PartnershipFavoriteFeedback import com.eatssu.android.presentation.map.component.MapRestaurantBottomSheet import com.eatssu.android.presentation.map.model.RestaurantInfo import com.eatssu.android.presentation.map.openMapWithoutResolution @@ -53,6 +54,7 @@ fun FavoriteDetailRoute( onBack: () -> Unit, ) { val uiState by viewModel.uiState.collectAsStateWithLifecycle() + val favoriteFeedback by viewModel.favoriteFeedback.collectAsStateWithLifecycle() val context = LocalContext.current val scope = rememberCoroutineScope() @@ -68,6 +70,10 @@ fun FavoriteDetailRoute( UiState.Error -> LaunchedEffect(Unit) { onBack() } is UiState.Success -> FavoriteDetailScreen( restaurant = state.data, + favoriteFeedback = favoriteFeedback, + onFavoriteClick = viewModel::toggleLike, + onUndoFavorite = viewModel::undoFavorite, + onDismissFeedback = viewModel::dismissFavoriteFeedback, onBack = onBack, onNaverMapClick = { scope.launch { @@ -87,6 +93,10 @@ fun FavoriteDetailRoute( @Composable private fun FavoriteDetailScreen( restaurant: PartnershipRestaurant, + favoriteFeedback: PartnershipFavoriteFeedback?, + onFavoriteClick: () -> Unit, + onUndoFavorite: () -> Unit, + onDismissFeedback: (Long) -> Unit, onBack: () -> Unit, onNaverMapClick: () -> Unit, onKakaoMapClick: () -> Unit, @@ -136,6 +146,11 @@ private fun FavoriteDetailScreen( MapRestaurantBottomSheet( storeName = restaurant.storeName, + isLiked = restaurant.likedByUser, + onFavoriteClick = onFavoriteClick, + favoriteFeedback = favoriteFeedback, + onUndoFavorite = onUndoFavorite, + onDismissFeedback = onDismissFeedback, storeType = restaurant.storeType, mapRestaurantList = listOf( RestaurantInfo( diff --git a/app/src/main/java/com/eatssu/android/presentation/favorite/FavoriteDetailViewModel.kt b/app/src/main/java/com/eatssu/android/presentation/favorite/FavoriteDetailViewModel.kt index e8b16d684..363295b1d 100644 --- a/app/src/main/java/com/eatssu/android/presentation/favorite/FavoriteDetailViewModel.kt +++ b/app/src/main/java/com/eatssu/android/presentation/favorite/FavoriteDetailViewModel.kt @@ -6,6 +6,7 @@ import com.eatssu.android.data.model.ApiResult import com.eatssu.android.domain.model.PartnershipRestaurant import com.eatssu.android.domain.repository.PartnershipRepository import com.eatssu.common.UiState +import com.eatssu.android.presentation.map.PartnershipFavoriteFeedback import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow @@ -20,10 +21,26 @@ class FavoriteDetailViewModel @Inject constructor( private val _uiState = MutableStateFlow>(UiState.Init) val uiState: StateFlow> = _uiState.asStateFlow() + private val _favoriteFeedback = MutableStateFlow(null) + val favoriteFeedback: StateFlow = _favoriteFeedback.asStateFlow() + private var isChangingFavorite = false + + fun dismissFavoriteFeedback(eventId: Long) { + if (_favoriteFeedback.value?.eventId == eventId) _favoriteFeedback.value = null + } + + fun undoFavorite() { + val feedback = _favoriteFeedback.value ?: return + val current = (_uiState.value as? UiState.Success)?.data ?: return + if (feedback.undoPartnershipId != current.id || current.likedByUser) return + _favoriteFeedback.value = null + toggleLike() + } fun showPartnership(partnership: PartnershipRestaurant) { // 찜 목록에서 받은 데이터를 재사용해 상세 진입 시 서버를 다시 조회하지 않는다. _uiState.value = UiState.Success(partnership) + _favoriteFeedback.value = null } fun loadPartnership(partnershipId: Int) { @@ -39,18 +56,27 @@ class FavoriteDetailViewModel @Inject constructor( fun toggleLike() { val current = (_uiState.value as? UiState.Success)?.data ?: return - + if (isChangingFavorite) return + isChangingFavorite = true viewModelScope.launch { - val result = partnershipRepository.likePartnership(current.id, current.likedByUser) - if (result is ApiResult.Success) { - _uiState.value = UiState.Success( - current.copy( - likedByUser = !current.likedByUser, - partnershipLikeCount = ( + try { + val result = partnershipRepository.likePartnership(current.id, current.likedByUser) + if ((_uiState.value as? UiState.Success)?.data?.id != current.id) return@launch + if (result is ApiResult.Success) { + _uiState.value = UiState.Success( + current.copy( + likedByUser = !current.likedByUser, + partnershipLikeCount = ( current.partnershipLikeCount + if (current.likedByUser) -1 else 1 ).coerceAtLeast(0), - ), - ) + ), + ) + _favoriteFeedback.value = PartnershipFavoriteFeedback.success(current.id, current.likedByUser) + } else { + _favoriteFeedback.value = PartnershipFavoriteFeedback.failure() + } + } finally { + isChangingFavorite = false } } } diff --git a/app/src/main/java/com/eatssu/android/presentation/favorite/FavoriteMenuContent.kt b/app/src/main/java/com/eatssu/android/presentation/favorite/FavoriteMenuContent.kt index 1e10d5293..437fccdea 100644 --- a/app/src/main/java/com/eatssu/android/presentation/favorite/FavoriteMenuContent.kt +++ b/app/src/main/java/com/eatssu/android/presentation/favorite/FavoriteMenuContent.kt @@ -7,13 +7,18 @@ import androidx.compose.foundation.clickable import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.BoxWithConstraints import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.IntrinsicSize import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.WindowInsets import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.heightIn +import androidx.compose.foundation.layout.ime import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width @@ -28,6 +33,7 @@ import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.mutableIntStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.runtime.setValue @@ -36,12 +42,17 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.focus.onFocusChanged import androidx.compose.ui.graphics.SolidColor +import androidx.compose.ui.graphics.Color import androidx.compose.ui.input.key.Key import androidx.compose.ui.input.key.KeyEventType import androidx.compose.ui.input.key.key import androidx.compose.ui.input.key.onPreviewKeyEvent import androidx.compose.ui.input.key.type import androidx.compose.ui.platform.LocalFocusManager +import androidx.compose.ui.platform.LocalDensity +import androidx.compose.ui.layout.onSizeChanged +import androidx.compose.ui.layout.onGloballyPositioned +import androidx.compose.ui.layout.positionInRoot import androidx.compose.ui.platform.LocalSoftwareKeyboardController import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource @@ -65,10 +76,12 @@ import com.eatssu.design_system.theme.Error import com.eatssu.design_system.theme.Gray100 import com.eatssu.design_system.theme.Gray200 import com.eatssu.design_system.theme.Gray400 -import com.eatssu.design_system.theme.Gray500 import com.eatssu.design_system.theme.Gray600 import com.eatssu.design_system.theme.Gray700 import com.eatssu.design_system.theme.pretendardBold +import com.eatssu.design_system.theme.pretendardMedium +import com.eatssu.design_system.theme.pretendardRegular +import com.eatssu.design_system.theme.pretendardSemiBold @Composable internal fun FavoriteMenuContent( @@ -85,15 +98,19 @@ internal fun FavoriteMenuContent( onSearchFocusChanged: (Boolean) -> Unit = {}, onSearchSubmit: () -> Unit = {}, onSearchExit: () -> Unit = {}, + onSearchFieldBottomChanged: (Float) -> Unit = {}, ) { val focusManager = LocalFocusManager.current val keyboard = LocalSoftwareKeyboardController.current + val isKeyboardVisible = WindowInsets.ime.getBottom(LocalDensity.current) > 0 val exitSearch = { focusManager.clearFocus(force = true) keyboard?.hide() onSearchExit() } - BackHandler(enabled = (uiState as? UiState.Success)?.data?.isMenuSearchMode == true) { exitSearch() } + BackHandler( + enabled = !isKeyboardVisible && (uiState as? UiState.Success)?.data?.isMenuSearchMode == true, + ) { exitSearch() } var showMealSelection by rememberSaveable { mutableStateOf(false) } if (showMealSelection) { TodayMealSelectionSheet( @@ -122,14 +139,22 @@ internal fun FavoriteMenuContent( onSubmit = onSearchSubmit, onExit = exitSearch, modifier = Modifier + .onGloballyPositioned { coordinates -> + onSearchFieldBottomChanged(coordinates.positionInRoot().y + coordinates.size.height) + } .fillMaxWidth() .padding(start = 24.dp, end = 24.dp, top = 24.dp), ) Spacer(Modifier.height(20.dp)) + BoxWithConstraints(Modifier.weight(1f).fillMaxWidth()) { + val viewportHeight = maxHeight + var todayHeightPx by remember { mutableIntStateOf(0) } + val density = LocalDensity.current + val emptyHeight = (viewportHeight - 24.dp - if (state.isMenuSearchMode) { + 0.dp + } else with(density) { todayHeightPx.toDp() }).coerceAtLeast(50.dp) LazyColumn( - modifier = Modifier - .weight(1f) - .fillMaxWidth(), + modifier = Modifier.fillMaxSize(), contentPadding = PaddingValues( start = 24.dp, end = 24.dp, @@ -137,6 +162,7 @@ internal fun FavoriteMenuContent( ), ) { if (!state.isMenuSearchMode) item(key = "today") { + Box(Modifier.onSizeChanged { todayHeightPx = it.height }) { TodayMenuAccordion( state = todayMenuState, favoriteIds = favoriteIds, @@ -147,6 +173,7 @@ internal fun FavoriteMenuContent( onSave = onTodaySave, onRetry = onTodayRetry, ) + } } if (state.isMenuSearchMode) { if (state.hasSubmittedMenuSearch) { @@ -164,6 +191,7 @@ internal fun FavoriteMenuContent( MenuFavoriteEmptyState( stringResource(R.string.favorite_menu_search_empty_title), stringResource(R.string.favorite_menu_search_empty_description), + modifier = Modifier.heightIn(min = emptyHeight), ) } items( @@ -186,7 +214,7 @@ internal fun FavoriteMenuContent( Spacer(Modifier.height(16.dp)) Text( stringResource(R.string.favorite_menu_section_title), - style = EatssuTheme.typography.subtitle1, + style = EatssuTheme.typography.subtitle2.copy(lineHeight = 24.sp), color = Gray700 ) Spacer(Modifier.height(12.dp)) @@ -209,6 +237,7 @@ internal fun FavoriteMenuContent( MenuFavoriteEmptyState( stringResource(R.string.favorite_menu_empty_title), stringResource(R.string.favorite_menu_empty_description), + modifier = Modifier.heightIn(min = emptyHeight), ) } items(state.favoriteMenus, key = { "favorite-${it.menuId}" }) { menu -> @@ -220,6 +249,7 @@ internal fun FavoriteMenuContent( } } } + } } } } @@ -320,9 +350,9 @@ private fun FavoriteMenuRow( MenuRow( text = menuLabel( menuName = menu.menuName, - restaurant = stringResource(menu.restaurant.displayNameResId), isDiscontinued = menu.isDiscontinued, ), + restaurant = stringResource(menu.restaurant.displayNameResId), isFavorite = isFavorite, onFavoriteClick = onFavoriteClick, ) @@ -337,9 +367,10 @@ private fun MenuSearchResultRow( MenuRow( text = menuLabel( menuName = menu.menuName, - restaurant = stringResource(menu.restaurant.displayNameResId), query = query, ), + restaurant = stringResource(menu.restaurant.displayNameResId), + isSearchResult = true, isFavorite = menu.isFavorite, onFavoriteClick = onFavoriteClick, ) @@ -348,23 +379,46 @@ private fun MenuSearchResultRow( @Composable private fun MenuRow( text: AnnotatedString, + restaurant: String, isFavorite: Boolean, onFavoriteClick: () -> Unit, + isSearchResult: Boolean = false, ) { Row( modifier = Modifier .fillMaxWidth() - .height(24.dp), + .padding(start = if (isSearchResult) 0.dp else 2.dp, end = if (isSearchResult) 4.dp else 2.dp) + .height(IntrinsicSize.Min), verticalAlignment = Alignment.CenterVertically, ) { - Text( - text = text, + Column( modifier = Modifier.weight(1f), - style = EatssuTheme.typography.body3, - color = Gray700, - maxLines = 1, - overflow = TextOverflow.Ellipsis, - ) + verticalArrangement = Arrangement.spacedBy(2.dp), + ) { + Text( + text = text, + style = EatssuTheme.typography.body2.copy( + fontFamily = if (isSearchResult) pretendardRegular else pretendardMedium, + fontSize = 14.sp, + lineHeight = 20.sp, + ), + color = Color.Black, + maxLines = 1, + overflow = TextOverflow.Ellipsis, + ) + Text( + text = restaurant, + style = EatssuTheme.typography.caption2.copy( + fontFamily = pretendardMedium, + fontSize = 10.sp, + lineHeight = 12.sp, + ), + color = Color(0xFF9D9D9D), + maxLines = 1, + overflow = TextOverflow.Ellipsis, + ) + } + Spacer(Modifier.width(8.dp)) Icon( painter = painterResource( if (isFavorite) R.drawable.ic_like_filled else R.drawable.ic_like_line, @@ -388,11 +442,10 @@ private fun MenuRow( private fun MenuFavoriteEmptyState( title: String, description: String, + modifier: Modifier = Modifier, ) { Box( - modifier = Modifier - .fillMaxWidth() - .height(260.dp), + modifier = modifier.fillMaxWidth(), contentAlignment = Alignment.Center, ) { Column( @@ -401,12 +454,15 @@ private fun MenuFavoriteEmptyState( ) { Text( text = title, - style = EatssuTheme.typography.subtitle1, + style = EatssuTheme.typography.subtitle2.copy( + fontFamily = pretendardSemiBold, + lineHeight = 24.sp, + ), color = Gray700, ) Text( text = description, - style = EatssuTheme.typography.caption2, + style = EatssuTheme.typography.caption2.copy(fontFamily = pretendardMedium), color = Gray600, ) } @@ -416,7 +472,6 @@ private fun MenuFavoriteEmptyState( @Composable private fun menuLabel( menuName: String, - restaurant: String, query: String? = null, isDiscontinued: Boolean = false, ): AnnotatedString = buildAnnotatedString { @@ -436,18 +491,6 @@ private fun menuLabel( } } - append(" · ") - val restaurantStart = length - append(restaurant) - addStyle( - style = SpanStyle( - color = Gray500, - fontSize = 12.sp, - ), - start = restaurantStart - 5, - end = length, - ) - if (isDiscontinued) { append(" ") val discontinuedStart = length diff --git a/app/src/main/java/com/eatssu/android/presentation/favorite/FavoriteScreen.kt b/app/src/main/java/com/eatssu/android/presentation/favorite/FavoriteScreen.kt index 6bdb3ce12..12faeb16f 100644 --- a/app/src/main/java/com/eatssu/android/presentation/favorite/FavoriteScreen.kt +++ b/app/src/main/java/com/eatssu/android/presentation/favorite/FavoriteScreen.kt @@ -3,6 +3,7 @@ package com.eatssu.android.presentation.favorite import androidx.activity.compose.BackHandler import androidx.compose.animation.AnimatedVisibility import androidx.compose.animation.core.Animatable +import androidx.compose.animation.core.animateFloatAsState import androidx.compose.animation.fadeIn import androidx.compose.animation.fadeOut import androidx.compose.animation.slideInVertically @@ -20,6 +21,7 @@ import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.ime import androidx.compose.foundation.layout.imePadding import androidx.compose.foundation.layout.IntrinsicSize import androidx.compose.foundation.layout.offset @@ -37,11 +39,13 @@ import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.Icon import androidx.compose.material3.IconButton +import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.Scaffold import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableFloatStateOf import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.rememberCoroutineScope @@ -56,6 +60,8 @@ import androidx.compose.ui.graphics.Path import androidx.compose.ui.graphics.StrokeCap import androidx.compose.ui.graphics.StrokeJoin import androidx.compose.ui.input.pointer.pointerInput +import androidx.compose.ui.layout.onGloballyPositioned +import androidx.compose.ui.layout.positionInRoot import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.res.dimensionResource @@ -87,6 +93,7 @@ import com.eatssu.common.enums.Time import com.eatssu.design_system.component.DelayedLoadingIndicator import com.eatssu.design_system.component.EatSsuSnackbar import com.eatssu.design_system.component.EatSsuSnackbarType +import com.eatssu.design_system.theme.Danger import com.eatssu.design_system.theme.EatssuTheme import com.eatssu.design_system.theme.Error import com.eatssu.design_system.theme.Gray200 @@ -99,7 +106,6 @@ import com.eatssu.design_system.theme.pretendardMedium import com.eatssu.design_system.theme.pretendardSemiBold import com.eatssu.design_system.theme.Primary import com.eatssu.design_system.theme.White -import kotlinx.coroutines.Job import kotlinx.coroutines.delay import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.launch @@ -145,7 +151,6 @@ fun FavoriteRoute( onPartnershipClick = onPartnershipClick, onRemoveFavorite = viewModel::removeFavorite, onRemoveFavorites = viewModel::removeFavorites, - onRestoreFavorites = viewModel::restoreFavorites, onMenuSearchQueryChanged = viewModel::onMenuSearchQueryChanged, onMenuSearchFocusChanged = viewModel::onMenuSearchFocusChanged, onMenuSearchSubmit = viewModel::submitMenuSearch, @@ -153,6 +158,12 @@ fun FavoriteRoute( onSearchFavoriteClick = viewModel::toggleMenuFavorite, onFavoriteMenuClick = viewModel::toggleFavoriteMenu, menuSnackbarEvent = menuSnackbarEvent, + onUndoSnackbar = { + val event = menuSnackbarEvent + menuSnackbarEvent = null + event?.removedMenu?.let(viewModel::restoreMenu) + event?.removedPartnerships?.let(viewModel::restoreFavorites) + }, todayMenuState = todayState, onTodayToggleExpanded = viewModel::toggleTodayMenus, onTodayChangeMeal = viewModel::changeTodayMeal, @@ -171,7 +182,6 @@ internal fun FavoriteScreen( onPartnershipClick: (PartnershipRestaurant) -> Unit, onRemoveFavorite: (Int) -> Unit = {}, onRemoveFavorites: (Set) -> Unit = {}, - onRestoreFavorites: (List) -> Unit = {}, onMenuSearchQueryChanged: (String) -> Unit = {}, onMenuSearchFocusChanged: (Boolean) -> Unit = {}, onMenuSearchSubmit: () -> Unit = {}, @@ -179,6 +189,7 @@ internal fun FavoriteScreen( onSearchFavoriteClick: (MenuFavoriteSearchResult) -> Unit = {}, onFavoriteMenuClick: (FavoriteMenu) -> Unit = {}, menuSnackbarEvent: FavoriteMenuSnackbarEvent? = null, + onUndoSnackbar: () -> Unit = {}, todayMenuState: TodayMenuFavoriteState = TodayMenuFavoriteState(), onTodayToggleExpanded: () -> Unit = {}, onTodayChangeMeal: (Restaurant, Time) -> Unit = { _, _ -> }, @@ -187,16 +198,26 @@ internal fun FavoriteScreen( onTodayRetry: () -> Unit = {}, ) { var selectedPage by rememberSaveable { mutableStateOf(if (showPartnership) PARTNERSHIP_PAGE else MENU_PAGE) } - val scope = rememberCoroutineScope() var isEditMode by remember { mutableStateOf(false) } var selectedPartnershipIds by remember { mutableStateOf(setOf()) } - var lastDeletedPartnerships by remember { - mutableStateOf>( - emptyList() - ) + var bodyTopInRoot by remember { mutableFloatStateOf(0f) } + var searchBottomInRoot by remember { mutableFloatStateOf(0f) } + val isKeyboardVisible = WindowInsets.ime.getBottom(LocalDensity.current) > 0 + val isShortSearchFeedback = menuSnackbarEvent?.messageRes == R.string.favorite_menu_search_too_short + val showFeedback = menuSnackbarEvent != null && + (!isShortSearchFeedback || selectedPage == MENU_PAGE && + (uiState as? UiState.Success)?.data?.isMenuSearchMode == true) + val searchAnchorProgress = animateFloatAsState( + targetValue = if (isShortSearchFeedback && isKeyboardVisible) 1f else 0f, + label = "shortSearchFeedbackAnchor", + ) + val feedbackBottomGap = with(LocalDensity.current) { 20.dp.roundToPx() } + val feedbackAlignment = Alignment { size, space, _ -> + val bottomAnchor = (space.height - size.height - feedbackBottomGap).coerceAtLeast(0) + val searchAnchor = (searchBottomInRoot - bodyTopInRoot).coerceIn(0f, bottomAnchor.toFloat()) + val top = bottomAnchor + (searchAnchor - bottomAnchor) * searchAnchorProgress.value + IntOffset((space.width - size.width) / 2, top.roundToInt()) } - var showDeleteSnackbar by remember { mutableStateOf(false) } - var snackbarJob by remember { mutableStateOf(null) } BackHandler(enabled = isEditMode) { isEditMode = false @@ -250,7 +271,8 @@ internal fun FavoriteScreen( modifier = Modifier .fillMaxSize() .padding(innerPadding) - .padding(bottom = dimensionResource(R.dimen.bottom_nav_height)), + .padding(bottom = dimensionResource(R.dimen.bottom_nav_height)) + .onGloballyPositioned { bodyTopInRoot = it.positionInRoot().y }, ) { Column(modifier = Modifier.fillMaxSize()) { if (isEditMode) { @@ -268,25 +290,14 @@ internal fun FavoriteScreen( selectedPartnershipIds = if (isAllSelected) emptySet() else allIds }, onDelete = { - val deletedItems = - (uiState as? UiState.Success)?.data?.partnerships?.filter { it.partnershipId in selectedPartnershipIds } - .orEmpty() onRemoveFavorites(selectedPartnershipIds) - if (deletedItems.isNotEmpty()) { - lastDeletedPartnerships = deletedItems - showDeleteSnackbar = true - snackbarJob?.cancel() - snackbarJob = scope.launch { - delay(3500) - showDeleteSnackbar = false - } - } selectedPartnershipIds = emptySet() isEditMode = false }, ) } else { MapStyleTabs( + favoritesDesign = true, labels = listOf( stringResource(R.string.favorite_menu_tab), stringResource(R.string.favorite_partnership_tab), @@ -301,20 +312,7 @@ internal fun FavoriteScreen( uiState = uiState, onStoreTypeSelected = onStoreTypeSelected, onPartnershipClick = onPartnershipClick, - onRemoveFavorite = { id -> - val deletedItem = - (uiState as? UiState.Success)?.data?.partnerships?.find { it.partnershipId == id } - onRemoveFavorite(id) - if (deletedItem != null) { - lastDeletedPartnerships = listOf(deletedItem) - showDeleteSnackbar = true - snackbarJob?.cancel() - snackbarJob = scope.launch { - delay(3500) - showDeleteSnackbar = false - } - } - }, + onRemoveFavorite = onRemoveFavorite, onEditClick = { isEditMode = true selectedPartnershipIds = emptySet() @@ -327,6 +325,7 @@ internal fun FavoriteScreen( onSearchFocusChanged = onMenuSearchFocusChanged, onSearchSubmit = onMenuSearchSubmit, onSearchExit = onMenuSearchExit, + onSearchFieldBottomChanged = { searchBottomInRoot = it }, onSearchFavoriteClick = onSearchFavoriteClick, onFavoriteMenuClick = onFavoriteMenuClick, todayMenuState = todayMenuState, @@ -341,49 +340,38 @@ internal fun FavoriteScreen( } } - AnimatedVisibility( - visible = showDeleteSnackbar, - enter = fadeIn() + slideInVertically { it / 2 }, - exit = fadeOut() + slideOutVertically { it / 2 }, - modifier = Modifier - .align(Alignment.BottomCenter) - .padding(bottom = 8.dp), - ) { - EatSsuSnackbar( - message = stringResource(R.string.favorite_deleted_snackbar), - actionLabel = stringResource(R.string.favorite_undo), - onActionClick = { - snackbarJob?.cancel() - showDeleteSnackbar = false - onRestoreFavorites(lastDeletedPartnerships) - lastDeletedPartnerships = emptyList() - }, - type = EatSsuSnackbarType.Success, - ) - } - - AnimatedVisibility( - visible = menuSnackbarEvent != null, - enter = fadeIn() + slideInVertically { it / 2 }, - exit = fadeOut() + slideOutVertically { it / 2 }, - modifier = Modifier - .imePadding() - .align(Alignment.BottomCenter) - .padding(horizontal = 8.dp) - .padding(bottom = 6.dp), - ) { - menuSnackbarEvent?.let { event -> - EatSsuSnackbar( - message = stringResource(event.messageRes), - modifier = Modifier.fillMaxWidth(), - messageStyle = EatssuTheme.typography.body2, - maxLines = 1, - type = if (event.isError) { - EatSsuSnackbarType.Danger - } else { - EatSsuSnackbarType.Success - }, - ) + Box(Modifier.matchParentSize().imePadding()) { + AnimatedVisibility( + visible = showFeedback, + enter = fadeIn() + slideInVertically { it / 2 }, + exit = fadeOut() + slideOutVertically { it / 2 }, + modifier = Modifier + .align(feedbackAlignment) + .padding(horizontal = 24.dp), + ) { + menuSnackbarEvent?.let { event -> + EatSsuSnackbar( + message = stringResource(event.messageRes), + modifier = Modifier.fillMaxWidth(), + messageStyle = EatssuTheme.typography.body2, + maxLines = 1, + compact = true, + actionLabel = if (event.removedMenu != null || event.removedPartnerships.isNotEmpty()) { + stringResource(R.string.favorite_undo) + } else null, + onActionClick = onUndoSnackbar, + actionStyle = EatssuTheme.typography.button2.copy( + fontFamily = pretendardSemiBold, + fontSize = if (event.removedMenu != null) 12.sp else 14.sp, + lineHeight = if (event.removedMenu != null) 18.sp else 20.sp, + ), + type = if (event.isError) { + EatSsuSnackbarType.Danger + } else { + EatSsuSnackbarType.Success + }, + ) + } } } } @@ -415,6 +403,7 @@ private fun FavoriteEditContent( isAllSelected = isAllSelected, onToggleSelectAll = { onToggleSelectAll(allIds, isAllSelected) }, ) + HorizontalDivider(color = Gray200, thickness = 2.dp) LazyColumn( modifier = Modifier @@ -424,13 +413,19 @@ private fun FavoriteEditContent( itemsIndexed( items = partnerships, key = { index, item -> "${item.partnershipId}_$index" }, - ) { _, item -> + ) { index, item -> val isSelected = item.partnershipId in selectedPartnershipIds FavoriteEditRow( item = item, isSelected = isSelected, onToggle = { onToggleSelect(item.partnershipId) }, ) + if (index < partnerships.lastIndex) { + HorizontalDivider( + modifier = Modifier.padding(horizontal = 24.dp), + color = Gray200, + ) + } } } @@ -439,9 +434,9 @@ private fun FavoriteEditContent( Box( modifier = Modifier .fillMaxWidth() - .padding(horizontal = 20.dp, vertical = 16.dp) - .height(56.dp) - .clip(RoundedCornerShape(12.dp)) + .padding(horizontal = 24.dp, vertical = 16.dp) + .height(52.dp) + .clip(RoundedCornerShape(8.dp)) .background(if (isEnabled) Error else Gray200) .clickable(enabled = isEnabled, onClick = onDelete), contentAlignment = Alignment.Center, @@ -452,7 +447,7 @@ private fun FavoriteEditContent( } else { stringResource(R.string.favorite_delete) }, - style = EatssuTheme.typography.button1, + style = EatssuTheme.typography.button1.copy(fontFamily = pretendardSemiBold), color = if (isEnabled) White else Gray400, ) } @@ -471,7 +466,7 @@ private fun FavoriteSelectAllRow( modifier = Modifier .fillMaxWidth() .clickable(onClick = onToggleSelectAll) - .padding(horizontal = 24.dp, vertical = 14.dp), + .padding(start = 32.dp, end = 24.dp, top = 8.dp, bottom = 8.dp), verticalAlignment = Alignment.CenterVertically, ) { CircularCheckbox( @@ -481,7 +476,7 @@ private fun FavoriteSelectAllRow( Spacer(modifier = Modifier.width(12.dp)) Text( text = stringResource(R.string.favorite_select_all), - style = EatssuTheme.typography.h2, + style = EatssuTheme.typography.subtitle2.copy(lineHeight = 24.sp), color = Color.Black, ) } @@ -497,7 +492,7 @@ private fun FavoriteEditRow( modifier = Modifier .fillMaxWidth() .clickable(onClick = onToggle) - .padding(horizontal = 24.dp, vertical = 18.dp), + .padding(horizontal = 24.dp, vertical = 12.dp), verticalAlignment = Alignment.CenterVertically, ) { CircularCheckbox( @@ -505,13 +500,13 @@ private fun FavoriteEditRow( onCheckedChange = onToggle, ) - Spacer(modifier = Modifier.width(16.dp)) + Spacer(modifier = Modifier.width(12.dp)) Column(modifier = Modifier.weight(1f)) { Row(verticalAlignment = Alignment.CenterVertically) { Text( text = item.storeName, - style = EatssuTheme.typography.h2, + style = EatssuTheme.typography.subtitle1, color = Color.Black, maxLines = 1, overflow = TextOverflow.Ellipsis, @@ -519,7 +514,7 @@ private fun FavoriteEditRow( Spacer(modifier = Modifier.width(8.dp)) Text( text = item.storeType.value, - style = EatssuTheme.typography.body3, + style = EatssuTheme.typography.caption2.copy(fontFamily = pretendardMedium), color = Gray600, ) } @@ -635,12 +630,18 @@ private fun FavoritePartnershipContent( itemsIndexed( items = uiState.data.filteredPartnerships, key = { index, item -> "${item.partnershipId}_$index" }, - ) { _, item -> + ) { index, item -> FavoriteSwipeToDismissItem( item = item, onClick = { item.detail?.let(onPartnershipClick) }, onRemoveFavorite = onRemoveFavorite, ) + if (index < uiState.data.filteredPartnerships.lastIndex) { + HorizontalDivider( + modifier = Modifier.padding(horizontal = 24.dp), + color = Gray200, + ) + } } } } @@ -708,9 +709,9 @@ private fun FavoriteSwipeToDismissItem( ) { Box( modifier = Modifier - .size(40.dp) + .size(36.dp) .clip(CircleShape) - .background(Color(0xFFE53935)) + .background(Danger) .clickable { scope.launch { offsetX.animateTo(0f) } onRemoveFavorite(item.partnershipId) @@ -718,10 +719,10 @@ private fun FavoriteSwipeToDismissItem( contentAlignment = Alignment.Center, ) { Icon( - painter = painterResource(R.drawable.ic_remove), + painter = painterResource(R.drawable.ic_favorite_swipe_delete), contentDescription = stringResource(R.string.button_delete), - tint = Color.White, - modifier = Modifier.size(22.dp), + tint = Color.Unspecified, + modifier = Modifier.size(24.dp), ) } } @@ -777,23 +778,23 @@ private fun FavoritePartnershipRow( .fillMaxWidth() .background(Color.White) .clickable(onClick = onClick) - .padding(horizontal = 24.dp, vertical = 18.dp), + .padding(horizontal = 24.dp, vertical = 12.dp), verticalAlignment = Alignment.CenterVertically, ) { Box( modifier = Modifier - .size(46.dp) + .size(36.dp) .background(Primary, CircleShape), contentAlignment = Alignment.Center, ) { Image( painter = painterResource(item.storeType.iconRes), contentDescription = null, - modifier = Modifier.size(28.dp), + modifier = Modifier.size(24.dp), ) } - Spacer(modifier = Modifier.width(14.dp)) + Spacer(modifier = Modifier.width(12.dp)) Column(modifier = Modifier.weight(1f)) { Row(verticalAlignment = Alignment.CenterVertically) { @@ -807,7 +808,7 @@ private fun FavoritePartnershipRow( Spacer(modifier = Modifier.width(8.dp)) Text( text = item.storeType.value, - style = EatssuTheme.typography.caption2, + style = EatssuTheme.typography.caption2.copy(fontFamily = pretendardMedium), color = Gray600, ) } diff --git a/app/src/main/java/com/eatssu/android/presentation/favorite/FavoriteViewModel.kt b/app/src/main/java/com/eatssu/android/presentation/favorite/FavoriteViewModel.kt index c72341899..2b656f875 100644 --- a/app/src/main/java/com/eatssu/android/presentation/favorite/FavoriteViewModel.kt +++ b/app/src/main/java/com/eatssu/android/presentation/favorite/FavoriteViewModel.kt @@ -76,6 +76,8 @@ data class FavoriteState( data class FavoriteMenuSnackbarEvent( @StringRes val messageRes: Int, val isError: Boolean, + val removedMenu: FavoriteMenu? = null, + val removedPartnerships: List = emptyList(), ) @HiltViewModel @@ -339,7 +341,12 @@ class FavoriteViewModel @Inject constructor( fun submitMenuSearch() { val current = (_uiState.value as? UiState.Success)?.data ?: return val keyword = current.normalizedMenuSearchQuery - if (keyword.length < MENU_SEARCH_MIN_LENGTH) return + if (keyword.length < MENU_SEARCH_MIN_LENGTH) { + if (keyword.isNotEmpty()) { + showMenuSnackbar(R.string.favorite_menu_search_too_short, isError = true) + } + return + } if (current.menuSearchLoadState == MenuFavoriteLoadState.Loading && current.submittedMenuSearchQuery == keyword ) return @@ -424,6 +431,9 @@ class FavoriteViewModel @Inject constructor( R.string.favorite_menu_added_snackbar }, isError = false, + removedMenu = if (item.isFavorite) { + FavoriteMenu(item.menuId, item.menuName, item.restaurant, false) + } else null, ) } else { showMenuSnackbar(R.string.favorite_menu_action_error, isError = true) @@ -469,6 +479,7 @@ class FavoriteViewModel @Inject constructor( if (isFavorite) R.string.favorite_menu_deleted_snackbar else R.string.favorite_menu_added_snackbar, isError = false, + removedMenu = item.takeIf { isFavorite }, ) } @@ -485,63 +496,88 @@ class FavoriteViewModel @Inject constructor( } fun removeFavorite(partnershipId: Int) { - viewModelScope.launch { - val result = partnershipRepository.likePartnership(partnershipId, wasLiked = true) - if (result is ApiResult.Success) { - updateState { state -> - state.copy( - partnerships = state.partnerships.filterNot { - it.partnershipId == partnershipId - }, - ) - } - } - } + removeFavorites(setOf(partnershipId)) } fun removeFavorites(partnershipIds: Set) { if (partnershipIds.isEmpty()) return - + val items = (_uiState.value as? UiState.Success)?.data?.partnerships + ?.filter { it.partnershipId in partnershipIds }.orEmpty() + val targets = items.filter { pendingPartnershipActions.add(it.partnershipId) } + if (targets.isEmpty()) return viewModelScope.launch { - val jobs = partnershipIds.map { id -> - async { - val result = partnershipRepository.likePartnership(id, wasLiked = true) - if (result is ApiResult.Success) id else null - } - } - val successfulIds = jobs.awaitAll().filterNotNull().toSet() - if (successfulIds.isNotEmpty()) { - updateState { state -> - state.copy( - partnerships = state.partnerships.filterNot { - it.partnershipId in successfulIds - }, + try { + val successfulItems = targets.map { item -> + async { + val result = partnershipRepository.likePartnership(item.partnershipId, wasLiked = true) + if (result is ApiResult.Success) item else null + } + }.awaitAll().filterNotNull() + val successfulIds = successfulItems.map { it.partnershipId }.toSet() + if (successfulItems.isNotEmpty()) { + updateState { state -> + state.copy(partnerships = state.partnerships.filterNot { it.partnershipId in successfulIds }) + } + showMenuSnackbar( + R.string.favorite_deleted_snackbar, isError = false, + removedPartnerships = successfulItems, ) + } else { + showMenuSnackbar(R.string.favorite_menu_action_error, true) } + } finally { + targets.forEach { pendingPartnershipActions.remove(it.partnershipId) } } } } fun restoreFavorites(items: List) { - if (items.isEmpty()) return + val targets = items.filter { pendingPartnershipActions.add(it.partnershipId) } + if (targets.isEmpty()) return viewModelScope.launch { - val jobs = items.map { item -> - async { - val result = partnershipRepository.likePartnership( - item.partnershipId, - wasLiked = false, - ) - if (result is ApiResult.Success) item else null + try { + val restoredItems = targets.map { item -> + async { + val result = partnershipRepository.likePartnership(item.partnershipId, wasLiked = false) + if (result is ApiResult.Success) item else null + } + }.awaitAll().filterNotNull() + if (restoredItems.isNotEmpty()) { + updateState { state -> + val existingIds = state.partnerships.map { it.partnershipId }.toSet() + val newlyAdded = restoredItems.filterNot { it.partnershipId in existingIds } + state.copy(partnerships = newlyAdded + state.partnerships) + } } + if (restoredItems.size != targets.size) showMenuSnackbar(R.string.favorite_menu_action_error, true) + } finally { + targets.forEach { pendingPartnershipActions.remove(it.partnershipId) } } - val restoredItems = jobs.awaitAll().filterNotNull() - if (restoredItems.isNotEmpty()) { - updateState { state -> - val existingIds = state.partnerships.map { it.partnershipId }.toSet() - val newlyAdded = restoredItems.filterNot { it.partnershipId in existingIds } - state.copy(partnerships = newlyAdded + state.partnerships) - } + } + } + + private val pendingPartnershipActions = mutableSetOf() + + fun restoreMenu(item: FavoriteMenu) { + if (!pendingMenuActions.add(item.menuId)) return + viewModelScope.launch { + try { + if (menuFavoriteRepository.addFavoriteMenu(item.menuId) is ApiResult.Success) { + updateState { state -> + state.copy( + favoriteMenus = if (state.favoriteMenus.any { it.menuId == item.menuId }) { + state.favoriteMenus + } else listOf(item) + state.favoriteMenus, + menuSearchResults = state.menuSearchResults.map { + if (it.menuId == item.menuId) it.copy(isFavorite = true) else it + }, + unfavoritedMenuIds = state.unfavoritedMenuIds - item.menuId, + ) + } + } else showMenuSnackbar(R.string.favorite_menu_action_error, true) + } finally { + pendingMenuActions.remove(item.menuId) } } } @@ -556,11 +592,18 @@ class FavoriteViewModel @Inject constructor( } } - private fun showMenuSnackbar(@StringRes messageRes: Int, isError: Boolean) { + private fun showMenuSnackbar( + @StringRes messageRes: Int, + isError: Boolean, + removedMenu: FavoriteMenu? = null, + removedPartnerships: List = emptyList(), + ) { _menuSnackbarEvents.tryEmit( FavoriteMenuSnackbarEvent( messageRes = messageRes, isError = isError, + removedMenu = removedMenu, + removedPartnerships = removedPartnerships, ), ) } diff --git a/app/src/main/java/com/eatssu/android/presentation/favorite/TodayMealSelectionSheet.kt b/app/src/main/java/com/eatssu/android/presentation/favorite/TodayMealSelectionSheet.kt index 1fca49115..35f025f18 100644 --- a/app/src/main/java/com/eatssu/android/presentation/favorite/TodayMealSelectionSheet.kt +++ b/app/src/main/java/com/eatssu/android/presentation/favorite/TodayMealSelectionSheet.kt @@ -31,6 +31,7 @@ import androidx.compose.ui.draw.clip import androidx.compose.ui.res.stringResource import androidx.compose.ui.semantics.Role import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp import com.eatssu.android.R import com.eatssu.common.enums.Restaurant import com.eatssu.common.enums.Time @@ -41,6 +42,7 @@ import com.eatssu.design_system.theme.Gray300 import com.eatssu.design_system.theme.Gray400 import com.eatssu.design_system.theme.Primary import com.eatssu.design_system.theme.White +import com.eatssu.design_system.theme.pretendardSemiBold @OptIn(ExperimentalMaterial3Api::class) @Composable @@ -85,7 +87,7 @@ internal fun TodayMealSelectionSheet( Spacer(Modifier.height(20.dp)) Text( stringResource(R.string.today_favorite_restaurant_title), - style = EatssuTheme.typography.subtitle2, + style = EatssuTheme.typography.subtitle2.copy(lineHeight = 24.sp), color = Black ) Spacer(Modifier.height(10.dp)) @@ -109,7 +111,7 @@ internal fun TodayMealSelectionSheet( Spacer(Modifier.height(12.dp)) Text( stringResource(R.string.today_favorite_time_title), - style = EatssuTheme.typography.subtitle2, + style = EatssuTheme.typography.subtitle2.copy(lineHeight = 24.sp), color = Black ) Spacer(Modifier.height(10.dp)) @@ -124,6 +126,8 @@ internal fun TodayMealSelectionSheet( Spacer(Modifier.height(50.dp)) EatSsuButton( text = stringResource(R.string.today_favorite_apply), + shape = RoundedCornerShape(10.dp), + textStyle = EatssuTheme.typography.button1.copy(fontFamily = pretendardSemiBold), enabled = isTodayMealAvailable(selectedRestaurant, selectedTime), onClick = { val chosenRestaurant = selectedRestaurant diff --git a/app/src/main/java/com/eatssu/android/presentation/favorite/TodayMenuAccordion.kt b/app/src/main/java/com/eatssu/android/presentation/favorite/TodayMenuAccordion.kt index e2ced5c9e..afc89cc38 100644 --- a/app/src/main/java/com/eatssu/android/presentation/favorite/TodayMenuAccordion.kt +++ b/app/src/main/java/com/eatssu/android/presentation/favorite/TodayMenuAccordion.kt @@ -53,6 +53,8 @@ import com.eatssu.design_system.theme.Primary import com.eatssu.design_system.theme.Secondary import com.eatssu.design_system.theme.White import com.eatssu.design_system.theme.pretendardMedium +import com.eatssu.design_system.theme.pretendardSemiBold +import androidx.compose.ui.unit.sp @Composable internal fun todayRestaurantLabel(restaurant: Restaurant): String = stringResource( @@ -137,7 +139,7 @@ internal fun TodayMenuAccordion( Row(Modifier.fillMaxWidth(), verticalAlignment = Alignment.CenterVertically) { Text( todayRestaurantLabel(state.restaurant), - style = EatssuTheme.typography.subtitle2, + style = EatssuTheme.typography.subtitle2.copy(lineHeight = 24.sp), color = Gray700 ) Icon( @@ -150,7 +152,7 @@ internal fun TodayMenuAccordion( ) Text( todayTimeLabel(state.time), - style = EatssuTheme.typography.subtitle2, + style = EatssuTheme.typography.subtitle2.copy(lineHeight = 24.sp), color = Gray700 ) Spacer(Modifier.weight(1f)) @@ -166,7 +168,7 @@ internal fun TodayMenuAccordion( } Text( stringResource(R.string.today_favorite_hint), - style = EatssuTheme.typography.caption2, + style = EatssuTheme.typography.caption2.copy(fontFamily = pretendardMedium), color = Gray400 ) } @@ -293,6 +295,6 @@ private fun TodayMenuSaveButton(text: String, enabled: Boolean, onClick: () -> U ), contentAlignment = Alignment.Center, ) { - Text(text, style = EatssuTheme.typography.button2, color = White) + Text(text, style = EatssuTheme.typography.button2.copy(fontFamily = pretendardSemiBold), color = White) } } diff --git a/app/src/main/java/com/eatssu/android/presentation/map/MapFragmentView.kt b/app/src/main/java/com/eatssu/android/presentation/map/MapFragmentView.kt index 1ae0e9b96..ddcf91f53 100644 --- a/app/src/main/java/com/eatssu/android/presentation/map/MapFragmentView.kt +++ b/app/src/main/java/com/eatssu/android/presentation/map/MapFragmentView.kt @@ -423,6 +423,7 @@ internal fun MapScreen( ) { val analyticsTracker = LocalAnalyticsTracker.current var showFestivalHelp by rememberSaveable { mutableStateOf(false) } + val favoriteFeedback by viewModel.favoriteFeedback.collectAsStateWithLifecycle() val markerItems = mapState.visiblePartnerships.toMarkerItems() val clusterItems = remember(markerItems) { markerItems.associateBy { marker -> @@ -470,6 +471,9 @@ internal fun MapScreen( MapRestaurantBottomSheet( storeName = info.storeName, isLiked = info.likedByUser, + favoriteFeedback = favoriteFeedback, + onUndoFavorite = viewModel::undoFavorite, + onDismissFeedback = viewModel::dismissFavoriteFeedback, onFavoriteClick = { viewModel.likePartnership(info.id) }, storeType = storeType, mapRestaurantList = mapState.restaurantInfoList, diff --git a/app/src/main/java/com/eatssu/android/presentation/map/MapViewModel.kt b/app/src/main/java/com/eatssu/android/presentation/map/MapViewModel.kt index 2bf3e87af..14c5f6638 100644 --- a/app/src/main/java/com/eatssu/android/presentation/map/MapViewModel.kt +++ b/app/src/main/java/com/eatssu/android/presentation/map/MapViewModel.kt @@ -75,6 +75,22 @@ class MapViewModel @Inject constructor( private val _uiEvent = MutableSharedFlow() val uiEvent: SharedFlow = _uiEvent + private val _favoriteFeedback = MutableStateFlow(null) + val favoriteFeedback: StateFlow = _favoriteFeedback.asStateFlow() + private val pendingFavoriteIds = mutableSetOf() + + fun dismissFavoriteFeedback(eventId: Long) { + if (_favoriteFeedback.value?.eventId == eventId) _favoriteFeedback.value = null + } + + fun undoFavorite() { + val feedback = _favoriteFeedback.value ?: return + val id = feedback.undoPartnershipId ?: return + _favoriteFeedback.value = null + val state = (_uiState.value as? UiState.Success)?.data ?: return + if (state.partnershipLikeStatus(id) == false) likePartnership(id) + } + private val _departmentId = MutableStateFlow(-1) val departmentId: StateFlow = _departmentId.asStateFlow() @@ -192,6 +208,7 @@ class MapViewModel @Inject constructor( } fun selectPartnershipByStoreName(storeName: String, partnershipId: Int? = null) { + _favoriteFeedback.value = null val current = uiState.value if (current !is UiState.Success) return val data = current.data @@ -224,6 +241,7 @@ class MapViewModel @Inject constructor( } fun clearSelectedPartnership() { + _favoriteFeedback.value = null val current = uiState.value if (current !is UiState.Success) return @@ -237,19 +255,28 @@ class MapViewModel @Inject constructor( } fun likePartnership(id: Int) { + if (!pendingFavoriteIds.add(id)) return viewModelScope.launch { - val current = _uiState.value as? UiState.Success ?: return@launch - val wasLiked = current.data.partnershipLikeStatus(id) ?: return@launch - - // 찜 상태는 즉시 화면에 반영하고, 서버 요청이 실패한 경우에만 원래 상태로 되돌린다. - _uiState.value = UiState.Success(current.data.togglePartnershipLike(id)) - - val result = partnershipRepository.likePartnership(id, wasLiked) - if (result is ApiResult.Success) return@launch - - val latest = _uiState.value as? UiState.Success ?: return@launch - if (latest.data.partnershipLikeStatus(id) == !wasLiked) { - _uiState.value = UiState.Success(latest.data.togglePartnershipLike(id)) + try { + val current = _uiState.value as? UiState.Success ?: return@launch + val wasLiked = current.data.partnershipLikeStatus(id) ?: return@launch + + // Keep marker identity stable; update only the selected favorite state. + _uiState.value = UiState.Success(current.data.togglePartnershipLike(id)) + val result = partnershipRepository.likePartnership(id, wasLiked) + val latest = _uiState.value as? UiState.Success ?: return@launch + if (result !is ApiResult.Success && latest.data.partnershipLikeStatus(id) == !wasLiked) { + _uiState.value = UiState.Success(latest.data.togglePartnershipLike(id)) + } + // A delayed response must not show another store's undo action in a new sheet. + val selectedId = latest.data.restaurantPartnershipInfo?.id + if (selectedId == null || selectedId == id) { + _favoriteFeedback.value = if (result is ApiResult.Success) { + PartnershipFavoriteFeedback.success(id, wasLiked) + } else PartnershipFavoriteFeedback.failure() + } + } finally { + pendingFavoriteIds.remove(id) } } } diff --git a/app/src/main/java/com/eatssu/android/presentation/map/PartnershipFavoriteFeedback.kt b/app/src/main/java/com/eatssu/android/presentation/map/PartnershipFavoriteFeedback.kt new file mode 100644 index 000000000..ae787d428 --- /dev/null +++ b/app/src/main/java/com/eatssu/android/presentation/map/PartnershipFavoriteFeedback.kt @@ -0,0 +1,20 @@ +package com.eatssu.android.presentation.map + +import androidx.annotation.StringRes +import com.eatssu.android.R + +data class PartnershipFavoriteFeedback( + @StringRes val messageRes: Int, + val isError: Boolean = false, + val undoPartnershipId: Int? = null, + val eventId: Long = System.nanoTime(), +) { + companion object { + fun success(id: Int, wasLiked: Boolean) = PartnershipFavoriteFeedback( + messageRes = if (wasLiked) R.string.favorite_deleted_snackbar else R.string.favorite_partnership_added_snackbar, + undoPartnershipId = id.takeIf { wasLiked }, + ) + + fun failure() = PartnershipFavoriteFeedback(R.string.favorite_menu_action_error, isError = true) + } +} diff --git a/app/src/main/java/com/eatssu/android/presentation/map/component/MapLinkButtons.kt b/app/src/main/java/com/eatssu/android/presentation/map/component/MapLinkButtons.kt index ead7a50eb..de52351eb 100644 --- a/app/src/main/java/com/eatssu/android/presentation/map/component/MapLinkButtons.kt +++ b/app/src/main/java/com/eatssu/android/presentation/map/component/MapLinkButtons.kt @@ -20,6 +20,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.Dp import com.eatssu.android.R import com.eatssu.design_system.theme.EatssuTheme import com.eatssu.design_system.theme.Gray200 @@ -31,6 +32,7 @@ internal fun MapLinkButtons( onKakaoMapClick: () -> Unit, onNaverMapClick: () -> Unit, modifier: Modifier = Modifier, + rowHeight: Dp = 64.dp, ) { Box( modifier = modifier @@ -42,7 +44,7 @@ internal fun MapLinkButtons( Row( modifier = Modifier .fillMaxWidth() - .height(64.dp) + .height(rowHeight) .padding(horizontal = 24.dp), verticalAlignment = Alignment.CenterVertically, ) { diff --git a/app/src/main/java/com/eatssu/android/presentation/map/component/MapRestaurantBottomSheet.kt b/app/src/main/java/com/eatssu/android/presentation/map/component/MapRestaurantBottomSheet.kt index 0b8f6e325..fa1228531 100644 --- a/app/src/main/java/com/eatssu/android/presentation/map/component/MapRestaurantBottomSheet.kt +++ b/app/src/main/java/com/eatssu/android/presentation/map/component/MapRestaurantBottomSheet.kt @@ -4,6 +4,9 @@ import androidx.compose.foundation.background import androidx.compose.foundation.Image import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.ExperimentalLayoutApi +import androidx.compose.foundation.layout.FlowRow import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding @@ -33,11 +36,10 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.buildAnnotatedString -import androidx.compose.ui.text.SpanStyle -import androidx.compose.ui.text.withStyle import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import com.eatssu.android.presentation.map.iconRes +import com.eatssu.android.presentation.map.PartnershipFavoriteFeedback import com.eatssu.android.presentation.map.model.RestaurantInfo import com.eatssu.android.presentation.util.TrackScreenViewEvent import com.eatssu.android.R @@ -49,8 +51,15 @@ import com.eatssu.design_system.theme.Gray400 import com.eatssu.design_system.theme.Gray500 import com.eatssu.design_system.theme.Gray600 import com.eatssu.design_system.theme.Primary +import com.eatssu.design_system.theme.pretendardBold +import com.eatssu.design_system.theme.pretendardMedium +import com.eatssu.design_system.theme.pretendardSemiBold +import androidx.compose.ui.unit.sp +import com.eatssu.design_system.component.EatSsuSnackbar +import com.eatssu.design_system.component.EatSsuSnackbarType +import kotlinx.coroutines.delay -@OptIn(ExperimentalMaterial3Api::class) +@OptIn(ExperimentalMaterial3Api::class, ExperimentalLayoutApi::class) @Composable fun MapRestaurantBottomSheet( storeName: String, @@ -62,6 +71,9 @@ fun MapRestaurantBottomSheet( onKakaoMapClick: () -> Unit = {}, onDismiss: () -> Unit = {}, scrimColor: Color = BottomSheetDefaults.ScrimColor, + favoriteFeedback: PartnershipFavoriteFeedback? = null, + onUndoFavorite: () -> Unit = {}, + onDismissFeedback: (Long) -> Unit = {}, ) { val sheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true) @@ -69,6 +81,13 @@ fun MapRestaurantBottomSheet( sheetState.show() } + LaunchedEffect(favoriteFeedback?.eventId) { + favoriteFeedback?.let { + delay(3500) + onDismissFeedback(it.eventId) + } + } + TrackScreenViewEvent(ScreenId.MAP_DETAIL) ModalBottomSheet( @@ -83,23 +102,23 @@ fun MapRestaurantBottomSheet( modifier = Modifier .fillMaxWidth() .background(White) - .padding(bottom = 40.dp) + .padding(bottom = 20.dp) ) { // 상단 회색 바 - Spacer(modifier = Modifier.height(14.dp)) + Spacer(modifier = Modifier.height(20.dp)) Box( modifier = Modifier .align(Alignment.CenterHorizontally) .width(30.dp) - .height(2.dp) + .height(4.dp) .background( color = Gray400, shape = RoundedCornerShape(10.dp) ) ) - Spacer(modifier = Modifier.height(14.dp)) + Spacer(modifier = Modifier.height(12.dp)) // 상단 타이틀 라인 Row( @@ -111,7 +130,11 @@ fun MapRestaurantBottomSheet( Column(modifier = Modifier.weight(1f)) { Text( text = storeName, - style = EatssuTheme.typography.subtitle2 + style = EatssuTheme.typography.subtitle1.copy( + fontFamily = pretendardBold, + fontSize = 18.sp, + lineHeight = 24.sp, + ), ) Spacer(modifier = Modifier.height(4.dp)) @@ -119,7 +142,7 @@ fun MapRestaurantBottomSheet( Row(verticalAlignment = Alignment.CenterVertically) { Box( modifier = Modifier - .size(16.dp) + .size(20.dp) .clip(CircleShape) .background(Primary), contentAlignment = Alignment.Center @@ -127,7 +150,7 @@ fun MapRestaurantBottomSheet( Image( painter = painterResource(id = storeType.iconRes), contentDescription = storeName, - modifier = Modifier.size(13.dp) + modifier = Modifier.size(16.dp) ) } @@ -135,8 +158,8 @@ fun MapRestaurantBottomSheet( Text( text = stringResource(id = storeType.displayNameResId), - style = EatssuTheme.typography.caption3, - color = Gray400, + style = EatssuTheme.typography.body2, + color = Gray500, ) } } @@ -158,7 +181,7 @@ fun MapRestaurantBottomSheet( } } - Spacer(modifier = Modifier.height(20.dp)) + Spacer(modifier = Modifier.height(24.dp)) // 제휴 리스트 LazyColumn( @@ -168,6 +191,11 @@ fun MapRestaurantBottomSheet( ) { itemsIndexed(mapRestaurantList) { index, item -> Column(modifier = Modifier.padding(horizontal = 24.dp)) { + if (index > 0) Spacer(Modifier.height(12.dp)) + FlowRow( + horizontalArrangement = Arrangement.spacedBy(8.dp), + verticalArrangement = Arrangement.spacedBy(4.dp), + ) { Text( text = buildAnnotatedString { when { @@ -185,26 +213,26 @@ fun MapRestaurantBottomSheet( } } - append(" ") - withStyle(style = SpanStyle(color = Gray500, fontSize = EatssuTheme.typography.caption3.fontSize)) { - append(item.period) - } }, style = EatssuTheme.typography.body2, - modifier = Modifier - .fillMaxWidth() - .padding(top = 10.dp) ) + Text( + text = item.period, + modifier = Modifier.padding(top = 1.dp), + style = EatssuTheme.typography.caption2.copy(fontFamily = pretendardMedium), + color = Gray500, + ) + } Spacer(modifier = Modifier.height(4.dp)) Text( text = item.benefit, - style = EatssuTheme.typography.caption2, + style = EatssuTheme.typography.body3, color = Gray600 ) - Spacer(modifier = Modifier.height(10.dp)) + Spacer(modifier = Modifier.height(12.dp)) if (index < mapRestaurantList.lastIndex) { Box( @@ -212,22 +240,40 @@ fun MapRestaurantBottomSheet( .fillMaxWidth() .height(1.dp) .background(Gray200) - .padding(vertical = 10.dp) ) } } } } - MapLinkButtons( - onKakaoMapClick = onKakaoMapClick, - onNaverMapClick = onNaverMapClick, - ) + // The feedback occupies its own footer space so the benefits remain scrollable and visible. + favoriteFeedback?.let { feedback -> + EatSsuSnackbar( + message = stringResource(feedback.messageRes), + modifier = Modifier + .padding(horizontal = 24.dp) + .fillMaxWidth(), + actionLabel = if (feedback.undoPartnershipId != null) { + stringResource(R.string.favorite_undo) + } else null, + onActionClick = onUndoFavorite, + type = if (feedback.isError) EatSsuSnackbarType.Danger else EatSsuSnackbarType.Success, + messageStyle = EatssuTheme.typography.body2, + actionStyle = EatssuTheme.typography.button2.copy(fontFamily = pretendardSemiBold), + compact = true, + ) + Spacer(Modifier.height(12.dp)) + } + MapLinkButtons( + onKakaoMapClick = onKakaoMapClick, + onNaverMapClick = onNaverMapClick, + rowHeight = 48.dp, + ) + } } } } -} @Preview(showBackground = true) @Composable diff --git a/app/src/main/java/com/eatssu/android/presentation/map/component/MapStyleTabs.kt b/app/src/main/java/com/eatssu/android/presentation/map/component/MapStyleTabs.kt index 011a9bd6c..ac43ce945 100644 --- a/app/src/main/java/com/eatssu/android/presentation/map/component/MapStyleTabs.kt +++ b/app/src/main/java/com/eatssu/android/presentation/map/component/MapStyleTabs.kt @@ -9,8 +9,11 @@ import androidx.compose.material3.TabRowDefaults.tabIndicatorOffset import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier +import androidx.compose.foundation.layout.height import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp +import com.eatssu.design_system.theme.pretendardSemiBold import com.eatssu.design_system.theme.EatssuTheme import com.eatssu.design_system.theme.Gray300 import com.eatssu.design_system.theme.Gray500 @@ -23,8 +26,10 @@ fun MapStyleTabs( labels: List, selectedPage: Int, onPageSelected: (Int) -> Unit, + favoritesDesign: Boolean = false, ) { TabRow( + modifier = if (favoritesDesign) Modifier.height(44.dp) else Modifier, selectedTabIndex = selectedPage, containerColor = White, contentColor = Primary, @@ -32,22 +37,27 @@ fun MapStyleTabs( TabRowDefaults.SecondaryIndicator( modifier = Modifier.tabIndicatorOffset(positions[selectedPage]), color = Primary, - height = 2.dp, + height = if (favoritesDesign) 3.dp else 2.dp, ) }, - divider = { HorizontalDivider(color = Gray300, thickness = 0.5.dp) }, + divider = { HorizontalDivider(color = Gray300, thickness = if (favoritesDesign) 3.dp else 0.5.dp) }, ) { labels.forEachIndexed { index, label -> Tab( + modifier = if (favoritesDesign) Modifier.height(44.dp) else Modifier, selected = selectedPage == index, onClick = { onPageSelected(index) }, text = { Text( text = label, - style = EatssuTheme.typography.subtitle2.copy( + style = if (favoritesDesign) EatssuTheme.typography.subtitle2.copy( + fontFamily = pretendardSemiBold, + lineHeight = 24.sp, + ) else EatssuTheme.typography.subtitle2.copy( fontWeight = if (selectedPage == index) FontWeight.Bold else FontWeight.Normal, ), color = if (selectedPage == index) Primary else Gray500, + maxLines = if (favoritesDesign) 1 else Int.MAX_VALUE, ) }, ) diff --git a/app/src/main/java/com/eatssu/android/presentation/mypage/MyPageFragment.kt b/app/src/main/java/com/eatssu/android/presentation/mypage/MyPageFragment.kt index e5a71b4a2..e0c8f7934 100644 --- a/app/src/main/java/com/eatssu/android/presentation/mypage/MyPageFragment.kt +++ b/app/src/main/java/com/eatssu/android/presentation/mypage/MyPageFragment.kt @@ -259,6 +259,7 @@ class MyPageFragment : Fragment() { title = getString(R.string.dialog_notification_permission_title), description = getString(R.string.dialog_notification_permission_description) ) { + notificationDesign = true confirmText = getString(R.string.dialog_settings) cancelText = getString(R.string.button_cancel) onConfirm { dialog -> diff --git a/app/src/main/java/com/eatssu/android/presentation/notification/NotificationScreen.kt b/app/src/main/java/com/eatssu/android/presentation/notification/NotificationScreen.kt index 51ad4217e..c147f6659 100644 --- a/app/src/main/java/com/eatssu/android/presentation/notification/NotificationScreen.kt +++ b/app/src/main/java/com/eatssu/android/presentation/notification/NotificationScreen.kt @@ -30,6 +30,7 @@ import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp import com.eatssu.android.R import com.eatssu.android.domain.model.notification.MenuNotification import com.eatssu.common.enums.Time @@ -41,6 +42,8 @@ import com.eatssu.design_system.theme.Gray700 import com.eatssu.design_system.theme.Primary import com.eatssu.design_system.theme.Secondary import com.eatssu.design_system.theme.White +import com.eatssu.design_system.theme.pretendardMedium +import com.eatssu.design_system.theme.pretendardSemiBold import kotlinx.coroutines.delay import java.time.Duration import java.time.Instant @@ -75,12 +78,12 @@ internal fun NotificationScreen( ) { Text( stringResource(R.string.notification_empty_title), - style = EatssuTheme.typography.subtitle2, + style = EatssuTheme.typography.subtitle2.copy(lineHeight = 24.sp), color = Gray600, ) Text( stringResource(R.string.notification_empty_description), - style = EatssuTheme.typography.caption2, + style = EatssuTheme.typography.caption2.copy(fontFamily = pretendardMedium), color = Gray600, ) } @@ -128,7 +131,7 @@ internal fun NotificationScreen( onClick = onMarkAllRead, ) .padding(vertical = 8.dp), - style = EatssuTheme.typography.button2, + style = EatssuTheme.typography.button2.copy(fontFamily = pretendardSemiBold), color = if (hasUnread) Gray600 else Gray600.copy(alpha = 0.2f), ) } @@ -142,7 +145,7 @@ internal fun NotificationScreen( modifier = Modifier .align(Alignment.CenterHorizontally) .padding(top = 16.dp, bottom = 28.dp), - style = EatssuTheme.typography.caption2, + style = EatssuTheme.typography.caption2.copy(fontFamily = pretendardMedium), color = Gray500, ) } @@ -197,7 +200,7 @@ private fun NotificationRow( style = EatssuTheme.typography.subtitle1, color = Gray700 ) - Text(time, style = EatssuTheme.typography.caption2, color = Gray600) + Text(time, style = EatssuTheme.typography.caption2.copy(fontFamily = pretendardMedium), color = Gray600) } Text(notification.body, style = EatssuTheme.typography.body3, color = Gray600) } diff --git a/app/src/main/java/com/eatssu/android/presentation/util/DialogUtil.kt b/app/src/main/java/com/eatssu/android/presentation/util/DialogUtil.kt index 1c4163b01..544f18dc8 100644 --- a/app/src/main/java/com/eatssu/android/presentation/util/DialogUtil.kt +++ b/app/src/main/java/com/eatssu/android/presentation/util/DialogUtil.kt @@ -3,11 +3,13 @@ package com.eatssu.android.presentation.util import android.app.Dialog import android.content.Context import android.graphics.Color +import android.util.TypedValue import android.view.Window import android.widget.Button import android.widget.TextView import androidx.annotation.StringRes import androidx.core.graphics.drawable.toDrawable +import androidx.core.content.res.ResourcesCompat import com.eatssu.android.R class DialogBuilder( @@ -46,6 +48,9 @@ class DialogBuilder( // Dialog를 생성 후 바로 열 것인지 여부 var showWhenStart: Boolean = true + // Opt in only for the notification designs; other shared dialogs keep their current style. + var notificationDesign: Boolean = false + fun onConfirm(action: (dialog: Dialog) -> Unit) = apply { this.onConfirm = action } @@ -73,6 +78,26 @@ class DialogBuilder( val confirmButton = dialog.findViewById