Skip to content

Commit

Permalink
feat(done): Align styling with Deck server app
Browse files Browse the repository at this point in the history
Refs: #1556

Signed-off-by: Stefan Niedermann <[email protected]>
  • Loading branch information
stefan-niedermann committed Jan 15, 2024
1 parent c970578 commit 5efb087
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.time.format.FormatStyle;
import java.util.stream.Stream;

import it.niedermann.nextcloud.deck.R;
import it.niedermann.nextcloud.deck.databinding.ViewCardDueDateBinding;
import it.niedermann.nextcloud.deck.ui.theme.ThemeUtils;
import it.niedermann.nextcloud.deck.ui.theme.Themed;
Expand All @@ -36,6 +37,7 @@ public class CardDueDateView extends FrameLayout implements DatePickerDialog.OnD
private final ViewCardDueDateBinding binding;
@Nullable
private DueDateChangedListener dueDateChangedListener;
private final DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("d. MMM yyyy HH:mm");
private final DateTimeFormatter dateFormatter = DateTimeFormatter.ofLocalizedDate(FormatStyle.MEDIUM);
private final DateTimeFormatter timeFormatter = DateTimeFormatter.ofLocalizedTime(FormatStyle.SHORT);
@Nullable
Expand Down Expand Up @@ -171,14 +173,14 @@ private void setTextState() {
binding.dueDateDate.setText(null);
binding.dueDateTime.setText(null);

binding.doneDate.setText(done.atZone(ZoneId.systemDefault()).format(dateFormatter));
binding.doneDate.setText(done.atZone(ZoneId.systemDefault()).format(dateTimeFormatter));

if (this.dueDate == null) {
binding.doneDueDate.setText(null);

} else {
final var dueDate = this.dueDate.atZone(ZoneId.systemDefault());
binding.doneDueDate.setText(dueDate.format(dateFormatter));
binding.doneDueDate.setText(getContext().getString(R.string.label_due_at, dueDate.format(dateTimeFormatter)));
}
}
}
Expand Down Expand Up @@ -267,10 +269,13 @@ public void applyTheme(int color) {
binding.dueDateTimeWrapper
).forEach(utils.material::colorTextInputLayout);

Stream.of(
binding.doneDueDate,
binding.doneDate
).forEach(utils.platform::colorTextView);
// Stream.of(
// binding.doneDueDate,
// binding.doneDate
// ).forEach(v -> utils.platform.colorTextView(v, ColorRole.ON_SURFACE));

utils.platform.colorTextView(binding.doneDate, ColorRole.ON_SURFACE);
utils.platform.colorTextView(binding.doneDueDate, ColorRole.ON_SURFACE_VARIANT);

Stream.of(
binding.clearDone,
Expand Down
33 changes: 20 additions & 13 deletions app/src/main/res/layout/view_card_due_date.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,40 @@
android:id="@+id/doneCheck"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginVertical="@dimen/spacer_1hx"
android:layout_marginStart="@dimen/spacer_1qx"
android:layout_marginEnd="0dp"
android:layout_marginBottom="@dimen/spacer_1hx"
android:contentDescription="@null"
android:padding="@dimen/spacer_11qx"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_check_white_24dp"
app:tint="?attr/colorOnSurface" />
app:tint="?attr/colorOnSurface"
tools:visibility="gone" />

<TextView
android:id="@+id/doneDate"
style="?attr/textAppearanceBody1"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="@id/doneCheck"
app:layout_constraintEnd_toStartOf="@id/clearDone"
app:layout_constraintStart_toEndOf="@id/doneCheck"
app:layout_constraintTop_toTopOf="@id/doneCheck"
tools:text="@tools:sample/date/ddmmyy" />
tools:text="@tools:sample/date/ddmmyy"
tools:visibility="gone" />

<TextView
android:id="@+id/done_due_date"
style="?attr/textAppearanceBody1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/spacer_1x"
app:layout_constraintEnd_toStartOf="@id/clearDone"
app:layout_constraintStart_toEndOf="@id/doneCheck"
app:layout_constraintTop_toBottomOf="@id/doneDate"
tools:text="@tools:sample/date/ddmmyy"
tools:visibility="gone" />

<ImageView
android:id="@+id/clearDone"
Expand All @@ -41,16 +56,8 @@
app:layout_constraintBottom_toBottomOf="@id/doneDate"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/doneDate"
app:srcCompat="@drawable/ic_close_circle_grey600" />

<TextView
android:id="@+id/done_due_date"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toStartOf="@id/clearDone"
app:layout_constraintStart_toEndOf="@id/doneCheck"
app:layout_constraintTop_toBottomOf="@id/doneDate"
tools:text="@tools:sample/date/ddmmyy" />
app:srcCompat="@drawable/ic_close_circle_grey600"
tools:visibility="gone" />

<com.google.android.material.textfield.TextInputLayout
android:id="@+id/dueDateDateWrapper"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@

<string name="label_clear_due_date">Clear due date</string>
<string name="label_clear_done">Not completed</string>
<string name="label_due_at">Due at: %1$s</string>
<string name="label_add">Add %1$s</string>

<string name="url_maintainer" translatable="false">https://www.niedermann.it/</string>
Expand Down

0 comments on commit 5efb087

Please sign in to comment.