Public Sub DesignerCreateView (Base As Object, Lbl As Label, Props As Map)
mBase = Base
Dim mlbl As B4XView = Lbl
#if B4J
Dim form As Form = Props.Get("Form")
MainPanel = form.RootPane
Dim df As TextField
df.Initialize("DateField")
Dim b As Button
b.Initialize("btnOpen")
Dim fx As JFX
b.Font = fx.CreateFontAwesome(30)
b.WrapText = False
#else if B4A
MainPanel = Props.Get("activity")
Dim df As EditText
df.Initialize("DateField")
df.SingleLine = True
df.Padding = Array As Int(20dip,0,0,0)
Dim b As Button
b.Initialize("btnOpen")
b.Typeface = Typeface.FONTAWESOME
#else if B4i
MainPanel = Props.Get("page")
Dim df As TextField
df.Initialize("DateField")
Dim b As Button
b.Initialize("btnOpen", b.STYLE_SYSTEM)
b.CustomLabel.Font = Font.CreateFontAwesome(30)
#end if
btnOpen = b
dateField = df
dateField.Font = mlbl.Font
dateField.SetColorAndBorder(xui.Color_White, 1dip, xui.Color_Black, 15dip)
dateField.TextColor = mlbl.TextColor
dateField.Enabled = False
mBase.AddView(dateField, 0,0,0,0)
btnOpen.Font = xui.CreateFontAwesome(UiCodeModule.ViewStyles.POSButton.TextSize)
btnOpen.Text = Chr(0xF073)
btnOpen.TextColor = xui.Color_RGB(209,32,39)
mBase.AddView(btnOpen, 0,0,0,0)
'It is not possible to load a layout file directly from DesignerCreateView.
Sleep(0)
selectedColor = xui.PaintOrColorToColor(Props.Get("SelectedColor"))
tempSelectedColor = xui.PaintOrColorToColor(Props.Get("HighlightedColor"))
pnlDialog = xui.CreatePanel("")
MainPanel.AddView(pnlDialog, 0, 0, 520dip,500dip)
pnlDialog.LoadLayout("datepicker")
pnlDialog.Visible = False
pnlDialog.SetColorAndBorder(xui.PaintOrColorToColor(Props.Get("BackgroundColor")), 1dip, selectedColor, 10dip)
pnlDialog.Tag = Me
#if B4i
For Each v As B4XView In pnlDialog.GetAllViewsRecursive
UiCodeModule.SetStyleForView(v)
Next
#End If
#if B4A
Dim p As Panel = pnlDialog
p.Elevation = 4dip
#End If
month = DateTime.GetMonth(DateTime.Now)
year = DateTime.GetYear(DateTime.Now)
minYear = Props.Get("MinYear")
maxYear = Props.Get("MaxYear")
months = DateUtils.GetMonthsNames
If selectedDate - INVALID_DATE = 0 Then selectedDate = DateTime.Now
setDate(selectedDate)
cvs.Initialize(DaysPaneFg)
cvsBackground.Initialize(DaysPaneBg)
boxW = cvs.TargetRect.Width / 7
boxH = cvs.TargetRect.Height / 6
vCorrection = 5dip
If xui.IsB4i Then vCorrection = 9dip
cvsDays.Initialize(DaysTitlesPane)
Dim alldays As List = Regex.Split("\|", "Sunday|Monday|Tuesday|Wednesday|Thursday|Friday|Saturday") 'need to escape the splitting character.
firstDay = alldays.IndexOf(Props.Get("FirstDay"))
Dim daysFont As B4XFont = xui.CreateDefaultBoldFont(14)
Dim i As Int
Dim days As List = DateUtils.GetDaysNames
For i = firstDay To firstDay + 7 - 1
Dim d As String = days.Get(i Mod 7)
cvsDays.DrawText(d.SubString2(0, 2), (i - firstDay + 0.5) * boxW, 20dip, daysFont, xui.Color_Gray, "CENTER")
Next
cvsDays.Invalidate
#if B4J
Dim p As Pane = DaysPaneFg
p.MouseCursor = fx.Cursors.HAND
#End If
Base_Resize(mBase.Width, mBase.Height)
End Sub