Skip to content

Commit

Permalink
1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
taetae98coding committed Nov 17, 2024
1 parent acb3b8d commit 06913ab
Show file tree
Hide file tree
Showing 18 changed files with 287 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package io.github.taetae98coding.diary.core.navigation.tag

import kotlinx.serialization.Serializable

@Serializable
public data object TagDestination
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<string name="title">제목</string>
<string name="description">설명</string>
<string name="date">날짜</string>
<string name="tag">태그</string>

<string name="year_and_month">%1$d년 %2$d월</string>
<string name="month_and_day">%1$d월 %2$d일</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<string name="title">Title</string>
<string name="description">Description</string>
<string name="date">Date</string>
<string name="tag">Tag</string>

<string name="year_and_month">%1$d. %2$d.</string>
<string name="month_and_day">%1$d. %2$d.</string>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package io.github.taetae98coding.diary.core.resources.icon

import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.rounded.Tag
import androidx.compose.material3.Icon
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier

@Composable
public fun TagIcon(
modifier: Modifier = Modifier,
) {
Icon(
imageVector = Icons.Rounded.Tag,
contentDescription = null,
modifier = modifier,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ internal fun MemoDetailScreen(
}
}

else -> Unit
is MemoDetailNavigationButton.None -> Unit
}
},
actions = {
Expand Down Expand Up @@ -111,7 +111,7 @@ internal fun MemoDetailScreen(
}
}

