Skip to content

Instantly share code, notes, and snippets.

View NickIliev's full-sized avatar

Nikolay Iliev NickIliev

  • Progress
  • Sofia, Bulgaria
View GitHub Profile
@NickIliev
NickIliev / is-pass-through-parent-enabled.xml
Last active August 14, 2019 12:25
Using isPassThroughParentEnabled property to pass gestures from disabled button to a parent layout.
<GridLayout id="outmost" margin="10" backgroundColor="orangered" tap="onTap">
<GridLayout id="middle" margin="50" backgroundColor="lightgray" tap="onTap">
<StackLayout id="inner" margin="50" backgroundColor="blue" tap="onTap" isPassThroughParentEnabled="true">
<Button text="Active Button" id="button-active" tap="onTap" backgroundColor="whitesmoke" margin="20" height="100"/>
<Button isUserInteractionEnabled="false" text="DISABLED Button" id="button-disabled" tap="onTap" backgroundColor="gray" margin="20" height="100"/>
</StackLayout>
</GridLayout>
</GridLayout>
@NickIliev
NickIliev / event-propagation-nativescript.ts
Created August 14, 2019 11:35
Event propagation (bubbling) in NativeScript
export function onTap(args: EventData) {
console.log(`>>>>>>>>>>> onTap invoked from: ${args.object}`);
const view: View = args.object as View;
animate(view);
}
@NickIliev
NickIliev / event-propagation-nativescript.xml
Created August 14, 2019 11:26
Event propagation (bubbling) in NativeScript
<GridLayout id="outmost" margin="10" backgroundColor="orangered" tap="onTap" >
<GridLayout id="middle" margin="50" backgroundColor="lightgray" tap="onTap">
<GridLayout id="inner" margin="50" backgroundColor="blue" tap="onTap"> <!-- The StackLayout will propagete the tap gesture to its parents -->
<Button text="Button" id="my-button" width="100" height="200" tap="onTap" backgroundColor="whitesmoke" /> <!-- The Button has its own tap logic and won't propagate the tap event -->
</GridLayout>
</GridLayout>
</GridLayout>
@NickIliev
NickIliev / hmr-by-default.sh
Created March 29, 2019 07:43
nativescript
tns run
@NickIliev
NickIliev / nsconfig.json
Created March 29, 2019 07:39
nativescript HMR commands
{
"useLegacyWorkflow": false
}
@NickIliev
NickIliev / nativescript.sh
Last active March 29, 2019 07:28
nativescript HMR commands
tns run --hmr
@NickIliev
NickIliev / main-view-model.ts
Created November 22, 2018 13:48
Firebase Storage Delete File (NativeScript)
deleteFile() {
storage.deleteFile({
// optional, can also be passed during init() as 'storageBucket' param so we can cache it
bucket: APPSPOT_BUCKET_URL,
// the full path of an existing file in your Firebase storage
remoteFullPath: 'uploads/images/firebase-storage.png'
}).then(() => {
console.log("File deleted from Firebase Storage.");
}).catch(error => {
console.log("File deletion Error: " + error);
@NickIliev
NickIliev / main-view-model.ts
Last active November 22, 2018 13:42
Firebase Storage get Download URL (NativeScript)
getDownloadUrl() {
storage.getDownloadUrl({
// optional, can also be passed during init() as 'storageBucket' param so we can cache it
bucket: APPSPOT_BUCKET_URL,
// the full path of an existing file in your Firebase storage
remoteFullPath: 'uploads/images/happy-homer-meme.png'
}).then(downloadURL => {
console.log("Download URL: " + downloadURL);
}).catch(error => {
console.log("Error: " + error);
@NickIliev
NickIliev / main-view-model.ts
Last active November 22, 2018 13:43
Firebase Storage Download a File (NativeScript)
downloadFile() {
let downloadPath: string;
let logoPath: string;
let fileName: string = "happy-homer-meme.png";
if (isAndroid) {
// use tns-platform-declarations to access the native Android & iOS APIs
downloadPath = android.os.Environment.getExternalStoragePublicDirectory(android.os.Environment.DIRECTORY_DOWNLOADS).toString();
} else if (isIOS) {
downloadPath = knownFolders.documents().path;
@NickIliev
NickIliev / main-view-model.ts
Last active November 22, 2018 13:25
Firebase Storage Upload File
import { storage } from "nativescript-plugin-firebase";
import { File, knownFolders, path } from "tns-core-modules/file-system";
import { APPSPOT_BUCKET_URL } from "./shared/link"; // e.g. gs://firebase-storage-demo.appspot.com
uploadFile() {
const appPath = knownFolders.currentApp().path;
// The path to the file we want to upload (this one is in `app/images` and is called `happy-homer-meme.png`)
const logoPath = appPath + "/images/happy-homer-meme.png";
// Upload the file with the options below: