B4A Library [B4X] AS WheelDateTimePicker - based on ASWheelPicker

This is a date and time picker in IOS picker design.

This library is based on the ASWheelPicker, without it the library will not work.

EQ5gfV8j4u2d3PaEtXi6p57dQCY9h7883CRjIizpVHqLx7YXhY.jpeg

Use:
B4X:
AS_WheelDateTimePicker1.Create
AS_WheelDateTimePicker
Author: Alexander Stolte
Version: 1.17

  • AS_WheelDateTimePicker
    • Events:
      • CustomDrawItemChange (NewItem As ASWheelPicker_CustomDraw, OldItem As ASWheelPicker_CustomDraw)
      • SelectedDateChanged (Date As Long)
      • SelectedTimeChanged (Hour As Int, Minute As Int)
    • Fields:
      • mBase As B4XView
      • Tag As Object
    • Functions:
      • Create
      • CreateASWheelDateTimePicker_MonthName (January As String, February As String, March As String, April As String, May As String, June As String, July As String, August As String, September As String, October As String, November As String, December As String) As ASWheelDateTimePicker_MonthName
      • CreateASWheelDateTimePicker_MonthNameShort (January As String, February As String, March As String, April As String, May As String, June As String, July As String, August As String, September As String, October As String, November As String, December As String) As ASWheelDateTimePicker_MonthNameShort
      • CreateASWheelDateTimePicker_WeekNameShort (Monday As String, Tuesday As String, Wednesday As String, Thursday As String, Friday As String, Saturday As String, Sunday As String) As ASWheelDateTimePicker_WeekNameShort
      • DesignerCreateView (Base As Object, Lbl As Label, Props As Map)
        Base type must be Object
      • Initialize (Callback As Object, EventName As String)
      • Refresh
      • SetDateTextOrder (WeekName As Int, MonthName As Int, DayOfMonth As Int)
        Weekname - Fri
        Monthname - Jun
        DayOfMonth - 19
        Example:1,2,3 = Fri Jun 19
        Example:2,1,3 = Jun Fri 19
        Example:3,2,1 = 19 Jun Fri
    • Properties:
      • BackgroundColor As Int
      • Date As Long
      • DisabledTextColor As Int
      • FadeColor As Int
      • HapticFeedback As Boolean
      • Hour As Int
      • HourShortText As String
      • MaxDate As Long
      • MinDate As Long
      • Minute As Int
      • MinuteShortText As String
      • MinuteSteps As Int
      • MonthName As ASWheelDateTimePicker_MonthName
      • MonthNameShort As ASWheelDateTimePicker_MonthNameShort
      • PickerType As String
        Call Refresh if you change something
      • PickerType_DatePicker As String [read only]
      • PickerType_TimePicker As String [read only]
      • SelectorColor As Int
      • ShowAMPM As Boolean
        Show the AM and PM column
      • ShowDate As Boolean
        Show the date column in the TimePicker
      • ShowTimeDivider As Boolean
        The separator between hour and minute is usually a colon ( : )
      • ShowTimeUnit As Boolean
        Display time unit (12hour 05 min) can be changed with the HourShort and MinuteShort property
      • TextColor As Int
      • Theme As AS_WheelDateTimePicker_Theme [write only]
      • Theme_Dark As AS_WheelDateTimePicker_Theme [read only]
      • Theme_Light As AS_WheelDateTimePicker_Theme [read only]
      • ThemeChangeTransition As String
        Fade or None
      • ThemeChangeTransition_Fade As String [read only]
      • ThemeChangeTransition_None As String [read only]
      • TodayText As String
        Call Refresh if you change something
      • WeekNameShort As ASWheelDateTimePicker_WeekNameShort
      • WheelPicker As ASWheelPicker [read only]
Changelog
  • 1.00
    • Release
  • 1.01
    • BugFixes
  • 1.02
    • Add set Hour
    • Add set Minute
    • Add set Date
  • 1.03
    • Add Refresh
  • 1.04
    • BugFixes
    • PickerType = DatePicker - The days in the month now adjust automatically
    • Add Designer Property TextColor
    • Add Designer Property FadeColor
    • Add Designer Property HapticFeedback
  • 1.05
    • Add Designer Property TodayText
      • Default: Today
    • Add get and set TodayText - Call Refresh if you change something
  • 1.06
    • BugFixes
  • 1.07
    • BugFixes - AM and PM mode works now as expected
    • BugFixes - setDate Number of days is now adjusted
  • 1.08
    • Add get and set FadeColor
    • Add get and set TextColor
    • Add get and set SelectorColor
    • Add get and set BackgroundColor
    • MonthName now comes from the DateUtils
  • 1.09
    • BugFixes
  • 1.10
    • BugFixes
  • 1.11
    • Add Designer Property MinuteSteps - 1-5-10-15 Block Interval
      • Default: False
  • 1.12
    • BugFixes
  • 1.13
    • Add get WheelPicker - gets the wheelpicker to modify font etc.
  • 1.14 (read more)
    • You need AS_WheelPicker V3.15+ for this update
    • If a month has 30 or 28 days, then these are now no longer removed from the list, but the new EnabledRow is used and the affected items are deactivated.
      • This prevents the list from behaving in an unusual way.
    • Add MinDate and MaxDate - You can specify a DateRange what may be selected
  • 1.15
    • You need AS_WheelPicker V3.20+
    • Breaking Change: You need to call Create
      • The view will not be built without it
      • Now you can make changes to the proepties without calling refresh at the beginning
      • Faster loading time
      • No crashes
    • Add SetDateTextOrder - You can change the text order of the date text
    • BugFixes
    • Add Event CustomDrawItemChange
  • 1.16
    • New Themes - You can now switch to Light or Dark mode
      • New set Theme
      • New get Theme_Dark
      • New get Theme_Light
    • New Designer Property ThemeChangeTransition
      • Default: Fade
  • 1.17
    • New all designer properties, now as get and set too
    • New designer property descriptions
    • BugFixes
  • 1.18
    • B4A BugFix
Have Fun :)
 

Attachments

  • AS WheelDateTimePicker Example.zip
    176.3 KB · Views: 322
  • AS_WheelDateTimePicker.b4xlib
    7.7 KB · Views: 6
Last edited:

MarcoRome

Expert
Licensed User
Longtime User
Hi dear.

IMG-20220921-WA0000.jpg


A few questions:
1. How can I set the background color. In this case I have entered the same color as the Panel but it is always black. For example i set the same color as the panel in the designer but as you can see from the image the object remains black
2. How can i set the time to automatically exit the current time, for the moment always hour: 00 minute: 00. As you can see from the image it starts with today but the time is always set to zero Even if i use
B4X:
AS_WheelDateTimePicker1.Hour = 10
dont changes
3. I noticed that if the panel starts in invisible mode, when it comes back visible and you try to change date or time with object AS_WheelDateTimePicker it crashes.

Attached example

I think it is the best datetimepicker available for ios and droid

Thank you @Alexander Stolte
 

Attachments

  • Example.zip
    9.7 KB · Views: 261

Alexander Stolte

Expert
Licensed User
Longtime User
1. How can I set the background color. In this case I have entered the same color as the Panel but it is always black. For example i set the same color as the panel in the designer but as you can see from the image the object remains black
Don't use colors with a alpha, lower than 255.
2. How can i set the time to automatically exit the current time, for the moment always hour: 00 minute: 00. As you can see from the image it starts with today but the time is always set to zero Even if i use
B4X:
AS_WheelDateTimePicker1.Hour = 10
dont changes
Fixed in the next update of the 2 libs.
3. I noticed that if the panel starts in invisible mode, when it comes back visible and you try to change date or time with object AS_WheelDateTimePicker it crashes.
This is the native behavior of android scrolllist. I added a xCustomListView to the panel and scrolled to the last item while the panel was still invisible. The result, the list did not scroll when the list was invisible.
So unfortunately there is nothing I can do. The WheelPicker must be visible when building. You can also load the DatePicker only when you need it, in release mode this is fast, I also do this in combination with the FloatingPanel.
 