else -> Unit
is MemoDetailFloatingButton.None -> Unit
}
},
) {
Expand Down
16 changes: 16 additions & 0 deletions app/feature/tag/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
plugins {
id("diary.app.feature")
}

kotlin {
sourceSets {
commonMain {
dependencies {
}
}
}
}

android {
namespace = "${Build.NAMESPACE}.feature.tag"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package io.github.taetae98coding.diary.feature.tag

import androidx.navigation.NavController
import androidx.navigation.NavGraphBuilder
import androidx.navigation.compose.composable
import io.github.taetae98coding.diary.core.navigation.tag.TagDestination

public fun NavGraphBuilder.tagNavigation(
navController: NavController,
) {
composable<TagDestination> {
TagRoute()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
package io.github.taetae98coding.diary.feature.tag

import androidx.compose.material3.adaptive.ExperimentalMaterial3AdaptiveApi
import androidx.compose.material3.adaptive.layout.AnimatedPane
import androidx.compose.material3.adaptive.layout.ListDetailPaneScaffold
import androidx.compose.material3.adaptive.layout.PaneAdaptedValue
import androidx.compose.material3.adaptive.layout.ThreePaneScaffoldRole
import androidx.compose.material3.adaptive.navigation.rememberListDetailPaneScaffoldNavigator
import androidx.compose.runtime.Composable
import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import io.github.taetae98coding.diary.feature.tag.detail.TagDetailFloatingButton
import io.github.taetae98coding.diary.feature.tag.detail.TagDetailNavigationButton
import io.github.taetae98coding.diary.feature.tag.detail.TagDetailScreen
import io.github.taetae98coding.diary.feature.tag.list.TagListFloatingButton
import io.github.taetae98coding.diary.feature.tag.list.TagListScreen

@OptIn(ExperimentalMaterial3AdaptiveApi::class)
@Composable
internal fun TagRoute(
modifier: Modifier = Modifier,
) {
val navigator = rememberListDetailPaneScaffoldNavigator<String?>()

ListDetailPaneScaffold(
directive = navigator.scaffoldDirective,
value = navigator.scaffoldValue,
listPane = {
AnimatedPane {
val isFloatingVisible by remember {
derivedStateOf {
val isAdd = navigator.currentDestination?.content == null
val isListVisible = navigator.scaffoldValue.secondary == PaneAdaptedValue.Expanded
val isDetailVisible = navigator.scaffoldValue.primary == PaneAdaptedValue.Expanded

isAdd && isListVisible && !isDetailVisible
}
}

TagListScreen(
floatingButtonProvider = {
if (isFloatingVisible) {
TagListFloatingButton.Add(onAdd = { navigator.navigateTo(ThreePaneScaffoldRole.Primary) })
} else {
TagListFloatingButton.None
}
},
)
}
},
detailPane = {
val isNavigateUpVisible by remember {
derivedStateOf {
val isListVisible = navigator.scaffoldValue.secondary == PaneAdaptedValue.Expanded
val isDetailVisible = navigator.scaffoldValue.primary == PaneAdaptedValue.Expanded

!isListVisible && isDetailVisible
}
}

val isFloatingVisible by remember {
derivedStateOf {
val isAdd = navigator.currentDestination?.content == null
val isDetailVisible = navigator.scaffoldValue.primary == PaneAdaptedValue.Expanded

isAdd && isDetailVisible
}
}

AnimatedPane {
TagDetailScreen(
navigateButtonProvider = {
if (isNavigateUpVisible) {
TagDetailNavigationButton.NavigateUp(onNavigateUp = navigator::navigateBack)
} else {
TagDetailNavigationButton.None
}
},
floatingButtonProvider = {
if (isFloatingVisible) {
TagDetailFloatingButton.Add(onAdd = { })
} else {
TagDetailFloatingButton.None
}
},
)
}
},
modifier = modifier,
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package io.github.taetae98coding.diary.feature.tag.detail

internal sealed class TagDetailFloatingButton {
data object None : TagDetailFloatingButton()
data class Add(val onAdd: () -> Unit) : TagDetailFloatingButton()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package io.github.taetae98coding.diary.feature.tag.detail

internal sealed class TagDetailNavigationButton {
data object None : TagDetailNavigationButton()
data class NavigateUp(val onNavigateUp: () -> Unit) : TagDetailNavigationButton()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package io.github.taetae98coding.diary.feature.tag.detail

import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.FloatingActionButton
import androidx.compose.material3.IconButton
import androidx.compose.material3.Scaffold
import androidx.compose.material3.TopAppBar
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import io.github.taetae98coding.diary.core.resources.icon.AddIcon
import io.github.taetae98coding.diary.core.resources.icon.NavigateUpIcon

@OptIn(ExperimentalMaterial3Api::class)
@Composable
internal fun TagDetailScreen(
navigateButtonProvider: () -> TagDetailNavigationButton,
floatingButtonProvider: () -> TagDetailFloatingButton,
modifier: Modifier = Modifier,
) {
Scaffold(
modifier = modifier,
topBar = {
TopAppBar(
title = {},
navigationIcon = {
when (val button = navigateButtonProvider()) {
is TagDetailNavigationButton.NavigateUp -> {
IconButton(onClick = button.onNavigateUp) {
NavigateUpIcon()
}
}

is TagDetailNavigationButton.None -> Unit
}
},
)
},
floatingActionButton = {
when(val button = floatingButtonProvider()) {
is TagDetailFloatingButton.Add -> {
FloatingActionButton(onClick = button.onAdd) {
AddIcon()
}
}
is TagDetailFloatingButton.None -> Unit
}
},
) {

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package io.github.taetae98coding.diary.feature.tag.list

internal sealed class TagListFloatingButton {
data object None : TagListFloatingButton()
data class Add(val onAdd: () -> Unit) : TagListFloatingButton()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package io.github.taetae98coding.diary.feature.tag.list

import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.FloatingActionButton
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import io.github.taetae98coding.diary.core.resources.Res
import io.github.taetae98coding.diary.core.resources.icon.AddIcon
import io.github.taetae98coding.diary.core.resources.tag
import org.jetbrains.compose.resources.stringResource

@OptIn(ExperimentalMaterial3Api::class)
@Composable
internal fun TagListScreen(
floatingButtonProvider: () -> TagListFloatingButton,
modifier: Modifier = Modifier,
) {
Scaffold(
modifier = modifier,
topBar = {
TopAppBar(
title = { Text(text = stringResource(Res.string.tag)) },
)
},
floatingActionButton = {
when(val button = floatingButtonProvider()) {
is TagListFloatingButton.Add -> {
FloatingActionButton(onClick = button.onAdd) {
AddIcon()
}
}
is TagListFloatingButton.None -> Unit
}
},
) {
Box(
modifier = Modifier.fillMaxSize()
.padding(it),
contentAlignment = Alignment.Center,
) {
Text(text = "태그 없어")
}
}
}
1 change: 1 addition & 0 deletions app/platform/common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ kotlin {
implementation(project(":app:core:holiday-service"))

implementation(project(":app:feature:memo"))
implementation(project(":app:feature:tag"))
implementation(project(":app:feature:calendar"))
implementation(project(":app:feature:more"))
implementation(project(":app:feature:account"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ import io.github.taetae98coding.diary.core.design.system.theme.DiaryTheme
import io.github.taetae98coding.diary.core.navigation.calendar.CalendarDestination
import io.github.taetae98coding.diary.core.navigation.memo.MemoDestination
import io.github.taetae98coding.diary.core.navigation.more.MoreDestination
import io.github.taetae98coding.diary.core.navigation.tag.TagDestination
import io.github.taetae98coding.diary.core.resources.icon.CalendarIcon
import io.github.taetae98coding.diary.core.resources.icon.MemoIcon
import io.github.taetae98coding.diary.core.resources.icon.MoreIcon
import io.github.taetae98coding.diary.core.resources.icon.TagIcon
import org.jetbrains.compose.resources.stringResource

@Composable
Expand All @@ -45,6 +47,7 @@ private fun AppScaffold(
val isNavigationVisible by remember {
derivedStateOf {
val visibleDestination = listOf(
TagDestination::class,
MemoDestination::class,
CalendarDestination::class,
MoreDestination::class,
Expand All @@ -62,6 +65,7 @@ private fun AppScaffold(
navigationSuiteItems = {
listOf(
// AppNavigation.Memo,
AppNavigation.Tag,
AppNavigation.Calendar,
AppNavigation.More,
).forEach { navigation ->
Expand Down Expand Up @@ -99,5 +103,6 @@ private fun AppNavigationIcon(
AppNavigation.Memo -> MemoIcon(modifier = modifier)
AppNavigation.Calendar -> CalendarIcon(modifier = modifier)
AppNavigation.More -> MoreIcon(modifier = modifier)
AppNavigation.Tag -> TagIcon(modifier = modifier)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import io.github.taetae98coding.diary.feature.account.accountNavigation
import io.github.taetae98coding.diary.feature.calendar.calendarNavigation
import io.github.taetae98coding.diary.feature.memo.memoNavigation
import io.github.taetae98coding.diary.feature.more.moreNavigation
import io.github.taetae98coding.diary.feature.tag.tagNavigation

@Composable
internal fun AppNavHost(
Expand All @@ -21,6 +22,7 @@ internal fun AppNavHost(
modifier = modifier,
) {
memoNavigation(navController = state.navController)
tagNavigation(navController = state.navController)
calendarNavigation(navController = state.navController)
moreNavigation(navController = state.navController)
accountNavigation(navController = state.navController)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ package io.github.taetae98coding.diary.app.navigation
import io.github.taetae98coding.diary.core.navigation.calendar.CalendarDestination
import io.github.taetae98coding.diary.core.navigation.memo.MemoDestination
import io.github.taetae98coding.diary.core.navigation.more.MoreDestination
import io.github.taetae98coding.diary.core.navigation.tag.TagDestination
import io.github.taetae98coding.diary.core.resources.Res
import io.github.taetae98coding.diary.core.resources.calendar
import io.github.taetae98coding.diary.core.resources.memo
import io.github.taetae98coding.diary.core.resources.more
import io.github.taetae98coding.diary.core.resources.tag
import org.jetbrains.compose.resources.StringResource

internal enum class AppNavigation(
Expand All @@ -18,6 +20,11 @@ internal enum class AppNavigation(
route = MemoDestination,
),

Tag(
title = Res.string.tag,
route = TagDestination,
),

Calendar(
title = Res.string.calendar,
route = CalendarDestination,
Expand Down
Loading

0 comments on commit 06913ab

Please sign in to comment.