Updated on 2026-08-14
This commit is contained in:
parent
326352be30
commit
75e2b0b554
27 changed files with 194 additions and 2 deletions
|
|
@ -0,0 +1,11 @@
|
|||
package com.tangem.core.ui.haptic
|
||||
|
||||
import androidx.compose.runtime.Stable
|
||||
|
||||
@Stable
|
||||
interface HapticManager {
|
||||
|
||||
fun vibrateShort()
|
||||
|
||||
fun vibrateLong()
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
package com.tangem.core.ui.haptic
|
||||
|
||||
object MockHapticManager : HapticManager {
|
||||
|
||||
override fun vibrateShort() {
|
||||
/** Intentionnaly do nothing */
|
||||
}
|
||||
|
||||
override fun vibrateLong() {
|
||||
/** Intentionnaly do nothing */
|
||||
}
|
||||
}
|
||||
|
|
@ -4,6 +4,8 @@ import androidx.compose.material.Colors
|
|||
import androidx.compose.material.MaterialTheme
|
||||
import androidx.compose.material.ProvideTextStyle
|
||||
import androidx.compose.runtime.*
|
||||
import com.tangem.core.ui.haptic.HapticManager
|
||||
import com.tangem.core.ui.haptic.MockHapticManager
|
||||
|
||||
// TODO: use isSystemInDarkTheme() for automatic color detection
|
||||
internal const val IS_SYSTEM_IN_DARK_THEME: Boolean = false
|
||||
|
|
@ -13,6 +15,7 @@ fun TangemTheme(
|
|||
isDark: Boolean = false,
|
||||
typography: TangemTypography = TangemTheme.typography,
|
||||
dimens: TangemDimens = TangemTheme.dimens,
|
||||
hapticManager: HapticManager = MockHapticManager,
|
||||
content: @Composable () -> Unit,
|
||||
) {
|
||||
val themeColors = if (isDark) darkThemeColors() else lightThemeColors()
|
||||
|
|
@ -29,6 +32,7 @@ fun TangemTheme(
|
|||
LocalTangemDimens provides dimens,
|
||||
LocalTangemShapes provides shapes,
|
||||
LocalIsInDarkTheme provides isDark,
|
||||
LocalHapticManager provides hapticManager,
|
||||
) {
|
||||
ProvideTextStyle(
|
||||
value = TangemTheme.typography.body1,
|
||||
|
|
@ -196,4 +200,8 @@ private val LocalTangemShapes = staticCompositionLocalOf<TangemShapes> {
|
|||
error("No TangemShapes provided")
|
||||
}
|
||||
|
||||
val LocalIsInDarkTheme = staticCompositionLocalOf { false }
|
||||
val LocalIsInDarkTheme = staticCompositionLocalOf { false }
|
||||
|
||||
val LocalHapticManager = staticCompositionLocalOf<HapticManager> {
|
||||
error("No HapticManager provided")
|
||||
}
|
||||
|
|
@ -8,6 +8,7 @@ import androidx.compose.runtime.ReadOnlyComposable
|
|||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.ComposeView
|
||||
import com.tangem.core.ui.haptic.HapticManager
|
||||
import com.tangem.core.ui.res.TangemTheme
|
||||
import com.tangem.core.ui.theme.AppThemeModeHolder
|
||||
import com.tangem.domain.apptheme.model.AppThemeMode
|
||||
|
|
@ -26,6 +27,11 @@ internal interface ComposeScreen {
|
|||
*/
|
||||
val appThemeModeHolder: AppThemeModeHolder
|
||||
|
||||
/**
|
||||
* Haptic manager.
|
||||
*/
|
||||
val hapticManager: HapticManager
|
||||
|
||||
/**
|
||||
* The screen modifier.
|
||||
*/
|
||||
|
|
@ -55,7 +61,10 @@ internal fun ComposeScreen.createComposeView(context: Context): ComposeView {
|
|||
setContent {
|
||||
val appThemeMode by appThemeModeHolder.appThemeMode
|
||||
|
||||
TangemTheme(isDark = shouldUseDarkTheme(appThemeMode)) {
|
||||
TangemTheme(
|
||||
isDark = shouldUseDarkTheme(appThemeMode),
|
||||
hapticManager = hapticManager,
|
||||
) {
|
||||
ScreenContent(modifier = screenModifier)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue