-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathCustomDateHeaderViewProvider.cs
More file actions
47 lines (40 loc) · 2.18 KB
/
Copy pathCustomDateHeaderViewProvider.cs
File metadata and controls
47 lines (40 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using Android.App;
using Android.Content;
using Android.Graphics;
using Android.Views;
using Android.Widget;
using DevExpress.XamarinAndroid.Scheduler.Visual.Data;
using DevExpress.XamarinForms.Scheduler;
using DevExpress.XamarinForms.Scheduler.Android;
namespace CustomDayViewProviders.Droid {
public class CustomDateHeaderViewProvider : IViewProvider {
LayoutInflater inflater;
public CustomDateHeaderViewProvider() {
this.inflater = LayoutInflater.From(Application.Context);
}
public void BindView(View view, ItemViewInfo viewInfo, ItemViewModel viewModel) {
HeaderViewInfo headerViewInfo = (HeaderViewInfo)viewInfo;
DayViewHeaderItemViewModel headerViewModel = (DayViewHeaderItemViewModel)viewModel;
view.SetBackgroundColor(new Color(viewInfo.BackColor));
TextView weekDayView = view.FindViewById<TextView>(Resource.Id.tvDay);
TextView dayNumberView = view.FindViewById<TextView>(Resource.Id.tvDayNumber);
weekDayView.Typeface = headerViewInfo.WeekDayTextElement.Typeface;
weekDayView.TextSize = (float)headerViewModel.WeekDayTextFontSize;
weekDayView.SetTextColor(new Color(headerViewInfo.WeekDayTextElement.TextColor));
weekDayView.Text = headerViewInfo.WeekDayTextElement.Text;
dayNumberView.Typeface = headerViewInfo.DayNumberTextElement.Typeface;
dayNumberView.TextSize = (float)headerViewModel.DayNumberTextFontSize;
if (headerViewModel.IsToday)
dayNumberView.SetTextColor(new Color(headerViewInfo.WeekDayTextElement.TextColor));
else
dayNumberView.SetTextColor(new Color(headerViewInfo.DayNumberTextElement.TextColor));
dayNumberView.Text = headerViewInfo.DayNumberTextElement.Text;
}
public View CreateNewView(int logicalIndex, ItemViewInfo viewInfo, ItemViewModel viewModel, Context context) {
return inflater.Inflate(Resource.Layout.CustomDateHeaderLayout, null);
}
public int GetStubColor(int logicalIndex, ItemViewInfo viewInfo, ItemViewModel viewModel) {
return viewInfo.BackColor;
}
}
}