Skip to content

Instantly share code, notes, and snippets.

View EddyVerbruggen's full-sized avatar
🔌
plugged in

Eddy Verbruggen EddyVerbruggen

🔌
plugged in
View GitHub Profile
@EddyVerbruggen
EddyVerbruggen / split-view-tablets-nativescript-angular.html
Last active June 14, 2017 08:46
Split view tablet support for NativeScript with Angular
<!-- 'master' view -->
<ActionBar></ActionBar>
<GridLayout [columns]="isTablet ? '*, *' : '*'">
<StackLayout>
<!-- 'master' ListView -->
</StackLayout>
<StackLayout col="1" *ngIf="isTablet">
<!-- 'detail-contents' component, only for tablets -->
<detail-contents></detail-contents>
</StackLayout>
@EddyVerbruggen
EddyVerbruggen / is-tablet.ts
Last active June 14, 2017 07:48
Determine running on a tablet in NativeScript
// required imports:
import { DeviceType } from "ui/enums";
import { device } from "platform";
// then wherever you need it:
const isTablet: boolean = device.deviceType === DeviceType.Tablet;
@EddyVerbruggen
EddyVerbruggen / nativescript-segmentedbar-selected-text-color.ts
Last active December 19, 2017 11:38
Change the text color of the selected item in a NativeScript SegmentedBar
import { Color } from "tns-core-modules/color";
declare const UIControlStateSelected: any;
export class CheckoutComponent implements OnInit {
// this assumes you have this in your html: <SegmentedBar #paymentOptionsBar ..>
@ViewChild("paymentOptionsBar") paymentOptionsBar: ElementRef;
ngOnInit(): void {
@EddyVerbruggen
EddyVerbruggen / nativescript-ios-caret-color.ts
Last active March 17, 2020 13:09
Changing the caret (cursor) color in NativeScript iOS
export class MyComponent implements AfterViewInit {
// assuming your view has this: <TextField #myTextField text="I have a red caret"></TextField>
@ViewChild("myTextField") myTextField: ElementRef;
ngAfterViewInit(): void {
// note that if you don't have iOS typings you can change 'UITextField' to 'any'
let textField: UITextField = (<TextField>this.myTextField.nativeElement).ios;
textField.tintColor = new Color("red").ios;
}
}
@EddyVerbruggen
EddyVerbruggen / radsidedrawer-component.ts
Last active September 11, 2018 10:23
Adding depth / shadow to your NativeScript RadSideDrawer (iOS)
// In case of Angular, this is the component that contains a view with a <RadSideDrawer>
export class MenuComponent implements AfterViewInit {
@ViewChild(RadSideDrawerComponent) public drawerComponent: RadSideDrawerComponent;
private _drawer: SideDrawerType;
ngAfterViewInit(): void {
this._drawer = this.drawerComponent.sideDrawer;
this._changeDetectionRef.detectChanges();
@EddyVerbruggen
EddyVerbruggen / label-max-lines.directive.ts
Last active November 22, 2023 06:13 — forked from m-abs/label-max-lines.directive.ts
Directive for NativeScript-angular, adding the property maxLines to Label
// Usage: <Label maxLines="3" .. />
import { Directive, ElementRef, Input, OnInit, OnChanges } from '@angular/core';
import { Label } from 'tns-core-modules/ui/label';
declare const android, NSLineBreakMode: any;
@Directive({
selector: 'Label[maxLines]',
})
@EddyVerbruggen
EddyVerbruggen / nativescript-speech-recognition-ios-plist.xml
Created March 7, 2017 10:03
Speech Recognition in NativeScript (iOS consent popup content)
<!-- Speech recognition usage consent -->
<key>NSSpeechRecognitionUsageDescription</key>
<string>My custom recognition usage description. Overriding the default empty one in the plugin.</string>
<!-- Microphone usage constent -->
<key>NSMicrophoneUsageDescription</key>
<string>My custom microphone usage description. Overriding the default empty one in the plugin.</string>
@EddyVerbruggen
EddyVerbruggen / nativescript-speech-recognition-listening.ts
Created March 7, 2017 08:54
Speech Recognition in NativeScript
// import the plugin
import { SpeechRecognition } from "nativescript-speech-recognition";
class SpeechRecognition {
// instantiate the plugin
private speechRecognition = new SpeechRecognition();
public checkAvailability(): void {
this.speechRecognition.available().then(
(available: boolean) => console.log(available ? "YES!" : "NO"),
@EddyVerbruggen
EddyVerbruggen / nativescript-speech-recognition-availability-check.ts
Last active March 7, 2017 08:54
Speech Recognition in NativeScript (availability check)
// import the plugin
import { SpeechRecognition } from "nativescript-speech-recognition";
class SpeechRecognition {
// instantiate the plugin
private speechRecognition = new SpeechRecognition();
public checkAvailability(): void {
this.speechRecognition.available().then(
(available: boolean) => console.log(available ? "YES!" : "NO"),
@EddyVerbruggen
EddyVerbruggen / partial-aws-sdk-package.json
Created March 1, 2017 09:35
browserify bits of AWS SDK package.json
"dependencies": {
"buffer": "4.9.1",
"querystring": "0.2.0",
"sax": "1.1.5",
"uuid": "3.0.0",
"xml2js": "0.4.15",
},
"main": "lib/aws.js",
"browser": {
"lib/aws.js": "./lib/browser.js",