mirror of
https://github.com/atsunatsu/Look4Sat.git
synced 2026-10-04 03:37:21 +00:00
Added several tweaks to TimerRow and NextPassRow
This commit is contained in:
1 parent
08767c5589
commit
68d814d996
15 files changed
+270
-133
No files matched your search
@@ -4,13 +4,15 @@ import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.widget.Toast
|
||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||
import androidx.compose.foundation.basicMarquee
|
||||
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.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.RowScope
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
@@ -21,97 +23,158 @@ import androidx.compose.material3.CircularProgressIndicator
|
||||
import androidx.compose.material3.ElevatedButton
|
||||
import androidx.compose.material3.ElevatedCard
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.LinearProgressIndicator
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.res.vectorResource
|
||||
import androidx.compose.ui.text.PlatformTextStyle
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import com.rtbishop.look4sat.R
|
||||
import com.rtbishop.look4sat.domain.predict.NearEarthObject
|
||||
import com.rtbishop.look4sat.domain.predict.OrbitalData
|
||||
import com.rtbishop.look4sat.domain.predict.OrbitalPass
|
||||
import com.rtbishop.look4sat.presentation.MainTheme
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
import java.util.Locale
|
||||
|
||||
private val sdf = SimpleDateFormat("HH:mm:ss", Locale.ENGLISH)
|
||||
|
||||
@Composable
|
||||
@Preview(showBackground = true)
|
||||
private fun TimerBarNewPreview() {
|
||||
MainTheme { TimerBarNew("88:88:88", "88:88:88") }
|
||||
private fun TimerRowPreview() = MainTheme {
|
||||
TimerRow {
|
||||
CardIcon(onClick = {}, iconId = R.drawable.ic_filter)
|
||||
TimerBar(timeString = "88:88:88", isTimeAos = true)
|
||||
CardIcon(onClick = {}, iconId = R.drawable.ic_satellite)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun TimerBarNew(aosTime: String, losTime: String) {
|
||||
val isAosSelected = remember { mutableStateOf(true) }
|
||||
val barHeightMod = Modifier.height(48.dp)
|
||||
val timerText = if (isAosSelected.value) aosTime else losTime
|
||||
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(6.dp)) {
|
||||
CardAosLos(onClick = { isAosSelected.value = true }, iconId = R.drawable.ic_aos, isAosSelected.value)
|
||||
ElevatedCard(modifier = barHeightMod.weight(1f)) {
|
||||
fun TimerRow(content: @Composable (RowScope.() -> Unit)) {
|
||||
Row(
|
||||
modifier = Modifier.height(48.dp),
|
||||
horizontalArrangement = Arrangement.spacedBy(6.dp),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) { content() }
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun RowScope.TimerBar(timeString: String, isTimeAos: Boolean) {
|
||||
val aosColor = if (isTimeAos) MaterialTheme.colorScheme.primary else MaterialTheme.colorScheme.onSurface
|
||||
val losColor = if (!isTimeAos) MaterialTheme.colorScheme.primary else MaterialTheme.colorScheme.onSurface
|
||||
ElevatedCard(modifier = Modifier.weight(1f)) {
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.SpaceEvenly,
|
||||
modifier = Modifier.fillMaxSize()
|
||||
) {
|
||||
Text(text = "AOS", fontSize = 16.sp, color = aosColor)
|
||||
Text(
|
||||
text = "T- $timerText",
|
||||
textAlign = TextAlign.Center,
|
||||
fontSize = 42.sp,
|
||||
text = timeString,
|
||||
fontSize = 32.sp,
|
||||
fontWeight = FontWeight.Bold,
|
||||
color = MaterialTheme.colorScheme.primary,
|
||||
style = TextStyle(platformStyle = PlatformTextStyle(includeFontPadding = false)),
|
||||
modifier = Modifier.fillMaxSize()
|
||||
color = MaterialTheme.colorScheme.primary
|
||||
)
|
||||
Text(text = "LOS", fontSize = 16.sp, color = losColor)
|
||||
}
|
||||
CardAosLos(onClick = { isAosSelected.value = false }, iconId = R.drawable.ic_los, isAosSelected.value.not())
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
@Preview(showBackground = true)
|
||||
private fun TimerBarPreview() {
|
||||
MainTheme { TimerBar(45555, "Satellite", "88:88:88", R.drawable.ic_filter) {} }
|
||||
private fun NextPassRowPreview() = MainTheme {
|
||||
NextPassRow(pass = getDefaultPass())
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalFoundationApi::class)
|
||||
@Composable
|
||||
fun TimerBar(id: Int, name: String, time: String, iconId: Int, action: () -> Unit) {
|
||||
val barHeightMod = Modifier.height(48.dp)
|
||||
val maxSizeMod = Modifier.fillMaxSize()
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(6.dp)
|
||||
) {
|
||||
ElevatedCard(modifier = barHeightMod.weight(1f)) {
|
||||
Row(
|
||||
modifier = maxSizeMod.padding(horizontal = 6.dp, vertical = 4.dp),
|
||||
verticalAlignment = Alignment.Top
|
||||
) {
|
||||
fun NextPassRow(pass: OrbitalPass) {
|
||||
ElevatedCard {
|
||||
Column(
|
||||
verticalArrangement = Arrangement.spacedBy(2.dp),
|
||||
modifier = Modifier
|
||||
.background(color = MaterialTheme.colorScheme.surface)
|
||||
.padding(horizontal = 6.dp, vertical = 4.dp)
|
||||
) {
|
||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||
Text(
|
||||
text = "Id:$id - ",
|
||||
text = "Id:${pass.catNum} - ",
|
||||
modifier = Modifier.width(82.dp),
|
||||
textAlign = TextAlign.End,
|
||||
color = MaterialTheme.colorScheme.primary
|
||||
)
|
||||
Text(
|
||||
text = name,
|
||||
text = pass.name,
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
.padding(end = 6.dp),
|
||||
fontWeight = FontWeight.Medium,
|
||||
modifier = Modifier.basicMarquee(iterations = Int.MAX_VALUE)
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis
|
||||
)
|
||||
Icon(
|
||||
painter = painterResource(id = R.drawable.ic_elevation),
|
||||
contentDescription = null,
|
||||
tint = MaterialTheme.colorScheme.primary,
|
||||
modifier = Modifier.size(16.dp)
|
||||
)
|
||||
Text(
|
||||
text = " ${pass.maxElevation}°",
|
||||
textAlign = TextAlign.End,
|
||||
color = MaterialTheme.colorScheme.primary
|
||||
)
|
||||
}
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
) {
|
||||
Text(
|
||||
text = stringResource(id = R.string.pass_aosAz, pass.aosAzimuth),
|
||||
textAlign = TextAlign.Start,
|
||||
fontSize = 15.sp,
|
||||
modifier = Modifier.weight(1f)
|
||||
)
|
||||
Text(
|
||||
text = stringResource(id = R.string.pass_altitude, pass.altitude),
|
||||
textAlign = TextAlign.Center,
|
||||
fontSize = 15.sp,
|
||||
modifier = Modifier.weight(2f)
|
||||
)
|
||||
Text(
|
||||
text = stringResource(id = R.string.pass_losAz, pass.losAzimuth),
|
||||
textAlign = TextAlign.End,
|
||||
fontSize = 15.sp,
|
||||
modifier = Modifier.weight(1f)
|
||||
)
|
||||
}
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
) {
|
||||
val defaultTime = " - - : - - "
|
||||
Text(text = if (pass.isDeepSpace) defaultTime else sdf.format(Date(pass.aosTime)), fontSize = 15.sp)
|
||||
LinearProgressIndicator(
|
||||
progress = { if (pass.isDeepSpace) 100f else pass.progress },
|
||||
modifier = Modifier
|
||||
.fillMaxWidth(0.75f)
|
||||
.padding(top = 2.dp),
|
||||
trackColor = MaterialTheme.colorScheme.inverseSurface
|
||||
)
|
||||
Text(text = if (pass.isDeepSpace) defaultTime else sdf.format(Date(pass.losTime)), fontSize = 15.sp)
|
||||
}
|
||||
}
|
||||
ElevatedCard(modifier = barHeightMod) {
|
||||
Text(
|
||||
text = time,
|
||||
fontSize = 32.sp,
|
||||
fontWeight = FontWeight.Bold,
|
||||
color = MaterialTheme.colorScheme.primary,
|
||||
modifier = Modifier.padding(horizontal = 8.dp, vertical = 6.dp),
|
||||
style = TextStyle(platformStyle = PlatformTextStyle(includeFontPadding = false))
|
||||
)
|
||||
}
|
||||
CardIcon(onClick = { action() }, iconId = iconId)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,17 +199,17 @@ fun CardIcon(onClick: () -> Unit, iconId: Int, description: String? = null) {
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun CardAosLos(onClick: () -> Unit, iconId: Int, isAos: Boolean = true, description: String? = null) {
|
||||
val cardColors = if (isAos) {
|
||||
fun StatusIcon(iconResId: Int, isEnabled: Boolean = false, description: String? = null, onClick: (() -> Unit)? = null) {
|
||||
val cardColors = if (isEnabled) {
|
||||
CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.primary)
|
||||
} else {
|
||||
CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surface)
|
||||
}
|
||||
val iconTint = if (isAos) MaterialTheme.colorScheme.surface else MaterialTheme.colorScheme.onSurface
|
||||
val clickableModifier = Modifier.clickable { onClick() }
|
||||
val clickableModifier = if (onClick != null) Modifier.clickable { onClick.invoke() } else Modifier
|
||||
val iconTint = if (isEnabled) MaterialTheme.colorScheme.surface else MaterialTheme.colorScheme.onSurface
|
||||
ElevatedCard(modifier = Modifier.size(48.dp), colors = cardColors) {
|
||||
Box(modifier = clickableModifier.fillMaxSize(), contentAlignment = Alignment.Center) {
|
||||
Icon(imageVector = ImageVector.vectorResource(iconId), tint = iconTint, contentDescription = description)
|
||||
Icon(imageVector = ImageVector.vectorResource(iconResId), tint = iconTint, contentDescription = description)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -166,6 +229,12 @@ fun gotoUrl(context: Context, url: String) {
|
||||
context.startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(url)))
|
||||
}
|
||||
|
||||
fun getDefaultPass(): OrbitalPass {
|
||||
val orbitalData = OrbitalData("Next Satellite", 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, 0.0)
|
||||
val satellite = NearEarthObject(orbitalData)
|
||||
return OrbitalPass(0L, 0.0, 0L, 0.0, 0, 0.0, satellite, 0f)
|
||||
}
|
||||
|
||||
//fun Modifier.onClick(onClick: () -> Unit): Modifier = composed {
|
||||
// clickable(remember { MutableInteractionSource() }, null) { onClick() }
|
||||
//}
|
||||
@@ -37,10 +37,12 @@ import com.rtbishop.look4sat.domain.predict.NearEarthObject
|
||||
import com.rtbishop.look4sat.domain.predict.OrbitalData
|
||||
import com.rtbishop.look4sat.domain.predict.OrbitalPass
|
||||
import com.rtbishop.look4sat.presentation.MainTheme
|
||||
import com.rtbishop.look4sat.presentation.components.CardIcon
|
||||
import com.rtbishop.look4sat.presentation.components.NextPassRow
|
||||
import com.rtbishop.look4sat.presentation.components.PullRefreshIndicator
|
||||
import com.rtbishop.look4sat.presentation.components.PullRefreshState
|
||||
import com.rtbishop.look4sat.presentation.components.TimerBar
|
||||
import com.rtbishop.look4sat.presentation.components.TimerBarNew
|
||||
import com.rtbishop.look4sat.presentation.components.TimerRow
|
||||
import com.rtbishop.look4sat.presentation.components.pullRefresh
|
||||
import com.rtbishop.look4sat.presentation.components.rememberPullRefreshState
|
||||
import java.text.SimpleDateFormat
|
||||
@@ -51,9 +53,8 @@ private val sdf = SimpleDateFormat("HH:mm:ss", Locale.ENGLISH)
|
||||
|
||||
@Composable
|
||||
fun PassesScreen(uiState: PassesState, navToRadar: (Int, Long) -> Unit) {
|
||||
val refreshState = rememberPullRefreshState(refreshing = uiState.isRefreshing, onRefresh = {
|
||||
uiState.takeAction(PassesAction.RefreshPasses)
|
||||
})
|
||||
val refreshPasses = { uiState.takeAction(PassesAction.RefreshPasses) }
|
||||
val refreshState = rememberPullRefreshState(refreshing = uiState.isRefreshing, onRefresh = refreshPasses)
|
||||
val toggleDialog = { uiState.takeAction(PassesAction.ToggleFilterDialog) }
|
||||
if (uiState.isDialogShown) {
|
||||
FilterDialog(uiState.hours, uiState.elevation, uiState.modes, toggleDialog) { hours, elevation, modes ->
|
||||
@@ -61,17 +62,38 @@ fun PassesScreen(uiState: PassesState, navToRadar: (Int, Long) -> Unit) {
|
||||
}
|
||||
}
|
||||
Column(modifier = Modifier.padding(6.dp), verticalArrangement = Arrangement.spacedBy(6.dp)) {
|
||||
TimerBarNew(aosTime = uiState.nextTime, losTime = uiState.nextTime)
|
||||
TimerBar(
|
||||
id = uiState.nextId,
|
||||
name = uiState.nextName,
|
||||
time = uiState.nextTime,
|
||||
iconId = R.drawable.ic_filter
|
||||
) { toggleDialog() }
|
||||
PassesCard(refreshState, uiState.isRefreshing, uiState.itemsList, navToRadar)
|
||||
TimerRow {
|
||||
CardIcon(onClick = { toggleDialog() }, iconId = R.drawable.ic_filter)
|
||||
TimerBar(timeString = uiState.nextTime, isTimeAos = uiState.isNextTimeAos)
|
||||
CardIcon(onClick = { toggleDialog() }, iconId = R.drawable.ic_satellite)
|
||||
}
|
||||
NextPassRow(pass = uiState.nextPass)
|
||||
PassesList(refreshState, uiState.isRefreshing, uiState.itemsList, navToRadar)
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalFoundationApi::class)
|
||||
@Composable
|
||||
private fun PassesList(
|
||||
refreshState: PullRefreshState,
|
||||
isRefreshing: Boolean,
|
||||
passes: List<OrbitalPass>,
|
||||
navToRadar: (Int, Long) -> Unit
|
||||
) {
|
||||
val backgroundColor = MaterialTheme.colorScheme.primary
|
||||
ElevatedCard(modifier = Modifier.fillMaxSize()) {
|
||||
Box(Modifier.pullRefresh(refreshState), contentAlignment = Alignment.TopCenter) {
|
||||
LazyColumn(modifier = Modifier.fillMaxSize()) {
|
||||
items(items = passes, key = { item -> item.catNum + item.aosTime }) { pass ->
|
||||
PassItem(pass = pass, navToRadar = navToRadar, modifier = Modifier.animateItemPlacement())
|
||||
}
|
||||
}
|
||||
PullRefreshIndicator(refreshing = isRefreshing, state = refreshState, backgroundColor = backgroundColor)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Preview(showBackground = true)
|
||||
@Composable
|
||||
private fun DeepSpacePassPreview() {
|
||||
@@ -80,7 +102,7 @@ private fun DeepSpacePassPreview() {
|
||||
)
|
||||
val satellite = DeepSpaceObject(data)
|
||||
val pass = OrbitalPass(1L, 0.0, 10L, 180.0, 850, 45.0, satellite, 0.5f)
|
||||
MainTheme { Pass(pass = pass, { _, _ -> }) }
|
||||
MainTheme { PassItem(pass = pass, { _, _ -> }) }
|
||||
}
|
||||
|
||||
@Preview(showBackground = true)
|
||||
@@ -91,13 +113,11 @@ private fun NearEarthPassPreview() {
|
||||
)
|
||||
val satellite = NearEarthObject(data)
|
||||
val pass = OrbitalPass(1L, 0.0, 10L, 180.0, 850, 45.0, satellite, 0.5f)
|
||||
MainTheme { Pass(pass = pass, { _, _ -> }) }
|
||||
MainTheme { PassItem(pass = pass, { _, _ -> }) }
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun Pass(
|
||||
pass: OrbitalPass, navToRadar: (Int, Long) -> Unit, modifier: Modifier = Modifier
|
||||
) {
|
||||
private fun PassItem(pass: OrbitalPass, navToRadar: (Int, Long) -> Unit, modifier: Modifier = Modifier) {
|
||||
Surface(color = MaterialTheme.colorScheme.background, modifier = modifier) {
|
||||
Surface(modifier = Modifier
|
||||
.padding(bottom = 2.dp)
|
||||
@@ -105,8 +125,8 @@ private fun Pass(
|
||||
Column(
|
||||
verticalArrangement = Arrangement.spacedBy(2.dp),
|
||||
modifier = Modifier
|
||||
.background(MaterialTheme.colorScheme.surface)
|
||||
.padding(6.dp)
|
||||
.background(color = MaterialTheme.colorScheme.surface)
|
||||
.padding(horizontal = 6.dp, vertical = 4.dp)
|
||||
) {
|
||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||
Text(
|
||||
@@ -160,55 +180,23 @@ private fun Pass(
|
||||
modifier = Modifier.weight(1f)
|
||||
)
|
||||
}
|
||||
if (!pass.isDeepSpace) {
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
) {
|
||||
Text(
|
||||
text = sdf.format(Date(pass.aosTime)),
|
||||
fontSize = 15.sp
|
||||
)
|
||||
LinearProgressIndicator(
|
||||
progress = pass.progress,
|
||||
modifier = modifier
|
||||
.fillMaxWidth(0.75f)
|
||||
.padding(top = 3.dp),
|
||||
trackColor = MaterialTheme.colorScheme.inverseSurface
|
||||
)
|
||||
Text(
|
||||
text = sdf.format(Date(pass.losTime)),
|
||||
fontSize = 15.sp
|
||||
)
|
||||
}
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
) {
|
||||
val defaultTime = " - - : - - "
|
||||
Text(text = if (pass.isDeepSpace) defaultTime else sdf.format(Date(pass.aosTime)), fontSize = 15.sp)
|
||||
LinearProgressIndicator(
|
||||
progress = { if (pass.isDeepSpace) 100f else pass.progress },
|
||||
modifier = modifier
|
||||
.fillMaxWidth(0.75f)
|
||||
.padding(top = 2.dp),
|
||||
trackColor = MaterialTheme.colorScheme.inverseSurface
|
||||
)
|
||||
Text(text = if (pass.isDeepSpace) defaultTime else sdf.format(Date(pass.losTime)), fontSize = 15.sp)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalFoundationApi::class)
|
||||
@Composable
|
||||
private fun PassesCard(
|
||||
refreshState: PullRefreshState,
|
||||
isRefreshing: Boolean,
|
||||
passes: List<OrbitalPass>,
|
||||
navToRadar: (Int, Long) -> Unit
|
||||
) {
|
||||
ElevatedCard(modifier = Modifier.fillMaxSize()) {
|
||||
Box(Modifier.pullRefresh(refreshState)) {
|
||||
LazyColumn(modifier = Modifier.fillMaxSize()) {
|
||||
items(items = passes, key = { item -> item.catNum + item.aosTime }) { pass ->
|
||||
Pass(pass, navToRadar, Modifier.animateItemPlacement())
|
||||
}
|
||||
}
|
||||
PullRefreshIndicator(
|
||||
refreshing = isRefreshing,
|
||||
state = refreshState,
|
||||
modifier = Modifier.align(Alignment.TopCenter),
|
||||
backgroundColor = MaterialTheme.colorScheme.primary
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,9 +6,9 @@ data class PassesState(
|
||||
val isDialogShown: Boolean,
|
||||
val isRefreshing: Boolean,
|
||||
val isUtc: Boolean,
|
||||
val nextId: Int,
|
||||
val nextName: String,
|
||||
val nextPass: OrbitalPass,
|
||||
val nextTime: String,
|
||||
val isNextTimeAos: Boolean,
|
||||
val hours: Int,
|
||||
val elevation: Double,
|
||||
val modes: List<String>,
|
||||
|
||||
@@ -30,6 +30,7 @@ import com.rtbishop.look4sat.domain.predict.OrbitalPass
|
||||
import com.rtbishop.look4sat.domain.repository.ISatelliteRepo
|
||||
import com.rtbishop.look4sat.domain.repository.ISettingsRepo
|
||||
import com.rtbishop.look4sat.domain.utility.toTimerString
|
||||
import com.rtbishop.look4sat.presentation.components.getDefaultPass
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.cancelAndJoin
|
||||
import kotlinx.coroutines.delay
|
||||
@@ -45,9 +46,9 @@ class PassesViewModel(
|
||||
isDialogShown = false,
|
||||
isRefreshing = true,
|
||||
isUtc = settingsRepo.otherSettings.value.stateOfUtc,
|
||||
nextId = 0,
|
||||
nextName = "...",
|
||||
nextTime = "00:00:00",
|
||||
isNextTimeAos = true,
|
||||
nextPass = getDefaultPass(),
|
||||
hours = settingsRepo.passesSettings.value.hoursAhead,
|
||||
elevation = settingsRepo.passesSettings.value.minElevation,
|
||||
modes = settingsRepo.passesSettings.value.selectedModes,
|
||||
@@ -103,11 +104,11 @@ class PassesViewModel(
|
||||
try {
|
||||
val nextPass = passes.first { it.aosTime.minus(timeNow) > 0 }
|
||||
val time = nextPass.aosTime.minus(timeNow).toTimerString()
|
||||
_uiState.value = _uiState.value.copy(nextId = nextPass.catNum, nextName = nextPass.name, nextTime = time)
|
||||
_uiState.value = _uiState.value.copy(nextPass = nextPass, nextTime = time, isNextTimeAos = true)
|
||||
} catch (exception: NoSuchElementException) {
|
||||
val lastPass = passes.last()
|
||||
val time = lastPass.losTime.minus(timeNow).toTimerString()
|
||||
_uiState.value = _uiState.value.copy(nextId = lastPass.catNum, nextName = lastPass.name, nextTime = time)
|
||||
_uiState.value = _uiState.value.copy(nextPass = lastPass, nextTime = time, isNextTimeAos = false)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@ import androidx.compose.ui.unit.sp
|
||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||
import com.rtbishop.look4sat.R
|
||||
import com.rtbishop.look4sat.domain.model.SatRadio
|
||||
import com.rtbishop.look4sat.presentation.components.TimerBar
|
||||
|
||||
@Composable
|
||||
fun RadarScreen() {
|
||||
@@ -36,7 +35,7 @@ fun RadarScreen() {
|
||||
val id = currentPass?.catNum ?: 99999
|
||||
val name = currentPass?.name ?: "Satellite"
|
||||
Column(modifier = Modifier.padding(6.dp), verticalArrangement = Arrangement.spacedBy(6.dp)) {
|
||||
TimerBar(id, name, "88:88:88", R.drawable.ic_notifications) {}
|
||||
// TimerBarNew(id, name, "88:88:88", R.drawable.ic_notifications) {}
|
||||
ElevatedCard(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
|
||||
Reference in new issue
Block a user