Skip to content

Commit

Permalink
Changes based on review
Browse files Browse the repository at this point in the history
  • Loading branch information
elijah-semyonov committed Apr 10, 2024
1 parent 0f5cf38 commit 1f4ad7d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import platform.UIKit.UISelectionFeedbackGenerator
// TODO: minor UX improvement, add `prepare()` calls when internal APIs are likely to use HapticFeedback
// (e.g. pan started during the text selection) to reduce haptic feedback latency
// see https://developer.apple.com/documentation/uikit/uifeedbackgenerator
internal fun HapticFeedback() = object : HapticFeedback {
internal class CupertinoHapticFeedback : HapticFeedback {
private val impactGenerator = UIImpactFeedbackGenerator()
private val selectionGenerator = UISelectionFeedbackGenerator()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import androidx.compose.runtime.MutableState
import androidx.compose.runtime.mutableStateOf
import androidx.compose.ui.LocalSystemTheme
import androidx.compose.ui.SystemTheme
import androidx.compose.ui.hapticfeedback.HapticFeedback
import androidx.compose.ui.hapticfeedback.CupertinoHapticFeedback
import androidx.compose.ui.interop.LocalUIViewController
import androidx.compose.ui.interop.UIKitInteropContext
import androidx.compose.ui.platform.LocalHapticFeedback
Expand Down Expand Up @@ -98,6 +98,7 @@ internal class ComposeContainer(
private val content: @Composable () -> Unit,
) : CMPViewController(nibName = null, bundle = null) {
val lifecycleOwner = ViewControllerBasedLifecycleOwner()
val hapticFeedback = CupertinoHapticFeedback()

private var isInsideSwiftUI = false
private var mediator: ComposeSceneMediator? = null
Expand Down Expand Up @@ -428,7 +429,7 @@ internal fun ProvideContainerCompositionLocals(
content: @Composable () -> Unit,
) = with(composeContainer) {
CompositionLocalProvider(
LocalHapticFeedback provides HapticFeedback(),
LocalHapticFeedback provides hapticFeedback,
LocalUIViewController provides this,
LocalInterfaceOrientation provides interfaceOrientationState.value,
LocalSystemTheme provides systemThemeState.value,
Expand Down

0 comments on commit 1f4ad7d

Please sign in to comment.