mirror of
https://github.com/rt-bishop/Look4Sat.git
synced 2026-10-02 03:15:37 +00:00
Removed the eclipsed badge, tweaked visual indication
This commit is contained in:
1 parent
6588291997
commit
b79fec13f4
2 files changed
+52
-47
No files matched your search
@@ -45,7 +45,6 @@ import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.alpha
|
||||
import androidx.compose.ui.draw.rotate
|
||||
import androidx.compose.ui.keepScreenOn
|
||||
import androidx.compose.ui.res.painterResource
|
||||
@@ -136,7 +135,27 @@ private fun RadarScreen(uiState: RadarState, navigateUp: () -> Unit) {
|
||||
|
||||
@Composable
|
||||
private fun RadarCard(uiState: RadarState, modifier: Modifier = Modifier) {
|
||||
ElevatedCard(modifier = modifier) {
|
||||
val isEclipsed = uiState.orbitalPos?.eclipsed == true
|
||||
val borderModifier = if (isEclipsed) {
|
||||
val infiniteTransition = rememberInfiniteTransition(label = "eclipsedBorder")
|
||||
val borderAlpha by infiniteTransition.animateFloat(
|
||||
initialValue = 1.0f,
|
||||
targetValue = 0.0f,
|
||||
animationSpec = infiniteRepeatable(
|
||||
animation = tween(durationMillis = 1000, delayMillis = 25, easing = LinearEasing),
|
||||
repeatMode = RepeatMode.Reverse
|
||||
),
|
||||
label = "eclipsedBorderAlpha"
|
||||
)
|
||||
Modifier.border(
|
||||
width = 0.5.dp,
|
||||
color = MaterialTheme.colorScheme.primary.copy(alpha = borderAlpha),
|
||||
shape = MaterialTheme.shapes.medium
|
||||
)
|
||||
} else {
|
||||
Modifier
|
||||
}
|
||||
ElevatedCard(modifier = modifier.then(borderModifier)) {
|
||||
Box(contentAlignment = Alignment.Center) {
|
||||
val position = uiState.orbitalPos
|
||||
if (position == null) {
|
||||
@@ -227,20 +246,15 @@ private fun TransmittersCard(uiState: RadarState, modifier: Modifier = Modifier)
|
||||
if (uiState.transmitters.isEmpty()) {
|
||||
EmptyTransmittersContent()
|
||||
} else {
|
||||
Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
|
||||
TransmittersList(
|
||||
transmitters = uiState.transmitters,
|
||||
selectedUuid = uiState.selectedTransmitterUuid,
|
||||
onSelect = { uuid ->
|
||||
if (uiState.selectedTransmitterUuid != null) {
|
||||
uiState.sendAction(RadarAction.SelectTransmitter(uuid))
|
||||
}
|
||||
TransmittersList(
|
||||
transmitters = uiState.transmitters,
|
||||
selectedUuid = uiState.selectedTransmitterUuid,
|
||||
onSelect = { uuid ->
|
||||
if (uiState.selectedTransmitterUuid != null) {
|
||||
uiState.sendAction(RadarAction.SelectTransmitter(uuid))
|
||||
}
|
||||
)
|
||||
if (uiState.orbitalPos?.eclipsed == true) {
|
||||
EclipsedIndicator()
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -296,38 +310,6 @@ private fun TransmitterItemPreview() {
|
||||
MainTheme { TransmitterItem(transmitter, isClickable = true, isSelected = true, onClick = {}) }
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun EclipsedIndicator() {
|
||||
val bgColor = MaterialTheme.colorScheme.primary
|
||||
val bgShape = MaterialTheme.shapes.medium
|
||||
val infiniteTransition = rememberInfiniteTransition(label = "eclipsed")
|
||||
val textAlpha by infiniteTransition.animateFloat(
|
||||
initialValue = 1.0f,
|
||||
targetValue = 0.0f,
|
||||
animationSpec = infiniteRepeatable(
|
||||
animation = tween(durationMillis = 1000, delayMillis = 25, easing = LinearEasing),
|
||||
repeatMode = RepeatMode.Reverse
|
||||
),
|
||||
label = "eclipsedAlpha"
|
||||
)
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.alpha(textAlpha)
|
||||
.border(width = 2.dp, color = bgColor, shape = bgShape),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
Text(
|
||||
text = stringResource(R.string.radar_eclipsed),
|
||||
fontSize = 18.sp,
|
||||
fontWeight = FontWeight.Medium,
|
||||
color = MaterialTheme.colorScheme.background,
|
||||
modifier = Modifier
|
||||
.background(color = bgColor, shape = bgShape)
|
||||
.padding(12.dp)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun TransmitterItem(
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
*/
|
||||
package com.rtbishop.look4sat.feature.radar
|
||||
|
||||
import androidx.compose.animation.core.LinearEasing
|
||||
import androidx.compose.animation.core.RepeatMode
|
||||
import androidx.compose.animation.core.animateFloat
|
||||
import androidx.compose.animation.core.infiniteRepeatable
|
||||
import androidx.compose.animation.core.rememberInfiniteTransition
|
||||
@@ -78,11 +80,21 @@ fun RadarViewCompose(
|
||||
animationSpec = infiniteRepeatable(tween(1000)),
|
||||
label = "animScale"
|
||||
)
|
||||
val eclipsedGlowAlpha by animTransition.animateFloat(
|
||||
initialValue = 1.0f,
|
||||
targetValue = 0.0f,
|
||||
animationSpec = infiniteRepeatable(
|
||||
animation = tween(durationMillis = 1000, delayMillis = 25, easing = LinearEasing),
|
||||
repeatMode = RepeatMode.Reverse
|
||||
),
|
||||
label = "eclipsedGlowAlpha"
|
||||
)
|
||||
val measurer = rememberTextMeasurer()
|
||||
var sweepDegrees by remember { mutableFloatStateOf(0f) }
|
||||
var cachedRadius by remember { mutableFloatStateOf(0f) }
|
||||
var trackPath by remember { mutableStateOf(Path()) }
|
||||
var trackEffect by remember { mutableStateOf(PathEffect.cornerPathEffect(0f)) }
|
||||
val isEclipsed = item.eclipsed
|
||||
|
||||
Canvas(modifier = modifier.aspectRatio(1f)) {
|
||||
val radius = size.minDimension / 2f * 0.95f
|
||||
@@ -97,7 +109,13 @@ fun RadarViewCompose(
|
||||
drawElevationLabels(radius, trackColor, measurer)
|
||||
translate(center.x, center.y) {
|
||||
drawTrack(trackPath, trackEffect, aimColor, trackColor)
|
||||
if (item.elevation > 0) drawPosition(item, radius, animScale, trackColor)
|
||||
if (item.elevation > 0) {
|
||||
if (isEclipsed) {
|
||||
drawEclipsedPosition(item, radius, eclipsedGlowAlpha, trackColor)
|
||||
} else {
|
||||
drawPosition(item, radius, animScale, trackColor)
|
||||
}
|
||||
}
|
||||
if (shouldUseCompass) drawAim(azimElev.first, azimElev.second, radius, aimColor)
|
||||
}
|
||||
sweepDegrees = (sweepDegrees + SWEEP_INCREMENT) % 360f
|
||||
@@ -135,6 +153,11 @@ private fun DrawScope.drawPosition(item: OrbitalPos, radius: Float, posRadius: F
|
||||
drawCircle(color.copy(alpha = 1 - (posRadius / 64f)), posRadius, pos)
|
||||
}
|
||||
|
||||
private fun DrawScope.drawEclipsedPosition(item: OrbitalPos, radius: Float, glowAlpha: Float, color: Color) {
|
||||
val pos = sph2Cart(item.azimuth, item.elevation, radius.toDouble())
|
||||
drawCircle(color.copy(alpha = glowAlpha), 16f, pos)
|
||||
}
|
||||
|
||||
private fun DrawScope.drawAim(azim: Float, elev: Float, radius: Float, color: Color) {
|
||||
val size = 36f
|
||||
val azimRad = azim.toDouble().toRadians()
|
||||
|
||||
Reference in new issue
Block a user