@@ -55,62 +55,61 @@ export const srcProperty = new Property<Svg, string>({
55
55
} ) ;
56
56
57
57
import { File } from '@nativescript/core' ;
58
- import { DOMParser } from 'xmldom' ;
59
58
import { layout } from '@nativescript/core/utils' ;
60
59
@CSSType ( 'Svg' )
61
60
export class Svg extends View {
62
61
public static readyEvent = 'ready' ;
63
62
_svg : any ;
64
63
src : string ;
65
- _domParser : DOMParser ;
66
64
constructor ( ) {
67
65
super ( ) ;
68
- this . _domParser = new DOMParser ( ) ;
69
66
if ( global . isAndroid ) {
70
67
const activity = Application . android . foregroundActivity || Application . android . startActivity ;
71
68
this . _svg = new ( com as any ) . github . triniwiz . canvas . TNSSVG ( activity ) ;
72
69
} else if ( global . isIOS ) {
73
- // this._svg = TNSSVG.new();
74
- // this._svg.backgroundColor = UIColor.clearColor;
70
+ // this._svg = TNSSVG.new();
71
+ // this._svg.backgroundColor = UIColor.clearColor;
75
72
}
76
73
}
77
74
78
75
[ srcProperty . setNative ] ( value : string ) {
79
76
if ( typeof value === 'string' ) {
80
77
if ( value . indexOf ( '<svg' ) > - 1 ) {
81
- if ( global . isAndroid ) {
78
+ if ( global . isAndroid ) {
82
79
this . _svg . setSrc ( value ) ;
83
- } else if ( global . isIOS ) {
84
- setTimeout ( ( ) => {
80
+ } else if ( global . isIOS ) {
81
+ setTimeout ( ( ) => {
85
82
this . _svg . src = value ;
86
83
} , 1000 ) ;
87
84
}
88
85
} else {
89
86
if ( value . startsWith ( '~' ) ) {
90
- if ( global . isAndroid ) {
87
+ if ( global . isAndroid ) {
91
88
this . _svg . setSrcPath ( path . join ( knownFolders . currentApp ( ) . path , value . replace ( '~' , '' ) ) ) ;
92
- } else if ( global . isIOS ) {
89
+ } else if ( global . isIOS ) {
93
90
this . _svg . srcPath = path . join ( knownFolders . currentApp ( ) . path , value . replace ( '~' , '' ) ) ;
94
91
}
95
92
} else if ( value . startsWith ( '/' ) ) {
96
- if ( global . isAndroid ) {
93
+ if ( global . isAndroid ) {
97
94
this . _svg . setSrcPath ( value ) ;
98
- } else if ( global . isIOS ) {
95
+ } else if ( global . isIOS ) {
99
96
this . _svg . srcPath = value ;
100
97
}
101
98
} else if ( value . startsWith ( 'http' ) ) {
102
- Http . getString ( value ) . then ( ( res ) => {
103
- if ( global . isAndroid ) {
104
- this . _svg . setSrc ( res ) ;
105
- } else if ( global . isIOS ) {
106
- setTimeout ( ( ) => {
107
- console . log ( ! ! res ) ;
108
- this . _svg . src = res ;
109
- } , 1000 ) ;
110
- }
111
- } ) . catch ( e => {
112
- console . log ( e ) ;
113
- } ) ;
99
+ Http . getString ( value )
100
+ . then ( ( res ) => {
101
+ if ( global . isAndroid ) {
102
+ this . _svg . setSrc ( res ) ;
103
+ } else if ( global . isIOS ) {
104
+ setTimeout ( ( ) => {
105
+ console . log ( ! ! res ) ;
106
+ this . _svg . src = res ;
107
+ } , 1000 ) ;
108
+ }
109
+ } )
110
+ . catch ( ( e ) => {
111
+ console . log ( e ) ;
112
+ } ) ;
114
113
}
115
114
}
116
115
}
0 commit comments