Skip to content

Commit

Permalink
Merge pull request #13579 from wordpress-mobile/issue/13268-polish-ca…
Browse files Browse the repository at this point in the history
…lendar-ui

Polish Date Range picker UI
  • Loading branch information
zwarm authored Dec 16, 2020
2 parents 8c87f4b + 8788064 commit 3ff280b
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import androidx.fragment.app.Fragment
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 @@ -189,6 +191,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

0 comments on commit 3ff280b

Please sign in to comment.