import { EventData , Page , isIOS } from "@nativescript/core" ; import { HelloWorldModel } from './main-view-model' ; const flashlight = require ( "nativescript-flashlight" ) ; export function pageLoaded ( args ) { const page = < Page > args . object ; let model = new HelloWorldModel ( ) ; model . screenshot = page . getViewById ( "screenshot" ) ; page . bindingContext = model ; model . page = page ; if ( isIOS ) { const flashlightSwitch = page . getViewById ( "flashlightSwitch" ) ; flashlightSwitch . on ( "checkedChange" , ( args ) => { args . value ? flashlight . on ( ) : flashlight . off ( ) ; } ) ; } }