-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using rotaryWithScroll and onRotaryInputAccumulatedWithFocus simultaneously #2112
Comments
They're both have the same input. So the can't. You will need to implement this yourself. What are you wanting to happen? |
I want to reset a CountDownTimer whenever the user interacts with the app which includes scrolling. |
You will need to look at the implementations of those and use some of the lower level APIs. if you make a sample screen, I can more easily suggest a change. |
@OptIn(ExperimentalHorologistApi::class, ExperimentalWearFoundationApi::class)
@Composable
fun SampleScreen(
modifier: Modifier = Modifier,
) {
val columnState = rememberColumnState()
val focusRequester = rememberActiveFocusRequester()
var showBlackScreenNow by remember { mutableStateOf(false) }
val screenTimeout: CountDownTimer = object : CountDownTimer(5000, 1000) {
override fun onTick(millisUntilFinished: Long) {}
override fun onFinish() {
showBlackScreenNow = true
}
}
Scaffold(modifier = modifier) {
ScalingLazyColumn(
modifier = Modifier
.fillMaxSize()
.rotaryWithScroll(columnState, focusRequester)
.onRotaryScrollEvent {
if (showBlackScreenNow) {
showBlackScreenNow = false
}
screenTimeout.cancel()
screenTimeout.start()
true
},
state = columnState.state
) {
item { Text(text = "...") }
}
if (showBlackScreenNow) {
Column(
modifier = Modifier
.fillMaxWidth()
.fillMaxHeight()
.wrapContentSize(Alignment.Center)
.clickable {
if (showBlackScreenNow) {
showBlackScreenNow = false
}
screenTimeout.cancel()
screenTimeout.start()
},
) {
Box(
modifier = Modifier
.fillMaxWidth()
.fillMaxHeight()
.clip(RectangleShape)
.background(Color.Black, RectangleShape)
)
}
}
}
} |
Thanks, I'll take a look. But it might be a couple of days. |
onRotaryInputAccumulatedWithFocus
does nothing whenrotaryWithScroll
is used too. So what's the best option to react to scrolling events?The text was updated successfully, but these errors were encountered: