<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Sam</title>
    <description>The latest articles on DEV Community by Sam (@mudlabs).</description>
    <link>https://dev.to/mudlabs</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F22573%2F308dad5b-0084-40be-8dc9-866e63e1bb4a.jpg</url>
      <title>DEV Community: Sam</title>
      <link>https://dev.to/mudlabs</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mudlabs"/>
    <language>en</language>
    <item>
      <title>Simple Diff</title>
      <dc:creator>Sam</dc:creator>
      <pubDate>Fri, 30 Oct 2020 07:04:29 +0000</pubDate>
      <link>https://dev.to/mudlabs/simple-diff-113i</link>
      <guid>https://dev.to/mudlabs/simple-diff-113i</guid>
      <description>&lt;p&gt;I was building a GitHub Action and needed the jobs to &lt;em&gt;NOT&lt;/em&gt; run if a file had just been deleted, so I built &lt;a href="https://github.com/marketplace/actions/simple-diff"&gt;Simple Diff&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/JCRjqeOhzk38k/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/JCRjqeOhzk38k/giphy.gif" alt="You're Welcome"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;h6&gt;
  
  
  😄   Fun Fact: It was built &lt;em&gt;100%&lt;/em&gt; on GitHubs' web UI with the help of &lt;a href="https://dev.to/mudlabs/npm-worker-aoh"&gt;NPM Worker&lt;/a&gt;
&lt;/h6&gt;
&lt;/blockquote&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vJ70wriM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://practicaldev-herokuapp-com.freetls.fastly.net/assets/github-logo-ba8488d21cd8ee1fee097b8410db9deaa41d0ca30b004c0c63de0a479114156f.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/mudlabs"&gt;
        mudlabs
      &lt;/a&gt; / &lt;a href="https://github.com/mudlabs/simple-diff"&gt;
        simple-diff
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      A super simple diff checker for your GitHub workflow.
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;p&gt;&lt;a href="https://github.com/marketplace/actions/simple-diff"&gt;&lt;img src="https://camo.githubusercontent.com/61fd5b4be04f3e95085a38b8f55d7951ba010d9d/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f75726c3d68747470733a2f2f7261772e67697468756275736572636f6e74656e742e636f6d2f6d75646c6162732f736869656c6473696f2f656e64706f696e742f6261646765732f6769746875622d616374696f6e2e6a736f6e" alt="github-action"&gt;&lt;/a&gt;
 
&lt;a href="https://github.com/sponsors/mudlabs"&gt;&lt;img src="https://camo.githubusercontent.com/197529618225e36600b50b20ba2ad5286a0b1a18/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f75726c3d68747470733a2f2f7261772e67697468756275736572636f6e74656e742e636f6d2f6d75646c6162732f736869656c6473696f2f656e64706f696e742f6261646765732f6769746875622d73706f6e736f722e6a736f6e" alt="github-sponsor"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h1&gt;
Simple Diff&lt;/h1&gt;
&lt;p&gt;A super simple diff checker for your GitHub workflow.&lt;/p&gt;
&lt;p&gt;Very simple, you provide the action with a &lt;code&gt;path&lt;/code&gt; to a &lt;em&gt;file&lt;/em&gt; or &lt;em&gt;folder&lt;/em&gt;, and it tells you if the file was &lt;code&gt;added&lt;/code&gt;, &lt;code&gt;modified&lt;/code&gt;, &lt;code&gt;removed&lt;/code&gt;, or &lt;code&gt;renamed&lt;/code&gt;. It will also output the items &lt;code&gt;name&lt;/code&gt; and &lt;code&gt;previous&lt;/code&gt; name, particularly usefull if it was just &lt;code&gt;renamed&lt;/code&gt;.&lt;/p&gt;
&lt;h2&gt;
Table of Contents&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/mudlabs/simple-diff/master/#usage"&gt;Usage&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/mudlabs/simple-diff/master/#inputs"&gt;Inputs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/mudlabs/simple-diff/master/#outputs"&gt;Outputs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/mudlabs/simple-diff/master/#example-case"&gt;Example Case&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
Usage&lt;/h2&gt;
&lt;div class="highlight highlight-source-yaml js-code-highlight"&gt;
&lt;pre&gt;- &lt;span class="pl-ent"&gt;name&lt;/span&gt;: &lt;span class="pl-s"&gt;Simple Diff&lt;/span&gt;
  &lt;span class="pl-ent"&gt;uses&lt;/span&gt;: &lt;span class="pl-s"&gt;mudlabs/simple-diff@v1.2.0&lt;/span&gt;
  &lt;span class="pl-ent"&gt;with&lt;/span&gt;
    &lt;span class="pl-ent"&gt;path&lt;/span&gt;: &lt;span class="pl-s"&gt;path/to/file   &lt;/span&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
Inputs&lt;/h2&gt;
&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Input&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;th&gt;Default&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;path&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Specifies a path from the &lt;em&gt;root&lt;/em&gt; of your repository to the file or folder you want to check. If not provided the action will try to find a path specification from the workflow file itself. The path can be a &lt;code&gt;glob&lt;/code&gt; string.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;strict&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Specifies the action should fail if the &lt;code&gt;path&lt;/code&gt; is not in the commits diff tree.&lt;/td&gt;
&lt;td&gt;&lt;code&gt;true&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;h2&gt;
Outputs&lt;/h2&gt;
&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Output&lt;/th&gt;
&lt;th&gt;Type&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;/table&gt;&lt;/div&gt;…&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/mudlabs/simple-diff"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


</description>
      <category>github</category>
      <category>action</category>
      <category>diff</category>
      <category>tool</category>
    </item>
    <item>
      <title>Svelte Transitions?</title>
      <dc:creator>Sam</dc:creator>
      <pubDate>Tue, 27 Oct 2020 10:46:00 +0000</pubDate>
      <link>https://dev.to/mudlabs/svelte-transitions-2m8m</link>
      <guid>https://dev.to/mudlabs/svelte-transitions-2m8m</guid>
      <description>&lt;p&gt;How are people handling page/component transitions in their &lt;a href="https://svelte.dev/"&gt;Svelte&lt;/a&gt; web apps?&lt;/p&gt;

&lt;p&gt;I found &lt;a href="https://barba.js.org/"&gt;Barba.js&lt;/a&gt; the other day and want to give it a go. Thought I might try in on a Svelte app I’m building.&lt;/p&gt;

&lt;p&gt;Anyone used Barba with Svelte? Would you recommend, or discourage?&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>webdev</category>
      <category>svelte</category>
      <category>javascript</category>
    </item>
    <item>
      <title>NPM Worker</title>
      <dc:creator>Sam</dc:creator>
      <pubDate>Sun, 11 Oct 2020 03:03:17 +0000</pubDate>
      <link>https://dev.to/mudlabs/npm-worker-aoh</link>
      <guid>https://dev.to/mudlabs/npm-worker-aoh</guid>
      <description>&lt;p&gt;Sometimes you're working on a repo and you don't want to clone it down to your local machine, init npm, install some packages and then push it all back up.&lt;/p&gt;

&lt;p&gt;Now there's &lt;a href="https://github.com/marketplace/actions/npm-worker"&gt;NPM Worker&lt;/a&gt;. A Github Action that lets you &lt;em&gt;init&lt;/em&gt;, &lt;em&gt;install&lt;/em&gt;, &lt;em&gt;update&lt;/em&gt;, and &lt;em&gt;uninstall&lt;/em&gt; npm package on your repo. All from a single configuration file.&lt;/p&gt;

&lt;p&gt;It also supports logging activity to an issue, so you can see what's changed from a glance.&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vJ70wriM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://practicaldev-herokuapp-com.freetls.fastly.net/assets/github-logo-ba8488d21cd8ee1fee097b8410db9deaa41d0ca30b004c0c63de0a479114156f.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/mudlabs"&gt;
        mudlabs
      &lt;/a&gt; / &lt;a href="https://github.com/mudlabs/npm-worker"&gt;
        npm-worker
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Manage node packages on your Github Action repository.
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;p&gt;&lt;a href="https://github.com/marketplace/action/npm-worker"&gt;&lt;img src="https://camo.githubusercontent.com/14c63b1b53088ab0a59ea01eaea9bb937c9be357/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f2d416374696f6e2d3234323932653f6c6f676f3d676974687562267374796c653d666f722d7468652d6261646765" alt="Github Action"&gt;&lt;/a&gt;
 
