Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SzobatárSCH
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Fodor Patrik
SzobatárSCH
Commits
34723b8b
Commit
34723b8b
authored
May 16, 2022
by
Fodor Patrik
Browse files
Options
Downloads
Patches
Plain Diff
Swipe animation
parent
86f78192
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/src/main/java/hu/bme/kszk/szobatarsch/composable/FindPeople.kt
+80
-1
80 additions, 1 deletion
...ain/java/hu/bme/kszk/szobatarsch/composable/FindPeople.kt
with
80 additions
and
1 deletion
app/src/main/java/hu/bme/kszk/szobatarsch/composable/FindPeople.kt
+
80
−
1
View file @
34723b8b
package
hu.bme.kszk.szobatarsch.composable
package
hu.bme.kszk.szobatarsch.composable
import
androidx.compose.runtime.Composable
import
androidx.compose.animation.core.animateDpAsState
import
androidx.compose.animation.core.animateFloatAsState
import
androidx.compose.foundation.gestures.detectDragGestures
import
androidx.compose.foundation.layout.Box
import
androidx.compose.foundation.layout.fillMaxSize
import
androidx.compose.foundation.layout.offset
import
androidx.compose.foundation.layout.padding
import
androidx.compose.material3.*
import
androidx.compose.runtime.*
import
androidx.compose.ui.ExperimentalComposeUiApi
import
androidx.compose.ui.Modifier
import
androidx.compose.ui.draw.rotate
import
androidx.compose.ui.input.pointer.pointerInput
import
androidx.compose.ui.platform.LocalConfiguration
import
androidx.compose.ui.platform.LocalDensity
import
androidx.compose.ui.unit.Dp
import
androidx.compose.ui.unit.dp
@OptIn
(
ExperimentalComposeUiApi
::
class
,
ExperimentalMaterial3Api
::
class
)
@Composable
@Composable
fun
FindPeople
()
{
fun
FindPeople
()
{
val
items
=
remember
{
mutableStateListOf
<
Int
>()
}
LaunchedEffect
(
Unit
)
{
(
1
..
5
).
forEach
{
items
+=
it
}
}
val
width
=
LocalConfiguration
.
current
.
screenWidthDp
.
dp
val
density
=
LocalDensity
.
current
fun
Float
.
pxToDp
()
=
with
(
density
)
{
this
@pxToDp
.
toDp
()
}
val
edge
=
width
+
100
.
dp
val
sens
=
width
/
2
val
degPerDp
=
20
/
width
.
value
fun
Dp
.
getRotation
()
=
value
*
degPerDp
Box
()
{
items
.
forEach
{
var
offset
by
remember
{
mutableStateOf
(
0
.
dp
)
}
val
animatedOffset
by
animateDpAsState
(
targetValue
=
offset
,
finishedListener
=
{
off
->
if
(
off
==
edge
)
{
items
-=
it
}
else
if
(
off
==
-
edge
)
{
items
-=
it
}
},
)
Card
(
modifier
=
Modifier
.
pointerInput
(
Unit
)
{
detectDragGestures
(
onDragEnd
=
{
offset
=
if
(
offset
>
sens
)
{
edge
}
else
if
(
offset
<
-
sens
)
{
-
edge
}
else
{
0
.
dp
}
},
onDrag
=
{
change
,
amount
->
offset
+=
amount
.
x
.
pxToDp
()
change
.
consume
()
},
)
}
.
offset
(
x
=
animatedOffset
)
.
rotate
(
animatedOffset
.
getRotation
())
.
fillMaxSize
()
.
padding
(
8
.
dp
),
elevation
=
CardDefaults
.
cardElevation
(
defaultElevation
=
10
.
dp
)
)
{
Text
(
it
.
toString
())
}
}
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment