Package 

Class RotaryKt

    • Method Detail

      • rotaryWithFling

        @Composable() final static Modifier rotaryWithFling(Modifier $self, FocusRequester focusRequester, ScrollableState scrollableState, FlingBehavior flingBehavior, RotaryHapticFeedback rotaryHaptics, Boolean reverseDirection)

        A modifier which connects rotary events with scrollable. This modifier supports fling.

        Fling algorithm:

        • A scroll with RSB/ Bezel happens.

        • If this is a first rotary event after the threshold ( by default 200ms), a new scroll session starts by resetting all necessary parameters

        • A delta value is added into VelocityTracker and a new speed is calculated.

        • If the current speed is bigger than the previous one, this value is remembered as a latest fling speed with a timestamp

        • After each scroll event a fling countdown starts ( by default 70ms) which resets if new scroll event is received

        • If fling countdown is finished - it means that the finger was probably raised from RSB, there will be no other events and probably this is the last event during this session. After it a fling is triggered.

        • Fling is stopped when a new scroll event happens

        The screen containing the scrollable item should request the focus by calling requestFocus method

        LaunchedEffect(Unit) {
          focusRequester.requestFocus()
        }
        Parameters:
        focusRequester - Requests the focus for rotary input
        scrollableState - Scrollable state which will be scrolled while receiving rotary events
        flingBehavior - Logic describing fling behavior.
        rotaryHaptics - Class which will handle haptic feedback
        reverseDirection - Reverse the direction of scrolling.
      • rotaryWithScroll

        @Composable() final static Modifier rotaryWithScroll(Modifier $self, FocusRequester focusRequester, ScrollableState scrollableState, RotaryHapticFeedback rotaryHaptics, Boolean reverseDirection)

        A modifier which connects rotary events with scrollable. This modifier only supports scroll without fling or snap. The screen containing the scrollable item should request the focus by calling requestFocus method

        LaunchedEffect(Unit) {
          focusRequester.requestFocus()
        }
        Parameters:
        focusRequester - Requests the focus for rotary input
        scrollableState - Scrollable state which will be scrolled while receiving rotary events
        rotaryHaptics - Class which will handle haptic feedback
        reverseDirection - Reverse the direction of scrolling.
      • rotaryWithSnap

        @Composable() final static Modifier rotaryWithSnap(Modifier $self, FocusRequester focusRequester, RotaryScrollAdapter rotaryScrollAdapter, RotaryHapticFeedback rotaryHaptics, Boolean reverseDirection)

        A modifier which connects rotary events with scrollable. This modifier supports snap.

        The screen containing the scrollable item should request the focus by calling requestFocus method

        LaunchedEffect(Unit) {
          focusRequester.requestFocus()
        }
        Parameters:
        focusRequester - Requests the focus for rotary input
        rotaryScrollAdapter - A connection between scrollable objects and rotary events
        rotaryHaptics - Class which will handle haptic feedback
        reverseDirection - Reverse the direction of scrolling.
      • rotaryHandler

         final static Modifier rotaryHandler(Modifier $self, RotaryScrollHandler rotaryScrollHandler, Long batchTimeframe, Boolean reverseDirection, RotaryHapticFeedback rotaryHaptics)

        A modifier which handles rotary events. It accepts ScrollHandler as the input - a class where main logic about how scroll should be handled is lying