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
5cdf9c4f
Commit
5cdf9c4f
authored
3 years ago
by
Fodor Patrik
Browse files
Options
Downloads
Patches
Plain Diff
Show UserCard, fix Firestore
parent
a7479c22
Branches
Branches containing commit
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
+53
-13
53 additions, 13 deletions
...ain/java/hu/bme/kszk/szobatarsch/composable/FindPeople.kt
with
53 additions
and
13 deletions
app/src/main/java/hu/bme/kszk/szobatarsch/composable/FindPeople.kt
+
53
−
13
View file @
5cdf9c4f
package
hu.bme.kszk.szobatarsch.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.la
yout.fillMaxSize
import
androidx.compose.foundation.
layout.offset
import
androidx.compose.foundation.
layout.padding
import
androidx.compose.foundation.layout.
*
import
androidx.compose.foundation.la
zy.LazyColumn
import
androidx.compose.foundation.
rememberScrollState
import
androidx.compose.foundation.
verticalScroll
import
androidx.compose.material3.*
import
androidx.compose.runtime.*
import
androidx.compose.ui.ExperimentalComposeUiApi
import
androidx.compose.ui.Modifier
import
androidx.compose.ui.draw.alpha
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
import
hu.bme.kszk.szobatarsch.firebase.*
import
kotlinx.coroutines.launch
@OptIn
(
ExperimentalComposeUiApi
::
class
,
ExperimentalMaterial3Api
::
class
)
@OptIn
(
ExperimentalMaterial3Api
::
class
)
@Composable
fun
FindPeople
()
{
val
items
=
remember
{
mutableStateListOf
<
User
>()
}
val
user
=
remember
{
mutableStateOf
<
User
?>(
null
)
}
val
coroutineScope
=
rememberCoroutineScope
()
LaunchedEffect
(
Unit
)
{
userData
.
collect
{
newUser
->
if
(
newUser
!=
user
.
value
)
{
user
.
value
=
newUser
}
}
}
val
items
=
remember
{
mutableStateListOf
<
Int
>()
}
LaunchedEffect
(
items
.
size
,
user
.
value
)
{
val
limit
=
3L
LaunchedEffect
(
Unit
)
{
(
1
..
5
).
forEach
{
items
+=
it
}
if
(
user
.
value
==
null
)
return
@LaunchedEffect
if
(
items
.
size
<
3
)
{
val
list
=
user
.
value
!!
.
likedUsers
+
user
.
value
!!
.
dismissedUsers
+
items
.
map
{
it
.
id
}
+
user
.
value
!!
.
id
geLimitedLikeableUsers
(
userList
=
list
,
limit
=
limit
).
forEach
{
items
+=
it
}
}
}
val
width
=
LocalConfiguration
.
current
.
screenWidthDp
.
dp
...
...
@@ -36,8 +58,10 @@ fun FindPeople() {
val
edge
=
width
+
100
.
dp
val
sens
=
width
/
2
val
degPerDp
=
20
/
width
.
value
val
degPerDp
=
15
/
width
.
value
val
alphaPerDp
=
0.75f
/
width
.
value
fun
Dp
.
getRotation
()
=
value
*
degPerDp
fun
Dp
.
getAlpha
()
=
if
(
value
<
0
)
(-
value
)
*
alphaPerDp
else
value
*
alphaPerDp
Box
()
{
items
.
forEach
{
...
...
@@ -47,8 +71,20 @@ fun FindPeople() {
targetValue
=
offset
,
finishedListener
=
{
off
->
if
(
off
==
edge
)
{
user
.
value
!!
.
likedUsers
+=
it
.
id
coroutineScope
.
launch
{
registerOrOverwriteUser
(
user
.
value
!!
)
}
items
-=
it
}
else
if
(
off
==
-
edge
)
{
user
.
value
!!
.
dismissedUsers
+=
it
.
id
coroutineScope
.
launch
{
registerOrOverwriteUser
(
user
.
value
!!
)
}
items
-=
it
}
},
...
...
@@ -75,11 +111,15 @@ fun FindPeople() {
}
.
offset
(
x
=
animatedOffset
)
.
rotate
(
animatedOffset
.
getRotation
())
.
alpha
(
1f
-
animatedOffset
.
getAlpha
())
.
fillMaxSize
()
.
padding
(
8
.
dp
),
.
padding
(
8
.
dp
)
.
verticalScroll
(
rememberScrollState
()),
elevation
=
CardDefaults
.
cardElevation
(
defaultElevation
=
10
.
dp
)
)
{
Text
(
it
.
toString
())
Column
(
Modifier
.
padding
(
8
.
dp
))
{
UserDataCard
(
it
,
true
)
}
}
}
}
...
...
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