feat: add explainers for certain statuses

Signed-off-by: Infi <infi@infi.sh>
This commit is contained in:
Infi 2023-10-22 22:38:45 +02:00
parent 3310e85adc
commit 97c31d0e3e
2 changed files with 26 additions and 2 deletions

View File

@ -16,6 +16,8 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import chat.revolt.R
import chat.revolt.components.generic.Presence
@ -31,6 +33,16 @@ fun Presence.stringResource(): Int {
}
}
fun Presence.explainerResource(): Int? {
return when (this) {
Presence.Online -> null
Presence.Idle -> null
Presence.Dnd -> R.string.status_dnd_explainer
Presence.Focus -> R.string.status_focus_explainer
Presence.Offline -> R.string.status_invisible_explainer
}
}
@Composable
fun StatusPicker(
currentStatus: Presence,
@ -49,7 +61,6 @@ fun StatusPicker(
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(8.dp),
modifier = Modifier
.clip(MaterialTheme.shapes.small)
.background(MaterialTheme.colorScheme.surfaceColorAtElevation(2.dp))
@ -66,8 +77,18 @@ fun StatusPicker(
Text(
text = stringResource(currentStatus.stringResource()),
style = MaterialTheme.typography.bodyLarge
style = MaterialTheme.typography.bodyLarge.copy(
fontWeight = FontWeight.Bold
)
)
currentStatus.explainerResource()?.let {
Text(
text = stringResource(it),
style = MaterialTheme.typography.bodyMedium,
textAlign = TextAlign.Center
)
}
}
}

View File

@ -185,9 +185,12 @@
<string name="status_online">Online</string>
<string name="status_idle">Idle</string>
<string name="status_focus">Focus</string>
<string name="status_focus_explainer">You will not receive any notifications for messages, but you will receive notifications for @mentions.</string>
<string name="status_dnd">Do Not Disturb</string>
<string name="status_dnd_explainer">You will not receive any notifications, including messages and @mentions.</string>
<string name="status_offline">Offline</string>
<string name="status_invisible">Invisible</string>
<string name="status_invisible_explainer">You will be able to use Revolt as usual, but you will not appear as online to other people.</string>
<string name="no_connection">No connection</string>
<string name="no_connection_message">You are not connected to the internet. Please check your connection and try again.</string>