&lt;a href="https://paypal.com/paypalme/mudlabs/" rel="nofollow"&gt;&lt;img src="https://camo.githubusercontent.com/7f2e21e47f08076e38ce66c4458b809aa04a1697/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f2d537570706f72742d6633663466363f6c6f676f3d70617970616c267374796c653d666f722d7468652d6261646765" alt="Support Mudlabs"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h1&gt;
NPM Worker&lt;/h1&gt;
&lt;p&gt;Manage node packages on your Github Action repository.&lt;/p&gt;
&lt;h2&gt;
Table of Contents&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/mudlabs/npm-worker/master/#requirements"&gt;Requirements&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/mudlabs/npm-worker/master/#usage"&gt;Usage&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/mudlabs/npm-worker/master/#notes"&gt;Notes&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
Requirements&lt;/h2&gt;
&lt;p&gt;You must include the YAML configuration file in your repository. If you don't specify its path to the &lt;code&gt;config&lt;/code&gt; key in your workflow, the action will try to find it in your &lt;code&gt;.github&lt;/code&gt; directory and then in root &lt;em&gt;(&lt;code&gt;./&lt;/code&gt;)&lt;/em&gt; .&lt;/p&gt;
&lt;p&gt;Any of the following are accepted config file names.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;npmworker.config.yaml&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;npmworker.config.yml&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;npm.worker.config.yaml&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;npm.worker.config.yml&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
Usage&lt;/h2&gt;
&lt;h4&gt;
1. Implement a Workflow for your action&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Here we specify the workflow should only run when a change to our config file is made.&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight highlight-source-yaml js-code-highlight"&gt;
&lt;pre&gt;&lt;span class="pl-c"&gt;&lt;span class="pl-c"&gt;#&lt;/span&gt; ./.github/workflows/npmworker.yaml&lt;/span&gt;
&lt;span class="pl-ent"&gt;name&lt;/span&gt;: &lt;span class="pl-s"&gt;NPM Worker&lt;/span&gt;
&lt;span class="pl-ent"&gt;on&lt;/span&gt;
  &lt;span class="pl-ent"&gt;push&lt;/span&gt;
    &lt;span class="pl-ent"&gt;branches&lt;/span&gt;
      - &lt;span class="pl-ent"&gt;master&lt;/span&gt;:
    &lt;span class="pl-ent"&gt;paths&lt;/span&gt;:
      - &lt;span class="pl-s"&gt;./path/to/npmworker.config.yaml&lt;/span&gt;
&lt;span class="pl-ent"&gt;jobs&lt;/span&gt;:
  &lt;span class="pl-ent"&gt;npm&lt;/span&gt;:
    &lt;span class="pl-ent"&gt;runs-on&lt;/span&gt;: &lt;span class="pl-s"&gt;ubuntu-latest&lt;/span&gt;
    &lt;span class="pl-ent"&gt;name&lt;/span&gt;: &lt;span class="pl-s"&gt;NPM Worker&lt;/span&gt;
    &lt;span class="pl-ent"&gt;steps&lt;/span&gt;:
      - &lt;span class="pl-ent"&gt;uses&lt;/span&gt;: &lt;span class="pl-s"&gt;actions/checkout@v2&lt;/span&gt;
      - &lt;span class="pl-ent"&gt;name&lt;/span&gt;: &lt;span class="pl-s"&gt;Worker&lt;/span&gt;
        &lt;span class="pl-ent"&gt;uses&lt;/span&gt;: &lt;span class="pl-s"&gt;mudlabs/npm-worker@1.3.0&lt;/span&gt;
        &lt;span class="pl-ent"&gt;with&lt;/span&gt;:
          &lt;span class="pl-c"&gt;&lt;span class="pl-c"&gt;#&lt;/span&gt; OPTIONAL: Provide a PAT for the repository,&lt;/span&gt;&lt;/pre&gt;…
&lt;/div&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/mudlabs/npm-worker"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


</description>
      <category>github</category>
      <category>npm</category>
      <category>actions</category>
      <category>workflows</category>
    </item>
    <item>
      <title>NativeScript-Play-Pit Actions</title>
      <dc:creator>Sam</dc:creator>
      <pubDate>Thu, 17 Sep 2020 13:57:37 +0000</pubDate>
      <link>https://dev.to/mudlabs/nativescript-play-pit-actions-3ee9</link>
      <guid>https://dev.to/mudlabs/nativescript-play-pit-actions-3ee9</guid>
      <description>&lt;h3&gt;
  
  
  My Workflow
&lt;/h3&gt;

&lt;p&gt;NativeScript-Play-Pit is an opensource repo for NativeScript playgrounds. Anyone can create a new project or contribute to an existing one. &lt;/p&gt;

&lt;p&gt;The newly added Github Actions workflow helps make contributing easy by collecting all user submitted data from issue templates. It automatically creates the project files, and opens a new pull request. Once the playground links have been verified by a reviewer the project is added to the list.&lt;/p&gt;

&lt;h3&gt;
  
  
  Submission Category:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Wacky Wildcards &lt;em&gt;(I guess)&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Yaml File or Link to Code
&lt;/h3&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vJ70wriM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://practicaldev-herokuapp-com.freetls.fastly.net/assets/github-logo-ba8488d21cd8ee1fee097b8410db9deaa41d0ca30b004c0c63de0a479114156f.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/mudlabs"&gt;
        mudlabs
      &lt;/a&gt; / &lt;a href="https://github.com/mudlabs/NativeScript-Play-Pit"&gt;
        NativeScript-Play-Pit
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      A growing collection of NativeScript playground projects demonstrating all the AWESOMENESS🤘 of NativeScript.
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;h1&gt;
NativeScript Play Pit&lt;/h1&gt;
&lt;p&gt;An open-source collection of NativeScript playground projects demonstrating all the &lt;em&gt;AWESOMENESS&lt;/em&gt;🤘 of NativeScript.&lt;/p&gt;
&lt;h2&gt;
Table of Contents&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/mudlabs/NativeScript-Play-Pit/master/#requirements"&gt;Requirements&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/mudlabs/NativeScript-Play-Pit/master/#projects"&gt;Projects&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/mudlabs/NativeScript-Play-Pit/master/#contributing"&gt;Contributing&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
Requirements&lt;/h2&gt;
&lt;p&gt;To view a project on your device you'll need the &lt;em&gt;Playground&lt;/em&gt; and &lt;em&gt;Preview&lt;/em&gt; apps. Once you have the apps you can tap a project link from you phones' browser and it will open in the &lt;em&gt;Preview&lt;/em&gt; app. Or you can navigate to the Playground from your computer and select &lt;code&gt;QR Code&lt;/code&gt; from the sites UI. Then use the &lt;em&gt;Playground&lt;/em&gt; app to scan the QR Code.&lt;/p&gt;
&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;iOS&lt;/th&gt;
&lt;th&gt;Android&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://apps.apple.com/au/app/nativescript-playground/id1263543946" rel="nofollow"&gt;Playground App&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href="https://play.google.com/store/apps/details?id=org.nativescript.play" rel="nofollow"&gt;Playground App&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://apps.apple.com/au/app/nativescript-preview/id1263543946" rel="nofollow"&gt;Preview App&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href="https://play.google.com/store/apps/details?id=org.nativescript.preview" rel="nofollow"&gt;Preview App&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
Projects&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/mudlabs/NativeScript-Play-Pit/master/projects/Animated%20Bottom%20Sheet"&gt;Animated Bottom Sheet&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/mudlabs/NativeScript-Play-Pit/master/projects/Dragging"&gt;Dragging&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/mudlabs/NativeScript-Play-Pit/master/projects/Ios%20Cover%20Art%20Animtion"&gt;Ios Cover Art Animtion&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/mudlabs/NativeScript-Play-Pit/master/projects/Spotify%20Artist%20Page"&gt;Spotify Artist Page&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/mudlabs/NativeScript-Play-Pit/master/projects/Star%20Rating"&gt;Star Rating&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/mudlabs/NativeScript-Play-Pit/master/projects/Text%20Converter"&gt;Text Converter&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
Contributing&lt;/h2&gt;
&lt;p&gt;All contributions are welcome. The repo deploys GitHub Actions triggered by new issues to create and update Projects; see below for details.&lt;/p&gt;
&lt;h3&gt;
Creating a New Project&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;First build the project in your chosen flavour…&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/mudlabs/NativeScript-Play-Pit"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


&lt;h3&gt;
  
  
  Additional Resources / Info
&lt;/h3&gt;

</description>
      <category>actionshackathon</category>
    </item>
    <item>
      <title>Roll your own comments cleaner</title>
      <dc:creator>Sam</dc:creator>
      <pubDate>Tue, 31 Mar 2020 01:34:17 +0000</pubDate>
      <link>https://dev.to/mudlabs/roll-your-own-comments-cleaner-3m79</link>
      <guid>https://dev.to/mudlabs/roll-your-own-comments-cleaner-3m79</guid>
      <description>&lt;h5&gt;
  
  
  Update - You actually don't need to do this. But it's still probably worth knowing for non-TypeScript projects, or other file manipulation.
&lt;/h5&gt;

&lt;p&gt;If you need to strip comments from your code before publishing a package, or pushing to production, you might be inclined to spin up &lt;strong&gt;Gulp&lt;/strong&gt;, or install an &lt;strong&gt;NPM&lt;/strong&gt; dependency to do the work for you. But you may not need to.&lt;/p&gt;

&lt;p&gt;It’s actually quite easy! &lt;em&gt;(once you know how)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I recently had the need while building an NPM package. The project is written in &lt;a href="https://www.typescriptlang.org/"&gt;TypeScript&lt;/a&gt;, and the problem arose when I needed to specify the &lt;code&gt;compilerOptions&lt;/code&gt; for the TypeScript compiler &lt;em&gt;(funnily enough)&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;When you’re ready to compile your TypeScript you’ll run the &lt;code&gt;tsc&lt;/code&gt; command, or something that ends up calling &lt;code&gt;tsc&lt;/code&gt;. When that runs TypeScript looks for a &lt;code&gt;tsconfig.json&lt;/code&gt; file. In this file you can specify that comments should be removed. &lt;/p&gt;

