Updated on 2026-08-14
This commit is contained in:
commit
888d26029b
7 changed files with 224 additions and 36 deletions
|
|
@ -1,16 +1,30 @@
|
|||
package com.tangem.core.ui.haptic
|
||||
|
||||
object MockHapticManager : HapticManager {
|
||||
import androidx.compose.ui.hapticfeedback.HapticFeedback
|
||||
import androidx.compose.ui.hapticfeedback.HapticFeedbackType
|
||||
|
||||
@Suppress("FunctionName")
|
||||
fun MockHapticManager(mockHapticFeedback: HapticFeedback? = null): HapticManager =
|
||||
if (mockHapticFeedback == null) MockHapticManager else MockHapticManagerImpl(mockHapticFeedback)
|
||||
|
||||
val MockHapticManager: HapticManager = MockHapticManagerImpl()
|
||||
|
||||
private class MockHapticManagerImpl(
|
||||
private val mockHapticFeedback: HapticFeedback? = null,
|
||||
) : HapticManager {
|
||||
|
||||
override fun vibrateShort() {
|
||||
/** Intentionnaly do nothing */
|
||||
mockHapticFeedback?.performHapticFeedback(HapticFeedbackType.TextHandleMove)
|
||||
/** Intentionally do nothing */
|
||||
}
|
||||
|
||||
override fun vibrateMeduim() {
|
||||
/** Intentionnaly do nothing */
|
||||
mockHapticFeedback?.performHapticFeedback(HapticFeedbackType.TextHandleMove)
|
||||
/** Intentionally do nothing */
|
||||
}
|
||||
|
||||
override fun vibrateLong() {
|
||||
/** Intentionnaly do nothing */
|
||||
mockHapticFeedback?.performHapticFeedback(HapticFeedbackType.LongPress)
|
||||
/** Intentionally do nothing */
|
||||
}
|
||||
}
|
||||
|
|
@ -3,6 +3,8 @@ package com.tangem.core.ui.res
|
|||
import androidx.compose.foundation.isSystemInDarkTheme
|
||||
import androidx.compose.foundation.layout.BoxWithConstraints
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.platform.LocalHapticFeedback
|
||||
import com.tangem.core.ui.haptic.MockHapticManager
|
||||
import com.tangem.core.ui.windowsize.rememberWindowSizePreview
|
||||
|
||||
@Composable
|
||||
|
|
@ -20,6 +22,7 @@ fun TangemThemePreview(
|
|||
typography = typography,
|
||||
dimens = dimens,
|
||||
windowSize = rememberWindowSizePreview(maxWidth, maxHeight),
|
||||
hapticManager = MockHapticManager(LocalHapticFeedback.current),
|
||||
content = content,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue