B4J Tutorial [Web][SithasoDaisy5] Let's create some layouts.

Mashiane

Expert
Licensed User
Longtime User
An Empty Gradient Page

1756570666622.png


For this to work, the pageview in the baselayout should just be basic without any padding.

We will use gradient properties in the property box of the SDUI5Page component.

1756570755539.png


These properties also exist on the SDUI5Container.

For your page to fill the complete screen space, please also set these settings on the SDUI5Page.

1756571871216.png
 

Attachments

  • SithasoDaisy5Multi.zip
    92.8 KB · Views: 10
Last edited:

Mashiane

Expert
Licensed User
Longtime User
Let's add some validation to the Modal..

We will check if the email and password are not blank.

LoginValidation.gif


If blank, the focus will be put to the input element

B4X:
Private Sub mdlLogin_Yes_Click (e As BANanoEvent)
    e.PreventDefault
    If txtEmailAddress.IsBlank Then Return
    If txtPassword.IsBlank Then Return
    mdlLogin.YesLoading = True
End Sub
 

Mashiane

Expert
Licensed User
Longtime User
Additional Validations

1756599054094.png


B4X:
Private Sub mdlLogin_Yes_Click (e As BANanoEvent)
    e.PreventDefault
    If txtServer.IsBlank Then Return
    If txtServer.IsValidUrl = False Then Return
    If txtEmailAddress.IsBlank Then Return
    If txtEmailAddress.IsValidEmail = False Then Return
    If txtPassword.IsBlank Then Return
    If txtPassword.IsMinLength(12) = False Then Return
    If txtPassword.IsStrongPassword = False Then Return
    mdlLogin.YesLoading = True
    Sleep(3000)
    mdlLogin.YesLoading = False
End Sub
 

Mashiane

Expert
Licensed User
Longtime User
Adding Remember Me (AES Encrypted)

Remember Me is a functionality that saves the current login details of the user to localstorage and then retrieves them when a user wants to login again.

1756647244451.png


Click Login... (save details to localstorage is Remember Me is active)

B4X:
Private Sub mdlLogin_Yes_Click (e As BANanoEvent)
    e.PreventDefault
    If txtServer.IsBlank Then Return
    If txtServer.IsValidUrl = False Then Return
    If txtEmailAddress.IsBlank Then Return
    If txtEmailAddress.IsValidEmail = False Then Return
    If txtPassword.IsBlank Then Return
    If txtPassword.IsMinLength(12) = False Then Return
    If txtPassword.IsStrongPassword = False Then Return
    'save the details to localstorage
    If chkRememberMe.Checked Then
        Dim srememberKey As String = $"${Main.appname}remember"$
        Dim rmap As Map = CreateMap()
        rmap.put("email", txtEmailAddress.Value)
        rmap.put("pwd", txtPassword.Value)
        rmap.put("server", txtServer.Value) 
        'convert to json
        Dim sremember As String = BANano.ToJson(rmap)
        'encrypt using api key
        Dim sout As String = BANano.Await(app.UI.AESEncrypt(sremember, Main.APIKey))
        'store encrypted data
        BANano.SetLocalStorage2(srememberKey, sout)
    End If
    
    mdlLogin.YesLoading = True
    Sleep(3000)
    mdlLogin.YesLoading = False
End Sub

Show Page...

When a page is shown, the localstorage is read and decrypted and input controls updated

B4X:
Private Sub BuildPage
    'define the rememberkey data for app
    Dim srememberKey As String = $"${Main.appname}remember"$
    'read data from local storage
    Dim sremember As String = BANano.GetLocalStorage2(srememberKey)
    'convert to string, this also deals with null
    sremember = app.UI.CStr(sremember)
    'there is data that was saved
    If sremember <> "" Then
        'decrypt the data
        Dim sout As String = BANano.Await(app.UI.AESDecrypt(sremember, Main.APIKey))
        Dim rmap As Map = BANano.FromJson(sout)
        chkRememberMe.Checked = True
        txtEmailAddress.Value = rmap.Get("email")
        txtPassword.Value = rmap.Get("pwd")
        txtServer.Value = rmap.Get("server")
    End If
End Sub
 

Mashiane

Expert
Licensed User
Longtime User
Table Expand

When a table is expanded, one can add content to the row being expanded.

TableExpand.gif


To expand this per row, you set the HasExpand property to true.

1756775581451.png


This has an event, that receives a zero based index of the row, the data of the row and then whether the row is hidden / not.

B4X:
Private Sub tblFeatureSchema_ExpandRow (Row As Int, item As Map, Hidden As Boolean)
    'clear the contents of the expand data
'    tblFeatureSchema.ClearRowExpandData(Row + 1)
    Log("tblFeatureSchema_ExpandRow")
    Log(Row)
    Log(item)
    Log(Hidden)
End Sub

ClearRowExpandData - clears the "data" portion of the expanded row.

GetExpandColumnDataID- retrieves the html element id of that expanded row. You can use this with BANano.LoadLayout.

To conserve memory, rather load content to the expanded row when you show it.
 
Top