-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Labels
enhancementNew feature or requestNew feature or request
Description
问题
过去的旧版本使用全局 Dialog 与全局 BottomSheetDialog 的方式,这导致了许多问题:
- 首次启动隐私协议弹窗的可点击链接点击后不能跳转 App 内浏览器,因为即使跳转了引导弹窗也不会消失,仍然在浏览器界面之上,只能打开外部浏览器查看
- 评论区查看子回复会展开 BottomSheetDialog,在其中点击用户头像会跳转到用户主页,此时需要将 BottomSheetDialog 关闭,如果不关闭它仍会显示在最顶部,而不是被用户主页的界面覆盖
解决方案
考虑到目前 Navigation 均使用了自己封装了一层的 animateCompose 方法,可以在该方法中使用 CompositionLocalProvider 提供 LocalDialog 与 LocalBottomSheetDialog,实现其每个页面的弹窗独立化,不再置于全局顶部
考虑修改以下代码
为:
@OptIn(ExperimentalAnimationApi::class)
fun NavGraphBuilder.animateCompose(
route: String,
arguments: List<NamedNavArgument> = emptyList(),
deepLinks: List<NavDeepLink> = emptyList(),
content: @Composable AnimatedVisibilityScope.(NavBackStackEntry) -> Unit
) =
composable(
route,
enterTransition = {
slideInHorizontally(initialOffsetX = { it }, animationSpec = animation)
},
exitTransition = {
slideOutHorizontally(targetOffsetX = { -it / 2 }, animationSpec = animation)
},
popEnterTransition = {
slideInHorizontally(initialOffsetX = { -it / 2 }, animationSpec = animation)
},
popExitTransition = {
slideOutHorizontally(targetOffsetX = { it }, animationSpec = animation)
},
arguments = arguments,
deepLinks = deepLinks,
content = {
+ // Wrap it with Dialog & BottomSheetDialog
content(it)
+ // Wrap it with Dialog & BottomSheetDialog
}
)Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request