├── src
├── .npmignore
├── angular
│ ├── index.ts
│ ├── index.d.ts
│ ├── nativescript-svg-module.d.ts
│ ├── package.json
│ ├── nativescript-svg-directives.d.ts
│ ├── index.js
│ ├── nativescript-svg-directives.ts
│ ├── nativescript-svg-module.ts
│ ├── nativescript-svg-directives.js
│ └── nativescript-svg-module.js
├── platforms
│ ├── ios
│ │ ├── build.xcconfig
│ │ └── Podfile
│ └── android
│ │ ├── libs
│ │ └── svg-android.jar
│ │ ├── include.gradle
│ │ └── src
│ │ └── main
│ │ ├── AndroidManifest.xml
│ │ └── assets
│ │ └── app
│ │ └── App_Resources
│ │ └── Android
│ │ └── AndroidManifest.xml
├── hooks
│ └── before-livesync
│ │ └── nativescript-angular-sync.js
├── references.d.ts
├── tsconfig.json
├── package.json
├── svg.android.js
├── svg.android.ts
├── svg.common.js
├── package-lock.json
├── svg.common.ts
├── svg.d.ts
├── svg.ios.js
└── svg.ios.ts
├── .npmignore
├── demo-angular
├── app
│ ├── app.component.html
│ ├── App_Resources
│ │ ├── iOS
│ │ │ ├── Assets.xcassets
│ │ │ │ ├── Contents.json
│ │ │ │ ├── AppIcon.appiconset
│ │ │ │ │ ├── icon-29.png
│ │ │ │ │ ├── icon-40.png
│ │ │ │ │ ├── icon-50.png
│ │ │ │ │ ├── icon-57.png
│ │ │ │ │ ├── icon-72.png
│ │ │ │ │ ├── icon-76.png
│ │ │ │ │ ├── icon-29@2x.png
│ │ │ │ │ ├── icon-29@3x.png
│ │ │ │ │ ├── icon-40@2x.png
│ │ │ │ │ ├── icon-40@3x.png
│ │ │ │ │ ├── icon-50@2x.png
│ │ │ │ │ ├── icon-57@2x.png
│ │ │ │ │ ├── icon-60@2x.png
│ │ │ │ │ ├── icon-60@3x.png
│ │ │ │ │ ├── icon-72@2x.png
│ │ │ │ │ ├── icon-76@2x.png
│ │ │ │ │ ├── icon-83.5@2x.png
│ │ │ │ │ └── Contents.json
│ │ │ │ ├── LaunchImage.launchimage
│ │ │ │ │ ├── Default.png
│ │ │ │ │ ├── Default@2x.png
│ │ │ │ │ ├── Default-568h@2x.png
│ │ │ │ │ ├── Default-667h@2x.png
│ │ │ │ │ ├── Default-736h@3x.png
│ │ │ │ │ ├── Default-Landscape.png
│ │ │ │ │ ├── Default-Portrait.png
│ │ │ │ │ ├── Default-Landscape@2x.png
│ │ │ │ │ ├── Default-Landscape@3x.png
│ │ │ │ │ ├── Default-Portrait@2x.png
│ │ │ │ │ └── Contents.json
│ │ │ │ ├── LaunchScreen.Center.imageset
│ │ │ │ │ ├── LaunchScreen-Center.png
│ │ │ │ │ ├── LaunchScreen-Center@2x.png
│ │ │ │ │ └── Contents.json
│ │ │ │ └── LaunchScreen.AspectFill.imageset
│ │ │ │ │ ├── LaunchScreen-AspectFill.png
│ │ │ │ │ ├── LaunchScreen-AspectFill@2x.png
│ │ │ │ │ └── Contents.json
│ │ │ ├── build.xcconfig
│ │ │ ├── Info.plist
│ │ │ └── LaunchScreen.storyboard
│ │ └── Android
│ │ │ ├── values-v21
│ │ │ ├── colors.xml
│ │ │ └── styles.xml
│ │ │ ├── drawable-hdpi
│ │ │ ├── icon.png
│ │ │ ├── logo.png
│ │ │ └── background.png
│ │ │ ├── drawable-ldpi
│ │ │ ├── icon.png
│ │ │ ├── logo.png
│ │ │ └── background.png
│ │ │ ├── drawable-mdpi
│ │ │ ├── icon.png
│ │ │ ├── logo.png
│ │ │ └── background.png
│ │ │ ├── drawable-xhdpi
│ │ │ ├── icon.png
│ │ │ ├── logo.png
│ │ │ └── background.png
│ │ │ ├── drawable-xxhdpi
│ │ │ ├── icon.png
│ │ │ ├── logo.png
│ │ │ └── background.png
│ │ │ ├── drawable-xxxhdpi
│ │ │ ├── icon.png
│ │ │ ├── logo.png
│ │ │ └── background.png
│ │ │ ├── values
│ │ │ ├── colors.xml
│ │ │ └── styles.xml
│ │ │ ├── drawable-nodpi
│ │ │ └── splash_screen.xml
│ │ │ ├── app.gradle
│ │ │ └── AndroidManifest.xml
│ ├── images
│ │ ├── nativescript.png
│ │ ├── nativescript.svg
│ │ ├── spider-test.svg
│ │ └── spider.svg
│ ├── package.json
│ ├── app.component.ts
│ ├── pages
│ │ ├── main-page.html
│ │ ├── main-page.ts
│ │ └── main-page.js
│ ├── main.ts
│ ├── main.aot.ts
│ ├── app.routing.ts
│ ├── app.css
│ ├── app.module.ts
│ ├── README.md
│ ├── main.js
│ ├── app.component.js
│ ├── app.routing.js
│ └── app.module.js
├── hooks
│ ├── before-watch
│ │ └── nativescript-dev-typescript.js
│ ├── before-livesync
│ │ └── nativescript-angular-sync.js
│ └── before-prepare
│ │ └── nativescript-dev-typescript.js
├── tsconfig.json
└── package.json
├── .gitignore
├── demo
├── app
│ ├── app.js
│ ├── images
│ │ ├── nativescript.png
│ │ ├── nativescript.svg
│ │ ├── spider-test.svg
│ │ └── spider.svg
│ ├── App_Resources
│ │ ├── iOS
│ │ │ ├── icon.png
│ │ │ ├── Default.png
│ │ │ ├── icon-40.png
│ │ │ ├── icon-60.png
│ │ │ ├── icon-72.png
│ │ │ ├── icon-76.png
│ │ │ ├── icon@2x.png
│ │ │ ├── Default@2x.png
│ │ │ ├── Icon-Small.png
│ │ │ ├── icon-40@2x.png
│ │ │ ├── icon-60@2x.png
│ │ │ ├── icon-72@2x.png
│ │ │ ├── icon-76@2x.png
│ │ │ ├── Icon-Small-50.png
│ │ │ ├── Icon-Small@2x.png
│ │ │ ├── Default-568h@2x.png
│ │ │ ├── Default-667h@2x.png
│ │ │ ├── Default-736h@3x.png
│ │ │ ├── Default-Landscape.png
│ │ │ ├── Default-Portrait.png
│ │ │ ├── Icon-Small-50@2x.png
│ │ │ ├── Default-Landscape@2x.png
│ │ │ ├── Default-Landscape@3x.png
│ │ │ ├── Default-Portrait@2x.png
│ │ │ ├── Default-Landscape-568h@2x.png
│ │ │ ├── Default-Landscape-667h@2x.png
│ │ │ ├── build.xcconfig
│ │ │ └── Info.plist
│ │ └── Android
│ │ │ ├── drawable-hdpi
│ │ │ └── icon.png
│ │ │ ├── drawable-ldpi
│ │ │ └── icon.png
│ │ │ ├── drawable-mdpi
│ │ │ └── icon.png
│ │ │ ├── drawable-nodpi
│ │ │ └── splashscreen.9.png
│ │ │ ├── app.gradle
│ │ │ └── AndroidManifest.xml
│ ├── references.d.ts
│ ├── main-page.js
│ ├── app.css
│ ├── package.json
│ ├── main-view-model.js
│ └── main-page.xml
└── package.json
├── LICENSE
└── README.md
/src/.npmignore:
--------------------------------------------------------------------------------
1 | demo/
2 | .vscode
3 | **/*.ts
4 | !**/*.d.ts
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | demo/
2 | .vscode
3 | src/**/*.ts
4 | !src/**/*.d.ts
--------------------------------------------------------------------------------
/src/angular/index.ts:
--------------------------------------------------------------------------------
1 | export * from "./nativescript-svg-module";
--------------------------------------------------------------------------------
/src/platforms/ios/build.xcconfig:
--------------------------------------------------------------------------------
1 | OTHER_LDFLAGS = $(inherited) -ObjC
--------------------------------------------------------------------------------
/src/angular/index.d.ts:
--------------------------------------------------------------------------------
1 | export * from "./nativescript-svg-module";
2 |
--------------------------------------------------------------------------------
/demo-angular/app/app.component.html:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | src/*.js.map
2 | src/node_modules
3 | demo/
4 | demo-angular/
5 | .vscode
6 |
--------------------------------------------------------------------------------
/src/angular/nativescript-svg-module.d.ts:
--------------------------------------------------------------------------------
1 | export declare class NativeScriptSvgModule {
2 | }
3 |
--------------------------------------------------------------------------------
/src/angular/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "nativescript-svg",
3 | "main": "index.js"
4 | }
--------------------------------------------------------------------------------
/demo/app/app.js:
--------------------------------------------------------------------------------
1 | var application = require("application");
2 | application.start({ moduleName: "main-page" });
3 |
--------------------------------------------------------------------------------
/demo/app/images/nativescript.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo/app/images/nativescript.png
--------------------------------------------------------------------------------
/src/hooks/before-livesync/nativescript-angular-sync.js:
--------------------------------------------------------------------------------
1 | module.exports = require("nativescript-angular/hooks/before-livesync");
2 |
--------------------------------------------------------------------------------
/demo-angular/hooks/before-watch/nativescript-dev-typescript.js:
--------------------------------------------------------------------------------
1 | module.exports = require("nativescript-dev-typescript/lib/watch.js");
2 |
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo/app/App_Resources/iOS/icon.png
--------------------------------------------------------------------------------
/demo-angular/hooks/before-livesync/nativescript-angular-sync.js:
--------------------------------------------------------------------------------
1 | module.exports = require("nativescript-angular/hooks/before-livesync");
2 |
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Default.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo/app/App_Resources/iOS/Default.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/icon-40.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo/app/App_Resources/iOS/icon-40.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/icon-60.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo/app/App_Resources/iOS/icon-60.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/icon-72.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo/app/App_Resources/iOS/icon-72.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/icon-76.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo/app/App_Resources/iOS/icon-76.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/icon@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo/app/App_Resources/iOS/icon@2x.png
--------------------------------------------------------------------------------
/demo-angular/app/App_Resources/iOS/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/demo-angular/app/images/nativescript.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo-angular/app/images/nativescript.png
--------------------------------------------------------------------------------
/demo-angular/hooks/before-prepare/nativescript-dev-typescript.js:
--------------------------------------------------------------------------------
1 | module.exports = require("nativescript-dev-typescript/lib/before-prepare.js");
2 |
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Default@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo/app/App_Resources/iOS/Default@2x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Icon-Small.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo/app/App_Resources/iOS/Icon-Small.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/icon-40@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo/app/App_Resources/iOS/icon-40@2x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/icon-60@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo/app/App_Resources/iOS/icon-60@2x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/icon-72@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo/app/App_Resources/iOS/icon-72@2x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/icon-76@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo/app/App_Resources/iOS/icon-76@2x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Icon-Small-50.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo/app/App_Resources/iOS/Icon-Small-50.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Icon-Small@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo/app/App_Resources/iOS/Icon-Small@2x.png
--------------------------------------------------------------------------------
/src/platforms/android/libs/svg-android.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/src/platforms/android/libs/svg-android.jar
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Default-568h@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo/app/App_Resources/iOS/Default-568h@2x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Default-667h@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo/app/App_Resources/iOS/Default-667h@2x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Default-736h@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo/app/App_Resources/iOS/Default-736h@3x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Default-Landscape.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo/app/App_Resources/iOS/Default-Landscape.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Default-Portrait.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo/app/App_Resources/iOS/Default-Portrait.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Icon-Small-50@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo/app/App_Resources/iOS/Icon-Small-50@2x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Default-Landscape@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo/app/App_Resources/iOS/Default-Landscape@2x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Default-Landscape@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo/app/App_Resources/iOS/Default-Landscape@3x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Default-Portrait@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo/app/App_Resources/iOS/Default-Portrait@2x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/Android/drawable-hdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo/app/App_Resources/Android/drawable-hdpi/icon.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/Android/drawable-ldpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo/app/App_Resources/Android/drawable-ldpi/icon.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/Android/drawable-mdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo/app/App_Resources/Android/drawable-mdpi/icon.png
--------------------------------------------------------------------------------
/demo-angular/app/App_Resources/Android/values-v21/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3d5afe
4 |
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Default-Landscape-568h@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo/app/App_Resources/iOS/Default-Landscape-568h@2x.png
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Default-Landscape-667h@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo/app/App_Resources/iOS/Default-Landscape-667h@2x.png
--------------------------------------------------------------------------------
/src/angular/nativescript-svg-directives.d.ts:
--------------------------------------------------------------------------------
1 | export declare class SVGImageDirective {
2 | constructor();
3 | }
4 | export declare const DIRECTIVES: typeof SVGImageDirective[];
5 |
--------------------------------------------------------------------------------
/src/references.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 | ///
3 |
--------------------------------------------------------------------------------
/demo-angular/app/App_Resources/Android/drawable-hdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo-angular/app/App_Resources/Android/drawable-hdpi/icon.png
--------------------------------------------------------------------------------
/demo-angular/app/App_Resources/Android/drawable-hdpi/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo-angular/app/App_Resources/Android/drawable-hdpi/logo.png
--------------------------------------------------------------------------------
/demo-angular/app/App_Resources/Android/drawable-ldpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo-angular/app/App_Resources/Android/drawable-ldpi/icon.png
--------------------------------------------------------------------------------
/demo-angular/app/App_Resources/Android/drawable-ldpi/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo-angular/app/App_Resources/Android/drawable-ldpi/logo.png
--------------------------------------------------------------------------------
/demo-angular/app/App_Resources/Android/drawable-mdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo-angular/app/App_Resources/Android/drawable-mdpi/icon.png
--------------------------------------------------------------------------------
/demo-angular/app/App_Resources/Android/drawable-mdpi/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo-angular/app/App_Resources/Android/drawable-mdpi/logo.png
--------------------------------------------------------------------------------
/demo-angular/app/App_Resources/Android/drawable-xhdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo-angular/app/App_Resources/Android/drawable-xhdpi/icon.png
--------------------------------------------------------------------------------
/demo-angular/app/App_Resources/Android/drawable-xhdpi/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo-angular/app/App_Resources/Android/drawable-xhdpi/logo.png
--------------------------------------------------------------------------------
/demo-angular/app/App_Resources/Android/drawable-xxhdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo-angular/app/App_Resources/Android/drawable-xxhdpi/icon.png
--------------------------------------------------------------------------------
/demo-angular/app/App_Resources/Android/drawable-xxhdpi/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo-angular/app/App_Resources/Android/drawable-xxhdpi/logo.png
--------------------------------------------------------------------------------
/demo-angular/app/App_Resources/Android/drawable-xxxhdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo-angular/app/App_Resources/Android/drawable-xxxhdpi/icon.png
--------------------------------------------------------------------------------
/demo-angular/app/App_Resources/Android/drawable-xxxhdpi/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo-angular/app/App_Resources/Android/drawable-xxxhdpi/logo.png
--------------------------------------------------------------------------------
/demo-angular/app/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "android": {
3 | "v8Flags": "--expose_gc"
4 | },
5 | "main": "main.js",
6 | "name": "tns-template-hello-world-ng",
7 | "version": "3.0.0"
8 | }
--------------------------------------------------------------------------------
/demo/app/App_Resources/Android/drawable-nodpi/splashscreen.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo/app/App_Resources/Android/drawable-nodpi/splashscreen.9.png
--------------------------------------------------------------------------------
/demo/app/references.d.ts:
--------------------------------------------------------------------------------
1 | /// Enable smart suggestions and completions in Visual Studio Code JavaScript projects.
2 |
--------------------------------------------------------------------------------
/demo-angular/app/App_Resources/Android/drawable-hdpi/background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo-angular/app/App_Resources/Android/drawable-hdpi/background.png
--------------------------------------------------------------------------------
/demo-angular/app/App_Resources/Android/drawable-ldpi/background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo-angular/app/App_Resources/Android/drawable-ldpi/background.png
--------------------------------------------------------------------------------
/demo-angular/app/App_Resources/Android/drawable-mdpi/background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo-angular/app/App_Resources/Android/drawable-mdpi/background.png
--------------------------------------------------------------------------------
/demo-angular/app/App_Resources/Android/drawable-xhdpi/background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo-angular/app/App_Resources/Android/drawable-xhdpi/background.png
--------------------------------------------------------------------------------
/demo-angular/app/App_Resources/Android/drawable-xxhdpi/background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo-angular/app/App_Resources/Android/drawable-xxhdpi/background.png
--------------------------------------------------------------------------------
/demo-angular/app/App_Resources/Android/drawable-xxxhdpi/background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo-angular/app/App_Resources/Android/drawable-xxxhdpi/background.png
--------------------------------------------------------------------------------
/demo-angular/app/app.component.ts:
--------------------------------------------------------------------------------
1 | import { Component } from "@angular/core";
2 |
3 | @Component({
4 | selector: "ns-app",
5 | templateUrl: "app.component.html",
6 | })
7 | export class AppComponent { }
8 |
--------------------------------------------------------------------------------
/demo-angular/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo-angular/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29.png
--------------------------------------------------------------------------------
/demo-angular/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo-angular/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40.png
--------------------------------------------------------------------------------
/demo-angular/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-50.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo-angular/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-50.png
--------------------------------------------------------------------------------
/demo-angular/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-57.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo-angular/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-57.png
--------------------------------------------------------------------------------
/demo-angular/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-72.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo-angular/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-72.png
--------------------------------------------------------------------------------
/demo-angular/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-76.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo-angular/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-76.png
--------------------------------------------------------------------------------
/demo-angular/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo-angular/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29@2x.png
--------------------------------------------------------------------------------
/demo-angular/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo-angular/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29@3x.png
--------------------------------------------------------------------------------
/demo-angular/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo-angular/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40@2x.png
--------------------------------------------------------------------------------
/demo-angular/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo-angular/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40@3x.png
--------------------------------------------------------------------------------
/demo-angular/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-50@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo-angular/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-50@2x.png
--------------------------------------------------------------------------------
/demo-angular/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-57@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo-angular/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-57@2x.png
--------------------------------------------------------------------------------
/demo-angular/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-60@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo-angular/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-60@2x.png
--------------------------------------------------------------------------------
/demo-angular/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-60@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo-angular/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-60@3x.png
--------------------------------------------------------------------------------
/demo-angular/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-72@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo-angular/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-72@2x.png
--------------------------------------------------------------------------------
/demo-angular/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-76@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo-angular/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-76@2x.png
--------------------------------------------------------------------------------
/demo-angular/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-83.5@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo-angular/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-83.5@2x.png
--------------------------------------------------------------------------------
/demo-angular/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo-angular/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default.png
--------------------------------------------------------------------------------
/demo-angular/app/pages/main-page.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/demo-angular/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo-angular/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default@2x.png
--------------------------------------------------------------------------------
/demo-angular/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-568h@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo-angular/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-568h@2x.png
--------------------------------------------------------------------------------
/demo-angular/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-667h@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo-angular/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-667h@2x.png
--------------------------------------------------------------------------------
/demo-angular/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-736h@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo-angular/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-736h@3x.png
--------------------------------------------------------------------------------
/src/platforms/ios/Podfile:
--------------------------------------------------------------------------------
1 | # Uncomment the next line to define a global platform for your project
2 | # platform :ios, '9.0'
3 |
4 | use_frameworks!
5 |
6 | pod 'SVGKit', :git => 'https://github.com/SVGKit/SVGKit.git', :branch => '2.x'
7 |
8 |
--------------------------------------------------------------------------------
/demo-angular/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo-angular/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape.png
--------------------------------------------------------------------------------
/demo-angular/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Portrait.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo-angular/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Portrait.png
--------------------------------------------------------------------------------
/demo-angular/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo-angular/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape@2x.png
--------------------------------------------------------------------------------
/demo-angular/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo-angular/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape@3x.png
--------------------------------------------------------------------------------
/demo-angular/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Portrait@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo-angular/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Portrait@2x.png
--------------------------------------------------------------------------------
/demo/app/main-page.js:
--------------------------------------------------------------------------------
1 | var createViewModel = require("./main-view-model").createViewModel;
2 |
3 | function onNavigatingTo(args) {
4 | var page = args.object;
5 | page.bindingContext = createViewModel();
6 | }
7 | exports.onNavigatingTo = onNavigatingTo;
--------------------------------------------------------------------------------
/src/angular/index.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | function __export(m) {
3 | for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
4 | }
5 | Object.defineProperty(exports, "__esModule", { value: true });
6 | __export(require("./nativescript-svg-module"));
7 |
--------------------------------------------------------------------------------
/demo-angular/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo-angular/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center.png
--------------------------------------------------------------------------------
/demo-angular/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo-angular/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center@2x.png
--------------------------------------------------------------------------------
/demo-angular/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo-angular/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill.png
--------------------------------------------------------------------------------
/demo-angular/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peoplewareDo/nativescript-svg/HEAD/demo-angular/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill@2x.png
--------------------------------------------------------------------------------
/src/angular/nativescript-svg-directives.ts:
--------------------------------------------------------------------------------
1 | import { Directive } from "@angular/core"; // TODO: check require .Directive without hacks
2 |
3 | @Directive({
4 | selector: "SVGImage"
5 | })
6 | export class SVGImageDirective { }
7 |
8 | export const DIRECTIVES = [SVGImageDirective];
9 |
--------------------------------------------------------------------------------
/demo-angular/app/App_Resources/Android/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #F5F5F5
4 | #757575
5 | #33B5E5
6 | #272734
7 |
--------------------------------------------------------------------------------
/demo-angular/app/main.ts:
--------------------------------------------------------------------------------
1 | // this import should be first in order to load some required settings (like globals and reflect-metadata)
2 | import { platformNativeScriptDynamic } from "nativescript-angular/platform";
3 |
4 | import { AppModule } from "./app.module";
5 |
6 | platformNativeScriptDynamic().bootstrapModule(AppModule);
7 |
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/build.xcconfig:
--------------------------------------------------------------------------------
1 | // You can add custom settings here
2 | // for example you can uncomment the following line to force distribution code signing
3 | // CODE_SIGN_IDENTITY = iPhone Distribution
4 | // ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
5 | // ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = Brand Assets;
6 |
--------------------------------------------------------------------------------
/demo-angular/app/pages/main-page.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from "@angular/core";
2 |
3 | @Component({
4 | selector: "ns-items",
5 | moduleId: module.id,
6 | templateUrl: "./main-page.html",
7 | })
8 | export class MainPage implements OnInit {
9 | constructor() { }
10 |
11 | ngOnInit(): void {
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/demo-angular/app/main.aot.ts:
--------------------------------------------------------------------------------
1 | // this import should be first in order to load some required settings (like globals and reflect-metadata)
2 | import { platformNativeScript } from "nativescript-angular/platform-static";
3 |
4 | import { AppModuleNgFactory } from "./app.module.ngfactory";
5 |
6 | platformNativeScript().bootstrapModuleFactory(AppModuleNgFactory);
7 |
--------------------------------------------------------------------------------
/demo/app/app.css:
--------------------------------------------------------------------------------
1 | .title {
2 | font-size: 30;
3 | horizontal-align: center;
4 | margin: 20;
5 | }
6 |
7 | button {
8 | font-size: 42;
9 | horizontal-align: center;
10 | }
11 |
12 | .message {
13 | font-size: 20;
14 | color: #284848;
15 | horizontal-align: center;
16 | margin: 0 20;
17 | text-align: center;
18 | }
19 |
--------------------------------------------------------------------------------
/src/platforms/android/include.gradle:
--------------------------------------------------------------------------------
1 | android {
2 | productFlavors {
3 | "nativescript-svg" {
4 | dimension "nativescript-svg"
5 | }
6 | }
7 | }
8 |
9 | repositories {
10 | mavenCentral()
11 | maven { url "http://dl.bintray.com/pixplicity/android" }
12 | }
13 | dependencies {
14 | compile 'com.pixplicity.sharp:library:1.0.2@aar'
15 | }
--------------------------------------------------------------------------------
/demo-angular/app/App_Resources/Android/drawable-nodpi/splash_screen.xml:
--------------------------------------------------------------------------------
1 |
2 | -
3 |
4 |
5 | -
6 |
7 |
8 |
--------------------------------------------------------------------------------
/demo/app/App_Resources/Android/app.gradle:
--------------------------------------------------------------------------------
1 | // Add your native dependencies here:
2 |
3 | // Uncomment to add recyclerview-v7 dependency
4 | //dependencies {
5 | // compile 'com.android.support:recyclerview-v7:+'
6 | //}
7 |
8 | android {
9 | defaultConfig {
10 | generatedDensities = []
11 | }
12 | aaptOptions {
13 | additionalParameters "--no-version-vectors"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/angular/nativescript-svg-module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from "@angular/core";
2 | import { registerElement } from "nativescript-angular/element-registry";
3 |
4 | import { DIRECTIVES } from "./nativescript-svg-directives";
5 |
6 | @NgModule({
7 | declarations: [DIRECTIVES],
8 | exports: [DIRECTIVES],
9 | })
10 | export class NativeScriptSvgModule { }
11 |
12 | registerElement("SVGImage", () => require("../").SVGImage);
13 |
--------------------------------------------------------------------------------
/demo-angular/app/App_Resources/Android/app.gradle:
--------------------------------------------------------------------------------
1 | // Add your native dependencies here:
2 |
3 | // Uncomment to add recyclerview-v7 dependency
4 | //dependencies {
5 | // compile 'com.android.support:recyclerview-v7:+'
6 | //}
7 |
8 | android {
9 | defaultConfig {
10 | generatedDensities = []
11 | applicationId = "org.nativescript.ngtest"
12 | }
13 | aaptOptions {
14 | additionalParameters "--no-version-vectors"
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/demo-angular/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "LaunchScreen-Center.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "filename" : "LaunchScreen-Center@2x.png",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "universal",
15 | "scale" : "3x"
16 | }
17 | ],
18 | "info" : {
19 | "version" : 1,
20 | "author" : "xcode"
21 | }
22 | }
--------------------------------------------------------------------------------
/demo-angular/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "LaunchScreen-AspectFill.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "filename" : "LaunchScreen-AspectFill@2x.png",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "universal",
15 | "scale" : "3x"
16 | }
17 | ],
18 | "info" : {
19 | "version" : 1,
20 | "author" : "xcode"
21 | }
22 | }
--------------------------------------------------------------------------------
/src/angular/nativescript-svg-directives.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | Object.defineProperty(exports, "__esModule", { value: true });
3 | var core_1 = require("@angular/core");
4 | var SVGImageDirective = (function () {
5 | function SVGImageDirective() {
6 | }
7 | SVGImageDirective = __decorate([
8 | core_1.Directive({
9 | selector: "SVGImage"
10 | })
11 | ], SVGImageDirective);
12 | return SVGImageDirective;
13 | }());
14 | exports.SVGImageDirective = SVGImageDirective;
15 | exports.DIRECTIVES = [SVGImageDirective];
16 |
--------------------------------------------------------------------------------
/demo-angular/app/App_Resources/iOS/build.xcconfig:
--------------------------------------------------------------------------------
1 | // You can add custom settings here
2 | // for example you can uncomment the following line to force distribution code signing
3 | // CODE_SIGN_IDENTITY = iPhone Distribution
4 | // To build for device with XCode 8 you need to specify your development team. More info: https://developer.apple.com/library/prerelease/content/releasenotes/DeveloperTools/RN-Xcode/Introduction.html
5 | // DEVELOPMENT_TEAM = YOUR_TEAM_ID;
6 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
7 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
8 |
--------------------------------------------------------------------------------
/demo-angular/app/app.routing.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from "@angular/core";
2 | import { NativeScriptRouterModule } from "nativescript-angular/router";
3 | import { Routes } from "@angular/router";
4 |
5 | import { MainPage } from "./pages/main-page";
6 |
7 | const routes: Routes = [
8 | { path: "", redirectTo: "/main-page", pathMatch: "full" },
9 | { path: "main-page", component: MainPage }
10 | ];
11 |
12 | @NgModule({
13 | imports: [NativeScriptRouterModule.forRoot(routes)],
14 | exports: [NativeScriptRouterModule]
15 | })
16 | export class AppRoutingModule { }
--------------------------------------------------------------------------------
/src/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "target": "es5",
5 | "noImplicitAny": false,
6 | "removeComments": true,
7 | "preserveConstEnums": true,
8 | "sourceMap": false,
9 | "declaration": false,
10 | "noLib": false,
11 | "noEmitHelpers": true,
12 | "experimentalDecorators": true,
13 | "lib": [
14 | "es6",
15 | "dom"
16 | ]
17 | },
18 | "exclude": [
19 | "node_modules",
20 | "platforms"
21 | ]
22 | }
--------------------------------------------------------------------------------
/demo-angular/app/app.css:
--------------------------------------------------------------------------------
1 | /*
2 | In NativeScript, the app.css file is where you place CSS rules that
3 | you would like to apply to your entire application. Check out
4 | http://docs.nativescript.org/ui/styling for a full list of the CSS
5 | selectors and properties you can use to style UI components.
6 |
7 | /*
8 | In many cases you may want to use the NativeScript core theme instead
9 | of writing your own CSS rules. For a full list of class names in the theme
10 | refer to http://docs.nativescript.org/ui/theme.
11 | */
12 | @import 'nativescript-theme-core/css/core.light.css';
13 |
--------------------------------------------------------------------------------
/demo/app/package.json:
--------------------------------------------------------------------------------
1 | {"name":"tns-template-hello-world","main":"app.js","version":"2.0.0","author":{"name":"Telerik","email":"support@telerik.com"},"description":"Nativescript hello-world project template","license":"Apache-2.0","keywords":["telerik","mobile","nativescript","{N}","tns","appbuilder","template"],"repository":{"type":"git","url":"git://github.com/NativeScript/template-hello-world.git"},"bugs":{"url":"https://github.com/NativeScript/template-hello-world/issues"},"homepage":"https://github.com/NativeScript/template-hello-world","android":{"v8Flags":"--expose_gc"},"readme":"ERROR: No README data found!","_id":"tns-template-hello-world@2.0.0","_from":"tns-template-hello-world@2.0.0"}
--------------------------------------------------------------------------------
/demo-angular/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "target": "es5",
5 | "experimentalDecorators": true,
6 | "emitDecoratorMetadata": true,
7 | "noEmitHelpers": true,
8 | "noEmitOnError": true,
9 | "lib": [
10 | "es6",
11 | "dom",
12 | "es2015.iterable"
13 | ],
14 | "baseUrl": ".",
15 | "paths": {
16 | "*": [
17 | "./node_modules/tns-core-modules/*",
18 | "./node_modules/*"
19 | ]
20 | }
21 | },
22 | "exclude": [
23 | "node_modules",
24 | "platforms",
25 | "**/*.aot.ts"
26 | ]
27 | }
--------------------------------------------------------------------------------
/demo/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "description": "NativeScript Application",
3 | "license": "SEE LICENSE IN ",
4 | "readme": "NativeScript Application",
5 | "repository": "",
6 | "nativescript": {
7 | "id": "org.nativescript.demo3",
8 | "tns-android": {
9 | "version": "3.0.0"
10 | },
11 | "tns-ios": {
12 | "version": "3.0.0"
13 | }
14 | },
15 | "dependencies": {
16 | "nativescript-svg": "../src/",
17 | "tns-core-modules": "^3.0.0"
18 | },
19 | "devDependencies": {
20 | "babel-traverse": "6.9.0",
21 | "babel-types": "6.10.0",
22 | "babylon": "6.8.1",
23 | "filewalker": "0.1.2",
24 | "lazy": "1.0.11"
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/demo-angular/app/app.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule, NO_ERRORS_SCHEMA } from "@angular/core";
2 | import { NativeScriptModule } from "nativescript-angular/nativescript.module";
3 | import { AppRoutingModule } from "./app.routing";
4 | import { AppComponent } from "./app.component";
5 |
6 | import { MainPage } from "./pages/main-page";
7 | import { NativeScriptSvgModule } from "nativescript-svg/angular";
8 |
9 | @NgModule({
10 | bootstrap: [
11 | AppComponent
12 | ],
13 | imports: [
14 | NativeScriptModule,
15 | AppRoutingModule,
16 | NativeScriptSvgModule
17 | ],
18 | declarations: [
19 | AppComponent,
20 | MainPage
21 | ],
22 | schemas: [
23 | NO_ERRORS_SCHEMA
24 | ]
25 | })
26 | export class AppModule { }
27 |
--------------------------------------------------------------------------------
/src/angular/nativescript-svg-module.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | Object.defineProperty(exports, "__esModule", { value: true });
3 | var core_1 = require("@angular/core");
4 | var element_registry_1 = require("nativescript-angular/element-registry");
5 | var nativescript_svg_directives_1 = require("./nativescript-svg-directives");
6 | var NativeScriptSvgModule = (function () {
7 | function NativeScriptSvgModule() {
8 | }
9 | NativeScriptSvgModule = __decorate([
10 | core_1.NgModule({
11 | declarations: [nativescript_svg_directives_1.DIRECTIVES],
12 | exports: [nativescript_svg_directives_1.DIRECTIVES],
13 | })
14 | ], NativeScriptSvgModule);
15 | return NativeScriptSvgModule;
16 | }());
17 | exports.NativeScriptSvgModule = NativeScriptSvgModule;
18 | element_registry_1.registerElement("SVGImage", function () { return require("../").SVGImage; });
19 |
--------------------------------------------------------------------------------
/demo-angular/app/README.md:
--------------------------------------------------------------------------------
1 | # NativeScript Angular Template
2 |
3 | This template creates a "Hello, world" NativeScript app using TypeScript and Angular.
4 |
5 | You can create a new app that uses this template with either the `--template` option.
6 |
7 | ```
8 | tns create my-app-name --template tns-template-hello-world-ng
9 | ```
10 |
11 | Or the `--ng` shorthand.
12 |
13 | ```
14 | tns create my-app-name --ng
15 | ```
16 |
17 | > Note: Both commands will create a new NativeScript app that uses the latest version of this template published to [npm] (https://www.npmjs.com/package/tns-template-hello-world-ng).
18 |
19 | If you want to create a new app that uses the source of the template from the `master` branch, you can execute the following:
20 |
21 | ```
22 | tns create my-app-name --template https://github.com/NativeScript/template-hello-world-ng.git#master
23 | ```
24 |
25 | **NB:** Please, have in mind that the master branch may refer to dependencies that are not on NPM yet!
26 |
--------------------------------------------------------------------------------
/demo-angular/app/App_Resources/Android/values-v21/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
9 |
10 |
11 |
14 |
15 |
16 |
19 |
20 |
23 |
--------------------------------------------------------------------------------
/demo-angular/app/main.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | Object.defineProperty(exports, "__esModule", { value: true });
3 | // this import should be first in order to load some required settings (like globals and reflect-metadata)
4 | var platform_1 = require("nativescript-angular/platform");
5 | var app_module_1 = require("./app.module");
6 | platform_1.platformNativeScriptDynamic().bootstrapModule(app_module_1.AppModule);
7 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWFpbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIm1haW4udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSwwR0FBMEc7QUFDMUcsMERBQTRFO0FBRTVFLDJDQUF5QztBQUV6QyxzQ0FBMkIsRUFBRSxDQUFDLGVBQWUsQ0FBQyxzQkFBUyxDQUFDLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyIvLyB0aGlzIGltcG9ydCBzaG91bGQgYmUgZmlyc3QgaW4gb3JkZXIgdG8gbG9hZCBzb21lIHJlcXVpcmVkIHNldHRpbmdzIChsaWtlIGdsb2JhbHMgYW5kIHJlZmxlY3QtbWV0YWRhdGEpXG5pbXBvcnQgeyBwbGF0Zm9ybU5hdGl2ZVNjcmlwdER5bmFtaWMgfSBmcm9tIFwibmF0aXZlc2NyaXB0LWFuZ3VsYXIvcGxhdGZvcm1cIjtcblxuaW1wb3J0IHsgQXBwTW9kdWxlIH0gZnJvbSBcIi4vYXBwLm1vZHVsZVwiO1xuXG5wbGF0Zm9ybU5hdGl2ZVNjcmlwdER5bmFtaWMoKS5ib290c3RyYXBNb2R1bGUoQXBwTW9kdWxlKTtcbiJdfQ==
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | nativescript-svg
4 | Copyright (c) 2016, PeopleWare
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy of
7 | this software and associated documentation files (the "Software"), to deal in
8 | the Software without restriction, including without limitation the rights to
9 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10 | the Software, and to permit persons to whom the Software is furnished to do so,
11 | subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/demo-angular/app/app.component.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | Object.defineProperty(exports, "__esModule", { value: true });
3 | var core_1 = require("@angular/core");
4 | var AppComponent = (function () {
5 | function AppComponent() {
6 | }
7 | return AppComponent;
8 | }());
9 | AppComponent = __decorate([
10 | core_1.Component({
11 | selector: "ns-app",
12 | templateUrl: "app.component.html",
13 | })
14 | ], AppComponent);
15 | exports.AppComponent = AppComponent;
16 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXBwLmNvbXBvbmVudC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbImFwcC5jb21wb25lbnQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSxzQ0FBMEM7QUFNMUMsSUFBYSxZQUFZO0lBQXpCO0lBQTRCLENBQUM7SUFBRCxtQkFBQztBQUFELENBQUMsQUFBN0IsSUFBNkI7QUFBaEIsWUFBWTtJQUp4QixnQkFBUyxDQUFDO1FBQ1AsUUFBUSxFQUFFLFFBQVE7UUFDbEIsV0FBVyxFQUFFLG9CQUFvQjtLQUNwQyxDQUFDO0dBQ1csWUFBWSxDQUFJO0FBQWhCLG9DQUFZIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgQ29tcG9uZW50IH0gZnJvbSBcIkBhbmd1bGFyL2NvcmVcIjtcblxuQENvbXBvbmVudCh7XG4gICAgc2VsZWN0b3I6IFwibnMtYXBwXCIsXG4gICAgdGVtcGxhdGVVcmw6IFwiYXBwLmNvbXBvbmVudC5odG1sXCIsXG59KVxuZXhwb3J0IGNsYXNzIEFwcENvbXBvbmVudCB7IH1cbiJdfQ==
--------------------------------------------------------------------------------
/demo/app/main-view-model.js:
--------------------------------------------------------------------------------
1 | var Observable = require("data/observable").Observable;
2 | var SVG = require("nativescript-svg");
3 | var svgParser = new SVG.ImageSourceSVG();
4 |
5 | function getMessage(counter) {
6 | if (counter <= 0) {
7 | return "Hoorraaay! You unlocked the NativeScript clicker achievement!";
8 | } else {
9 | return counter + " taps left";
10 | }
11 | }
12 |
13 | function createViewModel() {
14 |
15 | var loaded = svgParser.fromResource('images/spider-test.svg');
16 | if (loaded) {
17 | console.log("object loaded");
18 | } else {
19 | console.log("error");
20 | }
21 |
22 | // var loaded = svgParser.loadFromFile('~/images/spider-test.svg');
23 | var viewModel = new Observable();
24 | viewModel.counter = 42;
25 | viewModel.message = getMessage(viewModel.counter);
26 |
27 | viewModel.message2 = loaded ? "there is object" : "there isn't object";
28 |
29 | viewModel.onTap = function () {
30 | // this.set("svgSrc", '~/images/nativescript.svg');
31 | this.counter--;
32 | this.set("message", getMessage(this.counter));
33 | }
34 |
35 | return viewModel;
36 | }
37 |
38 | exports.createViewModel = createViewModel;
--------------------------------------------------------------------------------
/demo-angular/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "description": "NativeScript Application",
3 | "license": "SEE LICENSE IN ",
4 | "readme": "NativeScript Application",
5 | "repository": "",
6 | "nativescript": {
7 | "id": "org.nativescript.ngtest",
8 | "tns-android": {
9 | "version": "3.1.0-next-2017-06-15-1868"
10 | },
11 | "tns-ios": {
12 | "version": "3.1.0-2017-5-16-2"
13 | }
14 | },
15 | "dependencies": {
16 | "@angular/animations": "~4.1.0",
17 | "@angular/common": "~4.1.0",
18 | "@angular/compiler": "~4.1.0",
19 | "@angular/core": "~4.1.0",
20 | "@angular/forms": "~4.1.0",
21 | "@angular/http": "~4.1.0",
22 | "@angular/platform-browser": "~4.1.0",
23 | "@angular/router": "~4.1.0",
24 | "nativescript-angular": "~3.0.0",
25 | "nativescript-svg": "../src",
26 | "nativescript-theme-core": "~1.0.2",
27 | "reflect-metadata": "~0.1.8",
28 | "rxjs": "~5.3.0",
29 | "tns-core-modules": "~3.0.0",
30 | "zone.js": "~0.8.2"
31 | },
32 | "devDependencies": {
33 | "babel-traverse": "6.25.0",
34 | "babel-types": "6.25.0",
35 | "babylon": "6.17.3",
36 | "lazy": "1.0.11",
37 | "nativescript-dev-typescript": "~0.4.0",
38 | "typescript": "~2.2.1"
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/demo/app/App_Resources/Android/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
16 |
17 |
18 |
19 |
20 |
21 |
27 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/src/platforms/android/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
16 |
17 |
18 |
19 |
20 |
21 |
27 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/demo-angular/app/pages/main-page.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | Object.defineProperty(exports, "__esModule", { value: true });
3 | var core_1 = require("@angular/core");
4 | var MainPage = (function () {
5 | function MainPage() {
6 | }
7 | MainPage.prototype.ngOnInit = function () {
8 | };
9 | return MainPage;
10 | }());
11 | MainPage = __decorate([
12 | core_1.Component({
13 | selector: "ns-items",
14 | moduleId: module.id,
15 | templateUrl: "./main-page.html",
16 | }),
17 | __metadata("design:paramtypes", [])
18 | ], MainPage);
19 | exports.MainPage = MainPage;
20 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWFpbi1wYWdlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsibWFpbi1wYWdlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQUEsc0NBQWtEO0FBT2xELElBQWEsUUFBUTtJQUNqQjtJQUFnQixDQUFDO0lBRWpCLDJCQUFRLEdBQVI7SUFDQSxDQUFDO0lBQ0wsZUFBQztBQUFELENBQUMsQUFMRCxJQUtDO0FBTFksUUFBUTtJQUxwQixnQkFBUyxDQUFDO1FBQ1AsUUFBUSxFQUFFLFVBQVU7UUFDcEIsUUFBUSxFQUFFLE1BQU0sQ0FBQyxFQUFFO1FBQ25CLFdBQVcsRUFBRSxrQkFBa0I7S0FDbEMsQ0FBQzs7R0FDVyxRQUFRLENBS3BCO0FBTFksNEJBQVEiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBDb21wb25lbnQsIE9uSW5pdCB9IGZyb20gXCJAYW5ndWxhci9jb3JlXCI7XG5cbkBDb21wb25lbnQoe1xuICAgIHNlbGVjdG9yOiBcIm5zLWl0ZW1zXCIsXG4gICAgbW9kdWxlSWQ6IG1vZHVsZS5pZCxcbiAgICB0ZW1wbGF0ZVVybDogXCIuL21haW4tcGFnZS5odG1sXCIsXG59KVxuZXhwb3J0IGNsYXNzIE1haW5QYWdlIGltcGxlbWVudHMgT25Jbml0IHtcbiAgICBjb25zdHJ1Y3RvcigpIHsgfVxuXG4gICAgbmdPbkluaXQoKTogdm9pZCB7XG4gICAgfVxufVxuIl19
--------------------------------------------------------------------------------
/src/platforms/android/src/main/assets/app/App_Resources/Android/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
16 |
17 |
18 |
19 |
20 |
21 |
27 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/demo-angular/app/App_Resources/Android/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
16 |
17 |
18 |
19 |
20 |
21 |
27 |
28 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/demo-angular/app/App_Resources/iOS/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleDisplayName
8 | ${PRODUCT_NAME}
9 | CFBundleExecutable
10 | ${EXECUTABLE_NAME}
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | ${PRODUCT_NAME}
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1.0
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | UIRequiresFullScreen
28 |
29 | UIRequiredDeviceCapabilities
30 |
31 | armv7
32 |
33 | UISupportedInterfaceOrientations
34 |
35 | UIInterfaceOrientationPortrait
36 | UIInterfaceOrientationLandscapeLeft
37 | UIInterfaceOrientationLandscapeRight
38 |
39 | UISupportedInterfaceOrientations~ipad
40 |
41 | UIInterfaceOrientationPortrait
42 | UIInterfaceOrientationPortraitUpsideDown
43 | UIInterfaceOrientationLandscapeLeft
44 | UIInterfaceOrientationLandscapeRight
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/src/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "nativescript-svg",
3 | "version": "1.3.7",
4 | "description": "NativeScript SVG plugin",
5 | "main": "svg",
6 | "typings": "svg.d.ts",
7 | "nativescript": {
8 | "platforms": {
9 | "android": "3.0.0",
10 | "ios": "3.0.0"
11 | }
12 | },
13 | "scripts": {
14 | "build": "tsc -skipLibCheck",
15 | "demo.ios": "npm run preparedemo ; cd demo ; tns emulate ios",
16 | "demo.android": "npm run preparedemo ; cd demo ; tns run android",
17 | "preparedemo": "npm run build ; cd demo ; tns plugin remove nativescript-svg ; tns plugin add .. ; tns install",
18 | "setup": "cd demo ; npm install ; cd .. ; npm run build ; cd demo ; tns plugin add .. ; cd .."
19 | },
20 | "repository": {
21 | "type": "git",
22 | "url": "https://github.com/peoplewareDo/nativescript-svg.git"
23 | },
24 | "keywords": [
25 | "NativeScript",
26 | "JavaScript",
27 | "Android",
28 | "iOS",
29 | "svg"
30 | ],
31 | "author": {
32 | "name": "Victor Sosa",
33 | "email": "victor.sosa@peopleware.do"
34 | },
35 | "contributors": [
36 | {
37 | "name": "Brad Martin",
38 | "email": "bmartin@nstudio.io",
39 | "url": "https://github.com/bradmartin"
40 | }
41 | ],
42 | "bugs": {
43 | "url": "https://github.com/peoplewareDo/nativescript-svg/issues"
44 | },
45 | "license": "MIT",
46 | "homepage": "https://github.com/peoplewareDo/nativescript-svg",
47 | "readmeFilename": "README.md",
48 | "devDependencies": {
49 | "tns-core-modules": ">=3.0.0",
50 | "tns-platform-declarations": ">=3.0.0",
51 | "typescript": "^2.2.2",
52 | "nativescript-angular": ">=3.0.0 || ^2.0.0-rc.1",
53 | "@angular/core": "~4.0.1",
54 | "@angular/common": "~4.0.1",
55 | "@angular/compiler": "~4.0.1",
56 | "@angular/compiler-cli": "~4.0.1",
57 | "rxjs": "~5.3.0",
58 | "zone.js": "~0.8.4"
59 | }
60 | }
--------------------------------------------------------------------------------
/demo-angular/app/App_Resources/Android/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
18 |
19 |
21 |
22 |
23 |
31 |
32 |
34 |
35 |
36 |
42 |
43 |
45 |
46 |
--------------------------------------------------------------------------------
/demo-angular/app/app.routing.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | Object.defineProperty(exports, "__esModule", { value: true });
3 | var core_1 = require("@angular/core");
4 | var router_1 = require("nativescript-angular/router");
5 | var main_page_1 = require("./pages/main-page");
6 | var routes = [
7 | { path: "", redirectTo: "/main-page", pathMatch: "full" },
8 | { path: "main-page", component: main_page_1.MainPage }
9 | ];
10 | var AppRoutingModule = (function () {
11 | function AppRoutingModule() {
12 | }
13 | return AppRoutingModule;
14 | }());
15 | AppRoutingModule = __decorate([
16 | core_1.NgModule({
17 | imports: [router_1.NativeScriptRouterModule.forRoot(routes)],
18 | exports: [router_1.NativeScriptRouterModule]
19 | })
20 | ], AppRoutingModule);
21 | exports.AppRoutingModule = AppRoutingModule;
22 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXBwLnJvdXRpbmcuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJhcHAucm91dGluZy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLHNDQUF5QztBQUN6QyxzREFBdUU7QUFHdkUsK0NBQTZDO0FBRTdDLElBQU0sTUFBTSxHQUFXO0lBQ25CLEVBQUUsSUFBSSxFQUFFLEVBQUUsRUFBRSxVQUFVLEVBQUUsWUFBWSxFQUFFLFNBQVMsRUFBRSxNQUFNLEVBQUU7SUFDekQsRUFBRSxJQUFJLEVBQUUsV0FBVyxFQUFFLFNBQVMsRUFBRSxvQkFBUSxFQUFFO0NBQzdDLENBQUM7QUFNRixJQUFhLGdCQUFnQjtJQUE3QjtJQUFnQyxDQUFDO0lBQUQsdUJBQUM7QUFBRCxDQUFDLEFBQWpDLElBQWlDO0FBQXBCLGdCQUFnQjtJQUo1QixlQUFRLENBQUM7UUFDTixPQUFPLEVBQUUsQ0FBQyxpQ0FBd0IsQ0FBQyxPQUFPLENBQUMsTUFBTSxDQUFDLENBQUM7UUFDbkQsT0FBTyxFQUFFLENBQUMsaUNBQXdCLENBQUM7S0FDdEMsQ0FBQztHQUNXLGdCQUFnQixDQUFJO0FBQXBCLDRDQUFnQiIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7IE5nTW9kdWxlIH0gZnJvbSBcIkBhbmd1bGFyL2NvcmVcIjtcbmltcG9ydCB7IE5hdGl2ZVNjcmlwdFJvdXRlck1vZHVsZSB9IGZyb20gXCJuYXRpdmVzY3JpcHQtYW5ndWxhci9yb3V0ZXJcIjtcbmltcG9ydCB7IFJvdXRlcyB9IGZyb20gXCJAYW5ndWxhci9yb3V0ZXJcIjtcblxuaW1wb3J0IHsgTWFpblBhZ2UgfSBmcm9tIFwiLi9wYWdlcy9tYWluLXBhZ2VcIjtcblxuY29uc3Qgcm91dGVzOiBSb3V0ZXMgPSBbXG4gICAgeyBwYXRoOiBcIlwiLCByZWRpcmVjdFRvOiBcIi9tYWluLXBhZ2VcIiwgcGF0aE1hdGNoOiBcImZ1bGxcIiB9LFxuICAgIHsgcGF0aDogXCJtYWluLXBhZ2VcIiwgY29tcG9uZW50OiBNYWluUGFnZSB9XG5dO1xuXG5ATmdNb2R1bGUoe1xuICAgIGltcG9ydHM6IFtOYXRpdmVTY3JpcHRSb3V0ZXJNb2R1bGUuZm9yUm9vdChyb3V0ZXMpXSxcbiAgICBleHBvcnRzOiBbTmF0aXZlU2NyaXB0Um91dGVyTW9kdWxlXVxufSlcbmV4cG9ydCBjbGFzcyBBcHBSb3V0aW5nTW9kdWxlIHsgfSJdfQ==
--------------------------------------------------------------------------------
/demo/app/App_Resources/iOS/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleDisplayName
8 | ${PRODUCT_NAME}
9 | CFBundleExecutable
10 | ${EXECUTABLE_NAME}
11 | CFBundleIconFile
12 | icon.png
13 | CFBundleIcons
14 |
15 | CFBundlePrimaryIcon
16 |
17 | CFBundleIconFiles
18 |
19 | icon-40
20 | icon-60
21 | icon-72
22 | icon-76
23 | Icon-Small
24 | Icon-Small-50
25 |
26 | UIPrerenderedIcon
27 |
28 |
29 |
30 | CFBundleInfoDictionaryVersion
31 | 6.0
32 | CFBundleName
33 | ${PRODUCT_NAME}
34 | CFBundlePackageType
35 | APPL
36 | CFBundleShortVersionString
37 | 1.0
38 | CFBundleSignature
39 | ????
40 | CFBundleVersion
41 | 1.0
42 | LSRequiresIPhoneOS
43 |
44 | UILaunchStoryboardName
45 | LaunchScreen
46 | UIRequiresFullScreen
47 |
48 | NSPhotoLibraryUsageDescription
49 | $(PRODUCT_NAME) photo use
50 | UIRequiredDeviceCapabilities
51 |
52 | armv7
53 |
54 | UISupportedInterfaceOrientations
55 |
56 | UIInterfaceOrientationPortrait
57 | UIInterfaceOrientationLandscapeLeft
58 | UIInterfaceOrientationLandscapeRight
59 |
60 | UISupportedInterfaceOrientations~ipad
61 |
62 | UIInterfaceOrientationPortrait
63 | UIInterfaceOrientationPortraitUpsideDown
64 | UIInterfaceOrientationLandscapeLeft
65 | UIInterfaceOrientationLandscapeRight
66 |
67 |
68 |
69 |
--------------------------------------------------------------------------------
/demo/app/images/nativescript.svg:
--------------------------------------------------------------------------------
1 |
2 |
7 |
--------------------------------------------------------------------------------
/demo-angular/app/images/nativescript.svg:
--------------------------------------------------------------------------------
1 |
2 |
7 |
--------------------------------------------------------------------------------
/demo-angular/app/app.module.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | Object.defineProperty(exports, "__esModule", { value: true });
3 | var core_1 = require("@angular/core");
4 | var nativescript_module_1 = require("nativescript-angular/nativescript.module");
5 | var app_routing_1 = require("./app.routing");
6 | var app_component_1 = require("./app.component");
7 | var main_page_1 = require("./pages/main-page");
8 | var angular_1 = require("nativescript-svg/angular");
9 | var AppModule = (function () {
10 | function AppModule() {
11 | }
12 | return AppModule;
13 | }());
14 | AppModule = __decorate([
15 | core_1.NgModule({
16 | bootstrap: [
17 | app_component_1.AppComponent
18 | ],
19 | imports: [
20 | nativescript_module_1.NativeScriptModule,
21 | app_routing_1.AppRoutingModule,
22 | angular_1.NativeScriptSvgModule
23 | ],
24 | declarations: [
25 | app_component_1.AppComponent,
26 | main_page_1.MainPage
27 | ],
28 | schemas: [
29 | core_1.NO_ERRORS_SCHEMA
30 | ]
31 | })
32 | ], AppModule);
33 | exports.AppModule = AppModule;
34 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXBwLm1vZHVsZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbImFwcC5tb2R1bGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSxzQ0FBMkQ7QUFDM0QsZ0ZBQThFO0FBQzlFLDZDQUFpRDtBQUNqRCxpREFBK0M7QUFFL0MsK0NBQTZDO0FBQzdDLG9EQUFpRTtBQW1CakUsSUFBYSxTQUFTO0lBQXRCO0lBQXlCLENBQUM7SUFBRCxnQkFBQztBQUFELENBQUMsQUFBMUIsSUFBMEI7QUFBYixTQUFTO0lBakJyQixlQUFRLENBQUM7UUFDTixTQUFTLEVBQUU7WUFDUCw0QkFBWTtTQUNmO1FBQ0QsT0FBTyxFQUFFO1lBQ0wsd0NBQWtCO1lBQ2xCLDhCQUFnQjtZQUNoQiwrQkFBcUI7U0FDeEI7UUFDRCxZQUFZLEVBQUU7WUFDViw0QkFBWTtZQUNaLG9CQUFRO1NBQ1g7UUFDRCxPQUFPLEVBQUU7WUFDTCx1QkFBZ0I7U0FDbkI7S0FDSixDQUFDO0dBQ1csU0FBUyxDQUFJO0FBQWIsOEJBQVMiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBOZ01vZHVsZSwgTk9fRVJST1JTX1NDSEVNQSB9IGZyb20gXCJAYW5ndWxhci9jb3JlXCI7XG5pbXBvcnQgeyBOYXRpdmVTY3JpcHRNb2R1bGUgfSBmcm9tIFwibmF0aXZlc2NyaXB0LWFuZ3VsYXIvbmF0aXZlc2NyaXB0Lm1vZHVsZVwiO1xuaW1wb3J0IHsgQXBwUm91dGluZ01vZHVsZSB9IGZyb20gXCIuL2FwcC5yb3V0aW5nXCI7XG5pbXBvcnQgeyBBcHBDb21wb25lbnQgfSBmcm9tIFwiLi9hcHAuY29tcG9uZW50XCI7XG5cbmltcG9ydCB7IE1haW5QYWdlIH0gZnJvbSBcIi4vcGFnZXMvbWFpbi1wYWdlXCI7XG5pbXBvcnQgeyBOYXRpdmVTY3JpcHRTdmdNb2R1bGUgfSBmcm9tIFwibmF0aXZlc2NyaXB0LXN2Zy9hbmd1bGFyXCI7XG5cbkBOZ01vZHVsZSh7XG4gICAgYm9vdHN0cmFwOiBbXG4gICAgICAgIEFwcENvbXBvbmVudFxuICAgIF0sXG4gICAgaW1wb3J0czogW1xuICAgICAgICBOYXRpdmVTY3JpcHRNb2R1bGUsXG4gICAgICAgIEFwcFJvdXRpbmdNb2R1bGUsXG4gICAgICAgIE5hdGl2ZVNjcmlwdFN2Z01vZHVsZVxuICAgIF0sXG4gICAgZGVjbGFyYXRpb25zOiBbXG4gICAgICAgIEFwcENvbXBvbmVudCxcbiAgICAgICAgTWFpblBhZ2VcbiAgICBdLFxuICAgIHNjaGVtYXM6IFtcbiAgICAgICAgTk9fRVJST1JTX1NDSEVNQVxuICAgIF1cbn0pXG5leHBvcnQgY2xhc3MgQXBwTW9kdWxlIHsgfVxuIl19
--------------------------------------------------------------------------------
/demo-angular/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "size" : "29x29",
5 | "idiom" : "iphone",
6 | "filename" : "icon-29.png",
7 | "scale" : "1x"
8 | },
9 | {
10 | "size" : "29x29",
11 | "idiom" : "iphone",
12 | "filename" : "icon-29@2x.png",
13 | "scale" : "2x"
14 | },
15 | {
16 | "size" : "29x29",
17 | "idiom" : "iphone",
18 | "filename" : "icon-29@3x.png",
19 | "scale" : "3x"
20 | },
21 | {
22 | "size" : "40x40",
23 | "idiom" : "iphone",
24 | "filename" : "icon-40@2x.png",
25 | "scale" : "2x"
26 | },
27 | {
28 | "size" : "40x40",
29 | "idiom" : "iphone",
30 | "filename" : "icon-40@3x.png",
31 | "scale" : "3x"
32 | },
33 | {
34 | "size" : "57x57",
35 | "idiom" : "iphone",
36 | "filename" : "icon-57.png",
37 | "scale" : "1x"
38 | },
39 | {
40 | "size" : "57x57",
41 | "idiom" : "iphone",
42 | "filename" : "icon-57@2x.png",
43 | "scale" : "2x"
44 | },
45 | {
46 | "size" : "60x60",
47 | "idiom" : "iphone",
48 | "filename" : "icon-60@2x.png",
49 | "scale" : "2x"
50 | },
51 | {
52 | "size" : "60x60",
53 | "idiom" : "iphone",
54 | "filename" : "icon-60@3x.png",
55 | "scale" : "3x"
56 | },
57 | {
58 | "size" : "29x29",
59 | "idiom" : "ipad",
60 | "filename" : "icon-29.png",
61 | "scale" : "1x"
62 | },
63 | {
64 | "size" : "29x29",
65 | "idiom" : "ipad",
66 | "filename" : "icon-29@2x.png",
67 | "scale" : "2x"
68 | },
69 | {
70 | "size" : "40x40",
71 | "idiom" : "ipad",
72 | "filename" : "icon-40.png",
73 | "scale" : "1x"
74 | },
75 | {
76 | "size" : "40x40",
77 | "idiom" : "ipad",
78 | "filename" : "icon-40@2x.png",
79 | "scale" : "2x"
80 | },
81 | {
82 | "size" : "50x50",
83 | "idiom" : "ipad",
84 | "filename" : "icon-50.png",
85 | "scale" : "1x"
86 | },
87 | {
88 | "size" : "50x50",
89 | "idiom" : "ipad",
90 | "filename" : "icon-50@2x.png",
91 | "scale" : "2x"
92 | },
93 | {
94 | "size" : "72x72",
95 | "idiom" : "ipad",
96 | "filename" : "icon-72.png",
97 | "scale" : "1x"
98 | },
99 | {
100 | "size" : "72x72",
101 | "idiom" : "ipad",
102 | "filename" : "icon-72@2x.png",
103 | "scale" : "2x"
104 | },
105 | {
106 | "size" : "76x76",
107 | "idiom" : "ipad",
108 | "filename" : "icon-76.png",
109 | "scale" : "1x"
110 | },
111 | {
112 | "size" : "76x76",
113 | "idiom" : "ipad",
114 | "filename" : "icon-76@2x.png",
115 | "scale" : "2x"
116 | },
117 | {
118 | "size" : "83.5x83.5",
119 | "idiom" : "ipad",
120 | "filename" : "icon-83.5@2x.png",
121 | "scale" : "2x"
122 | }
123 | ],
124 | "info" : {
125 | "version" : 1,
126 | "author" : "xcode"
127 | }
128 | }
--------------------------------------------------------------------------------
/demo-angular/app/App_Resources/iOS/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
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 |
--------------------------------------------------------------------------------
/demo-angular/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "extent" : "full-screen",
5 | "idiom" : "iphone",
6 | "subtype" : "736h",
7 | "filename" : "Default-736h@3x.png",
8 | "minimum-system-version" : "8.0",
9 | "orientation" : "portrait",
10 | "scale" : "3x"
11 | },
12 | {
13 | "extent" : "full-screen",
14 | "idiom" : "iphone",
15 | "subtype" : "736h",
16 | "filename" : "Default-Landscape@3x.png",
17 | "minimum-system-version" : "8.0",
18 | "orientation" : "landscape",
19 | "scale" : "3x"
20 | },
21 | {
22 | "extent" : "full-screen",
23 | "idiom" : "iphone",
24 | "subtype" : "667h",
25 | "filename" : "Default-667h@2x.png",
26 | "minimum-system-version" : "8.0",
27 | "orientation" : "portrait",
28 | "scale" : "2x"
29 | },
30 | {
31 | "orientation" : "portrait",
32 | "idiom" : "iphone",
33 | "filename" : "Default@2x.png",
34 | "extent" : "full-screen",
35 | "minimum-system-version" : "7.0",
36 | "scale" : "2x"
37 | },
38 | {
39 | "extent" : "full-screen",
40 | "idiom" : "iphone",
41 | "subtype" : "retina4",
42 | "filename" : "Default-568h@2x.png",
43 | "minimum-system-version" : "7.0",
44 | "orientation" : "portrait",
45 | "scale" : "2x"
46 | },
47 | {
48 | "orientation" : "portrait",
49 | "idiom" : "ipad",
50 | "filename" : "Default-Portrait.png",
51 | "extent" : "full-screen",
52 | "minimum-system-version" : "7.0",
53 | "scale" : "1x"
54 | },
55 | {
56 | "orientation" : "landscape",
57 | "idiom" : "ipad",
58 | "filename" : "Default-Landscape.png",
59 | "extent" : "full-screen",
60 | "minimum-system-version" : "7.0",
61 | "scale" : "1x"
62 | },
63 | {
64 | "orientation" : "portrait",
65 | "idiom" : "ipad",
66 | "filename" : "Default-Portrait@2x.png",
67 | "extent" : "full-screen",
68 | "minimum-system-version" : "7.0",
69 | "scale" : "2x"
70 | },
71 | {
72 | "orientation" : "landscape",
73 | "idiom" : "ipad",
74 | "filename" : "Default-Landscape@2x.png",
75 | "extent" : "full-screen",
76 | "minimum-system-version" : "7.0",
77 | "scale" : "2x"
78 | },
79 | {
80 | "orientation" : "portrait",
81 | "idiom" : "iphone",
82 | "filename" : "Default.png",
83 | "extent" : "full-screen",
84 | "scale" : "1x"
85 | },
86 | {
87 | "orientation" : "portrait",
88 | "idiom" : "iphone",
89 | "filename" : "Default@2x.png",
90 | "extent" : "full-screen",
91 | "scale" : "2x"
92 | },
93 | {
94 | "orientation" : "portrait",
95 | "idiom" : "iphone",
96 | "filename" : "Default-568h@2x.png",
97 | "extent" : "full-screen",
98 | "subtype" : "retina4",
99 | "scale" : "2x"
100 | },
101 | {
102 | "orientation" : "portrait",
103 | "idiom" : "ipad",
104 | "extent" : "to-status-bar",
105 | "scale" : "1x"
106 | },
107 | {
108 | "orientation" : "portrait",
109 | "idiom" : "ipad",
110 | "filename" : "Default-Portrait.png",
111 | "extent" : "full-screen",
112 | "scale" : "1x"
113 | },
114 | {
115 | "orientation" : "landscape",
116 | "idiom" : "ipad",
117 | "extent" : "to-status-bar",
118 | "scale" : "1x"
119 | },
120 | {
121 | "orientation" : "landscape",
122 | "idiom" : "ipad",
123 | "filename" : "Default-Landscape.png",
124 | "extent" : "full-screen",
125 | "scale" : "1x"
126 | },
127 | {
128 | "orientation" : "portrait",
129 | "idiom" : "ipad",
130 | "extent" : "to-status-bar",
131 | "scale" : "2x"
132 | },
133 | {
134 | "orientation" : "portrait",
135 | "idiom" : "ipad",
136 | "filename" : "Default-Portrait@2x.png",
137 | "extent" : "full-screen",
138 | "scale" : "2x"
139 | },
140 | {
141 | "orientation" : "landscape",
142 | "idiom" : "ipad",
143 | "extent" : "to-status-bar",
144 | "scale" : "2x"
145 | },
146 | {
147 | "orientation" : "landscape",
148 | "idiom" : "ipad",
149 | "filename" : "Default-Landscape@2x.png",
150 | "extent" : "full-screen",
151 | "scale" : "2x"
152 | }
153 | ],
154 | "info" : {
155 | "version" : 1,
156 | "author" : "xcode"
157 | }
158 | }
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [](https://www.npmjs.com/package/nativescript-svg)
2 | [](https://www.npmjs.com/package/nativescript-svg)
3 | [](http://opensource.org/licenses/MIT)
4 | [](https://david-dm.org/peoplewareDo/nativescript-svg#info=dependencies)
5 | # NativeScript SVG
6 |
7 | ## Install
8 | `tns plugin add nativescript-svg`
9 |
10 |
11 | ### Usage
12 |
13 | You use it in the same way you use Image source.
14 |
15 | Android Library | iOS CocoaPod
16 | --------------- | ------------
17 | [pents90 svg-android](https://github.com/pents90/svg-android) | [SVGKit by SVGKit](https://github.com/SVGKit/SVGKit)
18 |
19 | ** there are limitations: **
20 | - saveToFile ins't working
21 |
22 | ### Quick start
23 | ```js
24 | var ImageSourceSVGModule = require("nativescript-svg");
25 | var svgFile = new ImageSourceSVGModule.ImageSourceSVG();
26 |
27 | var loaded = svgFile.fromResource('foxie');
28 |
29 | var path = '//somepath/file.svg';
30 | loaded = svgFile.loadFromFile(path);
31 |
32 | var url = 'http://somepath/file.svg';
33 | loaded = svgFile.loadFromUrl(url);
34 |
35 | if(loaded){
36 | console.log("object loaded");
37 | } else {
38 | console.log("error");
39 | }
40 | ```
41 |
42 | ## API
43 |
44 | ##### ImageSourceSVGModule.fromResource(name: string): ImageSourceSVG
45 | - Loads this instance from the specified resource name.
46 |
47 | ##### ImageSourceSVGModule.fromFile(path: string): ImageSourceSVG
48 | - Creates a new ImageSourceSVG instance and loads it from the specified file.
49 |
50 | ##### ImageSourceSVGModule.fromData(data: any): ImageSourceSVG
51 | - Creates a new ImageSourceSVG instance and loads it from the specified resource name.
52 |
53 | ##### ImageSourceSVGModule.fromBase64(source: string): ImageSourceSVG
54 | - Creates a new ImageSourceSVG instance and loads it from the specified resource name.
55 |
56 | ##### ImageSourceSVGModule.fromBase64(source: string): ImageSourceSVG
57 | - Creates a new ImageSourceSVG instance and loads it from the specified resource name.
58 |
59 | ##### ImageSourceSVGModule.fromUrl(url: string): Promise:ImageSourceSVG
60 | - Downloads the image from the provided Url and creates a new ImageSourceSVG instance from it.
61 |
62 | ***
63 | You can call every method in two ways, for example:
64 | ```
65 | //from the svf file object
66 | svgFile.loadFromResource(name: string): boolean // synchronously
67 | svgFile.fromResource(name: string): ImageSourceSVG //asynchronously
68 | ```
69 | or
70 | ```
71 | //from the svg module api
72 | ImageSourceSVGModule.fromResource(name: string): ImageSourceSVG
73 | ```
74 |
75 | Since ver 1.1 Implement a similar image tag to be used as for example:
76 | ```xml
77 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 | ```
89 |
90 | ### Roadmap
91 | ver 1.6 implement an SVGImage tag that can support svg tags.
92 | ```
93 |
94 |
95 |
96 |
97 | ```
98 | ver 1.5 Change api dependency from pents90/svg-android to Pixplicity/sharp
99 |
100 |
101 | ### Release note
102 | v1.3.7 -- Fix missing .JS file in the npm package build because npmignore file in the wrong place
103 |
104 | v1.3.5 -- Fix missing .JS file in the npm package build
105 |
106 | v1.3.4 -- Angular 4 support, please check example code
107 |
108 | v1.3.0 -- NS 3+ implementation and it will work with angular if you call registerElement before using it. Thanks to @tbozhikov
109 |
110 | v1.1.4 -- Fix svg & demo
111 |
112 | v1.1.3 -- Fix SVGImage for iOS - SVGKFastImageView issue#3
113 |
114 | v1.1.0 -- Implemented a similar image tag to render svg images.
115 |
116 | v1.0.11 -- Major fix for load library issue and demo include.
117 |
118 | v1.0.9 -- load from URL on Android and IOS included.
119 |
120 | v1.0.7 -- Fix svg.common override issue.
121 |
122 | v1.0.5 -- fix for npm package lib not including the .js files.
123 |
124 | v1.0.2 -- the base64 encondig on Android included - IOS pending.
125 |
126 |
--------------------------------------------------------------------------------
/demo/app/images/spider-test.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/demo-angular/app/images/spider-test.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/demo/app/images/spider.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
63 |
64 |
--------------------------------------------------------------------------------
/demo-angular/app/images/spider.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
63 |
64 |
--------------------------------------------------------------------------------
/demo/app/main-page.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/src/svg.android.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | Object.defineProperty(exports, "__esModule", { value: true });
3 | var common = require("./svg.common");
4 | var types = require("tns-core-modules/utils/types");
5 | var http;
6 | function ensureHttp() {
7 | if (!http) {
8 | http = require("http");
9 | }
10 | }
11 | global.moduleMerge(common, exports);
12 | var utils;
13 | function ensureUtils() {
14 | if (!utils) {
15 | utils = require("utils/utils");
16 | }
17 | }
18 | var fs;
19 | function ensureFS() {
20 | if (!fs) {
21 | fs = require("file-system");
22 | }
23 | }
24 | var ImageSourceSVG = (function () {
25 | function ImageSourceSVG() {
26 | }
27 | ImageSourceSVG.prototype.loadFromResource = function (name) {
28 | this.nativeView = null;
29 | ensureUtils();
30 | var res = utils.ad.getApplicationContext().getResources();
31 | if (res) {
32 | var identifier = res.getIdentifier(name, 'drawable', utils.ad.getApplication().getPackageName());
33 | if (0 < identifier) {
34 | this.nativeView = new com.larvalabs.svgandroid.SVGParser.getSVGFromResource(res, identifier);
35 | }
36 | }
37 | return this.nativeView != null;
38 | };
39 | ImageSourceSVG.prototype.fromResource = function (name) {
40 | var _this = this;
41 | return new Promise(function (resolve, reject) {
42 | resolve(_this.loadFromResource(name));
43 | });
44 | };
45 | ImageSourceSVG.prototype.loadFromFile = function (path) {
46 | ensureFS();
47 | var fileName = types.isString(path) ? path.trim() : "";
48 | if (fileName.indexOf("~/") === 0) {
49 | fileName = fs.path.join(fs.knownFolders.currentApp().path, fileName.replace("~/", ""));
50 | }
51 | this.nativeView = new com.larvalabs.svgandroid.SVGParser.getSVGFromInputStream(new java.io.FileInputStream(new java.io.File(fileName)));
52 | return this.nativeView != null;
53 | };
54 | ImageSourceSVG.prototype.fromFile = function (path) {
55 | var _this = this;
56 | return new Promise(function (resolve, reject) {
57 | resolve(_this.loadFromFile(path));
58 | });
59 | };
60 | ImageSourceSVG.prototype.loadFromData = function (data) {
61 | this.nativeView = new com.larvalabs.svgandroid.SVGParser.getSVGFromString(data);
62 | return this.nativeView != null;
63 | };
64 | ImageSourceSVG.prototype.fromData = function (data) {
65 | var _this = this;
66 | return new Promise(function (resolve, reject) {
67 | resolve(_this.loadFromData(data));
68 | });
69 | };
70 | ImageSourceSVG.prototype.loadFromBase64 = function (source) {
71 | var bytes = android.util.Base64.decode(source, android.util.Base64.DEFAULT);
72 | this.nativeView = new com.larvalabs.svgandroid.SVGParser.getSVGFromString(new java.lang.String(bytes));
73 | return this.nativeView != null;
74 | };
75 | ImageSourceSVG.prototype.fromBase64 = function (data) {
76 | var _this = this;
77 | return new Promise(function (resolve, reject) {
78 | resolve(_this.loadFromBase64(data));
79 | });
80 | };
81 | ImageSourceSVG.prototype.loadFromUrl = function (url) {
82 | ensureHttp();
83 | var result = http.getString(url);
84 | return this.setNativeSource(new com.larvalabs.svgandroid.SVGParser.getSVGFromString(result));
85 | };
86 | ImageSourceSVG.prototype.fromUrl = function (url) {
87 | var _this = this;
88 | return new Promise(function (resolve, reject) {
89 | resolve(_this.loadFromUrl(url));
90 | });
91 | };
92 | ImageSourceSVG.prototype.setNativeSource = function (source) {
93 | this.nativeView = source;
94 | return source != null;
95 | };
96 | ImageSourceSVG.prototype.saveToFile = function (path) {
97 | return false;
98 | };
99 | ImageSourceSVG.prototype.toBase64String = function (format) {
100 | if (!this.nativeView) {
101 | return null;
102 | ;
103 | }
104 | return android.util.Base64.encodeToString(format, android.util.Base64.DEFAULT);
105 | };
106 | Object.defineProperty(ImageSourceSVG.prototype, "height", {
107 | get: function () {
108 | if (this.nativeView) {
109 | return this.nativeView.getPitcture().getHeight();
110 | }
111 | return NaN;
112 | },
113 | enumerable: true,
114 | configurable: true
115 | });
116 | Object.defineProperty(ImageSourceSVG.prototype, "width", {
117 | get: function () {
118 | if (this.nativeView) {
119 | return this.nativeView.getPitcture().getWidth();
120 | }
121 | return NaN;
122 | },
123 | enumerable: true,
124 | configurable: true
125 | });
126 | return ImageSourceSVG;
127 | }());
128 | exports.ImageSourceSVG = ImageSourceSVG;
129 | var SVGImage = (function (_super) {
130 | __extends(SVGImage, _super);
131 | function SVGImage() {
132 | return _super.call(this) || this;
133 | }
134 | SVGImage.prototype.createNativeView = function () {
135 | return new org.nativescript.widgets.ImageView(this._context);
136 | };
137 | SVGImage.prototype._setNativeImage = function (nativeImage) {
138 | this._drawable = nativeImage.nativeView.createPictureDrawable();
139 | this.nativeView.setLayerType(android.view.View.LAYER_TYPE_SOFTWARE, null);
140 | this.nativeView.setImageDrawable(this._drawable);
141 | };
142 | SVGImage.prototype[common.imageSourceProperty.setNative] = function (value) {
143 | var image = value;
144 | if (!image || !image.nativeView) {
145 | return;
146 | }
147 | this._setNativeImage(image);
148 | };
149 | return SVGImage;
150 | }(common.SVGImage));
151 | exports.SVGImage = SVGImage;
152 |
--------------------------------------------------------------------------------
/src/svg.android.ts:
--------------------------------------------------------------------------------
1 | import svg = require("./svg");
2 | import common = require("./svg.common");
3 | import types = require("tns-core-modules/utils/types");
4 | import * as utilsModule from "tns-core-modules/utils/utils";
5 | import * as fileSystemModule from "tns-core-modules/file-system";
6 | import * as httpModule from "tns-core-modules/http";
7 |
8 | var http: typeof httpModule;
9 | function ensureHttp() {
10 | if (!http) {
11 | http = require("http");
12 | }
13 | }
14 |
15 | global.moduleMerge(common, exports);
16 |
17 | var utils: typeof utilsModule;
18 | function ensureUtils() {
19 | if (!utils) {
20 | utils = require("utils/utils");
21 | }
22 | }
23 |
24 | var fs: typeof fileSystemModule;
25 | function ensureFS() {
26 | if (!fs) {
27 | fs = require("file-system");
28 | }
29 | }
30 |
31 | declare var android: any;
32 | declare var com: any;
33 | declare var java: any;
34 | declare var org: any;
35 |
36 | export class ImageSourceSVG implements svg.ImageSourceSVG {
37 | private nativeView: any;
38 |
39 | public loadFromResource(name: string): boolean {
40 | this.nativeView = null;
41 |
42 | ensureUtils();
43 |
44 | var res = utils.ad.getApplicationContext().getResources();
45 | if (res) {
46 | var identifier: number = res.getIdentifier(name, 'drawable', utils.ad.getApplication().getPackageName());
47 | if (0 < identifier) {
48 | // Load SVG
49 | this.nativeView = new com.larvalabs.svgandroid.SVGParser.getSVGFromResource(res, identifier);
50 | }
51 | }
52 |
53 | return this.nativeView != null;
54 | }
55 |
56 | public fromResource(name: string): Promise {
57 | return new Promise((resolve, reject) => {
58 | resolve(this.loadFromResource(name));
59 | });
60 | }
61 |
62 | public loadFromFile(path: string): boolean {
63 | ensureFS();
64 |
65 | var fileName = types.isString(path) ? path.trim() : "";
66 | if (fileName.indexOf("~/") === 0) {
67 | fileName = fs.path.join(fs.knownFolders.currentApp().path, fileName.replace("~/", ""));
68 | }
69 |
70 | this.nativeView = new com.larvalabs.svgandroid.SVGParser.getSVGFromInputStream(new java.io.FileInputStream(new java.io.File(fileName)));
71 | return this.nativeView != null;
72 | }
73 |
74 | public fromFile(path: string): Promise {
75 | return new Promise((resolve, reject) => {
76 | resolve(this.loadFromFile(path));
77 | });
78 | }
79 |
80 | public loadFromData(data: any): boolean {
81 | this.nativeView = new com.larvalabs.svgandroid.SVGParser.getSVGFromString(data);
82 | return this.nativeView != null;
83 | }
84 |
85 | public fromData(data: any): Promise {
86 | return new Promise((resolve, reject) => {
87 | resolve(this.loadFromData(data));
88 | });
89 | }
90 |
91 | public loadFromBase64(source: string): boolean {
92 | var bytes = android.util.Base64.decode(source, android.util.Base64.DEFAULT);
93 | this.nativeView = new com.larvalabs.svgandroid.SVGParser.getSVGFromString(new java.lang.String(bytes));
94 | return this.nativeView != null;
95 | }
96 |
97 |
98 | public fromBase64(data: any): Promise {
99 | return new Promise((resolve, reject) => {
100 | resolve(this.loadFromBase64(data));
101 | });
102 | }
103 |
104 | public loadFromUrl(url: string): boolean {
105 | ensureHttp();
106 | var result = http.getString(url);
107 | return this.setNativeSource(new com.larvalabs.svgandroid.SVGParser.getSVGFromString(result));
108 | //var httpUrl = new java.net.URL(url);
109 | //var urlConnection = httpUrl.openConnection();
110 | //return this.setNativeSource(new com.larvalabs.svgandroid.SVGParser.getSVGFromInputStream(urlConnection.getInputStream()));
111 | }
112 |
113 | public fromUrl(url: string): Promise {
114 | return new Promise((resolve, reject) => {
115 | resolve(this.loadFromUrl(url));
116 | });
117 | }
118 |
119 | public setNativeSource(source: any): boolean {
120 | this.nativeView = source;
121 | return source != null;
122 | }
123 |
124 | public saveToFile(path: string): boolean {
125 | // TODO to be implemented
126 | return false;
127 | }
128 |
129 | public toBase64String(format: string): string {
130 | if (!this.nativeView) {
131 | return null;;
132 | }
133 |
134 | return android.util.Base64.encodeToString(format, android.util.Base64.DEFAULT);
135 | }
136 |
137 | get height(): number {
138 | if (this.nativeView) {
139 | return this.nativeView.getPitcture().getHeight();
140 | }
141 |
142 | return NaN;
143 | }
144 |
145 | get width(): number {
146 | if (this.nativeView) {
147 | return this.nativeView.getPitcture().getWidth();
148 | }
149 |
150 | return NaN;
151 | }
152 | }
153 |
154 | export class SVGImage extends common.SVGImage {
155 | private _drawable: android.graphics.drawable.PictureDrawable;
156 |
157 | constructor() {
158 | super();
159 | }
160 |
161 | public createNativeView() {
162 | return new org.nativescript.widgets.ImageView(this._context);
163 | }
164 |
165 | public _setNativeImage(nativeImage: any) {
166 | this._drawable = nativeImage.nativeView.createPictureDrawable();
167 | this.nativeView.setLayerType(android.view.View.LAYER_TYPE_SOFTWARE, null);
168 | this.nativeView.setImageDrawable(this._drawable);
169 | }
170 |
171 | [common.imageSourceProperty.setNative](value: any) {
172 | var image = value;
173 |
174 | if (!image || !image.nativeView) {
175 | return;
176 | }
177 |
178 | this._setNativeImage(image);
179 | }
180 | }
181 |
--------------------------------------------------------------------------------
/src/svg.common.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | Object.defineProperty(exports, "__esModule", { value: true });
3 | var view_1 = require("tns-core-modules/ui/core/view");
4 | var utils = require("tns-core-modules/utils/utils");
5 | var types = require("tns-core-modules/utils/types");
6 | var definition = require("./svg");
7 | var SRC = "src";
8 | var IMAGE_SOURCE = "imageSource";
9 | var LOAD_MODE = "loadMode";
10 | var SYNC = "sync";
11 | var ASYNC = "async";
12 | var ISLOADING = "isLoading";
13 | exports.srcProperty = new view_1.Property({ name: SRC, defaultValue: undefined, valueChanged: function (target, oldValue, newValue) { return target._createImageSourceFromSrc(); } });
14 | exports.imageSourceProperty = new view_1.Property({ name: IMAGE_SOURCE, defaultValue: undefined });
15 | exports.isLoadingProperty = new view_1.Property({ name: ISLOADING, defaultValue: false });
16 | exports.loadModeProperty = new view_1.Property({ name: LOAD_MODE, defaultValue: SYNC });
17 | var SVGImage = (function (_super) {
18 | __extends(SVGImage, _super);
19 | function SVGImage(options) {
20 | return _super.call(this) || this;
21 | }
22 | SVGImage.prototype._createImageSourceFromSrc = function () {
23 | var _this = this;
24 | var value = this.src;
25 | if (types.isString(value)) {
26 | value = value.trim();
27 | this.imageSource = null;
28 | this["_url"] = value;
29 | this.isLoading = true;
30 | var source = new definition.ImageSourceSVG();
31 | var imageLoaded = function () {
32 | var currentValue = _this.src;
33 | if (!types.isString(_this.src) || value !== currentValue.trim()) {
34 | return;
35 | }
36 | _this.imageSource = source;
37 | _this.isLoading = false;
38 | };
39 | if (utils.isDataURI(value)) {
40 | var base64Data = value.split(",")[1];
41 | if (types.isDefined(base64Data)) {
42 | if (this.loadMode === SYNC) {
43 | source.loadFromBase64(base64Data);
44 | imageLoaded();
45 | }
46 | else if (this.loadMode === ASYNC) {
47 | source.fromBase64(base64Data).then(imageLoaded);
48 | }
49 | }
50 | }
51 | else if (definition.isFileOrResourcePath(value)) {
52 | if (value.indexOf(utils.RESOURCE_PREFIX) === 0) {
53 | var resPath = value.substr(utils.RESOURCE_PREFIX.length);
54 | if (this.loadMode === SYNC) {
55 | source.loadFromResource(resPath);
56 | imageLoaded();
57 | }
58 | else if (this.loadMode === ASYNC) {
59 | this.imageSource = null;
60 | source.fromResource(resPath).then(imageLoaded);
61 | }
62 | }
63 | else {
64 | if (this.loadMode === SYNC) {
65 | source.loadFromFile(value);
66 | imageLoaded();
67 | }
68 | else if (this.loadMode === ASYNC) {
69 | this.imageSource = null;
70 | source.fromFile(value).then(imageLoaded);
71 | }
72 | }
73 | }
74 | else {
75 | this.imageSource = null;
76 | definition.fromUrl(value).then(function (r) {
77 | if (_this["_url"] === value) {
78 | _this.imageSource = r;
79 | _this.isLoading = false;
80 | }
81 | });
82 | }
83 | }
84 | else if (value instanceof definition.ImageSourceSVG) {
85 | this.imageSource = value;
86 | this.isLoading = false;
87 | }
88 | else {
89 | this.imageSource = definition.fromNativeSource(value);
90 | this.isLoading = false;
91 | }
92 | };
93 | return SVGImage;
94 | }(view_1.View));
95 | exports.SVGImage = SVGImage;
96 | function fromResource(name) {
97 | var image = new definition.ImageSourceSVG();
98 | return image.loadFromResource(name) ? image : null;
99 | }
100 | exports.fromResource = fromResource;
101 | function fromFile(path) {
102 | var image = new definition.ImageSourceSVG();
103 | return image.loadFromFile(path) ? image : null;
104 | }
105 | exports.fromFile = fromFile;
106 | function fromData(data) {
107 | var image = new definition.ImageSourceSVG();
108 | return image.loadFromData(data) ? image : null;
109 | }
110 | exports.fromData = fromData;
111 | function fromBase64(source) {
112 | var image = new definition.ImageSourceSVG();
113 | return image.loadFromBase64(source) ? image : null;
114 | }
115 | exports.fromBase64 = fromBase64;
116 | function fromNativeSource(source) {
117 | var image = new definition.ImageSourceSVG();
118 | return image.setNativeSource(source) ? image : null;
119 | }
120 | exports.fromNativeSource = fromNativeSource;
121 | function fromUrl(url) {
122 | var image = new definition.ImageSourceSVG();
123 | return image.loadFromUrl(url) ? image : null;
124 | }
125 | exports.fromUrl = fromUrl;
126 | function fromFileOrResource(path) {
127 | if (!isFileOrResourcePath(path)) {
128 | throw new Error("Path \"" + "\" is not a valid file or resource.");
129 | }
130 | if (path.indexOf(utils.RESOURCE_PREFIX) === 0) {
131 | return fromResource(path.substr(utils.RESOURCE_PREFIX.length));
132 | }
133 | return fromFile(path);
134 | }
135 | exports.fromFileOrResource = fromFileOrResource;
136 | function isFileOrResourcePath(path) {
137 | return utils.isFileOrResourcePath(path);
138 | }
139 | exports.isFileOrResourcePath = isFileOrResourcePath;
140 | exports.srcProperty.register(SVGImage);
141 | exports.imageSourceProperty.register(SVGImage);
142 | exports.loadModeProperty.register(SVGImage);
143 | exports.isLoadingProperty.register(SVGImage);
144 |
--------------------------------------------------------------------------------
/src/package-lock.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "nativescript-svg",
3 | "version": "1.3.4",
4 | "lockfileVersion": 1,
5 | "requires": true,
6 | "dependencies": {
7 | "@angular/common": {
8 | "version": "4.0.3",
9 | "resolved": "https://registry.npmjs.org/@angular/common/-/common-4.0.3.tgz",
10 | "integrity": "sha1-F0coletCXygSs6eRYrW0lNJQals=",
11 | "dev": true
12 | },
13 | "@angular/compiler": {
14 | "version": "4.0.3",
15 | "resolved": "https://registry.npmjs.org/@angular/compiler/-/compiler-4.0.3.tgz",
16 | "integrity": "sha1-izytM4rFOTKOEKakv6oFcJT3vIk=",
17 | "dev": true
18 | },
19 | "@angular/compiler-cli": {
20 | "version": "4.0.3",
21 | "resolved": "https://registry.npmjs.org/@angular/compiler-cli/-/compiler-cli-4.0.3.tgz",
22 | "integrity": "sha1-aR8oC8TWYRqI1lVfQ+VwMqDTQwA=",
23 | "dev": true,
24 | "requires": {
25 | "@angular/tsc-wrapped": "4.0.3",
26 | "minimist": "1.2.0",
27 | "reflect-metadata": "0.1.10"
28 | }
29 | },
30 | "@angular/core": {
31 | "version": "4.0.3",
32 | "resolved": "https://registry.npmjs.org/@angular/core/-/core-4.0.3.tgz",
33 | "integrity": "sha1-Yb4h22qld44zFZ/9OMu+uvFhINk=",
34 | "dev": true
35 | },
36 | "@angular/tsc-wrapped": {
37 | "version": "4.0.3",
38 | "resolved": "https://registry.npmjs.org/@angular/tsc-wrapped/-/tsc-wrapped-4.0.3.tgz",
39 | "integrity": "sha1-pf6mqH35w0j6pVd8NpjIo2MIJ4E=",
40 | "dev": true,
41 | "requires": {
42 | "tsickle": "0.21.6"
43 | }
44 | },
45 | "minimist": {
46 | "version": "1.2.0",
47 | "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
48 | "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=",
49 | "dev": true
50 | },
51 | "mkdirp": {
52 | "version": "0.5.1",
53 | "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
54 | "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
55 | "dev": true,
56 | "requires": {
57 | "minimist": "0.0.8"
58 | },
59 | "dependencies": {
60 | "minimist": {
61 | "version": "0.0.8",
62 | "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
63 | "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=",
64 | "dev": true
65 | }
66 | }
67 | },
68 | "nativescript-angular": {
69 | "version": "3.1.3",
70 | "resolved": "https://registry.npmjs.org/nativescript-angular/-/nativescript-angular-3.1.3.tgz",
71 | "integrity": "sha1-t8yB35PFHpF4Qgx8XQys0Y6t2uc=",
72 | "dev": true,
73 | "requires": {
74 | "nativescript-intl": "3.0.0",
75 | "reflect-metadata": "0.1.10"
76 | }
77 | },
78 | "nativescript-intl": {
79 | "version": "3.0.0",
80 | "resolved": "https://registry.npmjs.org/nativescript-intl/-/nativescript-intl-3.0.0.tgz",
81 | "integrity": "sha1-gu6b59N3Fys8QpVzRyMDdijhhqc=",
82 | "dev": true
83 | },
84 | "reflect-metadata": {
85 | "version": "0.1.10",
86 | "resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.1.10.tgz",
87 | "integrity": "sha1-tPg3BEFqytiZiMmxVjXUfgO5NEo=",
88 | "dev": true
89 | },
90 | "rxjs": {
91 | "version": "5.3.3",
92 | "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-5.3.3.tgz",
93 | "integrity": "sha1-3S+VEF9xPZXyW4lMvl9opfMskmw=",
94 | "dev": true,
95 | "requires": {
96 | "symbol-observable": "1.0.4"
97 | }
98 | },
99 | "source-map": {
100 | "version": "0.5.6",
101 | "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.6.tgz",
102 | "integrity": "sha1-dc449SvwczxafwwRjYEzSiu19BI=",
103 | "dev": true
104 | },
105 | "source-map-support": {
106 | "version": "0.4.15",
107 | "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.4.15.tgz",
108 | "integrity": "sha1-AyAt9lwG0r2MfsI2KhkwVv7407E=",
109 | "dev": true,
110 | "requires": {
111 | "source-map": "0.5.6"
112 | }
113 | },
114 | "symbol-observable": {
115 | "version": "1.0.4",
116 | "resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-1.0.4.tgz",
117 | "integrity": "sha1-Kb9hXUqnEhvdiYsi1LP5vE4qoD0=",
118 | "dev": true
119 | },
120 | "tns-core-modules": {
121 | "version": "3.1.0",
122 | "resolved": "https://registry.npmjs.org/tns-core-modules/-/tns-core-modules-3.1.0.tgz",
123 | "integrity": "sha1-iSXsrhZWsytOMmVJjLI8EHjC9mc=",
124 | "dev": true,
125 | "requires": {
126 | "tns-core-modules-widgets": "3.1.0"
127 | }
128 | },
129 | "tns-core-modules-widgets": {
130 | "version": "3.1.0",
131 | "resolved": "https://registry.npmjs.org/tns-core-modules-widgets/-/tns-core-modules-widgets-3.1.0.tgz",
132 | "integrity": "sha1-3pGlagyM+zhxxo1lGueAPyM/URk=",
133 | "dev": true
134 | },
135 | "tns-platform-declarations": {
136 | "version": "3.1.0",
137 | "resolved": "https://registry.npmjs.org/tns-platform-declarations/-/tns-platform-declarations-3.1.0.tgz",
138 | "integrity": "sha1-0+satz6UMCrGAQc2U2/tDGii+7U=",
139 | "dev": true
140 | },
141 | "tsickle": {
142 | "version": "0.21.6",
143 | "resolved": "https://registry.npmjs.org/tsickle/-/tsickle-0.21.6.tgz",
144 | "integrity": "sha1-U7Abl5xcE/2xOvs/uVgXflmRWI0=",
145 | "dev": true,
146 | "requires": {
147 | "minimist": "1.2.0",
148 | "mkdirp": "0.5.1",
149 | "source-map": "0.5.6",
150 | "source-map-support": "0.4.15"
151 | }
152 | },
153 | "typescript": {
154 | "version": "2.4.2",
155 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-2.4.2.tgz",
156 | "integrity": "sha1-+DlfhdRZJ2BnyYiqQYN6j4KHCEQ=",
157 | "dev": true
158 | },
159 | "zone.js": {
160 | "version": "0.8.14",
161 | "resolved": "https://registry.npmjs.org/zone.js/-/zone.js-0.8.14.tgz",
162 | "integrity": "sha1-DE2ySxeCMidMy0P3jJnbfzZCts8=",
163 | "dev": true
164 | }
165 | }
166 | }
167 |
--------------------------------------------------------------------------------
/src/svg.common.ts:
--------------------------------------------------------------------------------
1 | import { View, Property } from "tns-core-modules/ui/core/view";
2 | import * as utils from "tns-core-modules/utils/utils";
3 | import * as types from "tns-core-modules/utils/types"
4 |
5 | // This is used for definition purposes only, it does not generate JavaScript for it.
6 | import * as definition from "./svg";
7 |
8 | var SRC = "src";
9 | var IMAGE_SOURCE = "imageSource";
10 | var LOAD_MODE = "loadMode";
11 | var SYNC = "sync";
12 | var ASYNC = "async";
13 | var ISLOADING = "isLoading";
14 |
15 | export const srcProperty = new Property({ name: SRC, defaultValue: undefined, valueChanged: (target, oldValue, newValue) => target._createImageSourceFromSrc() });
16 | export const imageSourceProperty = new Property({ name: IMAGE_SOURCE, defaultValue: undefined });
17 | export const isLoadingProperty = new Property({ name: ISLOADING, defaultValue: false });
18 | export const loadModeProperty = new Property({ name: LOAD_MODE, defaultValue: SYNC });
19 |
20 | export class SVGImage extends View implements definition.SVGImage {
21 | src: any;
22 | imageSource: definition.ImageSourceSVG;
23 | isLoading: boolean;
24 | loadMode: "sync" | "async";
25 |
26 | constructor(options?: definition.Options) {
27 | // super(options);
28 | super();
29 | }
30 |
31 | /**
32 | * @internal
33 | */
34 | _createImageSourceFromSrc(): void {
35 | var value = this.src;
36 | if (types.isString(value)) {
37 | value = value.trim();
38 | this.imageSource = null;
39 | this["_url"] = value;
40 |
41 | // this._setValue(SVGImage.isLoadingProperty, true);
42 | this.isLoading = true;
43 |
44 | var source = new definition.ImageSourceSVG();
45 | var imageLoaded = () => {
46 | let currentValue = this.src;
47 | if (!types.isString(this.src) || value !== currentValue.trim()) {
48 | return;
49 | }
50 | this.imageSource = source;
51 | // imageSourceProperty.nativeValueChange(this, source);
52 | // this._setValue(SVGImage.isLoadingProperty, false);
53 | this.isLoading = false;
54 | }
55 | //WRONG IMplementation, it can't load data uri, just base xml encode
56 | if (utils.isDataURI(value)) {
57 | var base64Data = value.split(",")[1];
58 | if (types.isDefined(base64Data)) {
59 | if (this.loadMode === SYNC) {
60 | source.loadFromBase64(base64Data);
61 | imageLoaded();
62 | } else if (this.loadMode === ASYNC) {
63 | source.fromBase64(base64Data).then(imageLoaded);
64 | }
65 | }
66 | }
67 | else if (definition.isFileOrResourcePath(value)) {
68 | if (value.indexOf(utils.RESOURCE_PREFIX) === 0) {
69 | let resPath = value.substr(utils.RESOURCE_PREFIX.length);
70 | if (this.loadMode === SYNC) {
71 | source.loadFromResource(resPath);
72 | imageLoaded();
73 | } else if (this.loadMode === ASYNC) {
74 | this.imageSource = null;
75 | source.fromResource(resPath).then(imageLoaded);
76 | }
77 | } else {
78 | if (this.loadMode === SYNC) {
79 | source.loadFromFile(value);
80 | imageLoaded();
81 | } else if (this.loadMode === ASYNC) {
82 | this.imageSource = null;
83 | source.fromFile(value).then(imageLoaded);
84 | }
85 | }
86 | } else {
87 | this.imageSource = null;
88 | definition.fromUrl(value).then((r) => {
89 | if (this["_url"] === value) {
90 | this.imageSource = r;
91 | // this._setValue(SVGImage.isLoadingProperty, false);
92 | this.isLoading = false;
93 | }
94 | });
95 | }
96 | }
97 | else if (value instanceof definition.ImageSourceSVG) {
98 | // Support binding the imageSource trough the src property
99 | this.imageSource = value;
100 | // this._setValue(SVGImage.isLoadingProperty, false);
101 | this.isLoading = false;
102 |
103 | }
104 | else {
105 | this.imageSource = definition.fromNativeSource(value);
106 | // this._setValue(SVGImage.isLoadingProperty, false);
107 | this.isLoading = false;
108 | }
109 | }
110 |
111 | }
112 |
113 | export function fromResource(name: string): definition.ImageSourceSVG {
114 | var image = new definition.ImageSourceSVG();
115 | return image.loadFromResource(name) ? image : null;
116 | }
117 |
118 | export function fromFile(path: string): definition.ImageSourceSVG {
119 | var image = new definition.ImageSourceSVG();
120 | return image.loadFromFile(path) ? image : null;
121 | }
122 |
123 | export function fromData(data: any): definition.ImageSourceSVG {
124 | var image = new definition.ImageSourceSVG();
125 | return image.loadFromData(data) ? image : null;
126 | }
127 |
128 | export function fromBase64(source: string): definition.ImageSourceSVG {
129 | var image = new definition.ImageSourceSVG();
130 | return image.loadFromBase64(source) ? image : null;
131 | }
132 |
133 | export function fromNativeSource(source: any): definition.ImageSourceSVG {
134 | var image = new definition.ImageSourceSVG();
135 | return image.setNativeSource(source) ? image : null;
136 | }
137 |
138 | export function fromUrl(url: string): definition.ImageSourceSVG {
139 | var image = new definition.ImageSourceSVG();
140 | return image.loadFromUrl(url) ? image : null;
141 | }
142 |
143 | export function fromFileOrResource(path: string): definition.ImageSourceSVG {
144 | if (!isFileOrResourcePath(path)) {
145 | throw new Error("Path \"" + "\" is not a valid file or resource.");
146 | }
147 |
148 | if (path.indexOf(utils.RESOURCE_PREFIX) === 0) {
149 | return fromResource(path.substr(utils.RESOURCE_PREFIX.length));
150 | }
151 | return fromFile(path);
152 | }
153 |
154 | export function isFileOrResourcePath(path: string): boolean {
155 | return utils.isFileOrResourcePath(path);
156 | }
157 |
158 | srcProperty.register(SVGImage);
159 | imageSourceProperty.register(SVGImage);
160 | loadModeProperty.register(SVGImage);
161 | isLoadingProperty.register(SVGImage);
--------------------------------------------------------------------------------
/src/svg.d.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Allows you to parse SVG files.
3 | */
4 |
5 | import { Property } from "tns-core-modules/ui/core/dependency-observable";
6 | import { View } from "tns-core-modules/ui/core/view";
7 |
8 | /**
9 | * Represents a class that provides functionality for loading svg(s).
10 | */
11 | export class SVGImage extends View {
12 | public static srcProperty: Property;
13 | public static imageSourceProperty: Property;
14 | public static isLoadingProperty: Property;
15 |
16 | /**
17 | * Gets or sets the image source of the image.
18 | */
19 | imageSource: ImageSourceSVG;
20 |
21 | /**
22 | * Gets or sets the source of the svg. This can be either an URL string or a native svg instance.
23 | */
24 | src: any;
25 |
26 | /**
27 | * Gets a value indicating if the svg is currently loading
28 | */
29 | isLoading: boolean;
30 |
31 | /**
32 | * Gets or sets the loading strategy for images on the local file system:
33 | * - **sync** *(default)* - blocks the UI if necessary to display immediately, good for small icons.
34 | * - **async** - will try to load in the background, may appear with short delay, good for large images.
35 | */
36 | loadMode: string; // "sync" | "async";
37 | }
38 |
39 |
40 | /**
41 | * Provides common options for creating a animation
42 | */
43 | export interface Options {
44 |
45 | /**
46 | * Gets or sets the URL of the svg
47 | */
48 | src: string;
49 | }
50 |
51 | /**
52 | * Encapsulates the common abstraction behind a platform specific object SVG that is used as a source for images.
53 | */
54 | export class ImageSourceSVG {
55 |
56 | /**
57 | * Gets the height of this instance. This is a read-only property.
58 | */
59 | height: number;
60 |
61 | /**
62 | * Gets the width of this instance. This is a read-only property.
63 | */
64 | width: number;
65 |
66 | /**
67 | * Loads this instance from the specified resource name.
68 | * @param name The name of the resource (without its extension).
69 | */
70 | loadFromResource(name: string): boolean;
71 |
72 | /**
73 | * Loads this instance from the specified resource name asynchronously.
74 | * @param name The name of the resource (without its extension).
75 | */
76 | fromResource(name: string): Promise;
77 |
78 | /**
79 | * Loads this instance from the specified file.
80 | * @param path The location of the file on the file system.
81 | */
82 | loadFromFile(path: string): boolean;
83 |
84 | /**
85 | * Loads this instance from the specified file asynchronously.
86 | * @param path The location of the file on the file system.
87 | */
88 | fromFile(path: string): Promise;
89 |
90 | /**
91 | * Loads this instance from the specified native image data.
92 | * @param data The native data (byte array) to load the image from. This will be either Stream for Android or NSData for iOS.
93 | */
94 | loadFromData(data: any): boolean;
95 |
96 | /**
97 | * Loads this instance from the specified native image data asynchronously.
98 | * @param data The native data (byte array) to load the image from. This will be either Stream for Android or NSData for iOS.
99 | */
100 | fromData(data: any): Promise;
101 |
102 | /**
103 | * Loads this instance from the specified native image data.
104 | * @param source The Base64 string to load the image from.
105 | */
106 | loadFromBase64(source: string): boolean;
107 |
108 | /**
109 | * Loads this instance from the specified native image data asynchronously.
110 | * @param source The Base64 string to load the image from.
111 | */
112 | fromBase64(source: string): Promise;
113 |
114 | /**
115 | * Loads this instance from the specified url.
116 | * @param url string to load the image from.
117 | */
118 | loadFromUrl(url: string): boolean;
119 |
120 | /**
121 | * Loads this instance from the specified url asynchronously.
122 | * @param url string to load the image from.
123 | */
124 | fromUrl(url: string): Promise;
125 |
126 | /**
127 | * Sets the provided native source object.
128 | * This will update either the android or ios properties, depending on the target os.
129 | * @param source The native image object. Will be either a svg for Android or a UIImage for iOS.
130 | */
131 | setNativeSource(source: any): boolean;
132 |
133 | /**
134 | * Saves this instance to the specified file, using the provided image format and quality.
135 | * @param path The path of the file on the file system to save to.
136 | */
137 | saveToFile(path: string): boolean;
138 |
139 | /**
140 | * Converts the image to base64 encoded string, using the provided image format and quality.
141 | * @param format The format (encoding) of the image.
142 | */
143 | toBase64String(format: string): string;
144 | }
145 |
146 | /**
147 | * Creates a new ImageSourceSVG instance and loads it from the specified resource name.
148 | * @param name The name of the resource (without its extension).
149 | */
150 | export function fromResource(name: string): ImageSourceSVG;
151 |
152 | /**
153 | * Creates a new ImageSourceSVG instance and loads it from the specified file.
154 | * @param path The location of the file on the file system.
155 | */
156 | export function fromFile(path: string): ImageSourceSVG;
157 |
158 | /**
159 | * Creates a new ImageSourceSVG instance and loads it from the specified resource name.
160 | * @param data The native data (byte array) to load the image from. This will be either Stream for Android or NSData for iOS.
161 | */
162 | export function fromData(data: any): ImageSourceSVG;
163 |
164 | /**
165 | * Creates a new ImageSourceSVG instance and loads it from the specified resource name.
166 | * @param source The Base64 string to load the image from.
167 | */
168 | export function fromBase64(source: string): ImageSourceSVG;
169 |
170 | /**
171 | * Creates a new ImageSourceSVG instance and sets the provided native source object.
172 | * The native source object will update either the android or ios properties, depending on the target os.
173 | * @param source The native image object. Will be either a Bitmap for Android or a UIImage for iOS.
174 | */
175 | export function fromNativeSource(source: any): ImageSourceSVG;
176 |
177 | /**
178 | * Downloads the image from the provided Url and creates a new ImageSourceSVG instance from it.
179 | * @param url The link to the remote image object. This operation will download and decode the image.
180 | */
181 | export function fromUrl(url: string): Promise;
182 |
183 | /**
184 | * Creates a new ImageSourceSVG instance and loads it from the specified local file or resource(if spexified with "res://" prefix)
185 | * @param path The location of the file on the file system.
186 | */
187 | export function fromFileOrResource(path: string): ImageSourceSVG;
188 |
189 | /**
190 | * [Obsolete. Please use utils.isFileOrResourcePath instead!] Returns true if the specified path points to a resource or local file.
191 | * @param path The path.
192 | */
193 | export function isFileOrResourcePath(path: string): boolean
194 |
--------------------------------------------------------------------------------
/src/svg.ios.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | Object.defineProperty(exports, "__esModule", { value: true });
3 | var common = require("./svg.common");
4 | var types = require("tns-core-modules/utils/types");
5 | var fs = require("tns-core-modules/file-system");
6 | global.moduleMerge(common, exports);
7 | var ImageSourceSVG = (function () {
8 | function ImageSourceSVG() {
9 | }
10 | ImageSourceSVG.prototype.loadFromResource = function (name) {
11 | this.nativeView = SVGKImage.imageNamed(name) || SVGKImage.imageNamed(name + ".svg");
12 | return this.nativeView != null;
13 | };
14 | ImageSourceSVG.prototype.fromResource = function (name) {
15 | var _this = this;
16 | return new Promise(function (resolve, reject) {
17 | try {
18 | SVGKImage.imageAsynchronouslyNamed(name, function (image, parseResult) {
19 | if (image) {
20 | _this.nativeView = image;
21 | resolve(true);
22 | }
23 | else {
24 | SVGKImage.imageAsynchronouslyNamed(name + ".svg", function (image, parseResult) {
25 | _this.nativeView = image;
26 | resolve(true);
27 | });
28 | }
29 | });
30 | }
31 | catch (ex) {
32 | reject(ex);
33 | }
34 | });
35 | };
36 | ImageSourceSVG.prototype.loadFromFile = function (path) {
37 | var fileName = types.isString(path) ? path.trim() : "";
38 | if (fileName.indexOf("~/") === 0) {
39 | fileName = fs.path.join(fs.knownFolders.currentApp().path, fileName.replace("~/", ""));
40 | }
41 | this.nativeView = SVGKImage.imageWithContentsOfFile(fileName);
42 | return this.nativeView != null;
43 | };
44 | ImageSourceSVG.prototype.fromFile = function (path) {
45 | var _this = this;
46 | return new Promise(function (resolve, reject) {
47 | try {
48 | var fileName = types.isString(path) ? path.trim() : "";
49 | if (fileName.indexOf("~/") === 0) {
50 | fileName = fs.path.join(fs.knownFolders.currentApp().path, fileName.replace("~/", ""));
51 | }
52 | SVGKImage.imageWithContentsOfFileAsynchronously(fileName, function (image) {
53 | _this.nativeView = image;
54 | resolve(true);
55 | });
56 | }
57 | catch (ex) {
58 | reject(ex);
59 | }
60 | });
61 | };
62 | ImageSourceSVG.prototype.loadFromData = function (data) {
63 | this.nativeView = SVGKImage.imageWithData(data);
64 | return this.nativeView != null;
65 | };
66 | ImageSourceSVG.prototype.fromData = function (data) {
67 | var _this = this;
68 | return new Promise(function (resolve, reject) {
69 | try {
70 | SVGKImage.imageWithDataAsynchronously(data, function (image) {
71 | _this.nativeView = image;
72 | resolve(true);
73 | });
74 | }
75 | catch (ex) {
76 | reject(ex);
77 | }
78 | });
79 | };
80 | ImageSourceSVG.prototype.loadFromBase64 = function (source) {
81 | if (types.isString(source)) {
82 | var data = NSData.alloc().initWithBase64EncodedStringOptions(source, 1);
83 | this.nativeView = SVGKImage.imageWithData(data);
84 | }
85 | return this.nativeView != null;
86 | };
87 | ImageSourceSVG.prototype.fromBase64 = function (source) {
88 | var _this = this;
89 | return new Promise(function (resolve, reject) {
90 | try {
91 | var data = NSData.alloc().initWithBase64EncodedStringOptions(source, 1);
92 | SVGKImage.imageWithDataAsynchronously(data, function (image) {
93 | _this.nativeView = image;
94 | resolve(true);
95 | });
96 | }
97 | catch (ex) {
98 | reject(ex);
99 | }
100 | });
101 | };
102 | ImageSourceSVG.prototype.loadFromUrl = function (url) {
103 | this.nativeView = SVGKImage.imageWithContentsOfURL(NSURL.URLWithString(url));
104 | return this.nativeView != null;
105 | };
106 | ImageSourceSVG.prototype.fromUrl = function (url) {
107 | var _this = this;
108 | return new Promise(function (resolve, reject) {
109 | resolve(_this.loadFromUrl(url));
110 | });
111 | };
112 | ImageSourceSVG.prototype.setNativeSource = function (source) {
113 | this.nativeView = source;
114 | return source != null;
115 | };
116 | ImageSourceSVG.prototype.saveToFile = function (path) {
117 | if (!this.nativeView) {
118 | return false;
119 | }
120 | var data = getImageData(this.nativeView);
121 | if (data) {
122 | return data.writeToFileAtomically(path, true);
123 | }
124 | return false;
125 | };
126 | ImageSourceSVG.prototype.toBase64String = function (format) {
127 | var res = null;
128 | if (!this.nativeView) {
129 | return res;
130 | }
131 | var data = getImageData(this.nativeView);
132 | if (data) {
133 | res = data.base64EncodedStringWithOptions(1);
134 | }
135 | return res;
136 | };
137 | Object.defineProperty(ImageSourceSVG.prototype, "height", {
138 | get: function () {
139 | if (this.nativeView) {
140 | return this.nativeView.size.height;
141 | }
142 | return NaN;
143 | },
144 | enumerable: true,
145 | configurable: true
146 | });
147 | Object.defineProperty(ImageSourceSVG.prototype, "width", {
148 | get: function () {
149 | if (this.nativeView) {
150 | return this.nativeView.size.width;
151 | }
152 | return NaN;
153 | },
154 | enumerable: true,
155 | configurable: true
156 | });
157 | return ImageSourceSVG;
158 | }());
159 | exports.ImageSourceSVG = ImageSourceSVG;
160 | function getImageData(instance) {
161 | var buffer = instance.source.stream;
162 | throw new Error("Not supported operation");
163 | }
164 | var SVGImage = (function (_super) {
165 | __extends(SVGImage, _super);
166 | function SVGImage() {
167 | var _this = _super.call(this) || this;
168 | _this._imageSourceAffectsLayout = true;
169 | _this.nativeView = SVGKFastImageView.alloc().initWithSVGKImage(new SVGKImage());
170 | return _this;
171 | }
172 | SVGImage.prototype._setNativeImage = function (nativeImage) {
173 | this.nativeView.image = nativeImage.nativeView;
174 | if (this._imageSourceAffectsLayout) {
175 | this.requestLayout();
176 | }
177 | };
178 | SVGImage.prototype.onMeasure = function (widthMeasureSpec, heightMeasureSpec) {
179 | var utils = require("utils/utils");
180 | var width = utils.layout.getMeasureSpecSize(widthMeasureSpec);
181 | var widthMode = utils.layout.getMeasureSpecMode(widthMeasureSpec);
182 | var height = utils.layout.getMeasureSpecSize(heightMeasureSpec);
183 | var heightMode = utils.layout.getMeasureSpecMode(heightMeasureSpec);
184 | var nativeWidth = this.imageSource ? this.imageSource.width : 0;
185 | var nativeHeight = this.imageSource ? this.imageSource.height : 0;
186 | var measureWidth = Math.max(nativeWidth, this.effectiveMinWidth);
187 | var measureHeight = Math.max(nativeHeight, this.effectiveMinHeight);
188 | var finiteWidth = widthMode !== utils.layout.UNSPECIFIED;
189 | var finiteHeight = heightMode !== utils.layout.UNSPECIFIED;
190 | this._imageSourceAffectsLayout = widthMode !== utils.layout.EXACTLY || heightMode !== utils.layout.EXACTLY;
191 | if (nativeWidth !== 0 && nativeHeight !== 0 && (finiteWidth || finiteHeight)) {
192 | var resultW = nativeWidth;
193 | var resultH = nativeHeight;
194 | measureWidth = finiteWidth ? Math.min(resultW, width) : resultW;
195 | measureHeight = finiteHeight ? Math.min(resultH, height) : resultH;
196 | var trace = require("trace");
197 | if (trace.enabled) {
198 | trace.write("nativeWidth: " + nativeWidth + ", nativeHeight: " + nativeHeight, trace.categories.Layout);
199 | }
200 | }
201 | var view = require("ui/core/view");
202 | var widthAndState = view.View.resolveSizeAndState(measureWidth, width, widthMode, 0);
203 | var heightAndState = view.View.resolveSizeAndState(measureHeight, height, heightMode, 0);
204 | this.setMeasuredDimension(widthAndState, heightAndState);
205 | };
206 | SVGImage.prototype[common.imageSourceProperty.setNative] = function (value) {
207 | var image = value;
208 | if (!image || !image.nativeView) {
209 | return;
210 | }
211 | this._setNativeImage(image);
212 | };
213 | return SVGImage;
214 | }(common.SVGImage));
215 | exports.SVGImage = SVGImage;
216 |
--------------------------------------------------------------------------------
/src/svg.ios.ts:
--------------------------------------------------------------------------------
1 | import svg = require("./svg");
2 | import common = require("./svg.common");
3 | import types = require("tns-core-modules/utils/types");
4 | import fs = require("tns-core-modules/file-system");
5 |
6 | global.moduleMerge(common, exports);
7 | declare var SVGKImage: any;
8 |
9 | export class ImageSourceSVG implements svg.ImageSourceSVG {
10 | private nativeView: any;
11 |
12 | public loadFromResource(name: string): boolean {
13 | this.nativeView = SVGKImage.imageNamed(name) || SVGKImage.imageNamed(`${name}.svg`);
14 | return this.nativeView != null;
15 | }
16 |
17 | public fromResource(name: string): Promise {
18 | return new Promise((resolve, reject) => {
19 | try {
20 | (SVGKImage).imageAsynchronouslyNamed(name, (image, parseResult) => {
21 | if (image) {
22 | this.nativeView = image;
23 | resolve(true);
24 | } else {
25 | (SVGKImage).imageAsynchronouslyNamed(`${name}.svg`, (image, parseResult) => {
26 | this.nativeView = image;
27 | resolve(true);
28 | });
29 | }
30 | });
31 | } catch (ex) {
32 | reject(ex);
33 | }
34 | });
35 | }
36 |
37 | public loadFromFile(path: string): boolean {
38 | var fileName = types.isString(path) ? path.trim() : "";
39 |
40 | if (fileName.indexOf("~/") === 0) {
41 | fileName = fs.path.join(fs.knownFolders.currentApp().path, fileName.replace("~/", ""));
42 | }
43 |
44 | this.nativeView = SVGKImage.imageWithContentsOfFile(fileName);
45 | return this.nativeView != null;
46 | }
47 |
48 | public fromFile(path: string): Promise {
49 | return new Promise((resolve, reject) => {
50 | try {
51 | var fileName = types.isString(path) ? path.trim() : "";
52 |
53 | if (fileName.indexOf("~/") === 0) {
54 | fileName = fs.path.join(fs.knownFolders.currentApp().path, fileName.replace("~/", ""));
55 | }
56 |
57 | (SVGKImage).imageWithContentsOfFileAsynchronously(fileName, image => {
58 | this.nativeView = image;
59 | resolve(true);
60 | });
61 | } catch (ex) {
62 | reject(ex);
63 | }
64 | });
65 | }
66 |
67 | public loadFromData(data: any): boolean {
68 | this.nativeView = SVGKImage.imageWithData(data);
69 | return this.nativeView != null;
70 | }
71 |
72 | public fromData(data: any): Promise {
73 | return new Promise((resolve, reject) => {
74 | try {
75 | (SVGKImage).imageWithDataAsynchronously(data, image => {
76 | this.nativeView = image;
77 | resolve(true);
78 | });
79 | } catch (ex) {
80 | reject(ex);
81 | }
82 | });
83 | }
84 |
85 | public loadFromBase64(source: string): boolean {
86 | if (types.isString(source)) {
87 | var data = NSData.alloc().initWithBase64EncodedStringOptions(source, NSDataBase64DecodingOptions.IgnoreUnknownCharacters);
88 | this.nativeView = SVGKImage.imageWithData(data);
89 | }
90 | return this.nativeView != null;
91 | }
92 |
93 |
94 | public fromBase64(source: string): Promise {
95 | return new Promise((resolve, reject) => {
96 | try {
97 | var data = NSData.alloc().initWithBase64EncodedStringOptions(source, NSDataBase64DecodingOptions.IgnoreUnknownCharacters);
98 | SVGKImage.imageWithDataAsynchronously(data, image => {
99 | this.nativeView = image;
100 | resolve(true);
101 | });
102 |
103 | } catch (ex) {
104 | reject(ex);
105 | }
106 | });
107 | }
108 |
109 | public loadFromUrl(url: string): boolean {
110 | this.nativeView = SVGKImage.imageWithContentsOfURL(NSURL.URLWithString(url));
111 |
112 | return this.nativeView != null;
113 | }
114 |
115 | public fromUrl(url: string): Promise {
116 | return new Promise((resolve, reject) => {
117 | resolve(this.loadFromUrl(url));
118 | });
119 | }
120 |
121 | public setNativeSource(source: any): boolean {
122 | this.nativeView = source;
123 | return source != null;
124 | }
125 |
126 | public saveToFile(path: string): boolean {
127 | if (!this.nativeView) {
128 | return false;
129 | }
130 |
131 | var data = getImageData(this.nativeView);
132 |
133 | if (data) {
134 | return data.writeToFileAtomically(path, true);
135 | }
136 |
137 | return false;
138 | }
139 |
140 | public toBase64String(format: string): string {
141 | var res = null;
142 | if (!this.nativeView) {
143 | return res;
144 | }
145 |
146 | var data = getImageData(this.nativeView);
147 |
148 | if (data) {
149 | res = data.base64EncodedStringWithOptions(NSDataBase64EncodingOptions.Encoding64CharacterLineLength);
150 | }
151 |
152 | return res;
153 |
154 | }
155 |
156 | get height(): number {
157 | if (this.nativeView) {
158 | return this.nativeView.size.height;
159 | }
160 |
161 | return NaN;
162 | }
163 |
164 | get width(): number {
165 | if (this.nativeView) {
166 | return this.nativeView.size.width;
167 | }
168 |
169 | return NaN;
170 | }
171 | }
172 |
173 | function getImageData(instance: any): NSData {
174 | var buffer = instance.source.stream;
175 | //TODO fix issue, wrong type
176 | throw new Error("Not supported operation");
177 | // return NSData.alloc().initWithBytes(buffer, NSDataBase64DecodingOptions.NSDataBase64DecodingIgnoreUnknownCharacters);
178 | }
179 |
180 | declare var SVGKFastImageView: any;
181 |
182 | export class SVGImage extends common.SVGImage {
183 | private _imageSourceAffectsLayout: boolean = true;
184 |
185 | constructor() {
186 | super();
187 |
188 | //TODO: Think of unified way of setting all the default values.
189 | this.nativeView = SVGKFastImageView.alloc().initWithSVGKImage(new SVGKImage());
190 | //this._ios.contentMode = UIViewContentMode.UIViewContentModeScaleAspectFit;
191 | //this._ios.clipsToBounds = true;
192 | //this._ios.userInteractionEnabled = true;
193 | }
194 |
195 | public _setNativeImage(nativeImage: any) {
196 | this.nativeView.image = nativeImage.nativeView;
197 |
198 | if (this._imageSourceAffectsLayout) {
199 | this.requestLayout();
200 | }
201 | }
202 |
203 | public onMeasure(widthMeasureSpec: number, heightMeasureSpec: number): void {
204 | var utils = require("utils/utils");
205 |
206 | // We don't call super because we measure native view with specific size.
207 | var width = utils.layout.getMeasureSpecSize(widthMeasureSpec);
208 | var widthMode = utils.layout.getMeasureSpecMode(widthMeasureSpec);
209 |
210 | var height = utils.layout.getMeasureSpecSize(heightMeasureSpec);
211 | var heightMode = utils.layout.getMeasureSpecMode(heightMeasureSpec);
212 |
213 | var nativeWidth = this.imageSource ? this.imageSource.width : 0;
214 | var nativeHeight = this.imageSource ? this.imageSource.height : 0;
215 |
216 | var measureWidth = Math.max(nativeWidth, this.effectiveMinWidth);
217 | var measureHeight = Math.max(nativeHeight, this.effectiveMinHeight);
218 |
219 | var finiteWidth: boolean = widthMode !== utils.layout.UNSPECIFIED;
220 | var finiteHeight: boolean = heightMode !== utils.layout.UNSPECIFIED;
221 |
222 | this._imageSourceAffectsLayout = widthMode !== utils.layout.EXACTLY || heightMode !== utils.layout.EXACTLY;
223 |
224 | if (nativeWidth !== 0 && nativeHeight !== 0 && (finiteWidth || finiteHeight)) {
225 | var resultW = nativeWidth;
226 | var resultH = nativeHeight;
227 |
228 | measureWidth = finiteWidth ? Math.min(resultW, width) : resultW;
229 | measureHeight = finiteHeight ? Math.min(resultH, height) : resultH;
230 |
231 | var trace = require("trace");
232 |
233 | if (trace.enabled) {
234 | trace.write("nativeWidth: " + nativeWidth + ", nativeHeight: " + nativeHeight, trace.categories.Layout);
235 | }
236 | }
237 |
238 | var view = require("ui/core/view");
239 |
240 | var widthAndState = view.View.resolveSizeAndState(measureWidth, width, widthMode, 0);
241 | var heightAndState = view.View.resolveSizeAndState(measureHeight, height, heightMode, 0);
242 |
243 | this.setMeasuredDimension(widthAndState, heightAndState);
244 | }
245 |
246 | [common.imageSourceProperty.setNative](value: any) {
247 | var image = value;
248 |
249 | if (!image || !image.nativeView) {
250 | return;
251 | }
252 |
253 | this._setNativeImage(image);
254 | }
255 | }
--------------------------------------------------------------------------------