@@ -4,32 +4,21 @@ import androidx.compose.foundation.layout.Row
44import androidx.compose.foundation.layout.Spacer
55import androidx.compose.foundation.layout.padding
66import androidx.compose.foundation.layout.width
7- import androidx.compose.material.icons.Icons
8- import androidx.compose.material.icons.filled.Warning
97import androidx.compose.material3.AssistChip
108import androidx.compose.material3.AssistChipDefaults
11- import androidx.compose.material3.Icon
129import androidx.compose.material3.MaterialTheme
1310import androidx.compose.material3.Text
1411import androidx.compose.runtime.Composable
15- import androidx.compose.runtime.remember
1612import androidx.compose.ui.Alignment
1713import androidx.compose.ui.Modifier
1814import androidx.compose.ui.unit.dp
1915import org.mozilla.tryfox.model.AppState
20- import org.mozilla.tryfox.util.parseDateToMillis
21- import kotlin.time.Duration.Companion.milliseconds
2216
2317@Composable
2418fun CurrentInstallState (
2519 appState : AppState ? ,
26- apkDisplayDateString : String ,
2720 modifier : Modifier = Modifier ,
2821) {
29- val apkDateMillis: Long = remember(apkDisplayDateString) {
30- parseDateToMillis(apkDisplayDateString)
31- }
32-
3322 Row (
3423 modifier = modifier.padding(bottom = 8 .dp),
3524 verticalAlignment = Alignment .CenterVertically ,
@@ -46,52 +35,13 @@ fun CurrentInstallState(
4635 border = null ,
4736 )
4837 }
49- apkDateMillis == 0L || appState.installDateMillis == null -> {
38+ else -> {
5039 AssistChip (
5140 onClick = { /* No action */ },
5241 label = { Text (" Installed" ) },
5342 border = AssistChipDefaults .assistChipBorder(true ),
5443 )
5544 }
56- appState.installDateMillis >= apkDateMillis -> {
57- AssistChip (
58- onClick = { /* No action */ },
59- label = { Text (" Up to date" ) },
60- colors = AssistChipDefaults .assistChipColors(
61- containerColor = MaterialTheme .colorScheme.primaryContainer,
62- labelColor = MaterialTheme .colorScheme.onPrimaryContainer,
63- ),
64- border = null ,
65- )
66- }
67- else -> {
68- val diff = (apkDateMillis - appState.installDateMillis).milliseconds
69- val daysBehind = diff.inWholeDays
70- val hoursBehind = diff.inWholeHours
71-
72- val timeBehindText = when {
73- daysBehind > 31 -> " ${daysBehind / 7 } weeks behind"
74- daysBehind > 0 -> " $daysBehind days behind"
75- hoursBehind > 0 -> " $hoursBehind hours behind"
76- else -> " Less than an hour behind"
77- }
78- AssistChip (
79- onClick = { /* No action */ },
80- label = { Text (timeBehindText) },
81- leadingIcon = {
82- Icon (
83- Icons .Filled .Warning ,
84- contentDescription = " Warning" ,
85- tint = MaterialTheme .colorScheme.onTertiaryContainer,
86- )
87- },
88- colors = AssistChipDefaults .assistChipColors(
89- containerColor = MaterialTheme .colorScheme.tertiaryContainer,
90- labelColor = MaterialTheme .colorScheme.onTertiaryContainer,
91- ),
92- border = null ,
93- )
94- }
9545 }
9646
9747 if (appState != null && appState.isInstalled) {
0 commit comments