-
Notifications
You must be signed in to change notification settings - Fork 0
[Feat] 나만아니면돼 이벤트 팝업, 툴팁 추가 #498
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
fb08dde
feat: MainActivity 접속 시 이벤트 팝업 추가
PeraSite b01d3f6
refactor: 팝업 코드 정리
PeraSite f5c538d
refactor: 팝업 컨트롤러를 ActivityScoped로 변경
PeraSite 0c297eb
refactor: 브라우저 여는 함수 분리
PeraSite fe7a82f
feat: 나아돼 위에 이벤트 툴팁 추가
PeraSite c0276e4
refactor: caption2 사용
PeraSite File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
app/src/main/java/com/eatssu/android/data/local/AppFeatureDataStore.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| package com.eatssu.android.data.local | ||
|
|
||
| import android.content.Context | ||
| import androidx.datastore.core.DataStore | ||
| import androidx.datastore.preferences.core.Preferences | ||
| import androidx.datastore.preferences.core.booleanPreferencesKey | ||
| import androidx.datastore.preferences.core.edit | ||
| import androidx.datastore.preferences.preferencesDataStore | ||
| import dagger.hilt.android.qualifiers.ApplicationContext | ||
| import kotlinx.coroutines.flow.Flow | ||
| import kotlinx.coroutines.flow.map | ||
| import javax.inject.Inject | ||
|
|
||
| private val Context.appFeatureDataStore: DataStore<Preferences> by preferencesDataStore(name = "app_feature") | ||
|
|
||
| class AppFeatureDataStore @Inject constructor( | ||
| @ApplicationContext private val context: Context | ||
| ) { | ||
|
|
||
| companion object { | ||
| private val ANYONE_BUT_ME_EVENT_POPUP_DISMISSED = | ||
| booleanPreferencesKey("anyone_but_me_event_popup_dismissed") | ||
| } | ||
|
|
||
| val isAnyoneButMeEventPopupDismissed: Flow<Boolean> = context.appFeatureDataStore.data | ||
| .map { preferences -> | ||
| preferences[ANYONE_BUT_ME_EVENT_POPUP_DISMISSED] ?: false | ||
| } | ||
|
|
||
| suspend fun setAnyoneButMeEventPopupDismissed(dismissed: Boolean) { | ||
| context.appFeatureDataStore.edit { preferences -> | ||
| preferences[ANYONE_BUT_ME_EVENT_POPUP_DISMISSED] = dismissed | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
176 changes: 176 additions & 0 deletions
176
app/src/main/java/com/eatssu/android/presentation/event/AnyoneButMeEventDialog.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,176 @@ | ||
| package com.eatssu.android.presentation.event | ||
|
|
||
| import androidx.compose.foundation.Image | ||
| import androidx.compose.foundation.background | ||
| import androidx.compose.foundation.border | ||
| import androidx.compose.foundation.clickable | ||
| import androidx.compose.foundation.layout.Arrangement | ||
| import androidx.compose.foundation.layout.Box | ||
| import androidx.compose.foundation.layout.Column | ||
| import androidx.compose.foundation.layout.Row | ||
| import androidx.compose.foundation.layout.fillMaxSize | ||
| import androidx.compose.foundation.layout.fillMaxWidth | ||
| import androidx.compose.foundation.layout.height | ||
| import androidx.compose.foundation.layout.padding | ||
| import androidx.compose.foundation.layout.size | ||
| import androidx.compose.foundation.layout.aspectRatio | ||
| import androidx.compose.foundation.shape.CircleShape | ||
| import androidx.compose.foundation.shape.RoundedCornerShape | ||
| import androidx.compose.material3.Card | ||
| import androidx.compose.material3.CardDefaults | ||
| import androidx.compose.material3.Text | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.ui.Alignment | ||
| import androidx.compose.ui.Modifier | ||
| import androidx.compose.ui.draw.clip | ||
| import androidx.compose.ui.graphics.Color | ||
| import androidx.compose.ui.layout.ContentScale | ||
| import androidx.compose.ui.res.painterResource | ||
| import androidx.compose.ui.tooling.preview.Preview | ||
| import androidx.compose.ui.unit.dp | ||
| import androidx.compose.ui.window.Dialog | ||
| import androidx.compose.ui.window.DialogProperties | ||
| import com.eatssu.android.R | ||
| import com.eatssu.design_system.theme.EatssuTheme | ||
| import com.eatssu.design_system.theme.White | ||
|
|
||
| private val EventButton = Color(0xFF1F1F1F) | ||
|
|
||
| @Composable | ||
| fun AnyoneButMeEventDialog( | ||
| onDismiss: () -> Unit, | ||
| onDismissForever: () -> Unit, | ||
| onInstagramClick: () -> Unit, | ||
| onAnyoneButMeClick: () -> Unit, | ||
| ) { | ||
| Dialog( | ||
| onDismissRequest = onDismiss, | ||
| properties = DialogProperties( | ||
| dismissOnBackPress = true, | ||
| dismissOnClickOutside = false, | ||
| usePlatformDefaultWidth = false | ||
| ) | ||
| ) { | ||
| Box( | ||
| modifier = Modifier | ||
| .fillMaxSize() | ||
| .padding(horizontal = 20.dp), | ||
| contentAlignment = Alignment.Center | ||
| ) { | ||
| Column( | ||
| modifier = Modifier | ||
| .fillMaxWidth() | ||
| .padding(horizontal = 24.dp), | ||
| verticalArrangement = Arrangement.spacedBy(11.dp) | ||
| ) { | ||
| Card( | ||
| modifier = Modifier | ||
| .fillMaxWidth() | ||
| .clickable(onClick = onAnyoneButMeClick), | ||
| shape = RoundedCornerShape(20.dp), | ||
| colors = CardDefaults.cardColors(containerColor = White) | ||
| ) { | ||
| Box( | ||
| modifier = Modifier | ||
| .fillMaxWidth() | ||
| .aspectRatio(640f / 720f), | ||
| ) { | ||
| Image( | ||
| painter = painterResource(R.drawable.ic_event_popup), | ||
| contentDescription = null, | ||
| modifier = Modifier.fillMaxSize(), | ||
| contentScale = ContentScale.Fit | ||
| ) | ||
|
|
||
| Box( | ||
| modifier = Modifier | ||
| .align(Alignment.BottomCenter) | ||
| .padding(bottom = 40.dp) | ||
| ) { | ||
| InstagramButton(onClick = onInstagramClick) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| Row( | ||
| modifier = Modifier.fillMaxWidth(), | ||
| horizontalArrangement = Arrangement.SpaceBetween, | ||
| verticalAlignment = Alignment.CenterVertically | ||
| ) { | ||
| FooterActionText( | ||
| text = "다시 보지 않기", | ||
| onClick = onDismissForever | ||
| ) | ||
| FooterActionText( | ||
| text = "닫기", | ||
| onClick = onDismiss | ||
| ) | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @Composable | ||
| private fun InstagramButton(onClick: () -> Unit) { | ||
| Row( | ||
| modifier = Modifier | ||
| .clip(RoundedCornerShape(999.dp)) | ||
| .background(EventButton) | ||
| .border(1.dp, White, RoundedCornerShape(999.dp)) | ||
| .clickable(onClick = onClick) | ||
| .padding(start = 16.dp, end = 8.dp, top = 8.dp, bottom = 8.dp), | ||
| horizontalArrangement = Arrangement.spacedBy(4.dp), | ||
| verticalAlignment = Alignment.CenterVertically | ||
| ) { | ||
| Text( | ||
| text = "EAT-SSU 인스타그램 바로가기", | ||
| color = White, | ||
| style = EatssuTheme.typography.body2 | ||
| ) | ||
| Box( | ||
| modifier = Modifier | ||
| .size(24.dp) | ||
| .background(White, CircleShape), | ||
| contentAlignment = Alignment.Center | ||
| ) { | ||
| Image( | ||
| painter = painterResource(R.drawable.ic_arrow_right), | ||
| contentDescription = null, | ||
| modifier = Modifier.size(12.dp) | ||
| ) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @Composable | ||
| private fun FooterActionText( | ||
| text: String, | ||
| onClick: () -> Unit, | ||
| ) { | ||
| Text( | ||
| text = text, | ||
| modifier = Modifier.clickable(onClick = onClick), | ||
| color = White, | ||
| style = EatssuTheme.typography.body2 | ||
| ) | ||
| } | ||
|
|
||
| @Preview(showBackground = true) | ||
| @Composable | ||
| private fun AnyoneButMeEventDialogPreview() { | ||
| EatssuTheme { | ||
| Box( | ||
| modifier = Modifier | ||
| .fillMaxWidth() | ||
| .height(520.dp) | ||
| ) { | ||
| AnyoneButMeEventDialog( | ||
| onDismiss = {}, | ||
| onDismissForever = {}, | ||
| onInstagramClick = {}, | ||
| onAnyoneButMeClick = {} | ||
| ) | ||
| } | ||
| } | ||
| } |
104 changes: 104 additions & 0 deletions
104
app/src/main/java/com/eatssu/android/presentation/event/AnyoneButMeEventPopupController.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| package com.eatssu.android.presentation.event | ||
|
|
||
| import android.content.Context | ||
| import android.content.Intent | ||
| import androidx.compose.runtime.mutableStateOf | ||
| import androidx.compose.ui.platform.ComposeView | ||
| import androidx.compose.ui.platform.ViewCompositionStrategy | ||
| import androidx.lifecycle.LifecycleCoroutineScope | ||
| import com.eatssu.android.R | ||
| import com.eatssu.android.data.local.AppFeatureDataStore | ||
| import com.eatssu.android.presentation.mypage.terms.WebViewActivity | ||
| import com.eatssu.android.presentation.util.openInBrowser | ||
| import com.eatssu.common.enums.ScreenId | ||
| import com.eatssu.design_system.theme.EatssuTheme | ||
| import dagger.hilt.android.qualifiers.ActivityContext | ||
| import dagger.hilt.android.scopes.ActivityScoped | ||
| import kotlinx.coroutines.flow.collectLatest | ||
| import kotlinx.coroutines.launch | ||
| import javax.inject.Inject | ||
|
|
||
| @ActivityScoped | ||
| class AnyoneButMeEventPopupController @Inject constructor( | ||
| @ActivityContext private val context: Context, | ||
| private val appFeatureDataStore: AppFeatureDataStore, | ||
| ) { | ||
| private lateinit var composeView: ComposeView | ||
| private lateinit var lifecycleScope: LifecycleCoroutineScope | ||
| private var canAutoShowOnLaunch = false | ||
| private var hasHandledLaunchPopup = false | ||
| private val isPopupVisible = mutableStateOf(false) | ||
|
|
||
| fun bind( | ||
| composeView: ComposeView, | ||
| lifecycleScope: LifecycleCoroutineScope, | ||
| showOnLaunch: Boolean, | ||
| ) { | ||
| this.composeView = composeView | ||
| this.lifecycleScope = lifecycleScope | ||
| canAutoShowOnLaunch = showOnLaunch | ||
| setupContent() | ||
| observePopupState() | ||
| } | ||
|
|
||
| private fun setupContent() { | ||
| composeView.setViewCompositionStrategy( | ||
| ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed | ||
| ) | ||
| composeView.setContent { | ||
| EatssuTheme { | ||
| if (isPopupVisible.value) { | ||
| AnyoneButMeEventDialog( | ||
| onDismiss = ::hide, | ||
| onDismissForever = ::dismissForever, | ||
| onInstagramClick = ::openInstagram, | ||
| onAnyoneButMeClick = ::openAnyoneButMePage | ||
| ) | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private fun observePopupState() { | ||
| lifecycleScope.launch { | ||
| appFeatureDataStore.isAnyoneButMeEventPopupDismissed.collectLatest { dismissed -> | ||
| if (canAutoShowOnLaunch && !hasHandledLaunchPopup && !dismissed) { | ||
| hasHandledLaunchPopup = true | ||
| isPopupVisible.value = true | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private fun dismissForever() { | ||
| hide() | ||
| lifecycleScope.launch { | ||
| appFeatureDataStore.setAnyoneButMeEventPopupDismissed(true) | ||
| } | ||
| } | ||
|
|
||
| fun openAnyoneButMePage() { | ||
| hide() | ||
| context.startActivity( | ||
| Intent(context, WebViewActivity::class.java).apply { | ||
| putExtra(WebViewActivity.EXTRA_URL, context.getString(R.string.anyone_but_me_url)) | ||
| putExtra(WebViewActivity.EXTRA_TITLE, context.getString(R.string.nav_anyone_but_me)) | ||
| putExtra("SCREEN_ID", ScreenId.ANYONE_BUT_ME_MAIN.name) | ||
| putExtra( | ||
| WebViewActivity.EXTRA_BACK_ICON_RES_ID, | ||
| com.eatssu.design_system.R.drawable.ic_close | ||
| ) | ||
| } | ||
| ) | ||
| } | ||
|
|
||
| private fun openInstagram() { | ||
| hide() | ||
| context.openInBrowser(context.getString(R.string.eatssu_event_instagram_url)) | ||
| } | ||
|
|
||
| private fun hide() { | ||
| canAutoShowOnLaunch = false | ||
| isPopupVisible.value = false | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
인텐트 extra에 사용되는 키 "SCREEN_ID"가 하드코딩되어 있습니다.
WebViewActivity의 companion object에 상수로 정의하고, 이를 참조하여 사용하는 것이 타입 안정성을 높이고 실수를 방지하는 데 도움이 됩니다. 예를 들어,WebViewActivity.EXTRA_SCREEN_ID와 같이 정의할 수 있습니다.