Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feature/#28-interceptor-token' i…
Browse files Browse the repository at this point in the history
…nto feature/#28-interceptor-token
  • Loading branch information
jiwon2724 committed Aug 24, 2024
2 parents e08ccce + 10e1a4f commit c2e70c0
Show file tree
Hide file tree
Showing 259 changed files with 8,465 additions and 556 deletions.
16 changes: 16 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,14 @@ dependencies {
implementation(project(":core:ui"))
implementation(project(":data"))
implementation(project(":domain"))
implementation(project(":feature:addlink"))
implementation(project(":feature:addpokit"))
implementation(project(":feature:alarm"))
implementation(project(":feature:login"))
implementation(project(":feature:pokitdetail"))
implementation(project(":feature:search"))
implementation(project(":feature:settings"))
implementation(project(":feature:home"))

// hilt
implementation(libs.hilt)
Expand All @@ -81,4 +88,13 @@ dependencies {
// firebase
implementation(platform(libs.firebase.bom))
implementation(libs.firebase.auth.ktx)

// navigation
implementation(libs.androidx.navigation.compose)
implementation(libs.hilt.navigation.compose)

// orbit
implementation(libs.orbit.compose)
implementation(libs.orbit.core)
implementation(libs.orbit.viewmodel)
}
1 change: 0 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

<application
android:name=".PokitApplication"
android:allowBackup="false"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
Expand Down
22 changes: 21 additions & 1 deletion app/src/main/java/pokitmons/pokit/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,16 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.navigation.compose.currentBackStackEntryAsState
import androidx.navigation.compose.rememberNavController
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.delay
import pokitmons.pokit.core.ui.theme.PokitTheme
import pokitmons.pokit.navigation.LoginNavHost
import pokitmons.pokit.navigation.RootNavHost

@AndroidEntryPoint
class MainActivity : ComponentActivity() {
Expand All @@ -33,11 +39,25 @@ class MainActivity : ComponentActivity() {
}

PokitTheme {

if (showSplash) {
SplashScreen()
} else {
LoginNavHost()
}

val navHostController = rememberNavController()
val navBackStackEntry by navHostController.currentBackStackEntryAsState()
val currentDestination by remember(navBackStackEntry) { derivedStateOf { navBackStackEntry?.destination } }

LaunchedEffect(currentDestination) {
currentDestination?.route?.let { route ->
// 믹스패널/파베 애널리틱스 화면 이동 로깅용
}
}

RootNavHost(navHostController = navHostController)

}
}
}
Expand Down
59 changes: 59 additions & 0 deletions app/src/main/java/pokitmons/pokit/navigation/RootDestination.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package pokitmons.pokit.navigation

import androidx.navigation.NavType
import androidx.navigation.navArgument

object Login {
val route: String = "login"
}

object Home {
val route: String = "home"
}

object AddLink {
val route: String = "addLink"
val linkIdArg = "link_id"
val routeWithArgs = "$route?$linkIdArg={$linkIdArg}"
var arguments = listOf(
navArgument(linkIdArg) {
nullable = true
type = NavType.StringType
}
)
}

object AddPokit {
val route: String = "addPokit"
val pokitIdArg = "pokit_id"
val routeWithArgs = "$route?$pokitIdArg={$pokitIdArg}"
var arguments = listOf(
navArgument(pokitIdArg) {
nullable = true
type = NavType.StringType
}
)
}

object PokitDetail {
val route: String = "pokitDetail"
val pokitIdArg = "pokit_id"
val routeWithArgs = "$route/{$pokitIdArg}"
var arguments = listOf(navArgument(pokitIdArg) { defaultValue = "-" })
}

object Search {
val route: String = "search"
}

object Setting {
val route: String = "setting"
}

object EditNickname {
val route: String = "editNickname"
}

object Alarm {
val route: String = "alarm"
}
152 changes: 152 additions & 0 deletions app/src/main/java/pokitmons/pokit/navigation/RootNavHost.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
package pokitmons.pokit.navigation

import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.ui.Modifier
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.navigation.NavHostController
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import com.strayalpaca.addlink.AddLinkScreenContainer
import com.strayalpaca.addlink.AddLinkViewModel
import com.strayalpaca.addpokit.AddPokitScreenContainer
import com.strayalpaca.addpokit.AddPokitViewModel
import com.strayalpaca.pokitdetail.PokitDetailScreenContainer
import com.strayalpaca.pokitdetail.PokitDetailViewModel
import pokitmons.pokit.LoginViewModel
import pokitmons.pokit.alarm.AlarmScreenContainer
import pokitmons.pokit.alarm.AlarmViewModel
import pokitmons.pokit.home.HomeScreen
import pokitmons.pokit.home.pokit.PokitViewModel
import pokitmons.pokit.login.LoginScreen
import pokitmons.pokit.search.SearchScreenContainer
import pokitmons.pokit.search.SearchViewModel
import pokitmons.pokit.settings.SettingViewModel
import pokitmons.pokit.settings.nickname.EditNicknameScreen
import pokitmons.pokit.settings.setting.SettingsScreen

