-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathnativescript-sidedrawer.common.ts
73 lines (61 loc) · 1.75 KB
/
nativescript-sidedrawer.common.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//
import { Color } from 'color'
import { ImageSource } from 'image-source'
import { isDefined } from 'utils/types'
export interface TnsSideDrawerItem {
title: string
androidIcon?: string
iosIcon?: string
}
export type TnsSideDrawerOptionsListener = (index: number) => void
export interface TnsSideDrawerOptions {
templates: Array<TnsSideDrawerItem>
textColor?: Color
headerBackgroundColor?: Color
backgroundColor?: Color
logoImage?: ImageSource
title?: string
subtitle?: string
listener: TnsSideDrawerOptionsListener
context?: any
}
export class TnsSideDrawerCommonClass {
protected static isBuilt = false
protected templates: Array<TnsSideDrawerItem>
protected textColor = new Color('white')
protected headerBackgroundColor = new Color('#343C45')
protected backgroundColor = new Color('#556270')
protected logoImage: ImageSource
protected title: string
protected subtitle: string
protected listener: TnsSideDrawerOptionsListener
protected context: any
build(opts: TnsSideDrawerOptions): boolean {
if (TnsSideDrawerCommonClass.isBuilt == true) {
console.warn('TnsSideDrawer.isBuilt == true\nyouve already built a sidedrawer')
return true
}
TnsSideDrawerCommonClass.isBuilt = true
this.templates = opts.templates
this.listener = opts.listener
if (isDefined(opts.context)) {
this.context = opts.context
}
if (isDefined(opts.textColor)) {
this.textColor = opts.textColor
}
if (isDefined(opts.headerBackgroundColor)) {
this.headerBackgroundColor = opts.headerBackgroundColor
}
if (isDefined(opts.backgroundColor)) {
this.backgroundColor = opts.backgroundColor
}
if (isDefined(opts.title)) {
this.title = opts.title
}
if (isDefined(opts.subtitle)) {
this.subtitle = opts.subtitle
}
return false
}
}