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

Commit 4f27811

Browse files
committed
fix npmignore
1 parent f125a94 commit 4f27811

8 files changed

+103
-58
lines changed

.npmignore

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,12 @@
33
.vs/
44
demo/
55
screenshots/
6-
nativescript-snackbar.sln
76
.sln
87
*.sln
98
*.png
10-
CONTRIBUTING.md
9+
CONTRIBUTING.md
10+
*.ts
11+
!index.d.ts
12+
!cardview.d.ts
13+
*.map
14+
tsconfig.json

cardview.android.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
import {ContentView} from 'ui/content-view';
22
import {PropertyMetadata} from "ui/core/proxy";
33
import {Property, PropertyMetadataSettings} from "ui/core/dependency-observable";
4+
import { View } from "ui/core/view";
5+
import { Color } from "color";
46
import style = require("ui/styling/style");
5-
import view = require("ui/core/view");
6-
import color = require("color");
77

8+
declare var android: any;
89

910
export class CardView extends ContentView {
1011
private _radius: number;
1112
private _elevation: number;
13+
private _androidViewId: number;
1214
private _android: android.support.v7.widget.CardView;
1315

14-
get android(): android.support.v7.widget.CardView {
16+
get android(): any {
1517
return this._android;
1618
}
1719

18-
get _nativeView(): android.support.v7.widget.CardView {
20+
get _nativeView(): any {
1921
return this._android;
2022
}
2123

@@ -51,13 +53,13 @@ export class CardView extends ContentView {
5153

5254
export class CardViewStyler implements style.Styler {
5355

54-
private static setBackgroundProperty(view: view.View, newValue: any) {
56+
private static setBackgroundProperty(view: View, newValue: any) {
5557
var card = <android.support.v7.widget.CardView>view.android;
56-
var droidColor = new color.Color(newValue).android;
58+
var droidColor = new Color(newValue).android;
5759
card.setCardBackgroundColor(droidColor);
5860
}
5961

60-
private static resetBackgroundProperty(view: view.View, nativeValue: number) {
62+
private static resetBackgroundProperty(view: View, nativeValue: number) {
6163
// Do nothing.
6264
}
6365

cardview.d.ts

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/**
2+
* Contains the CardView class, which represents a card view component.
3+
*/
4+
5+
declare module "nativescript-cardview" {
6+
import { Property } from "ui/core/dependency-observable";
7+
import { ContentView } from "ui/content-view";
8+
9+
/**
10+
* Represents a CardView component.
11+
*/
12+
export class CardView extends ContentView {
13+
public static radiusProperty: Property;
14+
public static elevationProperty: Property;
15+
public static shadowOffsetWidth: Property;
16+
public static shadowOffsetHeight: Property;
17+
public static shadowColor: Property;
18+
public static shadowOpacity: Property;
19+
20+
21+
/**
22+
* Gets the native [android widget](https://developer.android.com/reference/android/support/v7/widget/CardView.html) that represents the user interface for this component. Valid only when running on Android OS.
23+
*/
24+
android: any /* android.support.v7.widget.CardView */;
25+
26+
/**
27+
* Gets the native [ios widget](https://github.com/NathanWalker/MaterialCard) that represents the user interface for this component. Valid only when running on iOS.
28+
*/
29+
ios: any /* MaterialCard */;
30+
31+
/**
32+
* Gets or set the radius of the card view.
33+
*/
34+
radius: any;
35+
36+
/**
37+
* Gets or set the elevation of the card view. ** Valid only when running on Android OS **
38+
*/
39+
elevation: number;
40+
41+
/**
42+
* Set the shadow offset height of the card view. ** Valid only when running on iOS **
43+
*/
44+
shadowOffsetWidth: string;
45+
46+
47+
/**
48+
* Set the shadow offset height of the card view. ** Valid only when running on iOS **
49+
*/
50+
shadowOffsetHeight: string;
51+
52+
/**
53+
* Set the shadow color of the card view. ** Valid only when running on iOS **
54+
*/
55+
shadowColor: string;
56+
57+
/**
58+
* Set the shadow opacity of the card view. ** Valid only when running on iOS **
59+
*/
60+
shadowOpacity: string;
61+
62+
}
63+
64+
}

cardview.ios.ts

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import {ContentView} from 'ui/content-view';
2-
import {Color} from "color";
3-
import * as uiUtils from 'ui/utils';
2+
import {Color} from 'color';
43
import {PropertyMetadata} from 'ui/core/proxy';
54
import {Property, PropertyMetadataSettings} from 'ui/core/dependency-observable';
6-
import * as Platform from 'platform';
5+
import { screen } from 'platform';
6+
import * as uiUtils from 'ui/utils';
7+
78

89
declare var MaterialCard: any, UIApplication: any, CGRectMake: any;
910

@@ -12,7 +13,7 @@ export class CardView extends ContentView {
1213

1314
constructor() {
1415
super();
15-
let width = Platform.screen.mainScreen.widthDIPs - 20;
16+
let width = screen.mainScreen.widthDIPs - 20;
1617
this._ios = new MaterialCard(CGRectMake(10, 30, width, 0));
1718

1819
// Default values for MaterialCard
@@ -21,41 +22,33 @@ export class CardView extends ContentView {
2122
// shadowOffsetHeight = 2;
2223
// shadowColor = new Color('#000').ios
2324
// shadowOpacity = 0.4;
24-
25-
// console.log(`CardView constructor ------`);
26-
// console.log(this._ios);
2725
}
2826

29-
get ios(): MaterialCard {
27+
get ios(): any {
3028
return this._ios;
3129
}
3230

33-
get _nativeView(): MaterialCard {
31+
get _nativeView(): any {
3432
return this._ios;
3533
}
3634

3735
set radius(value: string) {
38-
// console.log(`radius: ${value}`);
3936
this._ios.cornerRadius = +value;
4037
}
4138

4239
set shadowOffsetWidth(value: string) {
43-
// console.log(`shadowOffsetWidth: ${value}`);
4440
this._ios.shadowOffsetWidth = +value;
4541
}
4642

4743
set shadowOffsetHeight(value: string) {
48-
// console.log(`shadowOffsetHeight: ${value}`);
4944
this._ios.shadowOffsetHeight = +value;
5045
}
5146

5247
set shadowColor(value: string) {
53-
// console.log(`shadowColor: ${value}`);
5448
this._ios.shadowColor = new Color(value).ios;
5549
}
5650

5751
set shadowOpacity(value: string) {
58-
// console.log(`shadowOpacity: ${value}`);
5952
this._ios.shadowOpacity = +value;
6053
}
6154

demo/app/main-view-model.ts

Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
import {Observable, EventData} from 'data/observable';
21
import * as frame from 'ui/frame';
32
import * as app from 'application';
3+
import { Observable, EventData } from 'data/observable';
4+
import { isAndroid, isIOS } from "platform";
5+
import { CardView } from 'nativescript-cardview';
46

57
export class Demo extends Observable {
68

@@ -9,9 +11,8 @@ export class Demo extends Observable {
911
}
1012

1113
public goAway(args) {
12-
var page = frame.topmost().currentPage;
13-
var card = page.getViewById('batCard');
14-
console.log(card);
14+
let page = frame.topmost().currentPage;
15+
let card = <CardView>page.getViewById('batCard');
1516
card.animate({
1617
scale: { x: 0, y: 0 },
1718
opacity: 0,
@@ -22,9 +23,8 @@ export class Demo extends Observable {
2223
}
2324

2425
public goAwayJoker(args) {
25-
var page = frame.topmost().currentPage;
26-
var card = page.getViewById('jokerCard');
27-
console.log(card);
26+
let page = frame.topmost().currentPage;
27+
let card = page.getViewById('jokerCard');
2828
card.animate({
2929
scale: { x: 0, y: 0 },
3030
opacity: 0,
@@ -35,31 +35,12 @@ export class Demo extends Observable {
3535
}
3636

3737
public cardLoaded(args: EventData) {
38-
try {
39-
var card = args.object;
40-
console.log('card = ' + card);
41-
//console.log('card id = ' + card.id);
42-
if (app.android) {
43-
var androidCard = card.android;
44-
console.log('card native android = ' + androidCard);
45-
//console.log('radius = ' + card.radius);
46-
//console.log('elevation = ' + card.elevation);
47-
//console.log('padding = ' + card.padding);
48-
//console.log('card background = ' + card.backgroundColor.android);
49-
//var btn = new android.widget.Button(app.android.currentContext);
50-
//btn.setText('Hello Baby!');
51-
//androidCard.addView(btn);
52-
} else if (app.ios) {
53-
var iosCard = card.ios;
54-
console.log('card native ios = ' + iosCard);
55-
console.log(iosCard);
56-
}
57-
58-
// var sl = frame.topmost().currentPage.getViewById('stack');
59-
// console.log('sl = ' + sl);
60-
61-
} catch (error) {
62-
console.log(error);
38+
let card = <CardView>args.object;
39+
console.log('card = ' + card);
40+
if (isAndroid) {
41+
console.log('card native android = ' + card.android);
42+
} else if (isIOS) {
43+
console.log('card native ios = ' + card.ios);
6344
}
6445
}
6546

demo/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"version": "2.0.0"
66
},
77
"tns-android": {
8-
"version": "2.0.0"
8+
"version": "2.1.1"
99
}
1010
},
1111
"dependencies": {

index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './cardview'

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "nativescript-cardview",
3-
"version": "1.1.7",
4-
"description": "A NativeScript plugin to provide an XML widget to implement the Material Design CardView.",
3+
"version": "1.1.9",
4+
"description": "A NativeScript plugin for Material Design CardView component.",
55
"main": "cardview.js",
66
"nativescript": {
77
"platforms": {

0 commit comments

Comments
 (0)