mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-08 05:47:05 +09:00
DROID-2833 Tech | Refactoring after compose update (#1573)
This commit is contained in:
parent
47a07d05d0
commit
d315fd158d
1 changed files with 29 additions and 19 deletions
|
@ -2,12 +2,17 @@ package com.anytypeio.anytype.core_ui.features.multiplayer
|
|||
|
||||
import android.content.res.Configuration
|
||||
import androidx.compose.animation.AnimatedVisibility
|
||||
import androidx.compose.animation.core.tween
|
||||
import androidx.compose.animation.rememberSplineBasedDecay
|
||||
import androidx.compose.animation.slideInVertically
|
||||
import androidx.compose.animation.slideOutVertically
|
||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.gestures.AnchoredDraggableState
|
||||
import androidx.compose.foundation.gestures.DraggableAnchors
|
||||
import androidx.compose.foundation.gestures.Orientation
|
||||
import androidx.compose.foundation.gestures.anchoredDraggable
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
|
@ -16,6 +21,7 @@ import androidx.compose.foundation.layout.fillMaxHeight
|
|||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.offset
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.layout.width
|
||||
|
@ -29,6 +35,7 @@ import androidx.compose.material.DropdownMenuItem
|
|||
import androidx.compose.material3.DropdownMenu
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.SideEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
|
@ -49,6 +56,7 @@ import androidx.compose.ui.text.font.FontWeight
|
|||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.Dp
|
||||
import androidx.compose.ui.unit.IntOffset
|
||||
import androidx.compose.ui.unit.TextUnit
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
|
@ -264,21 +272,23 @@ fun ShareSpaceScreen(
|
|||
DragValue.DRAGGED_DOWN at draggedDownAnchorTop
|
||||
DragValue.DRAGGED_UP at 0f
|
||||
}
|
||||
// TODO https://linear.app/anytype/issue/DROID-2833/fix-anchoreddraggablestate-in-sharespacescreenkt
|
||||
// val anchoredDraggableState = remember {
|
||||
// AnchoredDraggableState(
|
||||
// initialValue = DragValue.DRAGGED_UP,
|
||||
// anchors = anchors,
|
||||
// positionalThreshold = { distance: Float -> distance * 0.5f },
|
||||
// velocityThreshold = { with(density) { 100.dp.toPx() } },
|
||||
// animationSpec = tween()
|
||||
// )
|
||||
// }
|
||||
// val offset =
|
||||
// if (anchoredDraggableState.offset.isNaN()) 0 else anchoredDraggableState.offset.toInt()
|
||||
// SideEffect {
|
||||
// anchoredDraggableState.updateAnchors(anchors)
|
||||
// }
|
||||
|
||||
val decayAnimation = rememberSplineBasedDecay<Float>()
|
||||
|
||||
val anchoredDraggableState = remember {
|
||||
AnchoredDraggableState(
|
||||
initialValue = DragValue.DRAGGED_UP,
|
||||
positionalThreshold = { distance: Float -> distance * 0.5f },
|
||||
velocityThreshold = { with(density) { 100.dp.toPx() } },
|
||||
snapAnimationSpec = tween(),
|
||||
decayAnimationSpec = decayAnimation
|
||||
)
|
||||
}
|
||||
val offset =
|
||||
if (anchoredDraggableState.offset.isNaN()) 0 else anchoredDraggableState.offset.toInt()
|
||||
SideEffect {
|
||||
anchoredDraggableState.updateAnchors(anchors)
|
||||
}
|
||||
AnimatedVisibility(
|
||||
visible = shareLinkViewState is ShareLinkViewState.Shared,
|
||||
enter = slideInVertically { it },
|
||||
|
@ -287,10 +297,10 @@ fun ShareSpaceScreen(
|
|||
) {
|
||||
Box(modifier = Modifier
|
||||
.padding(16.dp)
|
||||
// .offset {
|
||||
// IntOffset(x = 0, y = offset)
|
||||
// }
|
||||
// .anchoredDraggable(anchoredDraggableState, Orientation.Vertical)
|
||||
.offset {
|
||||
IntOffset(x = 0, y = offset)
|
||||
}
|
||||
.anchoredDraggable(anchoredDraggableState, Orientation.Vertical)
|
||||
) {
|
||||
if (shareLinkViewState is ShareLinkViewState.Shared) {
|
||||
ShareInviteLinkCard(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue