From dd7de3e50c342bdf77de61d725083d3d20ab8d9e Mon Sep 17 00:00:00 2001 From: Daniel Pereira Date: Mon, 15 Aug 2016 15:57:19 -0500 Subject: [PATCH] Added INotification and IConfiguration to electron notify --- electron-notify/electron-notify-tests.ts | 23 +++++++++++++ electron-notify/electron-notify.d.ts | 42 +++++++++++++++++++++--- 2 files changed, 60 insertions(+), 5 deletions(-) diff --git a/electron-notify/electron-notify-tests.ts b/electron-notify/electron-notify-tests.ts index e69de29bb2..9194a11f1b 100644 --- a/electron-notify/electron-notify-tests.ts +++ b/electron-notify/electron-notify-tests.ts @@ -0,0 +1,23 @@ +/// + +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') } +}); \ No newline at end of file diff --git a/electron-notify/electron-notify.d.ts b/electron-notify/electron-notify.d.ts index f6f4d47b07..d5ac7f1966 100644 --- a/electron-notify/electron-notify.d.ts +++ b/electron-notify/electron-notify.d.ts @@ -6,22 +6,54 @@ /// 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; } \ No newline at end of file