feat: polish user not found sheet
Signed-off-by: Infi <infi@infi.sh>
This commit is contained in:
parent
69c638b227
commit
769cf99529
|
|
@ -7,6 +7,7 @@ import androidx.compose.foundation.layout.Spacer
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.height
|
import androidx.compose.foundation.layout.height
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.foundation.layout.size
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.filled.Close
|
import androidx.compose.material.icons.filled.Close
|
||||||
import androidx.compose.material.icons.filled.Star
|
import androidx.compose.material.icons.filled.Star
|
||||||
|
|
@ -21,13 +22,16 @@ import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.CompositionLocalProvider
|
import androidx.compose.runtime.CompositionLocalProvider
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
|
import androidx.compose.ui.unit.Dp
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
|
|
||||||
private val NoneLambda = @Composable { throw UnsupportedOperationException() }
|
private val NoneLambda = @Composable { throw UnsupportedOperationException() }
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun NonIdealState(
|
fun NonIdealState(
|
||||||
icon: @Composable () -> Unit,
|
icon: @Composable (Dp) -> Unit,
|
||||||
title: @Composable () -> Unit,
|
title: @Composable () -> Unit,
|
||||||
description: @Composable () -> Unit = NoneLambda,
|
description: @Composable () -> Unit = NoneLambda,
|
||||||
actions: @Composable () -> Unit = NoneLambda
|
actions: @Composable () -> Unit = NoneLambda
|
||||||
|
|
@ -40,17 +44,25 @@ fun NonIdealState(
|
||||||
.padding(vertical = 32.dp)
|
.padding(vertical = 32.dp)
|
||||||
) {
|
) {
|
||||||
CompositionLocalProvider(LocalContentColor provides MaterialTheme.colorScheme.primary) {
|
CompositionLocalProvider(LocalContentColor provides MaterialTheme.colorScheme.primary) {
|
||||||
icon()
|
icon(38.dp)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (description != NoneLambda) Spacer(modifier = Modifier.height(16.dp))
|
if (description != NoneLambda) Spacer(modifier = Modifier.height(16.dp))
|
||||||
|
|
||||||
CompositionLocalProvider(LocalTextStyle provides MaterialTheme.typography.headlineMedium) {
|
CompositionLocalProvider(
|
||||||
|
LocalTextStyle provides MaterialTheme.typography.headlineMedium.copy(
|
||||||
|
textAlign = TextAlign.Center
|
||||||
|
)
|
||||||
|
) {
|
||||||
title()
|
title()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (description != NoneLambda) {
|
if (description != NoneLambda) {
|
||||||
CompositionLocalProvider(LocalTextStyle provides MaterialTheme.typography.bodyMedium) {
|
CompositionLocalProvider(
|
||||||
|
LocalTextStyle provides MaterialTheme.typography.bodyMedium.copy(
|
||||||
|
textAlign = TextAlign.Center
|
||||||
|
)
|
||||||
|
) {
|
||||||
description()
|
description()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -75,7 +87,8 @@ fun NonIdealStatePreview() {
|
||||||
icon = {
|
icon = {
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = Icons.Default.Star,
|
imageVector = Icons.Default.Star,
|
||||||
contentDescription = null
|
contentDescription = null,
|
||||||
|
modifier = Modifier.size(it)
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
title = { Text("Channel") },
|
title = { Text("Channel") },
|
||||||
|
|
@ -95,7 +108,8 @@ fun NonIdealStatePreviewNoActions() {
|
||||||
icon = {
|
icon = {
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = Icons.Default.Close,
|
imageVector = Icons.Default.Close,
|
||||||
contentDescription = null
|
contentDescription = null,
|
||||||
|
modifier = Modifier.size(it)
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
title = { Text("Error") },
|
title = { Text("Error") },
|
||||||
|
|
@ -110,7 +124,8 @@ fun NonIdealStatePreviewNoDescription() {
|
||||||
icon = {
|
icon = {
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = Icons.Default.Warning,
|
imageVector = Icons.Default.Warning,
|
||||||
contentDescription = null
|
contentDescription = null,
|
||||||
|
modifier = Modifier.size(it)
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
title = { Text("No channels") },
|
title = { Text("No channels") },
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,11 @@ import androidx.compose.foundation.layout.ExperimentalLayoutApi
|
||||||
import androidx.compose.foundation.layout.FlowRow
|
import androidx.compose.foundation.layout.FlowRow
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.foundation.layout.size
|
||||||
import androidx.compose.foundation.rememberScrollState
|
import androidx.compose.foundation.rememberScrollState
|
||||||
import androidx.compose.foundation.verticalScroll
|
import androidx.compose.foundation.verticalScroll
|
||||||
import androidx.compose.material3.CircularProgressIndicator
|
import androidx.compose.material3.CircularProgressIndicator
|
||||||
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.LocalContentColor
|
import androidx.compose.material3.LocalContentColor
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
|
|
@ -22,6 +24,7 @@ import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.Brush
|
import androidx.compose.ui.graphics.Brush
|
||||||
|
import androidx.compose.ui.res.painterResource
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import chat.revolt.R
|
import chat.revolt.R
|
||||||
|
|
@ -31,6 +34,7 @@ import chat.revolt.api.internals.solidColor
|
||||||
import chat.revolt.api.routes.user.fetchUserProfile
|
import chat.revolt.api.routes.user.fetchUserProfile
|
||||||
import chat.revolt.api.schemas.Profile
|
import chat.revolt.api.schemas.Profile
|
||||||
import chat.revolt.components.chat.RoleChip
|
import chat.revolt.components.chat.RoleChip
|
||||||
|
import chat.revolt.components.generic.NonIdealState
|
||||||
import chat.revolt.components.generic.WebMarkdown
|
import chat.revolt.components.generic.WebMarkdown
|
||||||
import chat.revolt.components.screens.settings.RawUserOverview
|
import chat.revolt.components.screens.settings.RawUserOverview
|
||||||
|
|
||||||
|
|
@ -62,16 +66,25 @@ fun UserContextSheet(
|
||||||
|
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
// TODO fetch user in this scenario
|
// TODO fetch user in this scenario
|
||||||
Column(Modifier.padding(16.dp)) {
|
NonIdealState(
|
||||||
Text(
|
icon = {
|
||||||
text = stringResource(R.string.user_context_sheet_user_not_found),
|
Icon(
|
||||||
style = MaterialTheme.typography.headlineSmall
|
painter = painterResource(R.drawable.ic_alert_decagram_24dp),
|
||||||
)
|
contentDescription = null,
|
||||||
Text(
|
modifier = Modifier.size(it)
|
||||||
text = stringResource(R.string.user_context_sheet_user_not_found_description),
|
)
|
||||||
style = MaterialTheme.typography.bodyMedium
|
},
|
||||||
)
|
title = {
|
||||||
}
|
Text(
|
||||||
|
text = stringResource(R.string.user_context_sheet_user_not_found)
|
||||||
|
)
|
||||||
|
},
|
||||||
|
description = {
|
||||||
|
Text(
|
||||||
|
text = stringResource(R.string.user_context_sheet_user_not_found_description)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue