Merge pull request #1035 from greenart7c3/main
Show relay ping with the relay icon
This commit is contained in:
+1
@@ -65,6 +65,7 @@ fun BasicRelaySetupInfoClickableRow(
|
|||||||
iconUrlFromRelayInfoDoc ?: item.briefInfo.favIcon,
|
iconUrlFromRelayInfoDoc ?: item.briefInfo.favIcon,
|
||||||
loadProfilePicture,
|
loadProfilePicture,
|
||||||
loadRobohash,
|
loadRobohash,
|
||||||
|
item.relayStat.pingInMs,
|
||||||
MaterialTheme.colorScheme.largeRelayIconModifier,
|
MaterialTheme.colorScheme.largeRelayIconModifier,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
+1
@@ -322,6 +322,7 @@ fun ClickableRelayItem(
|
|||||||
iconUrlFromRelayInfoDoc ?: item.briefInfo.favIcon,
|
iconUrlFromRelayInfoDoc ?: item.briefInfo.favIcon,
|
||||||
loadProfilePicture,
|
loadProfilePicture,
|
||||||
loadRobohash,
|
loadRobohash,
|
||||||
|
item.relayStat.pingInMs,
|
||||||
MaterialTheme.colorScheme.largeRelayIconModifier,
|
MaterialTheme.colorScheme.largeRelayIconModifier,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
+1
@@ -93,6 +93,7 @@ fun Kind3RelaySetupInfoProposalRow(
|
|||||||
iconUrlFromRelayInfoDoc ?: item.briefInfo.favIcon,
|
iconUrlFromRelayInfoDoc ?: item.briefInfo.favIcon,
|
||||||
loadProfilePicture,
|
loadProfilePicture,
|
||||||
loadRobohash,
|
loadRobohash,
|
||||||
|
item.relayStat.pingInMs,
|
||||||
MaterialTheme.colorScheme.largeRelayIconModifier,
|
MaterialTheme.colorScheme.largeRelayIconModifier,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
+1
@@ -135,6 +135,7 @@ fun RelayInformationDialog(
|
|||||||
iconUrl = relayInfo.icon ?: relayBriefInfo.favIcon,
|
iconUrl = relayInfo.icon ?: relayBriefInfo.favIcon,
|
||||||
loadProfilePicture = accountViewModel.settings.showProfilePictures.value,
|
loadProfilePicture = accountViewModel.settings.showProfilePictures.value,
|
||||||
loadRobohash = accountViewModel.settings.featureSet != FeatureSetType.PERFORMANCE,
|
loadRobohash = accountViewModel.settings.featureSet != FeatureSetType.PERFORMANCE,
|
||||||
|
RelayStats.get(url = relayBriefInfo.url).pingInMs,
|
||||||
iconModifier = MaterialTheme.colorScheme.largeRelayIconModifier,
|
iconModifier = MaterialTheme.colorScheme.largeRelayIconModifier,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,14 +20,18 @@
|
|||||||
*/
|
*/
|
||||||
package com.vitorpamplona.amethyst.ui.note
|
package com.vitorpamplona.amethyst.ui.note
|
||||||
|
|
||||||
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.clickable
|
import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.size
|
import androidx.compose.foundation.layout.size
|
||||||
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.filled.ChevronRight
|
import androidx.compose.material.icons.filled.ChevronRight
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
@@ -36,6 +40,10 @@ import androidx.compose.runtime.remember
|
|||||||
import androidx.compose.runtime.setValue
|
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.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 androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||||
import com.vitorpamplona.amethyst.R
|
import com.vitorpamplona.amethyst.R
|
||||||
import com.vitorpamplona.amethyst.model.FeatureSetType
|
import com.vitorpamplona.amethyst.model.FeatureSetType
|
||||||
@@ -179,6 +187,7 @@ fun RenderRelay(
|
|||||||
displayUrl = relay.displayUrl,
|
displayUrl = relay.displayUrl,
|
||||||
iconUrl = relayInfo?.icon ?: relay.favIcon,
|
iconUrl = relayInfo?.icon ?: relay.favIcon,
|
||||||
loadProfilePicture = accountViewModel.settings.showProfilePictures.value,
|
loadProfilePicture = accountViewModel.settings.showProfilePictures.value,
|
||||||
|
pingInMs = 0,
|
||||||
loadRobohash = accountViewModel.settings.featureSet != FeatureSetType.PERFORMANCE,
|
loadRobohash = accountViewModel.settings.featureSet != FeatureSetType.PERFORMANCE,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -190,15 +199,46 @@ fun RenderRelayIcon(
|
|||||||
iconUrl: String?,
|
iconUrl: String?,
|
||||||
loadProfilePicture: Boolean,
|
loadProfilePicture: Boolean,
|
||||||
loadRobohash: Boolean,
|
loadRobohash: Boolean,
|
||||||
|
pingInMs: Long,
|
||||||
iconModifier: Modifier = MaterialTheme.colorScheme.relayIconModifier,
|
iconModifier: Modifier = MaterialTheme.colorScheme.relayIconModifier,
|
||||||
) {
|
) {
|
||||||
RobohashFallbackAsyncImage(
|
Box(
|
||||||
robot = displayUrl,
|
contentAlignment = Alignment.TopEnd,
|
||||||
model = iconUrl,
|
) {
|
||||||
contentDescription = stringRes(id = R.string.relay_info, displayUrl),
|
RobohashFallbackAsyncImage(
|
||||||
colorFilter = RelayIconFilter,
|
robot = displayUrl,
|
||||||
modifier = iconModifier,
|
model = iconUrl,
|
||||||
loadProfilePicture = loadProfilePicture,
|
contentDescription = stringRes(id = R.string.relay_info, displayUrl),
|
||||||
loadRobohash = loadRobohash,
|
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",
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user