Skip to content

Commit

Permalink
Add ability to change new params through xml
Browse files Browse the repository at this point in the history
  • Loading branch information
Anatoliy Shulipov committed Apr 2, 2021
1 parent dff64a8 commit fc9f4e5
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -574,14 +574,6 @@ class CalendarView @JvmOverloads constructor(
setDateCellTextColor(colorStateList)
}

/**
* Sets
*/
fun useSeparateWeekendDaysBarTextColor(used: Boolean){
calendarStyleAttributes.useSeparateColorForWeekendDays = used
daysBarView.applyStyle(calendarStyleAttributes)
}

/**
* Add custom [RecyclerView.ItemDecoration] that will be used for the Calendar view decoration.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,15 @@ internal class CalendarStyleAttributes(

var monthTextStyle: Int = Typeface.NORMAL,

@DrawableRes
var dateCellBackgroundShapeForm: Int = R.drawable.calendar_date_shape_form,

@ColorRes
var dateCellBackgroundColorRes: Int = R.color.calendar_date_bg_selector,

var dateCellTextColorStateList: ColorStateList = requireNotNull(
ContextCompat.getColorStateList(context, R.color.calendar_date_text_selector)
),

var dateCellBackgroundShapeForm: Int = R.drawable.calendar_date_shape_form,

var useSeparateColorForWeekendDays: Boolean = false
)

) {

Expand All @@ -63,5 +62,5 @@ internal class CalendarStyleAttributes(
} else {
field
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ internal object CalendarStyleAttributesReader {
daysBarTextColor
)

daysBarWeekendTextColor = typedArray.getColor(
R.styleable.CalendarView_calendar_day_bar_weekend_text_color,
daysBarWeekendTextColor
)

monthTextColor = typedArray.getColor(
R.styleable.CalendarView_calendar_month_text_color,
monthTextColor
Expand All @@ -71,8 +76,13 @@ internal object CalendarStyleAttributesReader {
monthTextStyle
)

dateCellBackgroundColorRes = typedArray.getResourceId(
dateCellBackgroundShapeForm = typedArray.getResourceId(
R.styleable.CalendarView_calendar_date_background,
dateCellBackgroundShapeForm
)

dateCellBackgroundColorRes = typedArray.getResourceId(
R.styleable.CalendarView_calendar_date_background_tint,
dateCellBackgroundColorRes
)

Expand Down
2 changes: 2 additions & 0 deletions crunchycalendar/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<attr name="calendar_grid_color" format="color" />
<attr name="calendar_day_bar_background" format="color" />
<attr name="calendar_day_bar_text_color" format="color" />
<attr name="calendar_day_bar_weekend_text_color" format="color" />
<attr name="calendar_year_selection_background" format="color" />
<attr name="calendar_year_selection_arrows_color" format="color" />
<attr name="calendar_year_selection_text_color" format="color" />
Expand All @@ -21,6 +22,7 @@
<enum name="bold" value="1" />
</attr>
<attr name="calendar_date_background" format="reference" />
<attr name="calendar_date_background_tint" format="reference"/>
<attr name="calendar_date_text_color" format="reference" />
</declare-styleable>

Expand Down
1 change: 1 addition & 0 deletions sample/src/main/res/layout/fragment_demo_selection.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical">

<HorizontalScrollView
Expand Down

0 comments on commit fc9f4e5

Please sign in to comment.