astronald

Active Member
Licensed User
Longtime User
Hi Alexander, have nice programming day
set hour and minute how works?

Set Hour and minute:
wp.Hour = DateTime.GetHour(Inicio)
wp.Minute = DateTime.GetMinute(Inicio)
Log(DateTime.GetHour(Inicio) & "," & wp.Hour)
Log(DateTime.GetMinute(Inicio) & "," & wp.Minute)

log:
Inicio= 14:03
14,11
3,3

at the phone
hora.png



What is worng?
Thanks for your help.
 

MarcoRome

Expert
Licensed User
Longtime User
Hi dear
if i have this code
B4X:
DateTime.DateFormat = "MM/dd/yyyy"
AS_WheelDateTimePicker1_dalla_data.Date = DateTime.DateParse($"01/01/${DateTime.GetYear(DateTime.Now)}"$)
AS_WheelDateTimePicker1_dalla_data.Refresh

The date doesn't change, it is always today's date.
Any solution ?
Thank you
 

MarcoRome

Expert
Licensed User
Longtime User
Another thing.
if you enter Picker Type: DatePicker
select today's date 30/09/2022 by default, but unfortunately it also goes to 31/09 (which does not exist) causing the following crash

Error: Invalid value: d.C.20220931 000000
Error occurred on line: 878 (ASWheelPicker)
java.lang.NumberFormatException: For input string: "invalid date"
at jdk.internal.math.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2054)
 

MarcoRome

Expert
Licensed User
Longtime User
Hi dear
if i have this code
B4X:
DateTime.DateFormat = "MM/dd/yyyy"
AS_WheelDateTimePicker1_dalla_data.Date = DateTime.DateParse($"01/01/${DateTime.GetYear(DateTime.Now)}"$)
AS_WheelDateTimePicker1_dalla_data.Refresh

The date doesn't change, it is always today's date.
Any solution ?
Thank you
if you compile it works (does not show the 31st for September) maybe it's just a problem in debug (takes some time to load the object? ). In any case, there are no problems in compiling
 

MarcoRome

Expert
Licensed User
Longtime User
Hi dear
if i have this code
B4X:
DateTime.DateFormat = "MM/dd/yyyy"
AS_WheelDateTimePicker1_dalla_data.Date = DateTime.DateParse($"01/01/${DateTime.GetYear(DateTime.Now)}"$)
AS_WheelDateTimePicker1_dalla_data.Refresh

The date doesn't change, it is always today's date.
Any solution ?
Thank you
if you change the date later, for example when you view the panel where the object is inserted. Work, change the date ?
 

Alexander Stolte

Expert
Licensed User
Longtime User
Update
  • 1.07
    • BugFixes - AM and PM mode works now as expected
    • BugFixes - setDate Number of days is now adjusted
set hour and minute how works?
AM and PM mode works now as expected.
The date doesn't change, it is always today's date.
Any solution ?
Put a Sleep(0) before you change the date.
if you enter Picker Type: DatePicker
select today's date 30/09/2022 by default, but unfortunately it also goes to 31/09 (which does not exist) causing the following crash
setDate Number of days is now adjusted
 

MarcoRome

Expert
Licensed User
Longtime User
Update
  • 1.07
    • BugFixes - AM and PM mode works now as expected
    • BugFixes - setDate Number of days is now adjusted

AM and PM mode works now as expected.

Put a Sleep(0) before you change the date.

setDate Number of days is now adjusted

with new Rel. i have this error:

