Skip to content

Commit

Permalink
Merge pull request #19 from ltttttttttttt/dev
Browse files Browse the repository at this point in the history
Fix bug of BasicsProgressBar
  • Loading branch information
ltttttttttttt authored Oct 31, 2022
2 parents 87cc716 + b50ed07 commit b46ab2b
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 @@ -16,6 +16,7 @@

package com.lt.test_compose

import android.util.Log
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
Expand All @@ -24,6 +25,7 @@ import androidx.compose.material.Text
import androidx.compose.material.rememberDismissState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
Expand Down Expand Up @@ -61,7 +63,11 @@ class SwipeToDismissActivity : BaseComposeActivity() {
@Composable
private fun Star() {
var star by rememberMutableStateOf(value = 0)
StarBar(starValue = star, onStarValueChange = { star = it })
StarBar(
starValue = star,
onStarValueChange = { star = it },
onTouchUpEvent = remember { { Log.e("lllttt", "star=$star") } },
)
}

@OptIn(ExperimentalFoundationApi::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,11 @@ fun BasicsProgressBar(
state,
orientation,
userEnable,
interactionSource = if (onTouchUpEvent == null) null else DragInteractionSource {
if (it is DragInteraction.Stop || it is DragInteraction.Cancel)
onTouchUpEvent()
interactionSource = remember(onTouchUpEvent) {
if (onTouchUpEvent == null) null else DragInteractionSource {
if (it is DragInteraction.Stop || it is DragInteraction.Cancel)
onTouchUpEvent()
}
})
) {
content()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ fun StarBar(
onStarValueChange: (Int) -> Unit,
modifier: Modifier = Modifier,
maxStar: Int = 5,
starPainter: Painter = painterResource(id = R.drawable.star),
starSelectPainter: Painter = painterResource(id = R.drawable.star_select),
starPainter: Painter = painterResource(id = R.drawable.star_bar_star),
starSelectPainter: Painter = painterResource(id = R.drawable.star_bar_star_select),
starSize: Dp = 16.dp,
margin: Dp = 3.dp,
orientation: Orientation = Orientation.Horizontal,
Expand Down

0 comments on commit b46ab2b

Please sign in to comment.