Added INotification and IConfiguration to electron notify

This commit is contained in:
Daniel Pereira
2016-08-15 15:57:19 -05:00
parent 07084d3ae6
commit dd7de3e50c
2 changed files with 60 additions and 5 deletions

View File

@@ -0,0 +1,23 @@
/// <reference path="./electron-notify.d.ts" />
import * as eNotify from 'electron-notify';
eNotify.setConfig({
appIcon: 'images/otherIcon.png',
displayTime: 6000,
defaultStyleText: {
color: '#FF0000',
fontWeight: 'bold'
}
});
eNotify.notify({
title: 'Title',
text: 'Some text',
image: 'path/to/image.png',
url: 'http://google.de',
sound: 'notification.wav',
onClickFunc: function () { console.log('onClick') },
onShowFunc: function () { console.log('onShow') },
onCloseFunc: function () { console.log('onClose') }
});

View File

@@ -6,22 +6,54 @@
/// <reference path="../github-electron/github-electron.d.ts" />
declare namespace ElectronNotify {
interface INotification {
title: string,
text?: string,
image?: string,
url?: string,
sound?: string,
onClickFunc?: (event: string, id: number, closeNotification) => void,
onShowFunc?: (event: string, id: number, closeNotification) => void,
onCloseFunc?: (event: string, id: number) => void
}
interface IConfiguration {
width?: number,
height?: number,
padding?: number,
borderRadius?: number,
displayTime?: number,
animationSteps?: number,
animationStepMs?: number,
animateInParallel?: boolean,
appIcon?: string,
pathToModule?: string,
logging?: boolean,
defaultWindow?: Electron.BrowserWindowOptions,
defaultStyleContainer?: any,
defaultStyleAppIcon?: any,
defaultStyleImage?: any,
defaultStyleClose?: any,
defaultStyleText?: any
}
}
/** Nice and simple notifications for electron apps */
declare module 'electron-notify' {
/** Change some config options. Can be run multiple times, also between notify()-calls to change electron-notifys behaviour. */
export function setConfig(configObj);
export function setConfig(customConfig: ElectronNotify.IConfiguration);
/** Displays new notification. */
export function notify(notificationObj);
export function notify(notification: ElectronNotify.INotification);
/** Clears the animation queue and closes all windows opened by electron-notify. Call this to clean up before quiting your app. */
export function closeAll();
export function setTemplatePath(path);
export function getTemplatePath(): string;
export function setTemplatePath(path: string);
/** Returns the maximum amount of notifications that fit onto the users screen. */
export function calcMaxVisibleNotification(): number;
}