Skip to content

Instantly share code, notes, and snippets.

@khadorkin
Last active August 29, 2015 14:25
Show Gist options
  • Save khadorkin/203dec8a82ae266c5f38 to your computer and use it in GitHub Desktop.
Save khadorkin/203dec8a82ae266c5f38 to your computer and use it in GitHub Desktop.
import platform = require("platform");
import application = require("application");
export enum Length {
Short = 2000,
Long = 3500
}
export function show(message: string, length: Length = Length.Long) {
if (platform.device.os === platform.platformNames.android) {
android.widget.Toast.makeText(application.android.context, message, length).show();
} else if (platform.device.os === platform.platformNames.ios) {
var toast = new UIAlertView(null, message, null, null, null);
toast.show();
setTimeout(() => {
toast.dismissWithClickedButtonIndexAnimated(0, true);
}, length);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment