-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
acb3b8d
commit 06913ab
Showing
18 changed files
with
287 additions
and
2 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
...rc/commonMain/kotlin/io/github/taetae98coding/diary/core/navigation/tag/TagDestination.kt
This file contains 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,6 @@ | ||
package io.github.taetae98coding.diary.core.navigation.tag | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
public data object TagDestination |
This file contains 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
This file contains 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
18 changes: 18 additions & 0 deletions
18
...urces/src/commonMain/kotlin/io/github/taetae98coding/diary/core/resources/icon/TagIcon.kt
This file contains 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,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, | ||
) | ||
} |
This file contains 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
This file contains 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,16 @@ | ||
plugins { | ||
id("diary.app.feature") | ||
} | ||
|
||
kotlin { | ||
sourceSets { | ||
commonMain { | ||
dependencies { | ||
} | ||
} | ||
} | ||
} | ||
|
||
android { | ||
namespace = "${Build.NAMESPACE}.feature.tag" | ||
} |
14 changes: 14 additions & 0 deletions
14
...ure/tag/src/commonMain/kotlin/io/github/taetae98coding/diary/feature/tag/TagNavigation.kt
This file contains 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,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() | ||
} | ||
} |
93 changes: 93 additions & 0 deletions
93
app/feature/tag/src/commonMain/kotlin/io/github/taetae98coding/diary/feature/tag/TagRoute.kt
This file contains 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,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, | ||
) | ||
} |
6 changes: 6 additions & 0 deletions
6
...nMain/kotlin/io/github/taetae98coding/diary/feature/tag/detail/TagDetailFloatingButton.kt
This file contains 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,6 @@ | ||
package io.github.taetae98coding.diary.feature.tag.detail | ||
|
||
internal sealed class TagDetailFloatingButton { | ||
data object None : TagDetailFloatingButton() | ||
data class Add(val onAdd: () -> Unit) : TagDetailFloatingButton() | ||
} |
6 changes: 6 additions & 0 deletions
6
...ain/kotlin/io/github/taetae98coding/diary/feature/tag/detail/TagDetailNavigationButton.kt
This file contains 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,6 @@ | ||
package io.github.taetae98coding.diary.feature.tag.detail | ||
|
||
internal sealed class TagDetailNavigationButton { | ||
data object None : TagDetailNavigationButton() | ||
data class NavigateUp(val onNavigateUp: () -> Unit) : TagDetailNavigationButton() | ||
} |
51 changes: 51 additions & 0 deletions
51
...rc/commonMain/kotlin/io/github/taetae98coding/diary/feature/tag/detail/TagDetailScreen.kt
This file contains 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,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 | ||
} | ||
}, | ||
) { | ||
|
||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
...ommonMain/kotlin/io/github/taetae98coding/diary/feature/tag/list/TagListFloatingButton.kt
This file contains 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,6 @@ | ||
package io.github.taetae98coding.diary.feature.tag.list | ||
|
||
internal sealed class TagListFloatingButton { | ||
data object None : TagListFloatingButton() | ||
data class Add(val onAdd: () -> Unit) : TagListFloatingButton() | ||
} |
51 changes: 51 additions & 0 deletions
51
...ag/src/commonMain/kotlin/io/github/taetae98coding/diary/feature/tag/list/TagListScreen.kt
This file contains 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,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 = "태그 없어") | ||
} | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.