-
-
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
e248ecb
commit bff6f83
Showing
7 changed files
with
312 additions
and
8 deletions.
There are no files selected for viewing
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
118 changes: 118 additions & 0 deletions
118
.../io/github/reactivecircus/kstreamlined/android/designsystem/component/NavigationIsland.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,118 @@ | ||
package io.github.reactivecircus.kstreamlined.android.designsystem.component | ||
|
||
import androidx.compose.foundation.clickable | ||
import androidx.compose.foundation.interaction.MutableInteractionSource | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.IntrinsicSize | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.RowScope | ||
import androidx.compose.foundation.layout.height | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.layout.size | ||
import androidx.compose.foundation.shape.CircleShape | ||
import androidx.compose.material.ripple.rememberRipple | ||
import androidx.compose.material3.minimumInteractiveComponentSize | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.vector.ImageVector | ||
import androidx.compose.ui.semantics.Role | ||
import androidx.compose.ui.tooling.preview.PreviewLightDark | ||
import androidx.compose.ui.unit.dp | ||
import io.github.reactivecircus.kstreamlined.android.designsystem.foundation.KSTheme | ||
import io.github.reactivecircus.kstreamlined.android.designsystem.foundation.icon.Bookmarks | ||
import io.github.reactivecircus.kstreamlined.android.designsystem.foundation.icon.KSIcons | ||
import io.github.reactivecircus.kstreamlined.android.designsystem.foundation.icon.Kotlin | ||
|
||
@Composable | ||
public fun NavigationIsland( | ||
modifier: Modifier = Modifier, | ||
items: @Composable RowScope.() -> Unit, | ||
) { | ||
Surface( | ||
modifier = modifier, | ||
shape = CircleShape, | ||
color = KSTheme.colorScheme.containerInverse, | ||
contentColor = KSTheme.colorScheme.onContainerInverse, | ||
elevation = 4.dp, | ||
) { | ||
Row( | ||
modifier = Modifier.height(IntrinsicSize.Min), | ||
verticalAlignment = Alignment.CenterVertically, | ||
) { | ||
items() | ||
} | ||
} | ||
} | ||
|
||
@Composable | ||
public fun NavigationIslandItem( | ||
selected: Boolean, | ||
icon: ImageVector, | ||
contentDescription: String?, | ||
onClick: () -> Unit, | ||
modifier: Modifier = Modifier, | ||
) { | ||
Box( | ||
modifier = modifier | ||
.minimumInteractiveComponentSize() | ||
.size(72.dp) | ||
.clickable( | ||
onClick = onClick, | ||
role = Role.Button, | ||
interactionSource = remember { MutableInteractionSource() }, | ||
indication = rememberRipple( | ||
bounded = false, | ||
radius = 40.dp, | ||
), | ||
), | ||
contentAlignment = Alignment.Center, | ||
) { | ||
Icon( | ||
imageVector = icon, | ||
contentDescription = contentDescription, | ||
tint = if (selected) { | ||
KSTheme.colorScheme.primary | ||
} else { | ||
KSTheme.colorScheme.onContainerInverse | ||
}, | ||
) | ||
} | ||
} | ||
|
||
@Composable | ||
public fun NavigationIslandDivider( | ||
modifier: Modifier = Modifier, | ||
) { | ||
VerticalDivider( | ||
modifier = modifier.height(16.dp), | ||
color = KSTheme.colorScheme.onContainerInverse, | ||
) | ||
} | ||
|
||
@Composable | ||
@PreviewLightDark | ||
private fun PreviewNavigationIsland() { | ||
KSTheme { | ||
Surface { | ||
NavigationIsland( | ||
modifier = Modifier.padding(8.dp), | ||
) { | ||
NavigationIslandItem( | ||
selected = true, | ||
icon = KSIcons.Kotlin, | ||
contentDescription = "Home", | ||
onClick = {}, | ||
) | ||
NavigationIslandDivider() | ||
NavigationIslandItem( | ||
selected = false, | ||
icon = KSIcons.Bookmarks, | ||
contentDescription = "Saved", | ||
onClick = {}, | ||
) | ||
} | ||
} | ||
} | ||
} |
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
41 changes: 41 additions & 0 deletions
41
...a/io/github/reactivecircus/kstreamlined/android/designsystem/foundation/icon/Bookmarks.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,41 @@ | ||
package io.github.reactivecircus.kstreamlined.android.designsystem.foundation.icon | ||
|
||
import androidx.compose.material.icons.materialIcon | ||
import androidx.compose.material.icons.materialPath | ||
import androidx.compose.ui.graphics.vector.ImageVector | ||
|
||
/** | ||
* Copied from `androidx.compose.material.icons.rounded.Bookmarks`. | ||
*/ | ||
public val KSIcons.Bookmarks: ImageVector | ||
get() { | ||
if (_bookmarks != null) { | ||
return _bookmarks!! | ||
} | ||
_bookmarks = materialIcon(name = "Rounded.Bookmarks") { | ||
materialPath { | ||
moveTo(19.0f, 18.0f) | ||
lineToRelative(2.0f, 1.0f) | ||
verticalLineTo(3.0f) | ||
curveToRelative(0.0f, -1.1f, -0.9f, -2.0f, -2.0f, -2.0f) | ||
horizontalLineTo(8.99f) | ||
curveTo(7.89f, 1.0f, 7.0f, 1.9f, 7.0f, 3.0f) | ||
horizontalLineToRelative(10.0f) | ||
curveToRelative(1.1f, 0.0f, 2.0f, 0.9f, 2.0f, 2.0f) | ||
verticalLineToRelative(13.0f) | ||
close() | ||
moveTo(15.0f, 5.0f) | ||
horizontalLineTo(5.0f) | ||
curveToRelative(-1.1f, 0.0f, -2.0f, 0.9f, -2.0f, 2.0f) | ||
verticalLineToRelative(16.0f) | ||
lineToRelative(7.0f, -3.0f) | ||
lineToRelative(7.0f, 3.0f) | ||
verticalLineTo(7.0f) | ||
curveToRelative(0.0f, -1.1f, -0.9f, -2.0f, -2.0f, -2.0f) | ||
close() | ||
} | ||
} | ||
return _bookmarks!! | ||
} | ||
|
||
private var _bookmarks: ImageVector? = null |
38 changes: 38 additions & 0 deletions
38
.../github/reactivecircus/kstreamlined/android/designsystem/foundation/icon/KSIconBuilder.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,38 @@ | ||
package io.github.reactivecircus.kstreamlined.android.designsystem.foundation.icon | ||
|
||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.graphics.PathFillType | ||
import androidx.compose.ui.graphics.SolidColor | ||
import androidx.compose.ui.graphics.StrokeCap | ||
import androidx.compose.ui.graphics.StrokeJoin | ||
import androidx.compose.ui.graphics.vector.ImageVector | ||
import androidx.compose.ui.graphics.vector.addPathNodes | ||
import androidx.compose.ui.unit.dp | ||
|
||
internal fun ksIcon( | ||
name: String, | ||
pathData: List<PathData>, | ||
) = ImageVector.Builder( | ||
name = name, | ||
defaultWidth = IconSize.dp, | ||
defaultHeight = IconSize.dp, | ||
viewportWidth = IconSize, | ||
viewportHeight = IconSize, | ||
).apply { | ||
pathData.forEach { | ||
addPath( | ||
pathData = addPathNodes(it.path), | ||
pathFillType = it.fillType, | ||
fill = SolidColor(Color.Black), | ||
stroke = null, | ||
strokeLineWidth = 1f, | ||
strokeLineCap = StrokeCap.Butt, | ||
strokeLineJoin = StrokeJoin.Bevel, | ||
strokeLineMiter = 1f, | ||
) | ||
} | ||
}.build() | ||
|
||
internal class PathData(val path: String, val fillType: PathFillType) | ||
|
||
private const val IconSize = 24f |
23 changes: 23 additions & 0 deletions
23
...java/io/github/reactivecircus/kstreamlined/android/designsystem/foundation/icon/Kotlin.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,23 @@ | ||
package io.github.reactivecircus.kstreamlined.android.designsystem.foundation.icon | ||
|
||
import androidx.compose.ui.graphics.vector.DefaultFillType | ||
import androidx.compose.ui.graphics.vector.ImageVector | ||
|
||
public val KSIcons.Kotlin: ImageVector | ||
get() { | ||
if (_kotlin != null) { | ||
return _kotlin!! | ||
} | ||
_kotlin = ksIcon( | ||
name = "Kotlin", | ||
pathData = listOf( | ||
PathData( | ||
"M22 22H2V2H22L12 12L22 22Z", | ||
DefaultFillType, | ||
), | ||
) | ||
) | ||
return _kotlin!! | ||
} | ||
|
||
private var _kotlin: ImageVector? = null |
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