iOS Question XUI.View problems

Claude Brun

Active Member
Licensed User
Longtime User
Hi,
I have 2 problems with XUI. View

1) I use french words for DialogResponse: "Aujourd'hui" and "Annuler" (today and cancel in french). but for "Aujourd'hui" The word is truncated, the view is not wide enough. How to increase the size of the area

2) The months and days are in English, yet I do have the "fr.lproj" directory in the "B4i/Files/Special" directory.
if I add a call to the SetDateTimeLocale sub. I'm getting an error :
Error: Invalid value: AD20231101 000000
Error occurred on line: 68 (B4XDateTemplate)
Cannot parse: invalid date


What does this "AD" that denotes the date mean?

setlocale:
Sub SetDateTimeLocale (locale As String)
    Dim loc As NativeObject
    loc = loc.Initialize("NSLocale").RunMethod("localeWithLocaleIdentifier:", Array(locale))
    Dim no As NativeObject = DateTime
    no.GetField("dateFormat").SetField("locale", loc)
    no.GetField("timeFormat").SetField("locale", loc)
End Sub

call setlocale:
    SetDateTimeLocale("fr-FR")

Thank
 

Attachments

  • IMG_3691.PNG
    125.4 KB · Views: 97

Filippo

Expert
Licensed User
Longtime User
Try this code.
With "dialog.Base.GetView(2).Width" you can increase the width of the "Yes" button.
B4X:
    Dim rs As ResumableSub = dialog.Show("test", "Yes", "No", "Cancel")
    dialog.Base.GetView(2).Width = 150dip
 
Upvote 0

Claude Brun

Active Member
Licensed User
Longtime User
I've tried this solution, but it doesn't work for me.
I forgot to specify, but I don't use a "dialog.show" but a dialog.showtemplate with a templatedate

dialog.showtemplate:
Private Sub btncal_Click
    Wait For (Dialog.ShowTemplate(DateTemplate, "", "Aujourd'hui", "Annuler")) Complete (Result As Int)  
    If Result = xui.DialogResponse_Positive Then
        sai_txtdat.Text = DateTime.Date(DateTemplate.Date)
    Else
        If Result = xui.DialogResponse_Negative Then
            DateTemplate.Date = DateTime.now
            sai_txtdat.Text = DateTime.Date(DateTime.now)
        End If
    End If
End Sub
 
Last edited:
Upvote 0

Claude Brun

Active Member
Licensed User
Longtime User
Yes I set a localized app name.
I've found a solution to my problem. instead of using the iDateUtils library, I use the old DateUtils.bas module
In this module I made a change, comment line : d = GetEra(Years < 0) & d in SetDateAndTime sub
With this change my app work fine
setdateandtime:
Public Sub SetDateAndTime(Years As Int, Months As Int, Days As Int, Hours As Int, Minutes As Int, Seconds As Int) As Long
    Dim df = DateTime.DateFormat, tf = DateTime.TimeFormat As String
    DateTime.DateFormat = "GGyyyyMMdd"
    DateTime.TimeFormat = "HHmmss"
    Dim d As String = Format(Abs(Years), 4) & Format(Months, 2) & Format(Days, 2)
'    d = GetEra(Years < 0) & d
    Dim t As String = Format(Hours, 2) & Format(Minutes, 2) & Format(Seconds, 2)
    Try
        Dim ticks As Long = DateTime.DateTimeParse(d, t)
    Catch
        DateTime.DateFormat = df
        DateTime.TimeFormat = tf
        Log("Error: Invalid value: " & d & " " & t)
        Return "invalid date" + 1 'hack to throw an error
    End Try
    DateTime.DateFormat = df
    DateTime.TimeFormat = tf
    Return ticks
End Sub

Without this change the date is polluted by the era (ADyyyymmdd) when locale are set to "fr_FR"
 
Upvote 0

MarcoRome

Expert
Licensed User
Longtime User
Hi All.
Same problem on the calendar for the Italian language, despite having set the Files/Special/it.lproj folder.
Add also

B4X:
#PlistExtra: <key>CFBundleLocalizations</key><array><string>Italian</string></array>

Even if the language is in Italian i view the calendar in English (on Android it's ok)

B4X:
'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
    
    
    Base = Root
    Dialog.Initialize (Base)
    Dialog.BackgroundColor = Colors.White
    'Colore della Barra del Titolo Calendiario
    Dialog.TitleBarColor = xui.Color_ARGB(255, 0,129,129)
    'Colore del Pulsante Annulla
    Dialog.ButtonsColor = xui.Color_ARGB(255, 0,129,129)
    Dialog.ButtonsTextColor = Colors.White

    Log(GetPreferredLanguage)
    
    Dialog.Title = "Seleziona il Giorno"
    DateTemplate.Initialize
    DateTemplate.MinYear = 2016
    DateTemplate.MaxYear = 2030
    DateTemplate.DaysInMonthColor = Colors.Black
    DateTemplate.DaysInWeekColor = Colors.Black
    DateTemplate.SelectedColor =  xui.Color_ARGB(255, 0,129,129)
    DateTemplate.lblMonth.TextColor = Colors.Black
    DateTemplate.lblYear.TextColor = Colors.Black
End Sub

Sub GetPreferredLanguage As String
    Dim no As NativeObject
    Return no.Initialize("NSLocale").RunMethod("preferredLanguages", Null).RunMethod("objectAtIndex:", Array(0)).AsString
End Sub

'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.

Private Sub Button1_Click
    'only CANCEL needed
    Wait For (Dialog.ShowTemplate(DateTemplate, "", "", "ANNULLA")) Complete (Result As Int)
    If Result = xui.DialogResponse_Positive Then
        Log(DateTemplate.Date)
    End If
End Sub



If call SetDateTimeLocale("it-IT") i have the same error in post#1
The device locale set italian ( as you see into screenshot ).



furthermore, while on Android you can see the arrows next to the month and year to scroll, on iOS you can't see anything

android



iOS



In attachment example.
 

Attachments

  • Project.zip
    175.9 KB · Views: 97
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
 
Upvote 0

MarcoRome

Expert
Licensed User
Longtime User
Very fast ? work a charme
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…