From ecda08388330f8240f719126c26a88c1dc9228ec Mon Sep 17 00:00:00 2001 From: Avently <7953703+avently@users.noreply.github.com> Date: Wed, 5 Oct 2022 22:21:35 +0300 Subject: [PATCH] Testing idea --- .../java/chat/simplex/app/MainActivity.kt | 29 ++++++++++++++----- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/apps/android/app/src/main/java/chat/simplex/app/MainActivity.kt b/apps/android/app/src/main/java/chat/simplex/app/MainActivity.kt index a23590f408..54d69a088b 100644 --- a/apps/android/app/src/main/java/chat/simplex/app/MainActivity.kt +++ b/apps/android/app/src/main/java/chat/simplex/app/MainActivity.kt @@ -7,8 +7,10 @@ import android.os.Bundle import android.os.Parcelable import android.os.SystemClock.elapsedRealtime import android.util.Log +import androidx.activity.compose.BackHandler import androidx.activity.compose.setContent import androidx.activity.viewModels +import androidx.compose.animation.core.* import androidx.compose.foundation.background import androidx.compose.foundation.layout.* import androidx.compose.material.MaterialTheme @@ -20,6 +22,7 @@ import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource +import androidx.compose.ui.unit.dp import androidx.fragment.app.FragmentActivity import androidx.lifecycle.* import chat.simplex.app.model.ChatModel @@ -36,6 +39,7 @@ import chat.simplex.app.views.helpers.* import chat.simplex.app.views.newchat.connectViaUri import chat.simplex.app.views.newchat.withUriAction import chat.simplex.app.views.onboarding.* +import chat.simplex.app.views.usersettings.SettingsView import kotlinx.coroutines.delay class MainActivity: FragmentActivity() { @@ -327,13 +331,24 @@ 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) + BoxWithConstraints { + val offset1 by animateDpAsState(if (chatModel.chatId.value != null) -maxWidth else 0.dp, + //tween(durationMillis = 250, easing = FastOutSlowInEasing) + ) + val offset2 by animateDpAsState(if (chatModel.chatId.value != null) 0.dp else maxWidth, + //tween(durationMillis = 250, easing = FastOutSlowInEasing) + ) + Column(Modifier.offset(x = offset1)) { + if (chatModel.chatId.value == null) { + if (chatModel.sharedContent.value == null) + ChatListView(chatModel, setPerformLA, stopped) + else + ShareListView(chatModel, stopped) + } + } + Column(Modifier.offset(x = offset2)) { + if (chatModel.chatId.value != null) ChatView(chatModel.chatId.value!!, chatModel) + } } } }