Skip to content

Commit 2ca1a71

Browse files
committed
feat: new tabs component to replace N one
1 parent a837d08 commit 2ca1a71

File tree

13 files changed

+2472
-0
lines changed

13 files changed

+2472
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
node_modules/
2+
bin/
3+
src/
4+
hooks/
5+
*.ts
6+
*.old
7+
tsconfig.json
8+
!*.d.ts
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"name": "nativescript-material-tabs",
3+
"version": "3.1.17",
4+
"description": "Material Tabs component",
5+
"main": "./tabs",
6+
"typings": "./tabs.d.ts",
7+
"scripts": {
8+
"tsc-win": "..\\..\\node_modules\\.bin\\tsc && copy ..\\..\\src\\tabs\\tabs.d.ts .\\",
9+
"tsc": "cp ../../src/tabs/tabs.d.ts ./ && ../../node_modules/.bin/tsc --skipLibCheck",
10+
"ngc-win": "..\\..\\node_modules\\.bin\\ngc",
11+
"ngc": "NODE_OPTIONS=--max_old_space_size=8192 ../../node_modules/.bin/ngc",
12+
"clean": "../../node_modules/.bin/rimraf ./*.d.ts ./*.js ./*.js.map"
13+
},
14+
"nativescript": {
15+
"platforms": {
16+
"android": "6.2.0",
17+
"ios": "6.2.0"
18+
}
19+
},
20+
"keywords": [
21+
"NativeScript",
22+
"JavaScript",
23+
"Android",
24+
"iOS"
25+
],
26+
"author": {
27+
"name": "Martin Guillon",
28+
"email": "[email protected]"
29+
},
30+
"bugs": {
31+
"url": "https://github.com/Akylas/nativescript-material-components/issues"
32+
},
33+
"license": "Apache-2.0",
34+
"homepage": "https://github.com/Akylas/nativescript-material-components",
35+
"readmeFilename": "README.md",
36+
"dependencies": {
37+
"nativescript-material-core": "^3.1.17"
38+
}
39+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pod 'MaterialComponents/Tabs+ColorThemer'
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"extends": "../../tsconfig.json",
3+
"compilerOptions": {
4+
"rootDir": "../../src/tabs",
5+
"outDir": "./",
6+
"paths": {
7+
"tns-core-modules": ["./node_modules/@nativescript/core"],
8+
"tns-core-modules/*": ["./node_modules/@nativescript/core/*"],
9+
"*": ["node_modules/*", "packages/*"]
10+
}
11+
},
12+
"include": ["../../src/tabs/**/*.ts", "../../references.d.ts", "../../src/references.d.ts"]
13+
}

src/tabs/angular/index.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { NgModule } from '@angular/core';
2+
import { registerElement } from '@nativescript/angular/element-registry';
3+
4+
import { Directive } from '@angular/core';
5+
6+
@Directive({ selector: 'MDTabs' })
7+
export class MaterialTabsDirective {}
8+
9+
@NgModule({
10+
declarations: [MaterialTabsDirective],
11+
exports: [MaterialTabsDirective]
12+
})
13+
export class NativeScriptMaterialTabsModule {}
14+
15+
registerElement('MDTabs', () => require('../tabs').Tabs);

src/tabs/angular/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"main": "index.js"
3+
}

src/tabs/tabs-common.ts

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
// Types
2+
import { Tabs as TabsDefinition } from "./tabs";
3+
4+
// Requires
5+
import { TabNavigationBase } from "@nativescript/core/ui/tab-navigation-base/tab-navigation-base";
6+
import { CSSType, booleanConverter } from "@nativescript/core/ui/core/view";
7+
import { Property } from "@nativescript/core/ui/core/properties";
8+
9+
declare module '@nativescript/core/data/observable' {
10+
interface Observable {
11+
_emit(eventName: string);
12+
}
13+
}
14+
declare module '@nativescript/core/ui/core/view/view' {
15+
interface View {
16+
callLoaded(): void;
17+
_getFragmentManager();
18+
}
19+
}
20+
declare module '@nativescript/core/ui/frame' {
21+
interface Frame {
22+
_pushInFrameStackRecursive();
23+
_animationInProgress: boolean;
24+
}
25+
}
26+
declare module '@nativescript/core/ui/tab-navigation-base/tab-strip-item' {
27+
namespace TabStripItem {
28+
const selectEvent: string;
29+
const unselectEvent: string;
30+
}
31+
interface TabStripItem {
32+
_index: number;
33+
}
34+
}
35+
36+
// export * from "@nativescript/core/ui/tab-navigation-base/tab-content-item";
37+
// export * from "@nativescript/core/ui/tab-navigation-base/tab-navigation-base";
38+
// export * from "@nativescript/core/ui/tab-navigation-base/tab-strip";
39+
// export * from "@nativescript/core/ui/tab-navigation-base/tab-strip-item";
40+
41+
export const traceCategory = "TabView";
42+
43+
export module knownCollections {
44+
export const items = "items";
45+
}
46+
47+
@CSSType("Tabs")
48+
export class TabsBase extends TabNavigationBase implements TabsDefinition {
49+
public swipeEnabled: boolean;
50+
public offscreenTabLimit: number;
51+
public tabsPosition: "top" | "bottom";
52+
public iOSTabBarItemsAlignment: IOSTabBarItemsAlignment;
53+
}
54+
55+
// TODO: Add Unit tests
56+
export const swipeEnabledProperty = new Property<TabsBase, boolean>({
57+
name: "swipeEnabled", defaultValue: true, valueConverter: booleanConverter
58+
});
59+
swipeEnabledProperty.register(TabsBase);
60+
61+
// TODO: Add Unit tests
62+
// TODO: Coerce to max number of items?
63+
export const offscreenTabLimitProperty = new Property<TabsBase, number>({
64+
name: "offscreenTabLimit", defaultValue: 1, valueConverter: (v) => parseInt(v)
65+
});
66+
offscreenTabLimitProperty.register(TabsBase);
67+
68+
export const tabsPositionProperty = new Property<TabsBase, "top" | "bottom">({ name: "tabsPosition", defaultValue: "top" });
69+
tabsPositionProperty.register(TabsBase);
70+
71+
export type IOSTabBarItemsAlignment = "leading" | "justified" | "center" | "centerSelected";
72+
export const iOSTabBarItemsAlignmentProperty = new Property<TabsBase, IOSTabBarItemsAlignment>({ name: "iOSTabBarItemsAlignment", defaultValue: "justified" });
73+
iOSTabBarItemsAlignmentProperty.register(TabsBase);

0 commit comments

Comments
 (0)