Quicklook

API Reference: UI.QuickLook

Quick Look lets users preview Keynote, Numbers, Pages, and PDF documents, as well as images and other types of files, even if your app doesn't support these file formats.

This class works only for iOS.

For further information please refer to the following guide: https://developer.apple.com/ios/human-interface-guidelines/features/quick-look/

TypeScript code blocks include examples of how to implement, override and components within the theme. You can create page with the UI Editor to make your page compatible with theming and then you can implement themable components programmatically. Once the page is created with the UI Editor, it generates a class under scripts/generated/pages. You can then extend that class with the following TypeScript classes.

TypeScript
JavaScript
TypeScript
import PageSampleDesign from 'generated/pages/pageSample';
import FlexLayout = require('sf-core/ui/flexlayout');
import Application = require('sf-core/application');
import Button = require('sf-core/ui/button');
import System = require('sf-core/device/system');
import QuickLook = require('sf-core/ui/quicklook');
import Color = require('sf-core/ui/color');
//You should create new Page from UI-Editor and extend with it.
export default class Sample extends PageSampleDesign {
btnCancel: Button;
quickLook: QuickLook;
constructor() {
super();
// Overrides super.onShow method
this.onShow = onShow.bind(this, this.onShow.bind(this));
// Overrides super.onLoad method
this.onLoad = onLoad.bind(this, this.onLoad.bind(this));
this.layout.flexDirection = FlexLayout.FlexDirection.COLUMN;
this.layout.justifyContent = FlexLayout.JustifyContent.CENTER;
this.layout.alignItems = FlexLayout.AlignItems.CENTER;
}
}
/**
* @event onShow
* This event is called when a page appears on the screen (everytime).
* @param {function} superOnShow super onShow function
* @param {Object} parameters passed from Router.go function
*/
function onShow(superOnShow: () => void) {
const { headerBar } = this;
superOnShow();
Application.statusBar.visible = false;
headerBar.visible = false;
}
/**
* @event onLoad
* This event is called once when page is created.
* @param {function} superOnLoad super onLoad function
*/
function onLoad(superOnLoad: () => void) {
superOnLoad();
this.button = new Button({
text: "QuickLook",
onPress: (): void => {
if (System.OS == "iOS") {
this.quickLook = new QuickLook();
let pdf = "assets://smartfaceuniversity.pdf";
let image = "assets://smartface.png";
this.quickLook.document = [pdf, image];
this.quickLook.titleColor = Color.DARKGRAY;
this.quickLook.itemColor = Color.create("#00A1F1");
this.quickLook.show(this);
}
}
});
this.layout.addChild(this.button, "button", ".sf-button", {
height: 50,
width: 100
});
}
JavaScript
const Page = require("sf-core/ui/page");
const extend = require("js-base/core/extend");
const QuickLook = require('sf-core/ui/quicklook');
const FlexLayout = require('sf-core/ui/flexlayout');
const Color = require('sf-core/ui/color');
const System = require('sf-core/device/system');
const Button = require('sf-core/ui/button');
var Page1 = extend(Page)(
function(_super) {
_super(this, {
onShow: function(params) {
Application.statusBar.visible = false;
this.headerBar.visible = false;
}
});
this.layout.flexDirection = FlexLayout.FlexDirection.ROW;
this.layout.justifyContent = FlexLayout.JustifyContent.CENTER;
this.layout.alignItems = FlexLayout.AlignItems.CENTER;
var button = new Button();
button.text = "QuickLook";
button.width = 100;
button.height = 50;
button.onPress = function(){
if (System.OS == "iOS") {
var quickLook = new QuickLook();
var pdf = "assets://smartfaceuniversity.pdf";
var image = "assets://smartface.png";
quickLook.document = [pdf, image];
quickLook.titleColor = Color.DARKGRAY;
quickLook.itemColor = Color.create("#00A1F1");
quickLook.show(this);
}
}.bind(this);
this.layout.addChild(button);
}
);
module.exports = Page1;

Important :

For Images; if you have multiple sizes of image resource (e.g [email protected], [email protected]); you should give exact path of an image file. QuickLook object can't get device type's appropriate resource file automatically.