Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polish Date Range picker UI #13579

Merged
merged 8 commits into from
Dec 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.google.android.material.datepicker.CalendarConstraints
import com.google.android.material.datepicker.DateValidatorPointBackward
import com.google.android.material.datepicker.MaterialDatePicker
import com.google.android.material.snackbar.Snackbar
import kotlinx.android.synthetic.main.activity_log_list_fragment.*
Expand Down Expand Up @@ -185,6 +187,13 @@ class ActivityLogListFragment : Fragment() {
private fun showDateRangePicker(initialDateRange: DateRange?) {
val picker = MaterialDatePicker.Builder
.dateRangePicker()
.setTheme(R.style.WordPress_MaterialCalendarFullscreenTheme)
.setCalendarConstraints(
CalendarConstraints.Builder()
.setValidator(DateValidatorPointBackward.now())
.setEnd(MaterialDatePicker.todayInUtcMilliseconds())
.build()
)
.setSelection(initialDateRange)
.build()
initDateRangePickerButtonClickListener(picker)
Expand Down
32 changes: 27 additions & 5 deletions WordPress/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,23 +95,31 @@
<item name="layoutPickerBackground">@color/white</item>

<!-- Material Date Range Picker -->
<item name="materialCalendarStyle">@style/WordPress.MaterialCalendarStyle</item>
<item name="materialCalendarStyle">@style/Widget.MaterialComponents.MaterialCalendar</item>
<item name="materialCalendarFullscreenTheme">@style/WordPress.MaterialCalendarFullscreenTheme</item>
<item name="materialCalendarTheme">@style/WordPress.MaterialCalendarTheme</item>
</style>

<style name="WordPress.MaterialCalendarStyle" parent="Widget.MaterialComponents.MaterialCalendar">
</style>

<style name="WordPress.MaterialCalendarFullscreenTheme" parent="ThemeOverlay.MaterialComponents.MaterialCalendar.Fullscreen">
<item name="materialCalendarStyle">@style/WordPress.MaterialCalendarStyle</item>
<item name="materialCalendarHeaderTitle">@style/WordPress.MaterialCalendarHeaderTitle</item>
<item name="materialCalendarHeaderLayout">@style/WordPress.MaterialCalendarHeaderLayout</item>
<item name="materialCalendarHeaderSelection">@style/WordPress.MaterialCalendarHeaderSelection</item>
<item name="materialCalendarHeaderToggleButton">@style/WordPress.MaterialCalendarHeaderToggleButton</item>
<item name="materialCalendarHeaderConfirmButton">@style/WordPress.MaterialCalendarHeaderConfirmButton</item>
<item name="materialCalendarHeaderDivider">@style/WordPress.MaterialCalendarHeaderDivider</item>
<!-- Days of week header -->
<item name="textAppearanceBody2">@style/WordPress.TextAppearance.MaterialCalendarDaysOfWeek</item>
<!-- Grid day items -->
<item name="materialCalendarDay">@style/WordPress.MaterialCalendarDayTextView</item>
<!-- Used to color the cancel button which doesn't use any overridable styles -->
<item name="colorOnPrimary">?attr/colorOnSurface</item>
<item name="android:background">?attr/colorSurface</item>
</style>

<style name="WordPress.MaterialCalendarStyle" parent="Widget.MaterialComponents.MaterialCalendar.Fullscreen">
<!-- Grid selected day item -->
<item name="daySelectedStyle">@style/WordPress.MaterialCalendarSelectedDay</item>
</style>

<style name="WordPress.MaterialCalendarTheme" parent="ThemeOverlay.MaterialComponents.MaterialCalendar">
Expand All @@ -127,6 +135,8 @@

<style name="WordPress.MaterialCalendarHeaderSelection" parent="Widget.MaterialComponents.MaterialCalendar.HeaderSelection.Fullscreen">
<item name="android:textColor">?attr/colorOnSurface</item>
<item name="android:textAppearance">?attr/textAppearanceHeadline5</item>
<item name="android:background">@color/transparent</item>
</style>

<style name="WordPress.MaterialCalendarHeaderToggleButton" parent="Widget.MaterialComponents.MaterialCalendar.HeaderToggleButton">
Expand All @@ -140,7 +150,19 @@

<style name="WordPress.MaterialCalendarHeaderDivider" parent="Widget.MaterialComponents.MaterialCalendar.HeaderDivider">
<item name="android:visibility">visible</item>
<item name="android:background">?attr/colorOnSurface</item>
<item name="android:background">@color/divider</item>
</style>

<style name="WordPress.TextAppearance.MaterialCalendarDaysOfWeek" parent="TextAppearance.MaterialComponents.Body2">
<item name="android:textSize">@dimen/text_sz_medium</item>
</style>

<style name="WordPress.MaterialCalendarDayTextView" parent="Widget.MaterialComponents.MaterialCalendar.DayTextView">
<item name="android:textSize">@dimen/text_sz_medium</item>
</style>

<style name="WordPress.MaterialCalendarSelectedDay" parent="Widget.MaterialComponents.MaterialCalendar.Day.Selected">
<item name="itemTextColor">?attr/colorOnSecondary</item>
</style>

<style name="WordPress.ActionMode" parent="@style/Widget.AppCompat.ActionMode">
Expand Down