Back

CreateCard

Hello World
Content:
- Methods

A material implementation of a card.

crd = MUI.CreateCard( options ) → Object

It is fully customizable to suit your likings.

options propertiesdefinitions

titleString Title text

bodyString Body text

imageString Path to the image

buttonTextString Comma separated string for button text

colorString Color string

widthNumber Fraction of the screen width

divider1Boolean Divider below the avatar

divider2Boolean Divider below the body

avatarString Path to the avatar image

avatarOnTopBoolean Is the avatar on top of the image

buttonTypeString Can be 'raised', 'raisedoutline', 'round', 'roundoutline' or 'flat'

nameString Name of the card

Example - No-image, No-Avatar

cfg.Light
cfg.MUI

function OnStart()
{
    color = MUI.colors.teal
    app.InitializeUIKit(color.teal, "Light")

    lay = MUI.CreateLayout("Linear", "VCenter,FillXY")

        var options = {
            title: "Card Title",
            body: "Lorem ipsum dolor set amit consectetur elit",
            buttonText: "SEE MORE",
            width: 0.94
        }
        var card = UI.CreateCard(options)
        lay.AddChild(card)

    app.AddLayout(lay)
}
Copy All       Run      

Example - With-image, No-Avatar

cfg.Light
cfg.MUI

function OnStart()
{
    color = MUI.colors.teal
    app.InitializeUIKit(color.teal)

    lay = MUI.CreateLayout("Linear", "VCenter,FillXY")

        var options = {
            title: "Card Title",
            body: "Lorem ipsum dolor set amit consectetur elit",
            buttonText: "LINKS,SEE MORE",
            image: "/Sys/Img/Sky.jpg",
            width: 0.94
        }
        var card = UI.CreateCard(options)
        lay.AddChild(card)

    app.AddLayout(lay)
}
Copy All       Run      

Example - With Image, With Avatar

cfg.Light
cfg.MUI

function OnStart()
{
    color = MUI.colors.teal
    app.InitializeUIKit(color.teal)

    lay = MUI.CreateLayout("Linear", "VCenter,FillXY")

        var options = {
            title: "Card Title",
            body: "Lorem ipsum dolor set amit consectetur elit",
            buttonText: "LINKS,SEE MORE",
            image: "/Sys/Img/Sky.jpg",
            width: 0.94,
            avatar: "/Sys/Img/Droid1.png"
        }
        var card = UI.CreateCard(options)
        lay.AddChild(card)

    app.AddLayout(lay)
}
Copy All       Run      

Example - Complete

cfg.Dark
cfg.MUI

function OnStart()
{
    lay = MUI.CreateLayout("Linear", "VCenter,FillXY")
        scrl = app.CreateScroller(1, 1, "NoScrollBar")
            lay2 = MUI.CreateLayout("Linear", "VCenter")
            lay2.SetPadding(0, 0.02, 0, 0.02)
            lay2.SetSize(1)
                var options = {
                    title: "Card Title",
                    body: "Lorem ipsum dolor set amit consectetur elit",
                    buttonText: "LINKS,SEE MORE",
                    image: "/Sys/Img/Sky.jpg",
                    width: 0.94,
                    avatar: "/Sys/Img/Droid1.png",
                    avatarOnTop: true,
                    divider1: true,
                    divider2: true
                }

                options.name = "my-card1"
                card1 = UI.CreateCard(options)
                lay2.AddChild(card1)
                card1.SetOnButtonTouch(OnBtnTouch)

                options.name = "my-card2"
                options.buttonType = "raised"
                card2 = UI.CreateCard(options)
                card2.SetMargins(0, 0.02, 0, 0)
                lay2.AddChild(card2)
                card2.SetOnButtonTouch(OnBtnTouch)
            scrl.AddChild(lay2)
        lay.AddChild(scrl)
    app.AddLayout(lay)
}

function OnBtnTouch(btnText, cardName)
{
    app.ShowPopup(btnText + " : " + cardName)
}
Copy All       Run      

Methods

The following methods are available on the Card object:

Focus()
GetAbsHeight() → Number: integer
GetAbsWidth() → Number: integer
GetHeight( options ) → Number
GetLeft( options ) → Number
GetParent() → app object
GetPosition( options ) → Object: { left, top, right, bottom }
GetTop( options ) → Number
GetVisibility() → String: “Show” or “Hide” or “Gone”
GetWidth( options ) → Number
Gone()
Hide()
IsEnabled() → Boolean
IsOverlap( obj, depth ) → Boolean
IsVisible() → Boolean
Show()
Boolean
app object
Number
Number: fraction (0..1)
Number: integer
Number: milliseconds
String: “px”
String: “screen”, “px”
String: “px” or “sp” or “dip” or “mm” or “pt”
String: “Show” or “Hide” or “Gone”
String: “Linear.None” or “Quadratic.In/Out” or “Cubic.In/Out” or “Quartic.In/Out” or “Quintic.In/Out” or “Sinusoidal.In/Out” or “Exponential.In/Out” or “Circular.In/Out” or “Elastic.In/Out” or “Back.In/Out” or “Bounce.In/Out”
Object: {title, body, image, buttonText, color, width, dividerAvatar, dividerBody, avatar, avatarOnTop, buttonType}
Object: { x, y, w, w, sw, sh, rot }
function( cardName )
function( btnText, cardName )
function( title, cardName )
function()
crd.ClearFocus
Removes the focus of the control so that the user no longer has immediate access to it.
crd.Focus
Set the focus to the control so that the user can interact with it immediately.
crd.GetAbsHeight
Get the absolute height of the control in pixels.
crd.GetAbsWidth
Get the absolute width of the control in pixels.
crd.GetHeight
Get the height of the control as screen height relative float or in pixels with the px option.
crd.GetLeft
Get the distance from the control to the left parent border as width relative float or in pixels with the px option.
crd.GetParent
Returns the parent control object where the object was added to - commonly a layout.
crd.GetPosition
Returns data about the position and size of the control.
If the screen option is given the position on the screen will be returned. Otherwise relative to the parent control.
The px options turns the relative values into pixels.
crd.GetTop
Get the distance from the control to the upper parent border as height relative float or in pixels with the px option.
crd.GetVisibility
Returns the current visibility state of the control. The Values are:
Show: visible
Hide: invisible but still consuming space
Gone: invisible and not consuming space
crd.GetWidth
Get the width of the control as screen width relative float or in pixels with the px option.
crd.Gone
Hides the control without consuming any more layout space as if it were never there.
crd.Hide
Hide the control but keep the layout space free.
crd.IsEnabled
Returns whether the control is currently useable by the user.
crd.IsOverlap
Returns whether the control overlaps with another by a given distance.
crd.IsVisible
Returns whether the control is currently visible to the user, ignoring overlaying controls.
crd.SetEnabled
En/Disable the control physically and visually so that the user can/can not access the control. Events like OnTouch will still be fired.
crd.SetMargins
Define a distance to other controls on each side of the control.
crd.SetOnAvatarTouch
Calls a function when avatar is click.
crd.SetOnButtonTouch
Calls a function when buttons are click.
crd.SetOnImageTouch
Calls a function when the image is click.
crd.SetOnTitleTouch
Calls a function when title item is click.
crd.SetPosition
Defines the position and size for the control if the parent is an absolute layout.
crd.SetVisibility
Change the visibility of the control to one of the available modes:
Show: visible
Hide: invisible but still consuming space
Gone: invisible and not consuming space
crd.Show
Set the visibility of the control to “Show”.
crd.Tween
Performs an animation on the control.
The target object is for the position, size and rotation that the control has at the end of the animation.

The type specifies the behavior and the speed of the animation. Separated by a dot, you must also specify whether you want to apply this behavior to the beginning (In), end (Out), or to both (InOut) times of the animation.

With the amount of repeats you can control how many times you want to play the animation.

If you have jojo activated, the animation will alternate between forward and backward playback, so that if the repetition value is odd, the control will be at the start position again at the end of the animation.

Finally the callback function will be called after the animation has finished. Well, it's about time!