mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-03-31 05:25:47 +00:00
Experiments
This commit is contained in:
@@ -5,7 +5,7 @@ plugins {
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdk 32
|
||||
compileSdk 33
|
||||
|
||||
defaultConfig {
|
||||
applicationId "chat.simplex.app"
|
||||
@@ -113,6 +113,8 @@ dependencies {
|
||||
//Camera Permission
|
||||
implementation "com.google.accompanist:accompanist-permissions:0.23.0"
|
||||
|
||||
implementation "com.google.accompanist:accompanist-navigation-animation:0.26.4-beta"
|
||||
|
||||
// Link Previews
|
||||
implementation 'org.jsoup:jsoup:1.13.1'
|
||||
|
||||
|
||||
@@ -29,7 +29,6 @@ import chat.simplex.app.ui.theme.SimpleXTheme
|
||||
import chat.simplex.app.views.SplashView
|
||||
import chat.simplex.app.views.call.ActiveCallView
|
||||
import chat.simplex.app.views.call.IncomingCallAlertView
|
||||
import chat.simplex.app.views.chat.ChatView
|
||||
import chat.simplex.app.views.chatlist.*
|
||||
import chat.simplex.app.views.database.DatabaseErrorView
|
||||
import chat.simplex.app.views.helpers.*
|
||||
@@ -327,13 +326,12 @@ fun MainPage(
|
||||
else {
|
||||
showAdvertiseLAAlert = true
|
||||
val stopped = chatModel.chatRunning.value == false
|
||||
AnimateScreensNullable(chatModel.chatId) { currentChatId ->
|
||||
if (currentChatId == null) {
|
||||
if (chatModel.sharedContent.value == null)
|
||||
ChatListView(chatModel, setPerformLA, stopped)
|
||||
else
|
||||
ShareListView(chatModel, stopped)
|
||||
} else ChatView(currentChatId, chatModel)
|
||||
val nav = ExperimentalAnimationNav(chatModel, setPerformLA, stopped)
|
||||
val currentChatId = chatModel.chatId.value
|
||||
LaunchedEffect(currentChatId) {
|
||||
if (currentChatId == null && nav.backQueue.size == 2) nav.navigate("LEFT")
|
||||
else if (currentChatId == null) nav.popBackStack()
|
||||
else nav.navigate("RIGHT")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,12 @@ import androidx.compose.animation.core.FastOutSlowInEasing
|
||||
import androidx.compose.animation.core.tween
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.MutableState
|
||||
import androidx.navigation.NavHostController
|
||||
import chat.simplex.app.model.ChatModel
|
||||
import chat.simplex.app.views.chat.ChatView
|
||||
import chat.simplex.app.views.chatlist.ChatListView
|
||||
import chat.simplex.app.views.chatlist.ShareListView
|
||||
import com.google.accompanist.navigation.animation.*
|
||||
|
||||
@OptIn(ExperimentalAnimationApi::class)
|
||||
@Composable
|
||||
@@ -42,6 +48,83 @@ fun <S> AnimateScreensNullable(
|
||||
)
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalAnimationApi::class)
|
||||
@Composable
|
||||
fun ExperimentalAnimationNav(chatModel: ChatModel, setPerformLA: (Boolean) -> Unit, stopped: Boolean, ): NavHostController {
|
||||
val navController = rememberAnimatedNavController()
|
||||
AnimatedNavHost(navController, startDestination = "LEFT") {
|
||||
composable(
|
||||
"LEFT",
|
||||
enterTransition = {
|
||||
when (initialState.destination.route) {
|
||||
"RIGHT" ->
|
||||
slideIntoContainer(AnimatedContentScope.SlideDirection.Left, animationSpec = tween(700))
|
||||
else -> null
|
||||
}
|
||||
},
|
||||
exitTransition = {
|
||||
when (targetState.destination.route) {
|
||||
"RIGHT" ->
|
||||
slideOutOfContainer(AnimatedContentScope.SlideDirection.Left, animationSpec = tween(700))
|
||||
else -> null
|
||||
}
|
||||
},
|
||||
popEnterTransition = {
|
||||
when (initialState.destination.route) {
|
||||
"RIGHT" ->
|
||||
slideIntoContainer(AnimatedContentScope.SlideDirection.Right, animationSpec = tween(700))
|
||||
else -> null
|
||||
}
|
||||
},
|
||||
popExitTransition = {
|
||||
when (targetState.destination.route) {
|
||||
"RIGHT" ->
|
||||
slideOutOfContainer(AnimatedContentScope.SlideDirection.Right, animationSpec = tween(700))
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
) {
|
||||
if (chatModel.sharedContent.value == null)
|
||||
ChatListView(chatModel, setPerformLA, stopped)
|
||||
else
|
||||
ShareListView(chatModel, stopped)
|
||||
}
|
||||
composable(
|
||||
"RIGHT",
|
||||
enterTransition = {
|
||||
when (initialState.destination.route) {
|
||||
"LEFT" ->
|
||||
slideIntoContainer(AnimatedContentScope.SlideDirection.Left, animationSpec = tween(700))
|
||||
else -> null
|
||||
}
|
||||
},
|
||||
exitTransition = {
|
||||
when (targetState.destination.route) {
|
||||
"LEFT" ->
|
||||
slideOutOfContainer(AnimatedContentScope.SlideDirection.Left, animationSpec = tween(700))
|
||||
else -> null
|
||||
}
|
||||
},
|
||||
popEnterTransition = {
|
||||
when (initialState.destination.route) {
|
||||
"LEFT" ->
|
||||
slideIntoContainer(AnimatedContentScope.SlideDirection.Right, animationSpec = tween(700))
|
||||
else -> null
|
||||
}
|
||||
},
|
||||
popExitTransition = {
|
||||
when (targetState.destination.route) {
|
||||
"LEFT" ->
|
||||
slideOutOfContainer(AnimatedContentScope.SlideDirection.Right, animationSpec = tween(700))
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
) { ChatView("@2", chatModel) }
|
||||
}
|
||||
|
||||
return navController
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalAnimationApi::class)
|
||||
private fun fromStartToEndTransition() =
|
||||
slideInHorizontally(
|
||||
|
||||
Reference in New Issue
Block a user