Code Monkey home page Code Monkey logo

nativescript-advanced-webview's Introduction

npm npm [GitHub forks] GitHub stars PayPal Donate

NativeScript-Advanced-Webview

An advanced webview using Chrome Custom Tabs on Android and SFSafariViewController on iOS.

Here is a video showing off Chrome CustomTabs in NativeScript.

Perf Matters

Android Comparison

Android

CustomTabs

iOS

SFSafariViewController

Demo

Android iOS
Android Sample iOS Sample

Installation

To install execute

tns plugin add nativescript-advanced-webview

Example

TypeScript

Initiate the service before the app starts e.g app.ts, main.ts

import { init } from 'nativescript-advanced-webview';
init();
import { openAdvancedUrl, AdvancedWebViewOptions } from 'nativescript-advanced-webview';
    //// or
import * as AdvancedWebView from 'nativescript-advanced-webview'

public whateverYouLike() {

    let opts: AdvancedWebViewOptions = {
        url: 'https://www.youtube.com/watch?v=dQw4w9WgXcQ',
        toolbarColor: '#ff4081',
        toolbarControlsColor: '#333', // iOS only
        showTitle: false // Android only
    };

    openAdvancedUrl(opts);
}

Javascript

var AdvancedWebView = require("nativescript-advanced-webview");

Initiate the service before the app starts e.g app.ts, main.ts

AdvancedWebView.init();
exports.openChromTabs = function(args){
    //var gotoUrl = args.view.bindingContext.url;

    var opts = {
            url: args.view.bindingContext.url,
            toolbarColor: '#ff4081',
            toolbarControlsColor: '#333', // iOS only
            showTitle: false // Android only
    };
   console.log(args.view.bindingContext.url);

   AdvancedWebView.openAdvancedUrl(opts);

API

  • openAdvancedUrl(options: AdvancedWebViewOptions)
AdvancedWebViewOptions Properties
  • url: string
  • toolbarColor: string
  • toolbarControlsColor: string - ** iOS only **
  • showTitle: boolean - ** Android only **
  • isClosed: Function

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.