Skip to content

Commit

Permalink
Fix relay icons when using complete ui
Browse files Browse the repository at this point in the history
  • Loading branch information
greenart7c3 committed Aug 28, 2024
1 parent efde14a commit 06f37ab
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ fun BasicRelaySetupInfoClickableRow(
iconUrlFromRelayInfoDoc ?: item.briefInfo.favIcon,
loadProfilePicture,
loadRobohash,
item.relayStat.pingInMs,
MaterialTheme.colorScheme.largeRelayIconModifier,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ fun ClickableRelayItem(
iconUrlFromRelayInfoDoc ?: item.briefInfo.favIcon,
loadProfilePicture,
loadRobohash,
item.relayStat.pingInMs,
MaterialTheme.colorScheme.largeRelayIconModifier,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ fun Kind3RelaySetupInfoProposalRow(
iconUrlFromRelayInfoDoc ?: item.briefInfo.favIcon,
loadProfilePicture,
loadRobohash,
item.relayStat.pingInMs,
MaterialTheme.colorScheme.largeRelayIconModifier,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ import com.vitorpamplona.amethyst.ui.theme.StdStartPadding
import com.vitorpamplona.amethyst.ui.theme.placeholderText
import com.vitorpamplona.amethyst.ui.theme.relayIconModifier
import com.vitorpamplona.ammolite.relays.RelayBriefInfoCache
import com.vitorpamplona.ammolite.relays.RelayStats
import com.vitorpamplona.quartz.encoders.RelayUrlFormatter

@Composable
public fun RelayBadgesHorizontal(
Expand Down Expand Up @@ -189,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,
)
}
Expand All @@ -200,6 +199,7 @@ fun RenderRelayIcon(
iconUrl: String?,
loadProfilePicture: Boolean,
loadRobohash: Boolean,
pingInMs: Long,
iconModifier: Modifier = MaterialTheme.colorScheme.relayIconModifier,
) {
Box(
Expand All @@ -214,31 +214,31 @@ fun RenderRelayIcon(
loadProfilePicture = loadProfilePicture,
loadRobohash = loadRobohash,
)

Box(
modifier =
Modifier
.clip(RoundedCornerShape(8.dp))
.background(
Color.Gray,
),
) {
val pingInMs = RelayStats.get(RelayUrlFormatter.normalize(displayUrl)).pingInMs
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",
)
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",
)
}
}
}
}

0 comments on commit 06f37ab

Please sign in to comment.