Skip to content

Commit

Permalink
feat: pointer hover icon and optimize the details
Browse files Browse the repository at this point in the history
  • Loading branch information
Cdm2883 committed Jul 22, 2024
1 parent 7c0d61d commit 45318c5
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fun PanoramaBackground(content: @Composable BoxScope.() -> Unit) {
@OptIn(ExperimentalPanoramaApi::class)
@Composable
fun PanoramaBackground() {
val yaw by if (getPlatform() is Platform.WasmJs)
val yaw by if (getPlatform() !is Platform.Desktop)
remember { mutableFloatStateOf((8..55).random() * 0.1f) } // TODO wait for three.js support
else tickFloat(
begin = 0.8f,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ import androidx.compose.ui.window.Window
import androidx.compose.ui.window.application
import orecompose.example.generated.resources.Res
import orecompose.example.generated.resources.logo
import org.jetbrains.compose.resources.ExperimentalResourceApi
import org.jetbrains.compose.resources.painterResource

@OptIn(ExperimentalResourceApi::class)
fun main() = application {
Window(
onCloseRequest = ::exitApplication,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import androidx.compose.ui.geometry.Size
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.drawscope.ContentDrawScope
import androidx.compose.ui.graphics.drawscope.DrawScope
import androidx.compose.ui.input.pointer.PointerIcon
import androidx.compose.ui.input.pointer.pointerHoverIcon
import androidx.compose.ui.text.TextStyle
import vip.cdms.orecompose.effect.*
import vip.cdms.orecompose.style.*
Expand Down Expand Up @@ -117,6 +119,7 @@ fun Button(
enabled = enabled,
onClick = onClick
)
.run { if (enabled) pointerHoverIcon(PointerIcon.Hand) else this }
.padding(contentPadding),
Alignment.Center
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import androidx.compose.ui.draw.drawBehind
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.geometry.Size
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.input.pointer.PointerIcon
import androidx.compose.ui.input.pointer.pointerHoverIcon
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.unit.Dp
import vip.cdms.orecompose.effect.*
Expand Down Expand Up @@ -114,6 +116,7 @@ fun Toggle(
Modifier
.width(28.px)
.height(14.px)
.run { if (enabled) pointerHoverIcon(PointerIcon.Hand) else this }
.then(
if (onCheckedChange != null) Modifier.toggleable(
value = checked,
Expand Down
10 changes: 7 additions & 3 deletions oreui/src/commonMain/kotlin/vip/cdms/orecompose/layout/TopBar.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import androidx.compose.ui.geometry.Rect
import androidx.compose.ui.geometry.Size
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.input.pointer.PointerIcon
import androidx.compose.ui.input.pointer.pointerHoverIcon
import androidx.compose.ui.layout.onGloballyPositioned
import androidx.compose.ui.layout.positionInRoot
import androidx.compose.ui.text.ExperimentalTextApi
Expand All @@ -33,7 +35,7 @@ import vip.cdms.orecompose.style.OreTexts
import vip.cdms.orecompose.style.px
import vip.cdms.orecompose.utils.*

val TopBarLargeHeight @Composable get() = 28.px
val TopBarLargeHeight @Composable get() = 27.px

@Composable
fun TopBar(
Expand Down Expand Up @@ -121,6 +123,7 @@ fun TopBarNavigationButton(
onClick = onClick
)
.aspectRatio(1f, true)
.run { if (enabled) pointerHoverIcon(PointerIcon.Hand) else this }
.padding(contentPadding),
contentAlignment = Alignment.Center
) {
Expand Down Expand Up @@ -164,8 +167,9 @@ fun TopBarActionButton(
enabled = enabled,
onClick = onClick
)
.padding(horizontal = 9.px)
.padding(end = 1.px, bottom = 1.px),
.padding(end = 1.px, bottom = 1.px)
.run { if (enabled) pointerHoverIcon(PointerIcon.Hand) else this }
.padding(horizontal = 9.px),
horizontalArrangement = Arrangement.Center,
verticalAlignment = Alignment.CenterVertically
) {
Expand Down

0 comments on commit 45318c5

Please sign in to comment.