fix: prevent drawer gesture when not needed

This commit is contained in:
Diego Beraldin 2023-10-23 13:52:06 +02:00
parent 46baa4ec4c
commit 8efc873f62
8 changed files with 52 additions and 0 deletions

View File

@ -30,6 +30,7 @@ import androidx.compose.material3.TextFieldDefaults
import androidx.compose.material3.TopAppBar
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
@ -53,6 +54,7 @@ import com.github.diegoberaldin.raccoonforlemmy.core.appearance.di.getThemeRepos
import com.github.diegoberaldin.raccoonforlemmy.core.appearance.theme.Spacing
import com.github.diegoberaldin.raccoonforlemmy.core.architecture.bindToLifecycle
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.components.CustomImage
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.di.getDrawerCoordinator
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.di.getInboxChatViewModel
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.di.getNavigationCoordinator
import com.github.diegoberaldin.raccoonforlemmy.core.utils.onClick
@ -70,6 +72,13 @@ class InboxChatScreen(
val uiState by model.uiState.collectAsState()
val navigator = remember { getNavigationCoordinator().getRootNavigator() }
val focusManager = LocalFocusManager.current
val drawerCoordinator = remember { getDrawerCoordinator() }
DisposableEffect(key) {
drawerCoordinator.setGesturesEnabled(false)
onDispose {
drawerCoordinator.setGesturesEnabled(true)
}
}
Scaffold(
modifier = Modifier.background(MaterialTheme.colorScheme.background)

View File

@ -78,6 +78,7 @@ import com.github.diegoberaldin.raccoonforlemmy.core.commonui.components.Swipeab
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.createcomment.CreateCommentScreen
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.createpost.CreatePostScreen
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.di.getCommunityDetailViewModel
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.di.getDrawerCoordinator
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.di.getNavigationCoordinator
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.image.ZoomableImageScreen
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.instanceinfo.InstanceInfoScreen
@ -142,9 +143,12 @@ class CommunityDetailScreen(
val downvoteColor by themeRepository.downvoteColor.collectAsState()
val defaultUpvoteColor = MaterialTheme.colorScheme.primary
val defaultDownVoteColor = MaterialTheme.colorScheme.tertiary
val drawerCoordinator = remember { getDrawerCoordinator() }
DisposableEffect(key) {
drawerCoordinator.setGesturesEnabled(false)
onDispose {
notificationCenter.removeObserver(key)
drawerCoordinator.setGesturesEnabled(true)
}
}

View File

@ -85,6 +85,7 @@ import com.github.diegoberaldin.raccoonforlemmy.core.commonui.components.PostCar
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.components.SwipeableCard
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.createcomment.CreateCommentScreen
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.createpost.CreatePostScreen
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.di.getDrawerCoordinator
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.di.getNavigationCoordinator
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.di.getPostDetailViewModel
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.image.ZoomableImageScreen
@ -147,9 +148,12 @@ class PostDetailScreen(
}
}
val notificationCenter = remember { getNotificationCenter() }
val drawerCoordinator = remember { getDrawerCoordinator() }
DisposableEffect(key) {
drawerCoordinator.setGesturesEnabled(false)
onDispose {
notificationCenter.removeObserver(key)
drawerCoordinator.setGesturesEnabled(true)
}
}
val themeRepository = remember { getThemeRepository() }

View File

@ -32,6 +32,7 @@ import androidx.compose.material3.TopAppBar
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.material3.rememberTopAppBarState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
@ -58,6 +59,7 @@ import com.github.diegoberaldin.raccoonforlemmy.core.commonui.components.Floatin
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.components.PostCard
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.components.SectionSelector
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.createcomment.CreateCommentScreen
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.di.getDrawerCoordinator
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.di.getNavigationCoordinator
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.di.getSavedItemsViewModel
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.image.ZoomableImageScreen
@ -103,6 +105,13 @@ class SavedItemsScreen : Screen {
}
}
}
val drawerCoordinator = remember { getDrawerCoordinator() }
DisposableEffect(key) {
drawerCoordinator.setGesturesEnabled(false)
onDispose {
drawerCoordinator.setGesturesEnabled(true)
}
}
Scaffold(
topBar = {

View File

@ -78,6 +78,7 @@ import com.github.diegoberaldin.raccoonforlemmy.core.commonui.components.Section
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.components.SwipeableCard
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.components.UserHeader
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.createcomment.CreateCommentScreen
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.di.getDrawerCoordinator
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.di.getNavigationCoordinator
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.di.getUserDetailViewModel
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.image.ZoomableImageScreen
@ -139,9 +140,12 @@ class UserDetailScreen(
val downvoteColor by themeRepository.downvoteColor.collectAsState()
val defaultUpvoteColor = MaterialTheme.colorScheme.primary
val defaultDownVoteColor = MaterialTheme.colorScheme.tertiary
val drawerCoordinator = remember { getDrawerCoordinator() }
DisposableEffect(key) {
drawerCoordinator.setGesturesEnabled(false)
onDispose {
notificationCenter.removeObserver(key)
drawerCoordinator.setGesturesEnabled(true)
}
}
LaunchedEffect(model) {

View File

@ -37,6 +37,7 @@ import androidx.compose.material3.TopAppBar
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.material3.rememberTopAppBarState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
@ -60,6 +61,7 @@ import com.github.diegoberaldin.raccoonforlemmy.core.commonui.components.Floatin
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.components.FloatingActionButtonMenuItem
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.components.MultiCommunityItem
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.components.SwipeableCard
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.di.getDrawerCoordinator
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.di.getNavigationCoordinator
import com.github.diegoberaldin.raccoonforlemmy.core.utils.onClick
import com.github.diegoberaldin.raccoonforlemmy.feature.search.di.getManageSubscriptionsViewModel
@ -95,6 +97,13 @@ class ManageSubscriptionsScreen : Screen {
}
}
}
val drawerCoordinator = remember { getDrawerCoordinator() }
DisposableEffect(key) {
drawerCoordinator.setGesturesEnabled(false)
onDispose {
drawerCoordinator.setGesturesEnabled(true)
}
}
Scaffold(
topBar = {

View File

@ -70,6 +70,7 @@ import com.github.diegoberaldin.raccoonforlemmy.core.commonui.components.PostCar
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.components.PostCardPlaceholder
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.components.SwipeableCard
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.createcomment.CreateCommentScreen
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.di.getDrawerCoordinator
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.di.getNavigationCoordinator
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.image.ZoomableImageScreen
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.modals.SortBottomSheet
@ -123,9 +124,12 @@ class MultiCommunityScreen(
}
}
}
val drawerCoordinator = remember { getDrawerCoordinator() }
DisposableEffect(key) {
drawerCoordinator.setGesturesEnabled(false)
onDispose {
notificationCenter.removeObserver(key)
drawerCoordinator.setGesturesEnabled(true)
}
}

View File

@ -34,6 +34,7 @@ import androidx.compose.material3.TextField
import androidx.compose.material3.TextFieldDefaults
import androidx.compose.material3.TopAppBar
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
@ -58,6 +59,7 @@ import com.github.diegoberaldin.raccoonforlemmy.core.appearance.theme.Spacing
import com.github.diegoberaldin.raccoonforlemmy.core.architecture.bindToLifecycle
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.components.CommunityItem
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.components.CustomImage
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.di.getDrawerCoordinator
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.di.getNavigationCoordinator
import com.github.diegoberaldin.raccoonforlemmy.core.persistence.data.MultiCommunityModel
import com.github.diegoberaldin.raccoonforlemmy.core.utils.onClick
@ -89,6 +91,13 @@ class MultiCommunityEditorScreen(
}
}.launchIn(this)
}
val drawerCoordinator = remember { getDrawerCoordinator() }
DisposableEffect(key) {
drawerCoordinator.setGesturesEnabled(false)
onDispose {
drawerCoordinator.setGesturesEnabled(true)
}
}
Scaffold(
topBar = {