|
|
|
@ -2,6 +2,7 @@ package fr.iut.alldev.allin.ui.friends.tabs
|
|
|
|
|
|
|
|
|
|
import androidx.compose.foundation.background
|
|
|
|
|
import androidx.compose.foundation.layout.Arrangement
|
|
|
|
|
import androidx.compose.foundation.layout.Box
|
|
|
|
|
import androidx.compose.foundation.layout.WindowInsets
|
|
|
|
|
import androidx.compose.foundation.layout.fillMaxSize
|
|
|
|
|
import androidx.compose.foundation.layout.fillMaxWidth
|
|
|
|
@ -12,12 +13,14 @@ import androidx.compose.foundation.lazy.items
|
|
|
|
|
import androidx.compose.material.icons.Icons
|
|
|
|
|
import androidx.compose.material.icons.filled.Search
|
|
|
|
|
import androidx.compose.runtime.Composable
|
|
|
|
|
import androidx.compose.ui.Alignment
|
|
|
|
|
import androidx.compose.ui.Modifier
|
|
|
|
|
import androidx.compose.ui.graphics.Brush
|
|
|
|
|
import androidx.compose.ui.graphics.Color
|
|
|
|
|
import androidx.compose.ui.graphics.vector.rememberVectorPainter
|
|
|
|
|
import androidx.compose.ui.res.painterResource
|
|
|
|
|
import androidx.compose.ui.res.stringResource
|
|
|
|
|
import androidx.compose.ui.tooling.preview.Preview
|
|
|
|
|
import androidx.compose.ui.unit.dp
|
|
|
|
|
import fr.iut.alldev.allin.R
|
|
|
|
|
import fr.iut.alldev.allin.data.model.FriendStatus
|
|
|
|
@ -35,48 +38,59 @@ fun FriendsScreenAddTab(
|
|
|
|
|
onToggleDeleteFriend: (User) -> Unit,
|
|
|
|
|
setSearch: (String) -> Unit,
|
|
|
|
|
) {
|
|
|
|
|
LazyColumn(
|
|
|
|
|
modifier = Modifier.fillMaxSize(),
|
|
|
|
|
contentPadding = WindowInsets.navigationBars.asPaddingValues(start = 24.dp, end = 24.dp, top = 18.dp),
|
|
|
|
|
verticalArrangement = Arrangement.spacedBy(11.dp),
|
|
|
|
|
) {
|
|
|
|
|
stickyHeader {
|
|
|
|
|
AllInTextField(
|
|
|
|
|
value = search,
|
|
|
|
|
onValueChange = setSearch,
|
|
|
|
|
leadingIcon = rememberVectorPainter(image = Icons.Default.Search),
|
|
|
|
|
modifier = Modifier
|
|
|
|
|
.background(
|
|
|
|
|
Brush.verticalGradient(
|
|
|
|
|
0.5f to AllInTheme.colors.mainSurface,
|
|
|
|
|
1f to Color.Transparent
|
|
|
|
|
Box {
|
|
|
|
|
LazyColumn(
|
|
|
|
|
modifier = Modifier.fillMaxSize(),
|
|
|
|
|
contentPadding = WindowInsets.navigationBars.asPaddingValues(start = 24.dp, end = 24.dp, top = 18.dp),
|
|
|
|
|
verticalArrangement = Arrangement.spacedBy(11.dp),
|
|
|
|
|
) {
|
|
|
|
|
stickyHeader {
|
|
|
|
|
AllInTextField(
|
|
|
|
|
value = search,
|
|
|
|
|
onValueChange = setSearch,
|
|
|
|
|
leadingIcon = rememberVectorPainter(image = Icons.Default.Search),
|
|
|
|
|
modifier = Modifier
|
|
|
|
|
.background(
|
|
|
|
|
Brush.verticalGradient(
|
|
|
|
|
0.5f to AllInTheme.colors.mainSurface,
|
|
|
|
|
1f to Color.Transparent
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
.fillMaxWidth()
|
|
|
|
|
.padding(vertical = 8.dp)
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
.fillMaxWidth()
|
|
|
|
|
.padding(vertical = 8.dp)
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
items(friends) {
|
|
|
|
|
FriendsScreenLine(
|
|
|
|
|
username = it.username,
|
|
|
|
|
status = it.friendStatus ?: FriendStatus.NOT_FRIEND,
|
|
|
|
|
toggleIsFriend = { onToggleDeleteFriend(it) }
|
|
|
|
|
)
|
|
|
|
|
items(friends) {
|
|
|
|
|
FriendsScreenLine(
|
|
|
|
|
username = it.username,
|
|
|
|
|
status = it.friendStatus ?: FriendStatus.NOT_FRIEND,
|
|
|
|
|
toggleIsFriend = { onToggleDeleteFriend(it) }
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (friends.isEmpty() && search.isBlank()) {
|
|
|
|
|
item {
|
|
|
|
|
AllInEmptyView(
|
|
|
|
|
text = stringResource(id = R.string.friends_empty_text),
|
|
|
|
|
subtext = stringResource(id = R.string.friends_empty_subtext),
|
|
|
|
|
image = painterResource(id = R.drawable.silhouettes),
|
|
|
|
|
modifier = Modifier
|
|
|
|
|
.fillMaxWidth()
|
|
|
|
|
.padding(top = 24.dp)
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
AllInEmptyView(
|
|
|
|
|
text = stringResource(id = R.string.friends_empty_text),
|
|
|
|
|
subtext = stringResource(id = R.string.friends_empty_subtext),
|
|
|
|
|
image = painterResource(id = R.drawable.silhouettes),
|
|
|
|
|
modifier = Modifier.align(Alignment.Center)
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Preview
|
|
|
|
|
@Composable
|
|
|
|
|
private fun FriendsScreenAddTabPreview() {
|
|
|
|
|
AllInTheme {
|
|
|
|
|
FriendsScreenAddTab(
|
|
|
|
|
friends = emptyList(),
|
|
|
|
|
search = "",
|
|
|
|
|
onToggleDeleteFriend = { },
|
|
|
|
|
setSearch = { }
|
|
|
|
|
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|