Skip to content
This repository has been archived by the owner. It is now read-only.
master
Switch branches/tags
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 

README.md

Extendedlabel Extension from Smartface

Twitter: @Smartface_io License

Installation

Smartface Extendedlabel can be installed via npm easily from our public npm repository. The installation is pretty easy via Smartface Cloud IDE.

  • Run command (cd ~/workspace/scripts && npm i -S sf-extension-extendedlabel)

How to use

Initialize

const Page = require("sf-core/ui/page");
const extend = require("js-base/core/extend");
const Color = require('sf-core/ui/color');
const Font = require('sf-core/ui/font');

var Page1 = extend(Page)(
    function(_super) {
        _super(this, {
            onShow: function(params) {
                this.statusBar.visible = false;
                this.headerBar.visible = false;
            }
        });
        
     const ExtendedLabel = require('sf-extension-extendedlabel');
     const AttributedString = require('sf-extension-extendedlabel/attributedstring');
     const System = require('sf-core/device/system');
 
     var extendedlabel = new ExtendedLabel({
         flexGrow: 1,
         lineSpacing : 20
     });

     if (System.OS === "iOS") {
         extendedlabel.letterSpacing = 5;
     }else{
         // letterSpacing working on ANDROID Lollipop (API-21) AND UPPER
         extendedlabel.letterSpacing = 0.3;
     }
      
     extendedlabel.onClick = function(string){
         console.log("String " + string);
     };
     
     var attributeString = new AttributedString();
     attributeString.string = "First\n";
     attributeString.foregroundColor = Color.GREEN;
     
     var attributeString2 = new AttributedString();
     attributeString2.string = "Second";
     attributeString2.link = "Second Link ";
     
     var attributeString3 = new AttributedString();
     attributeString3.string = " Third";
     attributeString3.link = "Third Link";
     attributeString3.backgroundColor = Color.RED;
     attributeString3.underline = true;
     attributeString3.font = Font.create("Times New Roman",30,Font.NORMAL);
     attributeString3.ios.underlineColor = Color.YELLOW;
     
     extendedlabel.text = [attributeString,attributeString2,attributeString3];

     this.layout.addChild(extendedlabel);
    
    }
);
module.exports = Page1;

Create From Existing Label

var extendedlabel = ExtendedLabel.createFromLabel(label);

var attributeString = new AttributedString();
attributeString.string = "Text";
attributeString.link = "Text Link";
attributeString.backgroundColor = Color.RED;
attributeString.underline = true;
attributeString.font = Font.create("Times New Roman",30,Font.NORMAL);
attributeString.ios.underlineColor = Color.YELLOW;

extendedlabel.text = [attributeString];

License

This project is licensed under the terms of the MIT license. See the LICENSE file. Within the scope of this license, all modifications to the source code, regardless of the fact that it is used commercially or not, shall be committed as a contribution back to this repository.

About

No description, website, or topics provided.

Resources

License

Packages

No packages published