&lt;p&gt;End of story right, we need comments removed and that’s what &lt;code&gt;removeComments&lt;/code&gt; does. Note so fast.&lt;/p&gt;

&lt;p&gt;The problem with &lt;code&gt;removeComments&lt;/code&gt; is the comments &lt;em&gt;(a.k.a documentation)&lt;/em&gt; are not only removed from the generated JavaScript files, but also the declaration files. This might not always be a problem. But for me it was. I didn’t want the comments in the JavaScript, but keeping them in the declaration file is part of the projects documentation strategy.&lt;/p&gt;

&lt;p&gt;So, what do we need? &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;We need to run &lt;code&gt;tsc&lt;/code&gt; and compile our code.&lt;/li&gt;
&lt;li&gt;Grab the compiled JavaScript file and remove all the comments.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This is a small project with no dependencies. So it seems, shall we say... undesirable to add Gulp or what-not for this little task. But how else do we do it? 🤔&lt;/p&gt;




&lt;h3&gt;
  
  
  Here’s what I learned.
&lt;/h3&gt;

&lt;p&gt;The Node-CLI has a &lt;a href="https://nodejs.org/api/cli.html#cli_p_print_script"&gt;print&lt;/a&gt; command that we use to execute an exported function from a JavaScript file somewhere in our directory. We’ll use it like this;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="err"&gt;/**&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;package.json&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;**/&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
 &lt;/span&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="w"&gt;
 &lt;/span&gt;&lt;span class="nl"&gt;"scripts"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"prepare"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"tsc &amp;amp;&amp;amp; node -p &lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;require('./cleaner').clean()&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="w"&gt;
 &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
 &lt;/span&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When I call &lt;code&gt;npm run prepare&lt;/code&gt; in the terminal the TypeScript compiler &lt;em&gt;(tsc)&lt;/em&gt; will fire, and then node will look for a file called &lt;strong&gt;cleaner.js&lt;/strong&gt; at the same directory level as &lt;strong&gt;package.json&lt;/strong&gt;. If it finds one, it will attempt to call an exported function named &lt;strong&gt;clean&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Lets add the &lt;strong&gt;cleaner&lt;/strong&gt; file, and export the &lt;strong&gt;clean&lt;/strong&gt; function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// cleaner.js&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;fs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="err"&gt;“&lt;/span&gt;&lt;span class="nx"&gt;fs&lt;/span&gt;&lt;span class="err"&gt;”&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// comes with node.&lt;/span&gt;

&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;cleaner&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;file&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;nocomments&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;filePath&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;dist/index.js&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;regex&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;RegExp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="se"&gt;((&lt;/span&gt;&lt;span class="sr"&gt;^&lt;/span&gt;&lt;span class="se"&gt;\/\*\*\n(\D\W&lt;/span&gt;&lt;span class="sr"&gt;.+&lt;/span&gt;&lt;span class="se"&gt;\n)&lt;/span&gt;&lt;span class="sr"&gt;+&lt;/span&gt;&lt;span class="se"&gt;))&lt;/span&gt;&lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;gm&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="nx"&gt;fs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;accessSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;filePath&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;fs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;constants&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;F_OK&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="nx"&gt;file&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;fs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;openSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;filePath&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;r+&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;fs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;constants&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;O_RDWR&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;fs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;readFileSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;file&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;utf8&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;nocomments&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;regex&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="nx"&gt;fs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;writeFileSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;filePath&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;nocomments&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Comments Removed&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;And that's it!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When the &lt;code&gt;clean&lt;/code&gt; function executes it locates our newly generated JavaScript file, reads in its content, replaces all the comments with &lt;em&gt;nothing&lt;/em&gt;, and then writes the new version back to file.&lt;/p&gt;

