Skip to content
This repository was archived by the owner on May 8, 2023. It is now read-only.

fix(statically-loading) Use OpaqueToken for providing config #21

Merged
merged 3 commits into from
Mar 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Thumbs.db

# Node Files #
/node_modules
/src/app/node_modules
/bower_components

# Coverage #
Expand All @@ -53,9 +54,10 @@ __build__/**
# IDE #
.idea/
*.swp

*.tgz
*.js
*.js.map
*.metadata.json
*.d.ts
!index.d.ts
!*.e2e.js
Expand Down
44 changes: 44 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
os: osx
osx_image: xcode8
sudo: false
language: objective-c

env:
- NODE_VERSION="4"
- NODE_VERSION="5"
- NODE_VERSION="6"

licenses:
- 'android-sdk-preview-license-52d11cd2'
- 'android-sdk-license-.+'

script:
- export ANDROID_HOME=/usr/local/opt/android-sdk
- export PATH=$PATH:/usr/local/opt/android-sdk/tools:/usr/local/opt/android-sdk/platform-tools
- npm run build
before_install:
- export ANDROID_HOME=/usr/local/opt/android-sdk
- export PATH=$PATH:/usr/local/opt/android-sdk/tools:/usr/local/opt/android-sdk/platform-tools
- wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.31.0/install.sh | bash
- source ~/.nvm/nvm.sh && nvm install $NODE_VERSION && nvm use $NODE_VERSION
- PATH="`npm bin`:`npm bin -g`:$PATH"
- brew update > /dev/null;
- brew install android-sdk dash gnu-sed jpeg python3;
- echo y | android update sdk --filter tools,platform-tools,android-23,build-tools-23.0.3,extra-android-m2repository,extra-google-m2repository,extra-android-support --all --no-ui;
- npm install -g npm
- npm install -g nativescript
- npm install
# CocoaPods
- gem install cocoapods --pre --no-rdoc --no-ri --no-document --quiet
- gem install xcpretty --no-rdoc --no-ri --no-document --quiet
- pod --version
- pod setup --silent
- pod repo update --silent
# Show environment invo
- node --version
- npm --version
- xcpretty --version
- xcodebuild -version
- xcodebuild -showsdks
- echo $ANDROID_HOME
- npm run clean
25 changes: 22 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,14 @@ Then modify the css file to isolate just the icon fonts needed. [Watch this vide
Use the classname prefix as the `key` and the css filename as the value relative to the `app` directory.

```typescript
import { TNSFontIconModule } from 'nativescript-ngx-fonticon';
import { TNSFontIconModule, TNSFontIconModuleModuleConfig } from 'nativescript-ngx-fonticon';

export function icons() {
return {
'fa': './assets/fonts/font-awesome.css',
'ion': './assets/fonts/ionicons.css'
};
}

@NgModule({
declarations: [
Expand All @@ -80,7 +87,10 @@ import { TNSFontIconModule } from 'nativescript-ngx-fonticon';
imports: [
NativeScriptModule,
TNSFontIconModule.forRoot({
'fa': 'font-awesome.css'
fonts: {
provide: TranslateLoader,
useFactory: (icons)
}
})
]
})
Expand All @@ -95,6 +105,12 @@ import { TNSFontIconModule, TNSFontIconService } from 'nativescript-ngx-fonticon
// turn debug on
TNSFontIconService.debug = true;

export function icons() {
return {
'fa': './assets/fonts/font-awesome.css'
};
}

@NgModule({
declarations: [
DemoComponent,
Expand All @@ -105,7 +121,10 @@ TNSFontIconService.debug = true;
imports: [
NativeScriptModule,
TNSFontIconModule.forRoot({
'fa': 'font-awesome.css'
fonts: {
provide: TranslateLoader,
useFactory: (icons)
}
})
]
})
Expand Down
6 changes: 0 additions & 6 deletions index.d.ts

This file was deleted.

29 changes: 18 additions & 11 deletions nativescript-ngx-fonticon.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,34 @@
import { NgModule, ModuleWithProviders} from '@angular/core';
import { NgModule, ModuleWithProviders, Provider } from '@angular/core';
import { TNSFontIconPipe, TNSFontIconPurePipe } from './src/app/pipes/fonticon.pipe';
import { TNSFontIconService } from './src/app/services/fonticon.service';
import { TNSFontIconService, USE_STORE } from './src/app/services/fonticon.service';

// for manual imports
export * from './src/app/pipes/fonticon.pipe';
export * from './src/app/services/fonticon.service';

const PIPES: Array<any> = [
TNSFontIconPipe,
TNSFontIconPurePipe
];
export class TNSFontIconModuleModuleConfig {
fonts?: Provider
}

@NgModule({
declarations: PIPES,
exports: PIPES
declarations: [
TNSFontIconPipe,
TNSFontIconPurePipe
],
exports: [
TNSFontIconPipe,
TNSFontIconPurePipe
]
})
export class TNSFontIconModule {

static forRoot(providedConfig: any): ModuleWithProviders {
TNSFontIconService.config = providedConfig;
static forRoot(providedConfig: TNSFontIconModuleModuleConfig = {}): ModuleWithProviders {
return {
ngModule: TNSFontIconModule,
providers: [TNSFontIconService]
providers: [
{ provide: USE_STORE, useValue: providedConfig },
TNSFontIconService
]
};
}
}
146 changes: 80 additions & 66 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,68 +1,82 @@
{
"name": "nativescript-ngx-fonticon",
"version": "2.0.0",
"description": "Use custom font icon collections seamlessly with NativeScript for Angular.",
"main": "nativescript-ngx-fonticon",
"typings": "index.d.ts",
"nativescript": {
"platforms": {
"android": "2.4.1",
"ios": "2.4.0"
"name": "nativescript-ngx-fonticon",
"version": "2.0.0",
"description": "Use custom font icon collections seamlessly with NativeScript for Angular.",
"main": "nativescript-ngx-fonticon",
"module": "nativescript-ngx-fonticon.js",
"typings": "nativescript-ngx-fonticon.d.ts",
"nativescript": {
"platforms": {
"android": "2.4.1",
"ios": "2.4.0"
}
},
"repository": {
"type": "git",
"url": "git+https://github.com/NathanWalker/nativescript-ngx-fonticon.git"
},
"keywords": [
"angular",
"angular2",
"ng",
"ngx",
"ng2",
"nativescript",
"icon",
"font"
],
"author": "Nathan Walker <[email protected]>",
"contributors": [{
"name": "Nathanael Anderson",
"email": "nathan@master-technology",
"url": "https://github.com/nathanaela"
},
{
"name": "Martin Reinhardt",
"email": "[email protected]",
"url": "https://github.com/hypery2k"
}
],
"license": "MIT",
"bugs": {
"url": "https://github.com/NathanWalker/nativescript-ngx-fonticon/issues"
},
"homepage": "https://github.com/NathanWalker/nativescript-ngx-fonticon#readme",
"scripts": {
"prebuild": "npm i && cd src && npm i",
"build": "ngc",
"clean": "rm -rf src/platforms",
"demo.ios": "npm run preparedemo; cd src; tns run ios --emulator",
"demo.android": "npm run preparedemo; cd src; tns run android --emulator",
"preparedemo": "npm run build; cd src; tns plugin remove nativescript-ngx-fonticon; tns plugin add ..; tns install"
},
"peerDependencies": {
"@angular/core": ">=2.0.0 || >=4.0.0-beta.0",
"nativescript-angular": ">=1.3.0",
"tns-core-modules": ">=2.4.4"
},
"devDependencies": {
"@angular/common": "2.4.3",
"@angular/compiler": "2.4.3",
"@angular/compiler-cli": "2.4.3",
"@angular/core": "2.4.3",
"@angular/forms": "2.4.3",
"@angular/http": "2.4.3",
"@angular/platform-browser": "2.4.3",
"@angular/platform-browser-dynamic": "2.4.3",
"@angular/platform-server": "2.4.3",
"@angular/router": "3.4.3",
"@types/hammerjs": "2.0.34",
"@types/jasmine": "2.5.41",
"@types/node": "7.0.5",
"nativescript-angular": "1.4.1",
"reflect-metadata": "0.1.9",
"rimraf": "^2.5.1",
"rxjs": "5.1.1",
"tns-core-modules": "2.4.4",
"traceur": "^0.0.91",
"typedoc": "^0.3.12",
"typescript": "~2.0.10",
"zone.js": "~0.7.2"
}
},
"repository": {
"type": "git",
"url": "git+https://github.com/NathanWalker/nativescript-ngx-fonticon.git"
},
"keywords": [
"angular",
"angular2",
"ng",
"ngx",
"ng2",
"nativescript",
"icon",
"font"
],
"author": "Nathan Walker <[email protected]>",
"contributors": [
{
"name": "Nathanael Anderson",
"email": "nathan@master-technology",
"url": "https://github.com/nathanaela"
}
],
"license": "MIT",
"bugs": {
"url": "https://github.com/NathanWalker/nativescript-ngx-fonticon/issues"
},
"homepage": "https://github.com/NathanWalker/nativescript-ngx-fonticon#readme",
"scripts": {
"build": "tsc",
"clean": "rm -rf src/platforms",
"demo.ios": "npm run preparedemo; cd src; tns run ios --emulator",
"demo.android": "npm run preparedemo; cd src; tns run android --emulator",
"preparedemo": "npm run build; cd src; tns plugin remove nativescript-ngx-fonticon; tns plugin add ..; tns install"
},
"dependencies": {
"@angular/common": "2.3.1",
"@angular/compiler": "2.3.1",
"@angular/core": "2.3.1",
"@angular/forms": "2.3.1",
"@angular/http": "2.3.1",
"@angular/platform-browser": "2.3.1",
"@angular/platform-browser-dynamic": "2.3.1",
"@angular/router": "3.3.1",
"nativescript-angular": "1.3.0",
"reflect-metadata": "^0.1.8",
"rxjs": "5.0.0-rc.4",
"tns-core-modules": "^2.4.4"
},
"devDependencies": {
"rimraf": "^2.5.1",
"traceur": "^0.0.91",
"typedoc": "^0.3.12",
"typescript": "~2.0.10",
"zone.js": "~0.7.2"
}
}
}
3 changes: 2 additions & 1 deletion src/app/package.json
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
"v8Flags": "--expose_gc"
},
"devDependencies": {
"nativescript-dev-typescript": "^0.3.0"
"nativescript-dev-typescript": "^0.3.0",
"typescript": "^2.2.1"
},
"_id": "[email protected]",
"_shasum": "a567c2b9a56024818c06596dab9629d155c5b8a8",
Expand Down
Loading