@Composable
fun RootNavHost(
navHostController: NavHostController,
) {
NavHost(navController = navHostController, startDestination = Home.route) {
composable(Login.route) {
val viewModel: LoginViewModel = hiltViewModel()
LoginScreen(
loginViewModel = viewModel,
onNavigateToTermsOfServiceScreen = {}
)
}

composable(Home.route) {
Box(modifier = Modifier.fillMaxSize())
}

composable(
route = AddLink.routeWithArgs,
arguments = AddLink.arguments
) {
val viewModel: AddLinkViewModel = hiltViewModel()
AddLinkScreenContainer(
viewModel = viewModel,
onBackPressed = navHostController::popBackStack,
onNavigateToAddPokit = {
navHostController.navigate(AddPokit.route)
}
)
}

composable(
route = AddPokit.routeWithArgs,
arguments = AddPokit.arguments
) {
val viewModel: AddPokitViewModel = hiltViewModel()
AddPokitScreenContainer(
viewModel = viewModel,
onBackPressed = navHostController::popBackStack,
onBackWithModifySuccess = { modifiedPokitId ->
navHostController.popBackStack()
navHostController.currentBackStackEntry
?.savedStateHandle
?.set("modified_pokit_id", modifiedPokitId)
}
)
}

composable(
route = PokitDetail.routeWithArgs,
arguments = PokitDetail.arguments
) {
val viewModel: PokitDetailViewModel = hiltViewModel()
LaunchedEffect(it) {
val pokitId = navHostController.currentBackStackEntry?.savedStateHandle?.get<Int>("modified_pokit_id") ?: return@LaunchedEffect
viewModel.getPokit(pokitId)
}

PokitDetailScreenContainer(
viewModel = viewModel,
onBackPressed = navHostController::popBackStack,
onNavigateToLinkModify = { linkId ->
navHostController.navigate("${AddLink.route}?${AddLink.linkIdArg}=$linkId")
},
onNavigateToPokitModify = { pokitId ->
navHostController.navigate("${AddPokit.route}?${AddPokit.pokitIdArg}=$pokitId")
}
)
}

composable(
route = Search.route
) {
val viewModel: SearchViewModel = hiltViewModel()
SearchScreenContainer(
viewModel = viewModel,
onBackPressed = navHostController::popBackStack,
onNavigateToLinkModify = { linkId ->
navHostController.navigate("${AddLink.route}?${AddLink.linkIdArg}=$linkId")
}
)
}

composable(route = Setting.route) {
val viewModel: SettingViewModel = hiltViewModel()
SettingsScreen(
settingViewModel = viewModel,
onNavigateToEditNickname = { navHostController.navigate(EditNickname.route) }
)
}

composable(route = EditNickname.route) {
val viewModel: SettingViewModel = hiltViewModel()
EditNicknameScreen(
settingViewModel = viewModel,
onBackPressed = navHostController::popBackStack
)
}

composable(route = Home.route) {
val viewModel: PokitViewModel = hiltViewModel()
HomeScreen(
viewModel = viewModel,
onNavigateToSearch = { navHostController.navigate(Search.route) },
onNavigateToSetting = { navHostController.navigate(Setting.route) },
onNavigateToPokitDetail = { navHostController.navigate("${PokitDetail.route}/$it") },
onNavigateAddLink = { navHostController.navigate(AddLink.route) },
onNavigateAddPokit = { navHostController.navigate(AddPokit.route) }
)
}

composable(route = Alarm.route) {
val viewModel: AlarmViewModel = hiltViewModel()
AlarmScreenContainer(
viewModel = viewModel,
onBackPressed = navHostController::popBackStack,
onNavigateToLinkModify = { linkId ->
navHostController.navigate("${AddLink.route}?${AddLink.linkIdArg}=$linkId")
}
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ internal enum class PokitButtonState {
}

enum class PokitButtonStyle {
FILLED, STROKE,
FILLED, STROKE, DEFAULT
}

enum class PokitButtonSize {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ private fun getBorderWidth(
return when (style) {
PokitButtonStyle.FILLED -> 0.dp
PokitButtonStyle.STROKE -> 1.dp
PokitButtonStyle.DEFAULT -> 1.dp
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ private fun getColor(
style: PokitButtonStyle,
): Color {
return when {
style == PokitButtonStyle.DEFAULT -> {
PokitTheme.colors.borderSecondary
}

state == PokitButtonState.DISABLE -> {
PokitTheme.colors.iconDisable
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ private fun getColor(
style: PokitButtonStyle,
): Color {
return when {
style == PokitButtonStyle.DEFAULT -> {
PokitTheme.colors.textTertiary
}

state == PokitButtonState.DISABLE -> {
PokitTheme.colors.textDisable
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ fun<T> LinkCard(

Text(
text = sub,
style = PokitTheme.typography.detail2.copy(color = PokitTheme.colors.textTertiary)
style = PokitTheme.typography.detail2.copy(color = PokitTheme.colors.textTertiary),
maxLines = 1,
overflow = TextOverflow.Ellipsis
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fun LinkCardPreview() {
) {
LinkCard(
title = "타이틀\n컴포스는 왜 이런가",
sub = "2024.06.25. youtube.com",
sub = "2024.06.25. youtube.comyoutube.comyoutube.comyoutube",
badgeText = "텍스트",
painter = painterResource(id = R.drawable.icon_24_link),
notRead = true,
Expand Down
Loading

0 comments on commit c2e70c0

Please sign in to comment.