reveal icon indicating copy to clipboard operation
reveal copied to clipboard

Stuck after changing UIMode light/dark

Open myounis97 opened this issue 1 year ago • 1 comments

Describe the bug After switching from/to light/dark mode the overlay view becomes not clickable and the content under the overlay becomes clickable

To Reproduce Steps to reproduce the behavior:

  1. Make sure the overlay is presented
  2. Switch the UIMode from the notifications drawer
  3. Click on the overlay
  4. See error

Expected behavior The overlay should intercept click events not the content behind it

Smartphone (please complete the following information):

  • All devices

Additional Context This line becomes null after configuration change val rev by rememberUpdatedState(currentRevealable.value)

So the launched effect only takes the alpha as key and it would not update the clickModifier

val clickModifier = when {
			revealState.isVisible && rev != null -> Modifier.pointerInput(Unit) {
				detectTapGestures(
					onPress = { offset ->
						rev?.key?.let(
							if (rev?.area?.contains(offset) == true) {
								rev?.onClick ?: onRevealableClick
							} else {
								onOverlayClick
							},
						)
					},
				)
			}

			else -> Modifier
		}

		LaunchedEffect(animatedOverlayAlpha) {
			@Suppress("ktlint:standard:wrapping")
			revealCanvasState.overlayContent = when {
				animatedOverlayAlpha > 0.0f -> ({
					overlayEffect.Overlay(
						revealState = revealState,
						currentRevealable = currentRevealable,
						previousRevealable = previousRevealable,
						modifier = clickModifier
							.semantics { testTag = "overlay" }
							.fillMaxSize()
							.alpha(animatedOverlayAlpha),
						content = overlayContent,
					)
				})

				else -> null
			}
		}

myounis97 avatar May 22 '24 09:05 myounis97

Hello @myounis97, thanks for the bug report. I can confirm this behavior. I will have a look into it 👀

svenjacobs avatar May 23 '24 05:05 svenjacobs

This has been fixed in #130.

You're right that rev briefly becomes null. That is if a configuration change like dark mode is not explicitly handled by an application, the Activity will be restarted. Then RevealState is restored, since it is saveable, and rev points to the revealable item again.

However for some reason clickModifier wasn't properly updated and was still the empty Modifier from the else branch. By removing rev != null from the condition the modifier is properly updated.

The fix will be available in version 3.0.7.

svenjacobs avatar May 24 '24 20:05 svenjacobs

@myounis97 By the way, what a funny coincidence that your library has a similar name 😁

svenjacobs avatar May 24 '24 20:05 svenjacobs

This has been fixed in #130.

You're right that rev briefly becomes null. That is if a configuration change like dark mode is not explicitly handled by an application, the Activity will be restarted. Then RevealState is restored, since it is saveable, and rev points to the revealable item again.

However for some reason clickModifier wasn't properly updated and was still the empty Modifier from the else branch. By removing rev != null from the condition the modifier is properly updated.

The fix will be available in version 3.0.7.

Thanks for your efforts 🚀

myounis97 avatar May 24 '24 20:05 myounis97