ui: open a modal once when its button is double-clicked

A modal slides in over 250 ms, and until it covers the button that opened it the button still takes clicks, so a double click opened two copies (left-pane pages and most stacked center and right-pane pages on desktop, animated modals on Android). When a modal opens, the page it covers draws an empty pointerInput box over itself while it slides out; when a pane's first modal slides in, the empty page sliding out covers the view under the pane. The page sliding in already takes clicks, and nothing is blocked when a page closes.
This commit is contained in:
Narasimha-sc committed 2026-10-17 23:29:23 +00:00
1 parent 89ad9be7cb
commit d52e52bdd6
1 file changed
+5
@@ -9,6 +9,7 @@ import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.input.pointer.pointerInput
import chat.simplex.common.model.ChatController.appPrefs
import chat.simplex.common.platform.*
import LocalCardScreen
@@ -224,6 +225,10 @@ class ModalManager(private val placement: ModalPlacement? = null) {
if (toRemove.isNotEmpty() && it == modalCount.value && transition.currentState == EnterExitState.Visible && !transition.isRunning) {
runAtomically { toRemove.removeIf { elem -> modalViews.removeAt(elem); true } }
}
// Until the opening modal covers the page that opened it, or the view under the first modal, a second click there would open it again
if (transition.targetState == EnterExitState.PostExit && it < modalCount.value) {
Box(Modifier.fillMaxSize().pointerInput(Unit) {})
}
}
}