B4J Library [BANanoVueMaterial]: The first complete opensource VueJS UX based framework for BANano

Mashiane

Expert
Licensed User
Longtime User
Runtime Components - components created at run-time - Part 3

Comboboxes, Selectes, AutoComplete.



These work the same. We Add the component and then add the items to it following a key, value pair approach.

B4X:
dynaR1.AddSelect("days", "Days").SetCacheItems(True)
    dynaR1.AddItem(1, "Tesla")
    dynaR1.AddItem(2, "Jobs")
    dynaR1.AddItem(3, "Taleb")
    dynaR1.RefreshItems
    dynaR1.SetValue(2)

dynaR1.AddComboBox("cbo1", "Combo Box").SetCacheItems(True)
    dynaR1.AddItem(1, "Tesla")
    dynaR1.AddItem(2, "Jobs")
    dynaR1.AddItem(3, "Taleb")
    dynaR1.RefreshItems
    dynaR1.SetValue(1)
    
    dynaR1.AddAutoComplete("autoc", "Auto Complete").SetCacheItems(True).SetSearchInput(Null)
    dynaR1.SetReturnObject(True)
    dynaR1.AddItem(1, "Tesla")
    dynaR1.AddItem(2, "Jobs")
    dynaR1.AddItem(3, "Taleb")
    dynaR1.RefreshItems
    dynaR1.SetValue(3)

To detect which value has been selected / a change, one uses the global_change event.

B4X:
Sub dynaR1_change(val As Object)
    Dim ev As EventValue = dynaR1.GetEvent(val)
    Select Case ev.key
    Case "days"
        'click the select control change
        vm.ShowSnackBarSuccess(ev.value)

Here we get the selected value with ev.value.
 

Mashiane

Expert
Licensed User
Longtime User
Version 4.35 BETA

Updates to Extensions Demo to fix the ECharts bugs. Download here.

On other things:

  1. Runtime components: as this is a 3rd party component, date formatting has not been implemented.
  2. DataGridSelect - as this is a 3rd party component, some issues have not been fixed yet so this is not usable yet!
Ta!
 

Mashiane

Expert
Licensed User
Longtime User
Creating a decrement / increment text-field



Create the control..

B4X:
Dim txtn1 As VMTextField = vm.CreateTextField("n1", Me).SetVModel("n1x").SetReadOnly(True)
    txtn1.SetLabel("Number")
    txtn1.AddDecrementIcon(vm.color_red)
    txtn1.AddIncrementIcon(vm.color_green)
    txtn1.AddToContainer(cont, 10, 1)

The value of the textfield n1 is bound to the vmodel "n1x", so we increment and decrement a value stored there.

As soon as you add the decrement icon and increment icon, the expected events are <txtboxname>decrement_click and <txtboxname>_increment_click

So lets add these events that will use the bound state and increment / decrement it.

B4X:
Sub n1increment_click(e As BANanoEvent)
    vm.Increment("n1x", 1)
End Sub

Sub n1decrement_click(e As BANanoEvent)
    vm.Decrement("n1x", 1)
End Sub

Ta
 

Mashiane

Expert
Licensed User
Longtime User
One can add some fancy gradients to the buttons..



B4X:
vm.CreateButton("btnGradient", Me).SetLabel("Black Teal").SetGradient(vm.color_black, vm.color_teal).AddToContainer(cont, 15, 1)
    vm.CreateButton("btnGradient1", Me).SetLabel("Purple Teal").SetGradient(vm.color_purple, vm.color_teal).AddToContainer(cont, 15, 1)
    vm.CreateButton("btnGradient2", Me).SetLabel("Pink Indigo").SetGradient(vm.color_pink, vm.color_indigo).AddToContainer(cont, 15, 1)
    vm.CreateButton("btnGradient3", Me).SetLabel("Green Orange").SetGradient(vm.color_green, vm.color_orange).AddToContainer(cont, 15, 1)
    vm.CreateButton("btnGradient4", Me).SetLabel("Yellow Cyan").SetGradient(vm.color_yellow, vm.color_cyan).AddToContainer(cont, 15, 1)
    vm.CreateButton("btnGradient5", Me).SetLabel("Amber Yellow").SetGradient(vm.color_amber, vm.color_yellow).AddToContainer(cont, 15, 1)
    vm.CreateButton("btnGradient6", Me).SetLabel("Blue Red").SetGradient(vm.color_blue, vm.COLOR_RED).AddToContainer(cont, 15, 1)
    vm.CreateButton("btnGradient7", Me).SetLabel("Gray Light Blue").SetGradient(vm.color_grey, vm.color_Lightblue).AddToContainer(cont, 15, 1)
 

