mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-04-08 20:08:06 +02:00
Merge pull request #1035 from greenart7c3/main
Show relay ping with the relay icon
This commit is contained in:
commit
d44f5dad18
@ -65,6 +65,7 @@ fun BasicRelaySetupInfoClickableRow(
|
||||
iconUrlFromRelayInfoDoc ?: item.briefInfo.favIcon,
|
||||
loadProfilePicture,
|
||||
loadRobohash,
|
||||
item.relayStat.pingInMs,
|
||||
MaterialTheme.colorScheme.largeRelayIconModifier,
|
||||
)
|
||||
|
||||
|
@ -322,6 +322,7 @@ fun ClickableRelayItem(
|
||||
iconUrlFromRelayInfoDoc ?: item.briefInfo.favIcon,
|
||||
loadProfilePicture,
|
||||
loadRobohash,
|
||||
item.relayStat.pingInMs,
|
||||
MaterialTheme.colorScheme.largeRelayIconModifier,
|
||||
)
|
||||
|
||||
|
@ -93,6 +93,7 @@ fun Kind3RelaySetupInfoProposalRow(
|
||||
iconUrlFromRelayInfoDoc ?: item.briefInfo.favIcon,
|
||||
loadProfilePicture,
|
||||
loadRobohash,
|
||||
item.relayStat.pingInMs,
|
||||
MaterialTheme.colorScheme.largeRelayIconModifier,
|
||||
)
|
||||
|
||||
|
@ -135,6 +135,7 @@ fun RelayInformationDialog(
|
||||
iconUrl = relayInfo.icon ?: relayBriefInfo.favIcon,
|
||||
loadProfilePicture = accountViewModel.settings.showProfilePictures.value,
|
||||
loadRobohash = accountViewModel.settings.featureSet != FeatureSetType.PERFORMANCE,
|
||||
RelayStats.get(url = relayBriefInfo.url).pingInMs,
|
||||
iconModifier = MaterialTheme.colorScheme.largeRelayIconModifier,
|
||||
)
|
||||
}
|
||||
|
@ -20,14 +20,18 @@
|
||||
*/
|
||||
package com.vitorpamplona.amethyst.ui.note
|
||||
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.ChevronRight
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
@ -36,6 +40,10 @@ import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import com.vitorpamplona.amethyst.R
|
||||
import com.vitorpamplona.amethyst.model.FeatureSetType
|
||||
@ -179,6 +187,7 @@ fun RenderRelay(
|
||||
displayUrl = relay.displayUrl,
|
||||
iconUrl = relayInfo?.icon ?: relay.favIcon,
|
||||
loadProfilePicture = accountViewModel.settings.showProfilePictures.value,
|
||||
pingInMs = 0,
|
||||
loadRobohash = accountViewModel.settings.featureSet != FeatureSetType.PERFORMANCE,
|
||||
)
|
||||
}
|
||||
@ -190,15 +199,46 @@ fun RenderRelayIcon(
|
||||
iconUrl: String?,
|
||||
loadProfilePicture: Boolean,
|
||||
loadRobohash: Boolean,
|
||||
pingInMs: Long,
|
||||
iconModifier: Modifier = MaterialTheme.colorScheme.relayIconModifier,
|
||||
) {
|
||||
RobohashFallbackAsyncImage(
|
||||
robot = displayUrl,
|
||||
model = iconUrl,
|
||||
contentDescription = stringRes(id = R.string.relay_info, displayUrl),
|
||||
colorFilter = RelayIconFilter,
|
||||
modifier = iconModifier,
|
||||
loadProfilePicture = loadProfilePicture,
|
||||
loadRobohash = loadRobohash,
|
||||
)
|
||||
Box(
|
||||
contentAlignment = Alignment.TopEnd,
|
||||
) {
|
||||
RobohashFallbackAsyncImage(
|
||||
robot = displayUrl,
|
||||
model = iconUrl,
|
||||
contentDescription = stringRes(id = R.string.relay_info, displayUrl),
|
||||
colorFilter = RelayIconFilter,
|
||||
modifier = iconModifier,
|
||||
loadProfilePicture = loadProfilePicture,
|
||||
loadRobohash = loadRobohash,
|
||||
)
|
||||
if (pingInMs > 0) {
|
||||
Box(
|
||||
modifier =
|
||||
Modifier
|
||||
.clip(RoundedCornerShape(8.dp))
|
||||
.background(
|
||||
Color.Gray,
|
||||
),
|
||||
) {
|
||||
Text(
|
||||
modifier = Modifier.padding(4.dp),
|
||||
style =
|
||||
TextStyle(
|
||||
color =
|
||||
if (pingInMs <= 150) {
|
||||
Color.Green
|
||||
} else if (pingInMs <= 300) {
|
||||
Color.Yellow
|
||||
} else {
|
||||
Color.Red
|
||||
},
|
||||
),
|
||||
text = "$pingInMs",
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user