From d8c70a4b5c862bfe47a3c78f22fc71b77c2e0bc8 Mon Sep 17 00:00:00 2001 From: Alex Baker Date: Mon, 4 Jul 2022 01:21:24 -0500 Subject: [PATCH] Inline DeadlineControlSet variables --- .../java/org/tasks/ui/DeadlineControlSet.kt | 38 +++++++++---------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/app/src/main/java/org/tasks/ui/DeadlineControlSet.kt b/app/src/main/java/org/tasks/ui/DeadlineControlSet.kt index 21b7d5286..ac88f4a1e 100644 --- a/app/src/main/java/org/tasks/ui/DeadlineControlSet.kt +++ b/app/src/main/java/org/tasks/ui/DeadlineControlSet.kt @@ -27,7 +27,6 @@ import javax.inject.Inject @AndroidEntryPoint class DeadlineControlSet : TaskEditControlComposeFragment() { - @Inject lateinit var activity: Activity @Inject lateinit var locale: Locale @Inject lateinit var preferences: Preferences @@ -47,28 +46,25 @@ class DeadlineControlSet : TaskEditControlComposeFragment() { @Composable override fun Body() { - val context = LocalContext.current val dueDate = viewModel.dueDate.collectAsStateLifecycleAware().value - val text = if (dueDate == 0L) { - stringResource(id = R.string.no_due_date) - } else { - DateUtilities.getRelativeDateTime( - context, - dueDate, - locale, - FormatStyle.FULL, - preferences.alwaysDisplayFullDate, - false - ) - } - val color = when { - dueDate == 0L -> MaterialTheme.colors.onSurface.copy(alpha = ContentAlpha.disabled) - dueDate.isOverdue -> colorResource(id = R.color.overdue) - else -> MaterialTheme.colors.onSurface - } Text( - text = text, - color = color, + text = if (dueDate == 0L) { + stringResource(id = R.string.no_due_date) + } else { + DateUtilities.getRelativeDateTime( + LocalContext.current, + dueDate, + locale, + FormatStyle.FULL, + preferences.alwaysDisplayFullDate, + false + ) + }, + color = when { + dueDate == 0L -> MaterialTheme.colors.onSurface.copy(alpha = ContentAlpha.disabled) + dueDate.isOverdue -> colorResource(id = R.color.overdue) + else -> MaterialTheme.colors.onSurface + }, modifier = Modifier.padding(vertical = 20.dp) ) }