Mashiane

Expert
Licensed User
Longtime User
Important Information about the File Input Component

1. Multiple Files (use LIST argument on _change)


If you .SetMultiple(True), the file input expects a list of files. Then your change event should be passed a list of files.



2. Single File (use Map argument on _change)

If your file input is expecting a single file selection, you DONT use .SetMultiple(true) the argument passed to the change event is NO longer a list but a map.

 

Mashiane

Expert
Licensed User
Longtime User
We have converted the meal app to an Electron Windows Destop App with BANanoElectron:

 

Mashiane

Expert
Licensed User
Longtime User
CDN Things

To speed up apps, we are opting to use the CDN versions of the css and js files. This is inline with the vuetify website.

On Core: These are the only required css and js files.

B4X:
BANano.Header.AddCSSFile("https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900")
    BANano.Header.AddCSSFile("https://cdn.jsdelivr.net/npm/@mdi/font@4.x/css/materialdesignicons.min.css")
    BANano.Header.AddCSSFile("https://cdn.jsdelivr.net/npm/vuetify@2.x/dist/vuetify.min.css")
    BANano.Header.AddJavascriptFile("https://cdn.jsdelivr.net/npm/vue@2.x/dist/vue.min.js")
    BANano.Header.AddJavascriptFile("https://cdn.jsdelivr.net/npm/vuetify@2.x/dist/vuetify.min.js")
    BANano.Header.AddJavascriptFile("https://cdn.jsdelivr.net/npm/vue-router@3.4.7/dist/vue-router.min.js")

The font files being favored are available here: http://materialdesignicons.com/

There are also additional files used by the core, these are:

B4X:
    BANano.Header.AddJavascriptFile("https://cdn.jsdelivr.net/npm/dayjs@1.9.4/dayjs.min.js")
    BANano.Header.AddJavascriptFile("https://cdnjs.cloudflare.com/ajax/libs/numeral.js/2.0.6/numeral.min.js")

For dates and numeral calculations and formatting:
 
Last edited:

Mashiane

Expert
Licensed User
Longtime User
Version 4.43 Released.

Included:

Vuetify automatic update to v2.3.16

Known Issues:

  • DataGridSelect - multi-select bug
  • Dynamic Components - date formatting not added.
  • We are updating the icons used to materialdesignicons.com

If you want to use other icons on your project, you need to add this yourself on your project with BANano.Header.AddCss, for example

Google Material Fonts
B4X:
https://fonts.googleapis.com/css2?family=Material+Icons

As this uses cached versions of resources as noted in the post above, it will require an internet connection.

Ta!

PS: As the icons are not critical on any old code done before, I will not be maintaining those projects.
 
Last edited:

Mashiane

Expert
Licensed User
Longtime User
Pushed 4.44 to fix a few picked bugs.

IMPORTANT NOTIFICATION: Static vs Dynamic Sites/Apps

For element created with code, if you don't want to use bindings/state with your components, you can call .SetStatic(True) on the elements. This means you cannot change any of the attributes at runtime. This is useful for static sites. For more details you can see the MealPrep code examples of how this was used. With that said, these directives will still work with .SetStatic(True)
  • v-show
  • v-model
  • v-if
  • calling .Bind(":key", "x") directly
By default, SetStatic is OFF. This means any element you create is bound to a state for most of its attributes. This ensures that attributes can be changed at runtime per elements.

Ta!
 
Last edited:
Cookies are required to use this site. You must accept them to continue using the site. Learn more…