-
Notifications
You must be signed in to change notification settings - Fork 2
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
Showing
7 changed files
with
332 additions
and
108 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
53 changes: 53 additions & 0 deletions
53
core/presentation/src/main/java/dev/arkbuilders/rate/core/presentation/utils/Haptic.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,53 @@ | ||
package dev.arkbuilders.rate.core.presentation.utils | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.ui.platform.LocalView | ||
import androidx.core.view.HapticFeedbackConstantsCompat | ||
import androidx.core.view.ViewCompat | ||
|
||
enum class ReorderHapticFeedbackType { | ||
START, | ||
MOVE, | ||
END, | ||
} | ||
|
||
open class ReorderHapticFeedback { | ||
open fun performHapticFeedback(type: ReorderHapticFeedbackType) { | ||
// no-op | ||
} | ||
} | ||
|
||
@Composable | ||
fun rememberReorderHapticFeedback(): ReorderHapticFeedback { | ||
val view = LocalView.current | ||
|
||
val reorderHapticFeedback = | ||
remember { | ||
object : ReorderHapticFeedback() { | ||
override fun performHapticFeedback(type: ReorderHapticFeedbackType) { | ||
when (type) { | ||
ReorderHapticFeedbackType.START -> | ||
ViewCompat.performHapticFeedback( | ||
view, | ||
HapticFeedbackConstantsCompat.GESTURE_START, | ||
) | ||
|
||
ReorderHapticFeedbackType.MOVE -> | ||
ViewCompat.performHapticFeedback( | ||
view, | ||
HapticFeedbackConstantsCompat.SEGMENT_FREQUENT_TICK, | ||
) | ||
|
||
ReorderHapticFeedbackType.END -> | ||
ViewCompat.performHapticFeedback( | ||
view, | ||
HapticFeedbackConstantsCompat.GESTURE_END, | ||
) | ||
} | ||
} | ||
} | ||
} | ||
|
||
return reorderHapticFeedback | ||
} |
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,30 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="12dp" | ||
android:height="16dp" | ||
android:viewportWidth="12" | ||
android:viewportHeight="16"> | ||
<path | ||
android:pathData="M8,2.167C8,1.246 8.746,0.5 9.667,0.5C10.587,0.5 11.333,1.246 11.333,2.167C11.333,3.087 10.587,3.833 9.667,3.833C8.746,3.833 8,3.087 8,2.167Z" | ||
android:fillColor="#6C737F" | ||
android:fillType="evenOdd"/> | ||
<path | ||
android:pathData="M8,8C8,7.08 8.746,6.333 9.667,6.333C10.587,6.333 11.333,7.08 11.333,8C11.333,8.92 10.587,9.667 9.667,9.667C8.746,9.667 8,8.92 8,8Z" | ||
android:fillColor="#6C737F" | ||
android:fillType="evenOdd"/> | ||
<path | ||
android:pathData="M8,13.833C8,12.913 8.746,12.167 9.667,12.167C10.587,12.167 11.333,12.913 11.333,13.833C11.333,14.754 10.587,15.5 9.667,15.5C8.746,15.5 8,14.754 8,13.833Z" | ||
android:fillColor="#6C737F" | ||
android:fillType="evenOdd"/> | ||
<path | ||
android:pathData="M0.667,2.167C0.667,1.246 1.413,0.5 2.334,0.5C3.254,0.5 4,1.246 4,2.167C4,3.087 3.254,3.833 2.334,3.833C1.413,3.833 0.667,3.087 0.667,2.167Z" | ||
android:fillColor="#6C737F" | ||
android:fillType="evenOdd"/> | ||
<path | ||
android:pathData="M0.667,8C0.667,7.08 1.413,6.333 2.334,6.333C3.254,6.333 4,7.08 4,8C4,8.92 3.254,9.667 2.334,9.667C1.413,9.667 0.667,8.92 0.667,8Z" | ||
android:fillColor="#6C737F" | ||
android:fillType="evenOdd"/> | ||
<path | ||
android:pathData="M0.667,13.833C0.667,12.913 1.413,12.167 2.334,12.167C3.254,12.167 4,12.913 4,13.833C4,14.754 3.254,15.5 2.334,15.5C1.413,15.5 0.667,14.754 0.667,13.833Z" | ||
android:fillColor="#6C737F" | ||
android:fillType="evenOdd"/> | ||
</vector> |
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
Oops, something went wrong.