|
1 |
| -import {View, AddChildFromBuilder, Style, CssProperty} from '@nativescript/core'; |
2 |
| -import {Canvas} from '../Canvas'; |
3 |
| -import {DOMParser} from 'xmldom-qsa'; |
| 1 | +import { View, Style, CssProperty, AddChildFromBuilder } from '@nativescript/core'; |
| 2 | +import { Canvas } from '../Canvas'; |
4 | 3 |
|
5 | 4 | export const strokeProperty = new CssProperty<Style, any>({
|
6 |
| - name: 'stroke', |
7 |
| - cssName: 'stroke', |
8 |
| - defaultValue: undefined |
| 5 | + name: 'stroke', |
| 6 | + cssName: 'stroke', |
| 7 | + defaultValue: undefined, |
9 | 8 | });
|
10 | 9 |
|
11 | 10 | export const strokeWidthProperty = new CssProperty<Style, number>({
|
12 |
| - name: 'strokeWidth', |
13 |
| - cssName: 'stroke-width', |
14 |
| - defaultValue: 1, |
| 11 | + name: 'strokeWidth', |
| 12 | + cssName: 'stroke-width', |
| 13 | + defaultValue: 1, |
15 | 14 | });
|
16 | 15 |
|
17 | 16 | export const fillProperty = new CssProperty<Style, any>({
|
18 |
| - name: 'fill', |
19 |
| - cssName: 'fill', |
20 |
| - defaultValue: undefined |
| 17 | + name: 'fill', |
| 18 | + cssName: 'fill', |
| 19 | + defaultValue: undefined, |
21 | 20 | });
|
22 | 21 |
|
23 | 22 | export const fillOpacityProperty = new CssProperty<Style, any>({
|
24 |
| - name: 'fillOpacity', |
25 |
| - cssName: 'fill-opacity', |
26 |
| - defaultValue: undefined |
| 23 | + name: 'fillOpacity', |
| 24 | + cssName: 'fill-opacity', |
| 25 | + defaultValue: undefined, |
27 | 26 | });
|
28 | 27 |
|
29 | 28 | export const stopColorProperty = new CssProperty<Style, any>({
|
30 |
| - name: 'stopColor', |
31 |
| - cssName: 'stop-color', |
32 |
| - defaultValue: undefined |
| 29 | + name: 'stopColor', |
| 30 | + cssName: 'stop-color', |
| 31 | + defaultValue: undefined, |
33 | 32 | });
|
34 | 33 |
|
35 | 34 | export class SVG extends View implements AddChildFromBuilder {
|
36 |
| - _canvas: any; |
37 |
| - _views: any[]; |
38 |
| - _children: Map<string, View>; |
39 |
| - _parser: DOMParser; |
| 35 | + _canvas: any; |
| 36 | + _views: any[]; |
| 37 | + _children: Map<string, View>; |
40 | 38 |
|
41 |
| - constructor() { |
42 |
| - super(); |
43 |
| - this._canvas = new Canvas(); |
44 |
| - this._views = []; |
45 |
| - this._parser = new DOMParser(); |
46 |
| - this._children = new Map<string, View>(); |
47 |
| - } |
| 39 | + constructor() { |
| 40 | + super(); |
| 41 | + this._canvas = new Canvas(); |
| 42 | + this._views = []; |
| 43 | + this._children = new Map<string, View>(); |
| 44 | + } |
48 | 45 |
|
49 |
| - createNativeView(): Object { |
50 |
| - this.on('layoutChanged', args => { |
51 |
| - this._views.forEach(view => { |
52 |
| - if (typeof view.handleValues === 'function') { |
53 |
| - view.handleValues(); |
54 |
| - } |
55 |
| - }); |
56 |
| - }); |
57 |
| - if (this._canvas.ios) { |
58 |
| - return this._canvas.ios; |
59 |
| - } |
60 |
| - return this._canvas.android; |
61 |
| - } |
| 46 | + createNativeView(): Object { |
| 47 | + this.on('layoutChanged', (args) => { |
| 48 | + this._views.forEach((view) => { |
| 49 | + if (typeof view.handleValues === 'function') { |
| 50 | + view.handleValues(); |
| 51 | + } |
| 52 | + }); |
| 53 | + }); |
| 54 | + if (this._canvas.ios) { |
| 55 | + return this._canvas.ios; |
| 56 | + } |
| 57 | + return this._canvas.android; |
| 58 | + } |
62 | 59 |
|
63 |
| - _addChildFromBuilder(name: string, value: any): void { |
64 |
| - value._canvas = this._canvas; |
65 |
| - value.parent = this; |
66 |
| - this._views.push(value); |
67 |
| - this._children.set(value.id || value._domId, value); |
68 |
| - } |
| 60 | + _addChildFromBuilder(name: string, value: any): void { |
| 61 | + value._canvas = this._canvas; |
| 62 | + value.parent = this; |
| 63 | + this._views.push(value); |
| 64 | + this._children.set(value.id || value._domId, value); |
| 65 | + } |
69 | 66 |
|
| 67 | + _getViewById(name: string) { |
| 68 | + if (typeof name === 'string') { |
| 69 | + if (name.indexOf('url') > -1) { |
| 70 | + name = name.replace('url', '').replace('(', '').replace(')', ''); |
| 71 | + } |
70 | 72 |
|
71 |
| - _getViewById(name: string) { |
72 |
| - if (typeof name === 'string') { |
73 |
| - if (name.indexOf('url') > -1) { |
74 |
| - name = name.replace('url', '').replace('(', '').replace(')', ''); |
75 |
| - } |
| 73 | + if (name.indexOf('#')) { |
| 74 | + name = name.replace('#', ''); |
| 75 | + } |
76 | 76 |
|
77 |
| - if (name.indexOf('#')) { |
78 |
| - name = name.replace('#', ''); |
79 |
| - } |
80 |
| - |
81 |
| - if (name.startsWith("'")) { |
82 |
| - name = name.replace("'", '').replace("'", ''); |
83 |
| - } |
84 |
| - return (this as any)._children.get(name); |
85 |
| - } |
86 |
| - return null; |
87 |
| - } |
| 77 | + if (name.startsWith("'")) { |
| 78 | + name = name.replace("'", '').replace("'", ''); |
| 79 | + } |
| 80 | + return (this as any)._children.get(name); |
| 81 | + } |
| 82 | + return null; |
| 83 | + } |
88 | 84 | }
|
89 | 85 |
|
90 | 86 | stopColorProperty.register(Style);
|
|
0 commit comments