Skip to content

Commit

Permalink
Merge pull request #706 from navratan-soni/sc_reader_issue
Browse files Browse the repository at this point in the history
[PLATIR-41103] Added dialog for correct screen reader case
  • Loading branch information
prudrabhat authored Aug 23, 2024
2 parents 4639ee4 + b7e4b39 commit 11fe509
Showing 1 changed file with 58 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ import android.webkit.WebView
import androidx.activity.compose.BackHandler
import androidx.compose.animation.core.MutableTransitionState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.SideEffect
import androidx.compose.runtime.remember
import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.window.Dialog
import androidx.compose.ui.window.DialogProperties
import androidx.compose.ui.window.DialogWindowProvider
import com.adobe.marketing.mobile.services.ui.Presentable
import com.adobe.marketing.mobile.services.ui.common.PresentationStateManager
import com.adobe.marketing.mobile.services.ui.message.GestureTracker
Expand Down Expand Up @@ -67,7 +72,8 @@ internal fun MessageScreen(
inAppMessageSettings = inAppMessageSettings,
gestureTracker = gestureTracker,
onCreated = { onCreated(it) },
onDisposed = { onDisposed() }
onDisposed = { onDisposed() },
onBackPressed = onBackPressed
)
}

Expand All @@ -85,23 +91,61 @@ internal fun Message(
inAppMessageSettings: InAppMessageSettings,
gestureTracker: GestureTracker,
onCreated: (WebView) -> Unit,
onDisposed: () -> Unit
onDisposed: () -> Unit,
onBackPressed: () -> Unit
) {
// Backdrop for the InAppMessage only takes into effect if the InAppMessage is taking over the UI
if (inAppMessageSettings.shouldTakeOverUi) {
MessageBackdrop(
/* Dialog is used to take over the UI when the InAppMessage is set to take over the UI.
This is necessary to ensure that the InAppMessage is displayed on top of the UI.
Which will ensure that ScreenReader can read the content of the InAppMessage only and not the underlying UI.
*/
Dialog(
properties = DialogProperties(
usePlatformDefaultWidth = false,
dismissOnBackPress = true,
dismissOnClickOutside = false
),
onDismissRequest = {
onBackPressed()
}
) {
/* Remove the default dim and animations for the dialog window
Customer can set their own dim and animations if needed and those will be honoured in MessageBackdrop inside Message
*/

val dialogWindow = (LocalView.current.parent as? DialogWindowProvider)?.window

SideEffect {
dialogWindow?.let {
it.setDimAmount(0f)
it.setWindowAnimations(-1)
}
}

// Backdrop for the InAppMessage only takes into effect if the InAppMessage is taking over the UI
MessageBackdrop(
visibility = isVisible,
inAppMessageSettings = inAppMessageSettings,
gestureTracker = gestureTracker
)

// Frame that holds the InAppMessage
MessageFrame(
visibility = isVisible,
inAppMessageSettings = inAppMessageSettings,
gestureTracker = gestureTracker,
onCreated = onCreated,
onDisposed = onDisposed
)
}
} else {
// Frame that holds the InAppMessage
MessageFrame(
visibility = isVisible,
inAppMessageSettings = inAppMessageSettings,
gestureTracker = gestureTracker
gestureTracker = gestureTracker,
onCreated = onCreated,
onDisposed = onDisposed
)
}

// Frame that holds the InAppMessage
MessageFrame(
visibility = isVisible,
inAppMessageSettings = inAppMessageSettings,
gestureTracker = gestureTracker,
onCreated = onCreated,
onDisposed = onDisposed
)
}

0 comments on commit 11fe509

Please sign in to comment.