&lt;p&gt;There's probably a bit going on here you're not familiar with; what's all this &lt;code&gt;fs&lt;/code&gt; stuff? I didn't know either. But I found this good post that explains it all, so I'll point you there.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://areknawo.com/node-js-file-system-api-beginner-friendly-guide/"&gt;Node.js File System API, Beginner Friendly Guid&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Oh, and &lt;a href="https://www.npmjs.com/package/short-scale-units"&gt;NPM: Short Scale Units&lt;/a&gt;, incase you give any &lt;strong&gt;F&lt;/strong&gt;&lt;em&gt;s&lt;/em&gt; about my little project.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;This is a pretty specific solution. I now all the comments are block style, so the &lt;code&gt;RegExp&lt;/code&gt; has been designed to match that pattern.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="cm"&gt;/**
 * My block style comment explaining important stuff
 * @param tag explaining the param stuff.
 * @return tag explaining the return stuff.
 */&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And I know the compiler will output an &lt;code&gt;index.js&lt;/code&gt; file to a generated &lt;code&gt;dist/&lt;/code&gt; directory. But I think this gives a good outline of the type of solution you have available, with no added dependencies.&lt;/p&gt;




&lt;h3&gt;
  
  
  Update
&lt;/h3&gt;

&lt;h5&gt;
  
  
  &lt;a href="https://www.reddit.com/r/typescript/comments/frj1hn/when_compiling_can_you_specify_that_you_want/?utm_source=share&amp;amp;utm_medium=web2x"&gt;Thanks to these Redditors&lt;/a&gt;
&lt;/h5&gt;

&lt;p&gt;I since learned how to get the same desired outcome for a TypeScript project without needing to roll your own comments remover.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;tsconfig.json&lt;/code&gt; file has an available property named &lt;code&gt;extends&lt;/code&gt;. We can use that and the command chaining we already used here to remove the comments from the output JavaScript, but leave them in the declaration files.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;We'll change our run command in &lt;strong&gt;package.json&lt;/strong&gt; to&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"prepare": "tsc &amp;amp;&amp;amp; tsc -p ./tsconfig.nocomments.json"
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;We'll create the new config file, and extend it from the main &lt;code&gt;tsconfig&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"extends"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"./tsconfig.json"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"compilerOptions"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"declaration"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"removeComments"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The main, default &lt;code&gt;tsconfig&lt;/code&gt; file runs first generating declaration and JavaScript files with comments in place. Then our next call to &lt;code&gt;tsc&lt;/code&gt; specifies a path to the new config file &lt;em&gt;(&lt;code&gt;tsconfig.nocomments&lt;/code&gt;)&lt;/em&gt;, and that one does not create a new declaration file, but does create a new JavaScript file with &lt;em&gt;no&lt;/em&gt; comments; which replaces the existing file.&lt;/p&gt;

&lt;p&gt;So while you don't need to &lt;em&gt;roll your own comments cleaner&lt;/em&gt; in a TypeScript project, the strategy outlined here can still be used for non TypeScript projects, or to do some other manipulation of a files content.&lt;/p&gt;

</description>
      <category>npm</category>
      <category>node</category>
      <category>javascript</category>
      <category>typescript</category>
    </item>
    <item>
      <title>Getting tap location in NativeScript</title>
      <dc:creator>Sam</dc:creator>
      <pubDate>Thu, 19 Mar 2020 23:31:46 +0000</pubDate>
      <link>https://dev.to/mudlabs/getting-tap-location-in-nativescript-1oai</link>
      <guid>https://dev.to/mudlabs/getting-tap-location-in-nativescript-1oai</guid>
      <description>&lt;p&gt;Until now, if you wanted to get the &lt;code&gt;x&lt;/code&gt;/&lt;code&gt;y&lt;/code&gt; touch coordinates from a &lt;code&gt;tap&lt;/code&gt; event you needed to drop down into the underlying native code.&lt;/p&gt;

&lt;p&gt;As of &lt;code&gt;v6.5.0&lt;/code&gt; NativeScript exposes this functionality for you and provides a &lt;code&gt;TapGestureEventData&lt;/code&gt; interface. You use it like this;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;TapGestureEventData&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@nativescript/core&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;myTapHandler&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;TapGestureEventData&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getX&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// x coordinate in DP&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getY&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// y coordinate in DP&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;pointers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getPointerCount&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// number of pointers.&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;fingers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;pointers&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;fingers&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;finger&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`You tapped at (&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;,&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;y&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;), with &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;pointers&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;fingers&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// You tapped at (67, 123), with 1 finger.&lt;/span&gt;
&lt;span class="c1"&gt;// You tapped at (321, 45), with 2 fingers.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;TapGestureEventData&lt;/code&gt; is exposed for both &lt;code&gt;tap&lt;/code&gt; and &lt;code&gt;doubleTap&lt;/code&gt; events.&lt;/p&gt;

