-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: interaction during screen transitions [WPB-6533] 🍒 (#3180)
Co-authored-by: Michał Saleniuk <[email protected]> Co-authored-by: Michał Saleniuk <[email protected]>
- Loading branch information
1 parent
3213876
commit d7c13fd
Showing
66 changed files
with
222 additions
and
133 deletions.
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
app/src/main/kotlin/com/wire/android/navigation/WaitUntilTransitionEndsWrapper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Wire | ||
* Copyright (C) 2024 Wire Swiss GmbH | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
package com.wire.android.navigation | ||
|
||
import androidx.compose.animation.EnterExitState | ||
import androidx.compose.animation.ExperimentalAnimationApi | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.LaunchedEffect | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.runtime.mutableStateOf | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.runtime.setValue | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.input.pointer.pointerInput | ||
import com.ramcosta.composedestinations.scope.AnimatedDestinationScope | ||
import com.ramcosta.composedestinations.scope.DestinationScope | ||
import com.ramcosta.composedestinations.wrapper.DestinationWrapper | ||
|
||
@OptIn(ExperimentalAnimationApi::class) | ||
object WaitUntilTransitionEndsWrapper : DestinationWrapper { | ||
|
||
@Composable | ||
override fun <T> DestinationScope<T>.Wrap(screenContent: @Composable () -> Unit) { | ||
(this as? AnimatedDestinationScope<T>)?.let { | ||
var transitionComplete by remember { mutableStateOf(false) } | ||
LaunchedEffect(transition.isRunning, transition.currentState, transition.targetState) { | ||
with(transition) { | ||
transitionComplete = !isRunning && currentState == targetState && currentState == EnterExitState.Visible | ||
} | ||
} | ||
screenContent() | ||
if (!transitionComplete) { | ||
Box( | ||
modifier = Modifier | ||
.fillMaxSize() | ||
.pointerInput(Unit) { | ||
// empty, do nothing to prevent clicks | ||
} | ||
) | ||
} | ||
} | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
app/src/main/kotlin/com/wire/android/navigation/WireDestination.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Wire | ||
* Copyright (C) 2024 Wire Swiss GmbH | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
package com.wire.android.navigation | ||
|
||
import com.ramcosta.composedestinations.annotation.DeepLink | ||
import com.ramcosta.composedestinations.annotation.Destination | ||
import com.ramcosta.composedestinations.annotation.Destination.Companion.COMPOSABLE_NAME | ||
import com.ramcosta.composedestinations.spec.DestinationStyle | ||
import com.ramcosta.composedestinations.wrapper.DestinationWrapper | ||
import kotlin.reflect.KClass | ||
|
||
@Destination | ||
annotation class WireDestination( | ||
val route: String = COMPOSABLE_NAME, | ||
val navArgsDelegate: KClass<*> = Nothing::class, | ||
val deepLinks: Array<DeepLink> = [], | ||
val style: KClass<out DestinationStyle> = DestinationStyle.Default::class, | ||
val wrappers: Array<KClass<out DestinationWrapper>> = [WaitUntilTransitionEndsWrapper::class], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.