Error occurred on line: 0 (ASWheelPicker)
java.lang.Exception: Sub xwp_wheel_itemchange signature does not match expected signature.
public static anywheresoftware.b4a.pc.RemoteObject net.taxitaormina.app.as_wheeldatetimepicker_subs_0._xwp_wheel_itemchange(anywheresoftware.b4a.pc.RemoteObject,anywheresoftware.b4a.pc.RemoteObject,anywheresoftware.b4a.pc.RemoteObject,anywheresoftware.b4a.pc.RemoteObject) throws java.lang.Exception
class anywheresoftware.b4a.pc.RemoteObject, class anywheresoftware.b4a.pc.RemoteObject, class anywheresoftware.b4a.pc.RemoteObject,
 

astronald

Active Member
Licensed User
Longtime User
Hi Alexander
i modified this, please correct me if this is wrong
Gert Hour:
Public Sub getHour As Int
    Dim hora As Int = xwp_Wheel.GetSelectedItem(IIf(m_Date,1,0)).Value
    If xwp_Wheel.GetSelectedItem(IIf(m_Date,3,2)).Text.EqualsIgnoreCase("PM") And xwp_Wheel.GetIndex(IIf(m_Date,1,0)) > 0 Then
        hora = hora +12
    End If
    Return hora
End Sub

and this another suggestion, taking advantage of that DateUtils Locale MonthNames from device

Get Month Names:
Public Sub CreateASWheelDateTimePicker_MonthName (January As String, February As String, March As String, April As String, May As String, June As String, July As String, August As String, September As String, October As String, November As String, December As String) As ASWheelDateTimePicker_MonthName
    Dim t1 As ASWheelDateTimePicker_MonthName
    t1.Initialize
    t1.January = DateUtils.GetMonthsNames.Get(0)
    t1.February = DateUtils.GetMonthsNames.Get(1)
    t1.March = DateUtils.GetMonthsNames.Get(2)
    t1.April = DateUtils.GetMonthsNames.Get(3)
    t1.May = DateUtils.GetMonthsNames.Get(4)
    t1.June = DateUtils.GetMonthsNames.Get(5)
    t1.July = DateUtils.GetMonthsNames.Get(6)
    t1.August = DateUtils.GetMonthsNames.Get(7)
    t1.September = DateUtils.GetMonthsNames.Get(8)
    t1.October = DateUtils.GetMonthsNames.Get(9)
    t1.November = DateUtils.GetMonthsNames.Get(10)
    t1.December = DateUtils.GetMonthsNames.Get(11)
    Return t1
    
End Sub
 

Alexander Stolte

Expert
Licensed User
Longtime User
i modified this, please correct me if this is wrong
The question is, why?
Either you have the wheelPicker in 24 hour format, then you select 0-23, or you have AM/PM, then you can only select 0-11, so you don't have to convert it?
 

astronald

Active Member
Licensed User
Longtime User
A question How i change FadeColor And TextColor Programatically,
I try with this but not succes!
Color:
    xwp_Wheel.FadeColor = m_FadeColor
    xwp_Wheel.ItemTextProperties.TextColor = m_TextColor
    xwp_Wheel.Refresh

Color.png
 

Alexander Stolte

Expert
Licensed User
Longtime User
Update
  • 1.08
    • Add get and set FadeColor
    • Add get and set TextColor
    • Add get and set SelectorColor
    • Add get and set BackgroundColor
    • MonthName now comes from the DateUtils

When I change PM And get Hour This is 12 + Selected item
True, but then you should convert that outside the library, I don't know the 12 hour format well as I live in 24 format.

A question How i change FadeColor And TextColor Programatically,
don't do it in the .bas file and tell me that the properties are missing, so i can make an update :)
 

astronald

Active Member
Licensed User
Longtime User
Update
  • 1.08
    • Add get and set FadeColor
    • Add get and set TextColor
    • Add get and set SelectorColor
    • Add get and set BackgroundColor
    • MonthName now comes from the DateUtils


True, but then you should convert that outside the library, I don't know the 12 hour format well as I live in 24 format.


don't do it in the .bas file and tell me that the properties are missing, so i can make an update :)
Thanks very Much, but set textColor only afect new items as 31, i think is necesary Colored all items
 
Last edited:
Top