Skip to content

Commit

Permalink
[feature/#871] git pull from develop
Browse files Browse the repository at this point in the history
  • Loading branch information
leeeyubin committed Oct 13, 2024
2 parents fdfaf0b + 88c9628 commit b12835f
Show file tree
Hide file tree
Showing 27 changed files with 921 additions and 213 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import org.sopt.official.common.navigator.DeepLinkType
import org.sopt.official.common.navigator.NavigatorProvider
import org.sopt.official.feature.attendance.AttendanceActivity
import org.sopt.official.feature.auth.AuthActivity
import org.sopt.official.feature.fortune.FortuneActivity
import org.sopt.official.feature.home.HomeActivity
import org.sopt.official.feature.mypage.mypage.MyPageActivity
import org.sopt.official.feature.notification.SchemeActivity
Expand All @@ -43,48 +44,50 @@ import org.sopt.official.stamp.SoptampActivity
import javax.inject.Inject

class NavigatorProviderIntent @Inject constructor(
@ApplicationContext private val context: Context
@ApplicationContext private val context: Context,
) : NavigatorProvider {
override fun getAuthActivityIntent(): Intent = AuthActivity.newInstance(context)
override fun getNotificationActivityIntent() = NotificationActivity.newInstance(context)
override fun getNotificationDetailActivityIntent(notificationId: String) = NotificationDetailActivity.getIntent(
context,
notificationId
)
override fun getAuthActivityIntent(): Intent = AuthActivity.newInstance(context)
override fun getNotificationActivityIntent() = NotificationActivity.newInstance(context)
override fun getNotificationDetailActivityIntent(notificationId: String) = NotificationDetailActivity.getIntent(
context,
notificationId
)

override fun getMyPageActivityIntent(name: String) = MyPageActivity.getIntent(
context,
MyPageActivity.StartArgs(UserActiveState.valueOf(name))
)

override fun getMyPageActivityIntent(name: String) = MyPageActivity.getIntent(
context,
MyPageActivity.StartArgs(UserActiveState.valueOf(name))
)
override fun getAttendanceActivityIntent() = AttendanceActivity.newInstance(context)

override fun getAttendanceActivityIntent() = AttendanceActivity.newInstance(context)
override fun getSoptampActivityIntent() = SoptampActivity.getIntent(context)

override fun getSoptampActivityIntent() = SoptampActivity.getIntent(context)
override fun getPokeNotificationActivityIntent(name: String) = PokeNotificationActivity.getIntent(
context,
PokeNotificationActivity.Argument(name)
)

override fun getPokeNotificationActivityIntent(name: String) = PokeNotificationActivity.getIntent(
context,
PokeNotificationActivity.Argument(name)
)
override fun getFortuneActivityIntent(): Intent = FortuneActivity.getIntent(context)

override fun getSchemeActivityIntent(
notificationId: String,
link: String
) = SchemeActivity.getIntent(
context,
SchemeActivity.Argument(
notificationId,
link
override fun getSchemeActivityIntent(
notificationId: String,
link: String,
) = SchemeActivity.getIntent(
context,
SchemeActivity.Argument(
notificationId,
link
)
)
)

override fun getHomeActivityIntent(
userStatus: UserStatus,
deepLinkType: DeepLinkType?
) = HomeActivity.getIntent(
context,
HomeActivity.StartArgs(
userStatus,
deepLinkType
override fun getHomeActivityIntent(
userStatus: UserStatus,
deepLinkType: DeepLinkType?,
) = HomeActivity.getIntent(
context,
HomeActivity.StartArgs(
userStatus,
deepLinkType
)
)
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,72 +33,85 @@ import org.sopt.official.common.util.extractQueryParameter
import timber.log.Timber

internal val navigator by lazy {
EntryPointAccessors.fromApplication(appContext, NavigatorEntryPoint::class.java).navigatorProvider()
EntryPointAccessors.fromApplication(appContext, NavigatorEntryPoint::class.java).navigatorProvider()
}

enum class DeepLinkType(
val link: String
val link: String,
) {
HOME("home") {
override fun getIntent(context: Context, userStatus: UserStatus, deepLink: String) = getHomeIntent(userStatus)
},
NOTIFICATION_LIST("home/notification") {
override fun getIntent(context: Context, userStatus: UserStatus, deepLink: String) = userStatus.setIntent(navigator.getNotificationActivityIntent())
},
NOTIFICATION_DETAIL("home/notification/detail") {
override fun getIntent(context: Context, userStatus: UserStatus, deepLink: String): Intent {
val notificationId = deepLink.extractQueryParameter("id")
return userStatus.setIntent(navigator.getNotificationDetailActivityIntent(notificationId))
}
},
MY_PAGE("home/mypage") {
override fun getIntent(context: Context, userStatus: UserStatus, deepLink: String) = userStatus.setIntent(navigator.getMyPageActivityIntent(userStatus.name))
},
ATTENDANCE("home/attendance") {
override fun getIntent(context: Context, userStatus: UserStatus, deepLink: String) = userStatus.setIntent(navigator.getAttendanceActivityIntent())
},
ATTENDANCE_MODAL("home/attendance/attendance-modal") {
override fun getIntent(context: Context, userStatus: UserStatus, deepLink: String) = userStatus.setIntent(navigator.getAttendanceActivityIntent())
},
SOPTAMP("home/soptamp") {
override fun getIntent(context: Context, userStatus: UserStatus, deepLink: String) = userStatus.setIntent(navigator.getSoptampActivityIntent())
},
SOPTAMP_ENTIRE_RANKING("home/soptamp/entire-ranking") {
override fun getIntent(context: Context, userStatus: UserStatus, deepLink: String) = userStatus.setIntent(navigator.getSoptampActivityIntent())
},
SOPTAMP_CURRENT_GENERATION_RANKING("home/soptamp/current-generation-ranking") {
override fun getIntent(context: Context, userStatus: UserStatus, deepLink: String) = userStatus.setIntent(navigator.getSoptampActivityIntent())
},
POKE_NOTIFICATION_LIST("home/poke/notification-list") {
override fun getIntent(context: Context, userStatus: UserStatus, deepLink: String) = userStatus.setIntent(navigator.getPokeNotificationActivityIntent(userStatus.name))
},
UNKNOWN("unknown-deep-link") {
override fun getIntent(context: Context, userStatus: UserStatus, deepLink: String) = getHomeIntent(userStatus, UNKNOWN)
},
EXPIRED("expired") {
override fun getIntent(context: Context, userStatus: UserStatus, deepLink: String) = getHomeIntent(userStatus, EXPIRED)
};
HOME("home") {
override fun getIntent(context: Context, userStatus: UserStatus, deepLink: String) = getHomeIntent(userStatus)
},
NOTIFICATION_LIST("home/notification") {
override fun getIntent(context: Context, userStatus: UserStatus, deepLink: String) =
userStatus.setIntent(navigator.getNotificationActivityIntent())
},
NOTIFICATION_DETAIL("home/notification/detail") {
override fun getIntent(context: Context, userStatus: UserStatus, deepLink: String): Intent {
val notificationId = deepLink.extractQueryParameter("id")
return userStatus.setIntent(navigator.getNotificationDetailActivityIntent(notificationId))
}
},
MY_PAGE("home/mypage") {
override fun getIntent(context: Context, userStatus: UserStatus, deepLink: String) =
userStatus.setIntent(navigator.getMyPageActivityIntent(userStatus.name))
},
ATTENDANCE("home/attendance") {
override fun getIntent(context: Context, userStatus: UserStatus, deepLink: String) =
userStatus.setIntent(navigator.getAttendanceActivityIntent())
},
ATTENDANCE_MODAL("home/attendance/attendance-modal") {
override fun getIntent(context: Context, userStatus: UserStatus, deepLink: String) =
userStatus.setIntent(navigator.getAttendanceActivityIntent())
},
SOPTAMP("home/soptamp") {
override fun getIntent(context: Context, userStatus: UserStatus, deepLink: String) =
userStatus.setIntent(navigator.getSoptampActivityIntent())
},
SOPTAMP_ENTIRE_RANKING("home/soptamp/entire-ranking") {
override fun getIntent(context: Context, userStatus: UserStatus, deepLink: String) =
userStatus.setIntent(navigator.getSoptampActivityIntent())
},
SOPTAMP_CURRENT_GENERATION_RANKING("home/soptamp/current-generation-ranking") {
override fun getIntent(context: Context, userStatus: UserStatus, deepLink: String) =
userStatus.setIntent(navigator.getSoptampActivityIntent())
},
POKE_NOTIFICATION_LIST("home/poke/notification-list") {
override fun getIntent(context: Context, userStatus: UserStatus, deepLink: String) =
userStatus.setIntent(navigator.getPokeNotificationActivityIntent(userStatus.name))
},
FORTUNE("home/fortune") {
override fun getIntent(context: Context, userStatus: UserStatus, deepLink: String) =
userStatus.setIntent(navigator.getFortuneActivityIntent())
},
UNKNOWN("unknown-deep-link") {
override fun getIntent(context: Context, userStatus: UserStatus, deepLink: String) = getHomeIntent(userStatus, UNKNOWN)
},
EXPIRED("expired") {
override fun getIntent(context: Context, userStatus: UserStatus, deepLink: String) = getHomeIntent(userStatus, EXPIRED)
};

abstract fun getIntent(context: Context, userStatus: UserStatus, deepLink: String): Intent
abstract fun getIntent(context: Context, userStatus: UserStatus, deepLink: String): Intent

companion object {
private fun UserStatus.setIntent(intent: Intent): Intent {
return when (this == UserStatus.UNAUTHENTICATED) {
true -> navigator.getAuthActivityIntent()
false -> intent
}
}
companion object {
private fun UserStatus.setIntent(intent: Intent): Intent {
return when (this == UserStatus.UNAUTHENTICATED) {
true -> navigator.getAuthActivityIntent()
false -> intent
}
}

fun getHomeIntent(userStatus: UserStatus, deepLinkType: DeepLinkType? = null) = userStatus.setIntent(navigator.getHomeActivityIntent(userStatus, deepLinkType))
fun getHomeIntent(userStatus: UserStatus, deepLinkType: DeepLinkType? = null) =
userStatus.setIntent(navigator.getHomeActivityIntent(userStatus, deepLinkType))

fun of(deepLink: String): DeepLinkType {
return try {
val link = deepLink.split("?")[0]
entries.find { it.link == link } ?: UNKNOWN
} catch (exception: Exception) {
Timber.e(exception)
UNKNOWN
}
fun of(deepLink: String): DeepLinkType {
return try {
val link = deepLink.split("?")[0]
entries.find { it.link == link } ?: UNKNOWN
} catch (exception: Exception) {
Timber.e(exception)
UNKNOWN
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,27 @@ import dagger.hilt.components.SingletonComponent
import org.sopt.official.auth.model.UserStatus

interface NavigatorProvider {
fun getAuthActivityIntent(): Intent
fun getNotificationActivityIntent(): Intent
fun getNotificationDetailActivityIntent(notificationId: String): Intent
fun getMyPageActivityIntent(name: String): Intent
fun getAttendanceActivityIntent(): Intent
fun getSoptampActivityIntent(): Intent
fun getPokeNotificationActivityIntent(name: String): Intent
fun getHomeActivityIntent(
userStatus: UserStatus,
deepLinkType: DeepLinkType?
): Intent
fun getAuthActivityIntent(): Intent
fun getNotificationActivityIntent(): Intent
fun getNotificationDetailActivityIntent(notificationId: String): Intent
fun getMyPageActivityIntent(name: String): Intent
fun getAttendanceActivityIntent(): Intent
fun getSoptampActivityIntent(): Intent
fun getPokeNotificationActivityIntent(name: String): Intent
fun getFortuneActivityIntent(): Intent
fun getHomeActivityIntent(
userStatus: UserStatus,
deepLinkType: DeepLinkType?,
): Intent

fun getSchemeActivityIntent(
notificationId: String,
link: String
): Intent
fun getSchemeActivityIntent(
notificationId: String,
link: String,
): Intent
}

@InstallIn(SingletonComponent::class)
@EntryPoint
interface NavigatorEntryPoint {
fun navigatorProvider(): NavigatorProvider
fun navigatorProvider(): NavigatorProvider
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
*/
package org.sopt.official.feature.fortune.fortuneDetail

import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.ui.semantics.SemanticsProperties
import androidx.compose.ui.semantics.getOrNull
import androidx.compose.ui.test.assertIsDisplayed
Expand Down Expand Up @@ -55,7 +54,6 @@ internal class FortuneDetailScreenTest {
composeRule.setContent {
SoptTheme {
FortuneDetailScreen(
paddingValue = PaddingValues(),
date = date,
onFortuneAmuletClick = { },
onPokeClick = { },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class FortuneActivity : AppCompatActivity() {
setContent {
SoptTheme {
FoundationScreen(
navigateToNotification = {
onClickLeadingIcon = {
startActivity(navigator.getNotificationActivityIntent())
},
navigateToHome = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,32 +29,56 @@ import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Scaffold
import androidx.compose.material3.SnackbarHost
import androidx.compose.material3.SnackbarHostState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.navigation.NavHostController
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.rememberNavController
import org.sopt.official.designsystem.SoptTheme
import org.sopt.official.feature.fortune.component.FortuneTopBar
import org.sopt.official.feature.fortune.feature.fortuneAmulet.navigation.FortuneAmulet
import org.sopt.official.feature.fortune.feature.fortuneAmulet.navigation.fortuneAmuletNavGraph
import org.sopt.official.feature.fortune.feature.fortuneDetail.component.PokeSnackBar
import org.sopt.official.feature.fortune.feature.fortuneDetail.navigation.FortuneDetail
import org.sopt.official.feature.fortune.feature.fortuneDetail.navigation.fortuneDetailNavGraph
import org.sopt.official.feature.fortune.feature.home.navigation.Home
import org.sopt.official.feature.fortune.feature.home.navigation.homeNavGraph

@Composable
fun FoundationScreen(
navigateToNotification: () -> Unit,
onClickLeadingIcon: () -> Unit,
navigateToHome: () -> Unit,
navController: NavHostController = rememberNavController(),
) {
var isBottomSheetVisible by remember { mutableStateOf(false) }
val snackBarHostState = remember { SnackbarHostState() }

Scaffold(
snackbarHost = {
Box(modifier = Modifier.fillMaxSize()) {
SnackbarHost(
hostState = snackBarHostState,
modifier = Modifier
.padding(top = 16.dp)
.align(alignment = Alignment.TopCenter),
snackbar = { PokeSnackBar() },
)
}
},
modifier = Modifier.fillMaxSize(),
topBar = {
FortuneTopBar(
onClickNavigationIcon = navigateToNotification
isEnabled = !isBottomSheetVisible,
onClickNavigationIcon = onClickLeadingIcon,
)
},
content = { paddingValue ->
Expand All @@ -75,10 +99,13 @@ fun FoundationScreen(
)

fortuneDetailNavGraph(
paddingValue = paddingValue,
navigateToFortuneAmulet = {
navController.navigate(FortuneAmulet)
}
},
isBottomSheetVisible = {
isBottomSheetVisible = it
},
snackBarHostState = snackBarHostState,
)

fortuneAmuletNavGraph(
Expand All @@ -95,7 +122,7 @@ fun FoundationScreen(
fun FoundationScreenPreview() {
SoptTheme {
FoundationScreen(
navigateToNotification = {},
onClickLeadingIcon = {},
navigateToHome = {}
)
}
Expand Down
Loading

0 comments on commit b12835f

Please sign in to comment.