Convert from DS to Hybrid/enjine.io ?

208 views
Skip to first unread message

Alan Hendry

unread,
Aug 8, 2022, 6:36:49 AM8/8/22
to DroidScript
Hi,

DS is limited to writing apps on Android to run on Android.
Enjine.io will be very similar and will support Android, iOS, Windows, etc.
(AFAIK I know there is no target date).
A few enjine.io objects (for controls) with a few methods have been added to the latest versions of DS (Hybrid).
I have previously suggested a tool for converting DS code to enjine.io
which would aid in converting DS apps so they could run on Android/iOS etc
Please respond if you think this is worthwhile (or not) , or can foresee other problems.

Here's a list in DS
    var data = "Folder:folder,Audio:audio,Photo:photo,Video:video";
    lst = app.AddList( layout,data, 0.8, 0.4 );
And a list in Hybrid
         var myList = [
            [ "favorite", "Javascript", "Some text here" ],
            [ "delete", "Python", "Some text here" ],
            [ "star", "Java", "Some text here" ]
        ]
        lst = ui.addList(lstLay, myList, "link,icon,dense", 0.45)
Approach 1 - 
It would be pretty simple to substitute app.AddList with ui.addList
A little more difficult to re-order the parameter sequence, possibly converting the options (not sure if new Dense is equivalent to old Horiz)
Difficult to modify the list and it could come from a file, website etc.
Approach 2 - 
Replace app.AddList with AddList, and use app.Script to bring in functions
which will (at run time) get the parameters in the new order, map the options, and reformat the list. Even the special built in icons could be transformed.

See code below. 
It handles the list in string or array form; Simple, Title+Icon, and Title+Body.
(Probably needs validation of incoming list format, or at least a try/catch.) 
(Not really happy with using global variable str)

There are loads of DS objects (some may require very simple functions).
Hoping that the methods on the objects are compatible without change.
It could also be extended to MUI objects.
DS uses FontAweSome icons, but (thus far) Hybrid uses MUI icons.
We could either hard-code replacements for the common icons, or use a large JSON file 
(pretty massive undertaking, unless someone has already done it).

Regards, ah

Here's some examples
    lstMenu0 = AddList(drawerLay, "One,Two")

    lstMenu1 = AddList(drawerLay, "Audio:audio,Photo:photo,Video:video,Folder:folder,AudioFolder:audiofolder,PhotoFolder:photofolder,VideoFolder:videofolder,PlayList:playlist",0.4, 0.8)
  
    var data = "The Hobbit:Author - J.R.R. Tolkien:null";
    data += ",Watership Down:Author - Richard Adams:null";
    lstMenu2 = AddList(drawerLay,data,0.8,0.4,"horiz")

    var array = ["Three","Four"]
    lstMenu3 = AddList(mainLay,array,0.8,0.4,"horiz")
    array = ["5:Five:audio","6:Six:video"]
    lstMenu4 = AddList(mainLay,array,0.8,0.4,"horiz")

And the function(s)
function AddList(parent,list,width,height,options,delim) {
    if (options != null) options = options.replace(/horiz/i,"dense")
    if (delim == "" || delim == null) delim = ","
    if (typeof list == "string") {var arr = list.split(delim);} else {var arr = list;}
    str = ""
    arr.forEach(ds0)
    var q = ui.addList(parent,str,options+",icon",width)
    return q
}
// convert app list to hybrid list
function ds0(val) {
    if (val.endsWith(":audio")) val=val.replace(":audio",":music_note")
    if (val.endsWith(":photo")) val=val.replace(":photo",":image")
    if (val.endsWith(":video")) val=val.replace(":video",":movie")
    if (val.endsWith(":folder")) val=val.replace(":folder",":folder")
    if (val.endsWith(":audiofolder")) val=val.replace(":audiofolder",":library_music")
    if (val.endsWith(":photofolder")) val=val.replace(":photofolder",":photo_library")
    if (val.endsWith(":videofolder")) val=val.replace(":videofolder",":video_library")
    if (val.endsWith(":playlist")) val=val.replace(":playlist",":queue_music")
    var arr2 = val.split(":")
    if (arr2.length == 2) val = val.replace(":","::")
    if (str != "") str+= ","
    str = str + val
}

Nii Darko Darkoh

unread,
Aug 18, 2022, 4:58:12 AM8/18/22
to DroidScript
Hi DS, 
Hi, Alan, could you pls tell the tool you suggested for converting DS code to 
iOS?
Hi Dave, how far with enjine.io?
Regards to all.

Alan Hendry

unread,
Aug 18, 2022, 8:00:41 AM8/18/22
to DroidScript
HI,
The tool would be as above (I've written a few functions for controls).
The aim is to try and do SOME of the conversion automatically, 
some manual conversion and testing will still be necessary.
Here's a few more details of how I imagine the tool working.
It would run under DS  (so that it has access to all your apps). 
Probably first would be to display a list of all your apps and let you choose one.
It should probably leave your app alone, 
and copy everything (javascipt, assets, etc) to a new app (your-app-name plus Enjine perhaps).
All the js files (main js and additional js files) would need a bunch of replaces (e.g. app.AddList to AddList).
Your main javascript file would probably need directives (cfg.Hybrid at the moment), 
and app.Script("Enjine.js") and your app would need Enjine.js (which will include functions like AddList and DS0 above).
app.AddLayout(lay) doesn't seem to be needed, so could be removed.
It's not clear if Hybrid/Enjine will have FontAweSome 
(some FontAweSome icons have direct equivalents in Material Icons, some don't). 
Some things will probably need manual conversion (depends on the final form of Hybrid/Enjine.io)
Scroller, MUI AppBar, Dialogs (?), MUI colors (?)
To take advantage of new facilities would  require conversion by hand
(for example options primary and secondary which control colours).
Regards, ah

Nii Darko Darkoh

unread,
Aug 20, 2022, 9:46:07 PM8/20/22
to DroidScript
Thanks Alan
Reply all
Reply to author
Forward
0 new messages