mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-04-09 21:16:04 +00:00
split android and desktop scaffold for picker
This commit is contained in:
@@ -1,19 +1,23 @@
|
||||
package chat.simplex.common.views.chatlist
|
||||
|
||||
import SectionItemView
|
||||
import androidx.compose.animation.*
|
||||
import androidx.compose.foundation.*
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.material.*
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.drawBehind
|
||||
import androidx.compose.ui.graphics.Brush
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.unit.dp
|
||||
import chat.simplex.common.model.User
|
||||
import chat.simplex.common.model.UserInfo
|
||||
import chat.simplex.common.platform.appPlatform
|
||||
import chat.simplex.common.ui.theme.*
|
||||
import chat.simplex.common.views.helpers.fontSizeSqrtMultiplier
|
||||
import chat.simplex.common.views.helpers.userPickerAnimSpec
|
||||
import chat.simplex.res.MR
|
||||
import dev.icerock.moko.resources.compose.painterResource
|
||||
import dev.icerock.moko.resources.compose.stringResource
|
||||
@@ -89,3 +93,30 @@ actual fun UserPickerInactiveUsersSection(
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
actual fun UserPickerScaffold(isVisible: Boolean, content: @Composable () -> Unit) {
|
||||
Box {
|
||||
AnimatedVisibility(
|
||||
visible = isVisible,
|
||||
enter = if (appPlatform.isAndroid) {
|
||||
slideInVertically(
|
||||
initialOffsetY = { it },
|
||||
animationSpec = userPickerAnimSpec()
|
||||
) + fadeIn(animationSpec = userPickerAnimSpec())
|
||||
} else {
|
||||
fadeIn()
|
||||
},
|
||||
exit = if (appPlatform.isAndroid) {
|
||||
slideOutVertically(
|
||||
targetOffsetY = { it },
|
||||
animationSpec = userPickerAnimSpec()
|
||||
) + fadeOut(animationSpec = userPickerAnimSpec())
|
||||
} else {
|
||||
fadeOut()
|
||||
}
|
||||
) {
|
||||
content()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -291,6 +291,7 @@ private fun GlobalSettingsSection(
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Composable
|
||||
fun UserPicker(
|
||||
chatModel: ChatModel,
|
||||
@@ -318,10 +319,9 @@ fun UserPicker(
|
||||
}
|
||||
val currentTheme by CurrentColors.collectAsState()
|
||||
val animatedFloat = remember { Animatable(if (newChat.isVisible()) 0f else 1f) }
|
||||
|
||||
val resultingColor by remember {
|
||||
derivedStateOf {
|
||||
if (currentTheme.colors.isLight) currentTheme.colors.onSurface.copy(alpha = ScrimOpacity)else Color.Black.copy(0.64f)
|
||||
if (currentTheme.colors.isLight) currentTheme.colors.onSurface.copy(alpha = ScrimOpacity) else Color.Black.copy(0.64f)
|
||||
}
|
||||
}
|
||||
val animatedColor = remember {
|
||||
@@ -437,32 +437,11 @@ fun UserPicker(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var drawerHeightPx by remember { mutableStateOf(0) }
|
||||
var offsetY by remember { mutableStateOf(0f) }
|
||||
|
||||
Box(
|
||||
if (appPlatform.isAndroid) Modifier.drawBehind { drawRect(animatedColor.value) } else Modifier
|
||||
) {
|
||||
AnimatedVisibility(
|
||||
visible = newChat.isVisible(),
|
||||
enter = if (appPlatform.isAndroid) {
|
||||
slideInVertically(
|
||||
initialOffsetY = { it },
|
||||
animationSpec = userPickerAnimSpec()
|
||||
) + fadeIn(animationSpec = userPickerAnimSpec())
|
||||
} else {
|
||||
fadeIn()
|
||||
},
|
||||
exit = if (appPlatform.isAndroid) {
|
||||
slideOutVertically(
|
||||
targetOffsetY = { it },
|
||||
animationSpec = userPickerAnimSpec()
|
||||
) + fadeOut(animationSpec = userPickerAnimSpec())
|
||||
} else {
|
||||
fadeOut()
|
||||
}
|
||||
) {
|
||||
Box(if (appPlatform.isAndroid) Modifier.drawBehind { drawRect(animatedColor.value) } else Modifier) {
|
||||
UserPickerScaffold(isVisible = newChat.isVisible()) {
|
||||
Box(
|
||||
Modifier
|
||||
.fillMaxSize()
|
||||
@@ -515,7 +494,6 @@ fun UserPicker(
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
val showCustomModal: (@Composable() (ModalData.(ChatModel, () -> Unit) -> Unit)) -> () -> Unit = { modalView ->
|
||||
{
|
||||
if (appPlatform.isDesktop) {
|
||||
@@ -532,7 +510,6 @@ fun UserPicker(
|
||||
)
|
||||
|
||||
Divider(Modifier.padding(DEFAULT_PADDING))
|
||||
|
||||
val profileHidden = rememberSaveable { mutableStateOf(false) }
|
||||
|
||||
GlobalSettingsSection(
|
||||
@@ -623,7 +600,7 @@ fun UserProfilePickerItem(
|
||||
}
|
||||
} else if (!u.showNtfs) {
|
||||
Icon(painterResource(MR.images.ic_notifications_off), null, Modifier.size(20.dp), tint = MaterialTheme.colors.secondary)
|
||||
} else {
|
||||
} else {
|
||||
Box(Modifier.size(20.dp))
|
||||
}
|
||||
}
|
||||
@@ -716,6 +693,12 @@ expect fun UserPickerInactiveUsersSection(
|
||||
onUserClicked: (user: User) -> Unit,
|
||||
)
|
||||
|
||||
@Composable
|
||||
expect fun UserPickerScaffold(
|
||||
isVisible: Boolean,
|
||||
content: @Composable () -> Unit
|
||||
)
|
||||
|
||||
@Composable
|
||||
fun DevicePill(
|
||||
active: Boolean,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package chat.simplex.common.views.chatlist
|
||||
|
||||
import androidx.compose.animation.*
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.runtime.Composable
|
||||
@@ -11,6 +12,7 @@ import chat.simplex.common.model.UserInfo
|
||||
import chat.simplex.common.platform.*
|
||||
import chat.simplex.common.ui.theme.*
|
||||
import chat.simplex.common.views.helpers.fontSizeSqrtMultiplier
|
||||
import chat.simplex.common.views.helpers.userPickerAnimSpec
|
||||
import chat.simplex.res.MR
|
||||
import dev.icerock.moko.resources.compose.painterResource
|
||||
import dev.icerock.moko.resources.compose.stringResource
|
||||
@@ -58,3 +60,14 @@ actual fun UserPickerInactiveUsersSection(
|
||||
onShowAllProfilesClicked
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
actual fun UserPickerScaffold(isVisible: Boolean, content: @Composable () -> Unit) {
|
||||
AnimatedVisibility(
|
||||
visible = isVisible,
|
||||
enter = fadeIn(),
|
||||
exit = fadeOut()
|
||||
) {
|
||||
content()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user