Skip to content

Commit

Permalink
Switch input/output with drag
Browse files Browse the repository at this point in the history
  • Loading branch information
mdrlzy committed Dec 22, 2024
1 parent b73d7e9 commit f070f82
Show file tree
Hide file tree
Showing 7 changed files with 332 additions and 108 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,6 @@ object ArkColor {
val UtilitySuccess200 = Color(0xFFABEFC6)
val UtilitySuccess500 = Color(0xFF17B26A)
val UtilitySuccess700 = Color(0xFF067647)

val NeutralGray500 = Color(0xFF6C737F)
}
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
}
30 changes: 30 additions & 0 deletions core/presentation/src/main/res/drawable/ic_drag.xml
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>
1 change: 1 addition & 0 deletions feature/quick/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ dependencies {
implementation(libs.androidx.lifecycle.runtime.ktx)
implementation(libs.androidx.activity.compose)
implementation(libs.constraintlayout.compose)
implementation(libs.reorderable)

implementation(libs.timber)

Expand Down
Loading

0 comments on commit f070f82

Please sign in to comment.