Sub Class_Globals
Private Root As B4XView
Private xui As XUI
Private dialog As B4XDialog
Private DateTemplate As B4XDateTemplate
End Sub
Public Sub Initialize
End Sub
'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage")
dialog.Initialize(Root)
DateTemplate.Initialize
SetDialogTheme
End Sub
Sub Button2_Click
Wait For (GetDate(10)) Complete (Ticks As Long)
If Ticks > 0 Then
Log($"Selected date: $Date{Ticks}"$)
End If
End Sub
Private Sub GetDate(MaxIntervalInDays As Int) As ResumableSub
Do While True
Wait For (dialog.ShowTemplate(DateTemplate, "", "", "Cancel")) Complete (Result As Int)
Dim zero As Long = 0 'type must be exact
If Result = xui.DialogResponse_Cancel Then Return zero
Dim days As Int = DateUtils.PeriodBetweenInDays(DateTime.Now, DateTemplate.Date).Days
If Abs(days) > MaxIntervalInDays Then
DateTemplate.Date = DateTime.Now
Wait For (dialog.Show("Invalid date", "Ok", "", "")) Complete (Result As Int)
Else
Return DateTemplate.Date
End If
Loop
Return 0
End Sub
Private Sub B4XPage_CloseRequest As ResumableSub
If dialog.Visible Then
dialog.Close(xui.DialogResponse_Cancel)
Return False
End If
Return True
End Sub
Private Sub SetDialogTheme
dialog.OverlayColor = xui.Color_Transparent
dialog.TitleBarColor = 0xFF0A0B37 'Hintergrundfarbe der Titelzeile: dunkelblau
dialog.TitleBarTextColor = 0xFFFFBD59
dialog.ButtonsColor = 0xFF0A0B37 'Hintergrundfarbe der Buttons einstellen: dunkelblau
dialog.ButtonsTextColor = 0xFFFFBD59 'Farbe des Buttons einstellen: Gold
dialog.BackgroundColor = 0xFF0A0B37 'Hintergrundfarbe der Templates einstellen: dunkelblau
DateTemplate.SelectedColor = 0xFFFFBD59 'Goldene Farbe von Buttons und co
DateTemplate.DaysInMonthColor = xui.Color_White 'Schriftfarbe der Monate weiß
DateTemplate.DaysInWeekColor = xui.Color_White 'Schriftfarbe der Tage weiß
DateTemplate.lblMonth.TextColor = xui.Color_White 'Schriftfarbe der Monatsauswahl weiß
DateTemplate.lblYear.TextColor = xui.Color_White 'Schriftfarbe der Jahresauswahl weiß
For Each x As B4XView In Array(DateTemplate.btnMonthLeft, DateTemplate.btnMonthRight, DateTemplate.btnYearLeft, DateTemplate.btnYearRight)
x.Color = xui.Color_Transparent
x.TextColor = xui.Color_White
Next
End Sub