&lt;p&gt;The returned coordinates are in Device Pixels &lt;strong&gt;&lt;em&gt;(DP)&lt;/em&gt;&lt;/strong&gt;. To convert them to Device Independent Pixels &lt;strong&gt;&lt;em&gt;(DIP)&lt;/em&gt;&lt;/strong&gt; use;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;layout&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@nativescript/core&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="nx"&gt;myTapHandler&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;TapGestureEventData&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;x_dp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getX&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;x_dip&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;layout&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;toDeviceIndependentPixels&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;x_dp&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Your x coordinate is (DP: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;x_dp&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;, DIP: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;x_dip&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;)`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Assuming a screen scale of 3.&lt;/span&gt;
&lt;span class="c1"&gt;// Your x coordinate is (DP: 63, DIP: 21)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There is an open &lt;a href="https://github.com/NativeScript/NativeScript/issues/8427"&gt;issue&lt;/a&gt; requesting a standardisation of UI values provided by the NativeScript API. The issue requests all API properties and methods that hold or provide UI coordinates or view dimensions are in &lt;strong&gt;DIP&lt;/strong&gt;. If the core team accepts the standardisation you will no longer need to do this conversion.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; If you need to convert &lt;strong&gt;&lt;em&gt;DIP&lt;/em&gt;&lt;/strong&gt; to &lt;strong&gt;DP&lt;/strong&gt; use &lt;code&gt;layout.toDevicePixels(dip);&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>nativescript</category>
      <category>ios</category>
      <category>android</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Shadows in NativeScript</title>
      <dc:creator>Sam</dc:creator>
      <pubDate>Fri, 09 Aug 2019 07:26:20 +0000</pubDate>
      <link>https://dev.to/mudlabs/shadows-in-nativescript-2di9</link>
      <guid>https://dev.to/mudlabs/shadows-in-nativescript-2di9</guid>
      <description>&lt;p&gt;Before we begin it's worth remembering, &lt;em&gt;there's many ways to skin a cat&lt;/em&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  😸 (🔪,✂️,🐶) 🙀
&lt;/h2&gt;

&lt;p&gt;But for this post we're going to look at implementing a &lt;strong&gt;shadow&lt;/strong&gt; in NativeScript using a single view; the &lt;code&gt;label&lt;/code&gt; view shown below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="c"&gt;&amp;lt;!--
  main-page.xml

  This is the `xml` layout we'll be referring to throughout.
--&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;Page&lt;/span&gt; &lt;span class="na"&gt;loaded=&lt;/span&gt;&lt;span class="s"&gt;"onLoaded"&lt;/span&gt; &lt;span class="na"&gt;xmlns=&lt;/span&gt;&lt;span class="s"&gt;"http://schemas.nativescript.org/tns.xsd"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;Label&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"label"&lt;/span&gt; &lt;span class="na"&gt;text=&lt;/span&gt;&lt;span class="s"&gt;"Shadow Games"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/Page&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  iOS Shadows
&lt;/h1&gt;

&lt;p&gt;In the &lt;code&gt;xml&lt;/code&gt; above you'll note that no &lt;code&gt;backgroundColor&lt;/code&gt; or &lt;code&gt;borderRadius&lt;/code&gt; have been set.&lt;/p&gt;

&lt;p&gt;That's because on iOS the same view that's implementing a shadow can not also implement a &lt;code&gt;backgroundColor&lt;/code&gt; or &lt;code&gt;borderRadius&lt;/code&gt; &lt;em&gt;(a.k.a. cornerRadius)&lt;/em&gt;. Well it can, but they'll need to be set with the shadow, on the views underlying &lt;code&gt;CALayer&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// main-page.js&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;onLoaded&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;args&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;object&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;label&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getViewById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;label&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ios&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;layer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;label&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ios&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;layer&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nx"&gt;layer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;backgroundColor&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;UIColor&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;whiteColor&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;CGColor&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nx"&gt;layer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;shadowOffset&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;CGSizeMake&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;layer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;shadowOpacity&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nx"&gt;layer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;shadowRadius&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nx"&gt;layer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;cornerRadius&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="cm"&gt;/*
     You can also specify the shadow colour;
     (i.e. layer.shadowColor = UIColor.yellowColor.CGColor)

     But it will default to black if not set.
    */&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And now we have a shadow in iOS&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fclcrapx4xs3ojzaazvq0.png" alt="shadow-ios"&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h1&gt;
  
  
  Android Shadows
&lt;/h1&gt;

&lt;p&gt;Since NativeScript 5.4 we have &lt;code&gt;androidElevation&lt;/code&gt;. The feature is currently only available on Android, &lt;em&gt;hence the name&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;androidElevation&lt;/code&gt; is an implementation of Material Designs elevation. To use it you just set the elevation and give your view a &lt;code&gt;backgroundColor&lt;/code&gt; and a &lt;code&gt;margin&lt;/code&gt; &lt;em&gt;(and a &lt;code&gt;borderRadius&lt;/code&gt; if you like that)&lt;/em&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;Label&lt;/span&gt; 
  &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"label"&lt;/span&gt; 
  &lt;span class="na"&gt;text=&lt;/span&gt;&lt;span class="s"&gt;"Shadow Games"&lt;/span&gt;

  &lt;span class="na"&gt;margin=&lt;/span&gt;&lt;span class="s"&gt;"10"&lt;/span&gt;
  &lt;span class="na"&gt;borderRadius=&lt;/span&gt;&lt;span class="s"&gt;"20"&lt;/span&gt;
  &lt;span class="na"&gt;androidElevation=&lt;/span&gt;&lt;span class="s"&gt;"12"&lt;/span&gt;
  &lt;span class="na"&gt;backgroundColor=&lt;/span&gt;&lt;span class="s"&gt;"white"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F5fbm4umfxn84arkfecco.png" alt="shadow-android"&gt;&lt;/th&gt;
&lt;th&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fycruyu710dkjzaim3tqr.png" alt="shadow-ios--lost"&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Android shadow using elevation&lt;/td&gt;
&lt;td&gt;iOS shadow has been lost&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Unfortunately, setting the &lt;code&gt;backgroundColor&lt;/code&gt; and &lt;code&gt;borderRadius&lt;/code&gt; will mean our iOS shadows will stop working. To fix that we can scope the offending properties to android.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;Label&lt;/span&gt; 
  &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"label"&lt;/span&gt;
  &lt;span class="na"&gt;text=&lt;/span&gt;&lt;span class="s"&gt;"Shadow Games"&lt;/span&gt;

  &lt;span class="na"&gt;margin=&lt;/span&gt;&lt;span class="s"&gt;"10"&lt;/span&gt;
  &lt;span class="na"&gt;android:borderRadius=&lt;/span&gt;&lt;span class="s"&gt;"20"&lt;/span&gt;
  &lt;span class="na"&gt;androidElevation=&lt;/span&gt;&lt;span class="s"&gt;"12"&lt;/span&gt;
  &lt;span class="na"&gt;android:backgroundColor=&lt;/span&gt;&lt;span class="s"&gt;"white"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Voila, we have our cross platform shadows 🤘.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F5fbm4umfxn84arkfecco.png" alt="shadow-android"&gt;&lt;/th&gt;
&lt;th&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fclcrapx4xs3ojzaazvq0.png" alt="shadow-ios"&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Android shadow&lt;/td&gt;
&lt;td&gt;iOS shadow&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h1&gt;
  
  
  Where does it break down?
&lt;/h1&gt;

&lt;p&gt;In a word, &lt;strong&gt;&lt;em&gt;animation&lt;/em&gt;&lt;/strong&gt;. On Android you won't have any problems animating the views &lt;code&gt;backgroundColor&lt;/code&gt;, but on iOS you'll lose the shadow. &lt;/p&gt;

&lt;p&gt;Thats because NativeScript animations animate the &lt;em&gt;view properties&lt;/em&gt;, but we implemented the iOS &lt;code&gt;backgroundColor&lt;/code&gt; &lt;em&gt;(and &lt;code&gt;borderRadius&lt;/code&gt;)&lt;/em&gt; on the views underlying &lt;code&gt;CALayer&lt;/code&gt;. So in order to animate the &lt;code&gt;backgroundColor&lt;/code&gt; we're going to have to animate it down there.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// ...&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;layer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;label&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ios&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;layer&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;newColor&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;UIColor&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;yellowColor&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;CGColor&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;bgAnimation&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;CABasicAnimation&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;animationWithKeyPath&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;background&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nx"&gt;bgAnimation&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;fromValue&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;layer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;backgroundColor&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;bgAnimation&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;toValue&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;newColor&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;bgAnimation&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;duration&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="c1"&gt;// seconds&lt;/span&gt;

&lt;span class="c1"&gt;// triggers the animation to run.&lt;/span&gt;
&lt;span class="nx"&gt;layer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addAnimationForKey&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;bgAnimation&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;bgAnimation&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// update layer prop to new value after animation, else it pops back to the initial value.&lt;/span&gt;
&lt;span class="nx"&gt;layer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;backgroundColor&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;newColor&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And if you made it this far, here's a &lt;a href="https://play.nativescript.org/?template=play-js&amp;amp;id=vc8Ahs" rel="noopener noreferrer"&gt;Playground&lt;/a&gt; with the animations in full effect.&lt;/p&gt;

</description>
      <category>nativescript</category>
      <category>ios</category>
      <category>android</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
