-
Notifications
You must be signed in to change notification settings - Fork 445
/
native.module.ts
92 lines (81 loc) · 2.89 KB
/
native.module.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// nativescript
import {
NativeScriptRouterModule,
RouterExtensions as TNSRouterExtensions
} from 'nativescript-angular/router';
import { SegmentedBarItem } from 'tns-core-modules/ui/segmented-bar';
// angular
import { NgModule, CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA } from '@angular/core';
// libs
import { StoreModule } from '@ngrx/store';
import { EffectsModule } from '@ngrx/effects';
// app
import {
WindowService,
ConsoleService,
RouterExtensions,
AppService
} from './app/modules/core/index';
import { AppComponent } from './app/components/app.component';
import { routes } from './app/components/app.routes';
// feature modules
import { CoreModule } from './app/modules/core/core.module';
import { AppReducer } from './app/modules/ngrx/index';
import { MultilingualEffects } from './app/modules/i18n/index';
import { SampleEffects } from './app/modules/sample/index';
import { ComponentsModule, cons, consoleLogTarget } from './components.module';
// {N} custom app specific
import { WindowNative, NSAppService } from './mobile/core/index';
import { NS_ANALYTICS_PROVIDERS } from './mobile/analytics/index';
/**
* Config
* Seed provided configuration options
*/
import { Config, LogTarget } from './app/modules/core/index';
import { Page } from 'ui/page';
Config.PageClass = Page;
// (required) platform target (allows component decorators to use the right view template)
Config.PLATFORM_TARGET = Config.PLATFORMS.MOBILE_NATIVE;
// (optional) log level - defaults to no logging if not set
Config.DEBUG.LEVEL_4 = true;
import { Languages, LanguageViewHelper } from './app/modules/i18n/index';
// helper for SegmentedBar view bindings in lang-switcher shared component
export function segmentViewHelper(languages) {
let segmentItems = [];
for (let lang of languages) {
// {N} requires items to be SegmentedBarItem class
let item = new SegmentedBarItem();
item.title = lang.title;
(<any>item).code = lang.code;
segmentItems.push(item);
}
return segmentItems;
}
@NgModule({
imports: [
CoreModule.forRoot([
{ provide: WindowService, useClass: WindowNative },
{ provide: ConsoleService, useFactory: (cons) },
{ provide: LogTarget, multi: true, deps: [ConsoleService], useFactory: (consoleLogTarget) }
]),
ComponentsModule,
NativeScriptRouterModule.forRoot(<any>routes),
StoreModule.provideStore(AppReducer),
EffectsModule.run(MultilingualEffects),
EffectsModule.run(SampleEffects)
],
providers: [
NS_ANALYTICS_PROVIDERS,
{ provide: RouterExtensions, useClass: TNSRouterExtensions },
{ provide: AppService, useClass: NSAppService },
// i18n
{ provide: Languages, useValue: Config.GET_SUPPORTED_LANGUAGES() },
{ provide: LanguageViewHelper, deps: [Languages], useFactory: (segmentViewHelper) }
],
schemas: [
NO_ERRORS_SCHEMA,
CUSTOM_ELEMENTS_SCHEMA
],
bootstrap: [AppComponent]
})
export class NativeModule { }