Empty views
continuous-integration/drone/push Build is passing Details

pull/5/head
avalin 8 months ago
parent 9daa8be251
commit 5f868f30d9

@ -30,10 +30,12 @@ import androidx.compose.ui.draw.alpha
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalDensity
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 androidx.compose.ui.zIndex
import fr.iut.alldev.allin.R
import fr.iut.alldev.allin.data.ext.formatToMediumDateNoYear
import fr.iut.alldev.allin.data.ext.formatToTime
import fr.iut.alldev.allin.data.model.bet.Bet
@ -43,6 +45,7 @@ import fr.iut.alldev.allin.data.model.bet.BinaryBet
import fr.iut.alldev.allin.ext.textId
import fr.iut.alldev.allin.theme.AllInTheme
import fr.iut.alldev.allin.ui.core.AllInChip
import fr.iut.alldev.allin.ui.core.bet.AllInEmptyView
import java.time.ZonedDateTime
private const val DISABLED_OPACITY = .5f
@ -152,6 +155,17 @@ fun BetScreenLoadedContent(
}
}
if (bets.isEmpty()) {
AllInEmptyView(
text = stringResource(id = R.string.bet_empty_text),
subtext = null,
image = painterResource(id = R.drawable.video_game),
modifier = Modifier
.fillMaxWidth()
.align(Alignment.Center)
)
}
PullRefreshIndicator(
modifier = Modifier.align(Alignment.TopCenter),
refreshing = isRefreshing,

@ -0,0 +1,81 @@
package fr.iut.alldev.allin.ui.core.bet
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.aspectRatio
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import fr.iut.alldev.allin.R
import fr.iut.alldev.allin.theme.AllInTheme
@Composable
fun AllInEmptyView(
image: Painter,
text: String,
subtext: String?,
modifier: Modifier = Modifier
) {
Column(
modifier = modifier
.alpha(.35f)
.padding(24.dp),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center
) {
Image(
painter = image,
contentDescription = null,
modifier = Modifier
.fillMaxWidth(.5f)
.aspectRatio(1f)
)
Spacer(modifier = Modifier.height(12.dp))
Text(
text = text,
textAlign = TextAlign.Center,
style = AllInTheme.typography.h2,
color = AllInTheme.colors.onMainSurface,
fontSize = 16.sp
)
subtext?.let {
Text(
text = subtext,
textAlign = TextAlign.Center,
style = AllInTheme.typography.p1,
color = AllInTheme.colors.onBackground2,
fontSize = 14.sp
)
}
}
}
@Preview(showBackground = true)
@Composable
private fun AllInEmptyViewPreview() {
AllInTheme {
AllInEmptyView(
text = "C'est un peu vide par ici",
subtext = "Ajoutez des amis pour les afficher dans le classement, et voir qui est le meilleur !",
image = painterResource(id = R.drawable.eyes),
modifier = Modifier.fillMaxSize()
)
}
}

@ -16,12 +16,16 @@ 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.unit.dp
import fr.iut.alldev.allin.R
import fr.iut.alldev.allin.data.model.FriendStatus
import fr.iut.alldev.allin.data.model.User
import fr.iut.alldev.allin.ext.asPaddingValues
import fr.iut.alldev.allin.theme.AllInTheme
import fr.iut.alldev.allin.ui.core.AllInTextField
import fr.iut.alldev.allin.ui.core.bet.AllInEmptyView
import fr.iut.alldev.allin.ui.friends.components.FriendsScreenLine
@Composable
@ -61,5 +65,18 @@ fun FriendsScreenAddTab(
)
}
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)
)
}
}
}
}

@ -6,12 +6,14 @@ import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.navigationBars
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
@ -22,6 +24,7 @@ import fr.iut.alldev.allin.data.model.User
import fr.iut.alldev.allin.ext.asPaddingValues
import fr.iut.alldev.allin.theme.AllInColorToken
import fr.iut.alldev.allin.theme.AllInTheme
import fr.iut.alldev.allin.ui.core.bet.AllInEmptyView
@Composable
fun RankingScreenContent(
@ -76,6 +79,19 @@ fun RankingScreenContent(
)
}
}
if (users.size == 1) {
item {
AllInEmptyView(
text = stringResource(id = R.string.ranking_empty_text),
subtext = stringResource(id = R.string.ranking_empty_subtext),
image = painterResource(id = R.drawable.eyes),
modifier = Modifier
.fillMaxWidth()
.padding(top = 24.dp)
)
}
}
}
}
@ -118,4 +134,21 @@ private fun RankingScreenContentPreview() {
)
)
}
}
@Preview
@Composable
private fun RankingScreenContentEmptyPreview() {
AllInTheme {
RankingScreenContent(
users = listOf(
User(
id = "1",
username = "Owen",
email = "",
coins = 8533
)
)
)
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 132 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

@ -130,6 +130,7 @@
<item quantity="other">%s points en jeu</item>
<item quantity="many">%s points en jeu</item>
</plurals>
<string name="bet_empty_text">Aucun bet ne correspond à votre recherche</string>
<!--Bet status-->
<string name="bet_status_finished">Terminé !</string>
@ -164,6 +165,8 @@
<!--Ranking-->
<string name="ranking_title">Classement</string>
<string name="ranking_empty_text">C\'est un peu vide ici</string>
<string name="ranking_empty_subtext">Ajoutez des amis pour les afficher dans le classement</string>
<!--Friends-->
<string name="friends_title">Amis</string>
@ -172,6 +175,8 @@
<string name="friends_requests_tab">Demandes</string>
<string name="friends_requests_accept">Accepter</string>
<string name="friends_requests_decline">Refuser</string>
<string name="friends_empty_text">Vous n\'avez pas encore d\'amis</string>
<string name="friends_empty_subtext">Ajoutez des amis depuis cet écran</string>
<!--Daily reward-->
<string name="daily_reward_title">Récompense quotidienne</string>

@ -129,6 +129,7 @@
<item quantity="one">%s point at stake</item>
<item quantity="other">%s points at stake</item>
</plurals>
<string name="bet_empty_text">No Bet corresponds to your research</string>
<!--Bet status-->
<string name="bet_status_finished">Finished !</string>
@ -161,6 +162,8 @@
<!--Ranking-->
<string name="ranking_title">Ranking</string>
<string name="ranking_empty_text">It\'s a bit lonely here</string>
<string name="ranking_empty_subtext">Add friends to display them in the ranking</string>
<!--Friends-->
<string name="friends_title">Friends</string>
@ -169,6 +172,8 @@
<string name="friends_requests_tab">Requests</string>
<string name="friends_requests_accept">Accept</string>
<string name="friends_requests_decline">Decline</string>
<string name="friends_empty_text">You don\'t have any friends yet</string>
<string name="friends_empty_subtext">Add new friends from this screen</string>
<!--Daily reward-->
<string name="daily_reward_title">Daily reward</string>

Loading…
Cancel
Save