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

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
bradmartin committed Apr 23, 2018
1 parent ba3ea90 commit c76e1aa
Show file tree
Hide file tree
Showing 15 changed files with 93 additions and 98 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*.js
!src/scripts/*.js
*.js.map
*.log
*.d.ts
Expand All @@ -10,6 +11,5 @@ demo/platforms
demo/node_modules
demo/.vscode
node_modules
.vscode/
*.DS_Store
package-lock.json
8 changes: 4 additions & 4 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"singleQuote": true,
"semi": true,
"printWidth": 120
}
"singleQuote": true,
"semi": true,
"printWidth": 120
}
9 changes: 9 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"files.watcherExclude": {
"**/.git/objects/**": true,
"**/.git/subtree-cache/**": true,
"**/platforms/**": true,
"**/hooks/**": true,
"**/node_modules/**": true
}
}
29 changes: 0 additions & 29 deletions CONTRIBUTING.md

This file was deleted.

18 changes: 5 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ Be sure to run a new build after adding plugins to avoid any issues. Here is a p

### Usage

_iOS note: Setting a background-color will help if you do not see the card on the page._

## Plain NativeScript

<span style="color:red">IMPORTANT: </span>_Make sure you include `xmlns:Card="nativescript-cardview"` on the Page element_
Expand Down Expand Up @@ -85,12 +87,12 @@ Be sure to run a new build after adding plugins to avoid any issues. Here is a p
}
```

## Angular NativeScript
## NativeScript + Angular

```TS
```typescript
import { registerElement } from 'nativescript-angular/element-registry';
import { CardView } from 'nativescript-cardview';
registerElement("CardView", () => CardView);
registerElement('CardView', () => CardView);
```

```html
Expand Down Expand Up @@ -168,10 +170,6 @@ shadowRadius = 1;
| --------------------------------------- | --------------------------------------- |
| ![Sample1](images/sample_card1_ios.png) | ![Sample2](images/sample_card3_ios.png) |

#### Contributing

[Please follow here](https://github.com/bradmartin/nativescript-cardview/blob/master/CONTRIBUTING.md)

#### Contributors

| [<img alt="bradmartin" src="https://avatars3.githubusercontent.com/u/6006148?v=3&s=117" width="117">](https://github.com/bradmartin) | [<img alt="NathanWalker" src="https://avatars1.githubusercontent.com/u/457187?v=3&s=117" width="117">](https://github.com/NathanWalker) | [<img alt="manijak" src="https://avatars3.githubusercontent.com/u/3605066?v=3&s=117" width="117">](https://github.com/manijak) | [<img alt="NathanaelA" src="https://avatars0.githubusercontent.com/u/850871?v=3&s=117" width="117">](https://github.com/NathanaelA) | [<img alt="EddyVerbruggen" src="https://avatars2.githubusercontent.com/u/1426370?v=3&s=117" width="117">](https://github.com/EddyVerbruggen) | [<img alt="sis0k0" src="https://avatars1.githubusercontent.com/u/7893485?v=3&s=117" width="117">](https://github.com/sis0k0) |
Expand All @@ -181,9 +179,3 @@ shadowRadius = 1;
| [<img alt="vladimirnani" src="https://avatars0.githubusercontent.com/u/3397077?v=3&s=117" width="117">](https://github.com/vladimirnani) | [<img alt="DickSmith" src="https://avatars0.githubusercontent.com/u/6675511?v=3&s=117" width="117">](https://github.com/DickSmith) |
| :--------------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------: |
| [vladimirnani](https://github.com/vladimirnani) | [DickSmith](https://github.com/DickSmith) |

## [nStudio, LLC](http://nstudio.io)

[![nStudio](./images/nstudio-banner.png 'nStudio')](http://nStudio.io)

Do you need assistance on your project or plugin? Contact the nStudio team anytime at <mailto:[email protected]> to get up to speed with the best practices in mobile and web app development.
19 changes: 9 additions & 10 deletions demo/app/main-page.xml
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
<page xmlns="http://schemas.nativescript.org/tns.xsd"
xmlns:Card="nativescript-cardview"
loaded="pageLoaded">

<page
xmlns="http://schemas.nativescript.org/tns.xsd"
xmlns:Card="nativescript-cardview" loaded="pageLoaded">
<action-bar title="CardView" backgroundColor="#009688" color="#fff" />
<scroll-view>
<stack-layout>
<Card:CardView class="blackCard" radius="10" loaded="cardLoaded" elevation="20" margin="10" id="batCard">
<grid-layout rows="200, auto, auto" columns="auto, auto, *">
<image src="~/images/batman.jpg" stretch="aspectFill" margin="10" colSpan="3" row="0" />
<label text="Batman wants to be friends?" class="info" textWrap="true" row="1" colSpan="3" />
<button text="DECLINE" tap="{{ goAway }}" class="blue" row="2" col="0" />
<button text="ACCEPT" class="blue" row="2" col="1" />
<Card:CardView margin="5" loaded="{{ cardLoaded }}" id="batCard" class="whiteCard">
<grid-layout rows="200, auto, auto" columns="*, *">
<image src="~/images/batman.jpg" stretch="aspectFill" margin="10" colSpan="2" row="0" />
<label text="Batman wants to be friends?" class="info" textWrap="true" row="1" colSpan="2" />
<button text="Decline" tap="{{ goAway }}" class="blue" row="2" col="0" />
<button text="Accept" tap="{{ goAway }}" class="blue" row="2" col="1" />
</grid-layout>
</Card:CardView>
<grid-layout rows="*" columns="*, *">
Expand Down
2 changes: 1 addition & 1 deletion demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"nativescript": {
"id": "org.nativescript.demo",
"tns-android": {
"version": "4.0.0"
"version": "4.0.1"
},
"tns-ios": {
"version": "4.0.1"
Expand Down
13 changes: 12 additions & 1 deletion src/.npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
.vs/
demo/
screenshots/
node_modules/
scripts/
images/
.sln
*.sln
Expand All @@ -13,4 +15,13 @@ README.md
!index.d.ts
*.map
tsconfig.json
*.log
*.log

*.map
*.ts
!*.d.ts
tsconfig.json
platforms/android/*
!platforms/android/include.gradle
!platforms/android/*.aar
!platforms/android/*.jar
29 changes: 10 additions & 19 deletions src/cardview-common.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
import { Color } from "tns-core-modules/color";
import { ContentView } from "tns-core-modules/ui/content-view";
import {
backgroundColorProperty,
backgroundInternalProperty,
Property
} from "tns-core-modules/ui/core/view";

export {
backgroundColorProperty,
backgroundInternalProperty
} from "tns-core-modules/ui/core/view";
import { Color } from 'tns-core-modules/color';
import { ContentView, Property } from 'tns-core-modules/ui/content-view';
export { backgroundColorProperty, backgroundInternalProperty } from 'tns-core-modules/ui/core/view';

/**
* Contains the CardView class, which represents a card view component.
Expand Down Expand Up @@ -62,43 +53,43 @@ export class CardViewCommon extends ContentView {
}

export const radiusProperty = new Property<CardViewCommon, number>({
name: "radius",
name: 'radius',
valueConverter: value => +value
});
radiusProperty.register(CardViewCommon);

export const elevationProperty = new Property<CardViewCommon, number>({
name: "elevation",
name: 'elevation',
valueConverter: value => +value
});
elevationProperty.register(CardViewCommon);

export const shadowRadiusProperty = new Property<CardViewCommon, number>({
name: "shadowRadius",
name: 'shadowRadius',
valueConverter: value => +value
});
shadowRadiusProperty.register(CardViewCommon);

export const shadowOffsetWidthProperty = new Property<CardViewCommon, number>({
name: "shadowOffsetWidth",
name: 'shadowOffsetWidth',
valueConverter: value => +value
});
shadowOffsetWidthProperty.register(CardViewCommon);

export const shadowOffsetHeightProperty = new Property<CardViewCommon, number>({
name: "shadowOffsetHeight",
name: 'shadowOffsetHeight',
valueConverter: value => +value
});
shadowOffsetHeightProperty.register(CardViewCommon);

export const shadowColorProperty = new Property<CardViewCommon, Color>({
name: "shadowColor",
name: 'shadowColor',
valueConverter: value => new Color(value)
});
shadowColorProperty.register(CardViewCommon);

export const shadowOpacityProperty = new Property<CardViewCommon, number>({
name: "shadowOpacity",
name: 'shadowOpacity',
valueConverter: value => +value
});
shadowOpacityProperty.register(CardViewCommon);
6 changes: 3 additions & 3 deletions src/cardview.android.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/// <reference path="./node_modules/tns-platform-declarations/android.d.ts" />

import { Color } from 'tns-core-modules/color';
import {
backgroundColorProperty,
Expand All @@ -7,8 +9,6 @@ import {
radiusProperty
} from './cardview-common';

declare var android: any;

export class CardView extends CardViewCommon {
private _androidViewId: number;
public nativeView;
Expand All @@ -26,7 +26,7 @@ export class CardView extends CardViewCommon {
}

public createNativeView() {
return new android.support.v7.widget.CardView(this._context);
return new (android.support.v7.widget as any).CardView(this._context);
}

public initNativeView() {
Expand Down
10 changes: 5 additions & 5 deletions src/cardview.ios.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/// <reference path="./node_modules/tns-platform-declarations/ios.d.ts" />

import { Color } from 'tns-core-modules/color';
import { screen } from 'tns-core-modules/platform';
import {
Expand All @@ -12,15 +14,13 @@ import {
shadowRadiusProperty
} from './cardview-common';

declare var UIView: any, CGRectMake: any, CGSizeMake: any;

export class CardView extends CardViewCommon {
public nativeView;
public nativeView: UIView;

constructor() {
super();
let width = screen.mainScreen.widthDIPs - 20;
this.nativeView = new UIView(CGRectMake(10, 30, width, 0));
const width = screen.mainScreen.widthDIPs - 20;
this.nativeView = new UIView({ frame: CGRectMake(10, 30, width, 0) });
this.nativeView.layer.masksToBounds = false;
this.shadowColor = 'black';
this.radius = 1;
Expand Down
2 changes: 1 addition & 1 deletion src/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ContentView } from "ui/content-view";
import { ContentView } from 'tns-core-modules/ui/content-view';

/**
* Contains the CardView class, which represents a card view component.
Expand Down
18 changes: 8 additions & 10 deletions src/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nativescript-cardview",
"version": "3.0.0",
"version": "3.0.1",
"description": "A NativeScript plugin for Material Design CardView component.",
"main": "cardview",
"typings": "index.d.ts",
Expand All @@ -12,7 +12,8 @@
},
"scripts": {
"tsc": "tsc -skipLibCheck",
"build": "npm i && tsc",
"build": "npm i && tsc && npm run build.native",
"build.native": "node scripts/build-native.js",
"postclone": "npm i && node scripts/postclone.js && cd ../demo && npm i && cd ../src && npm run plugin.link",
"test.android":
"npm i && npm run tsc && npm run tslint && cd ../demo && tns build android && tns test android --justlaunch",
Expand All @@ -27,7 +28,7 @@
"clean":
"cd ../demo && rimraf hooks node_modules platforms && cd ../src && rimraf node_modules && npm run plugin.link",
"ci.tslint": "npm i && tslint '**/*.ts' --config '../tslint.json' --exclude '**/node_modules/**'",
"prepare": "node scripts/prepare.js"
"prepack": "npm run build.native"
},
"lint-staged": {
"*.ts": ["prettier --write", "git add"]
Expand Down Expand Up @@ -86,14 +87,11 @@
"homepage": "https://github.com/bradmartin/nativescript-cardview",
"readme": "README.md",
"readmeFilename": "README.md",
"peerDependencies": {
"tns-core-modules": "^3.3.0"
},
"devDependencies": {
"husky": "^0.13.4",
"lint-staged": "^3.6.1",
"prettier": "^1.12.0",
"tns-core-modules": "^3.4.0",
"husky": "^0.14.3",
"lint-staged": "^7.0.4",
"prettier": "^1.12.1",
"tns-core-modules": "^4.0.0",
"tns-platform-declarations": "~3.4.0",
"typescript": "2.6.2",
"prompt": "^1.0.0",
Expand Down
24 changes: 24 additions & 0 deletions src/scripts/build-native.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const { exec } = require('child_process');
const semver = require('semver');

exec('tns --version', (err, stdout, stderr) => {
if (err) {
// node couldn't execute the command
console.log(`tns --version err: ${err}`);
return;
}

const tnsVersion = semver.major(stdout);

// execute 'tns plugin build' for {N} version > 4. This command builds .aar in platforms/android folder.
if (tnsVersion >= 4) {
console.log(`executing 'tns plugin build'`);
exec('tns plugin build', (err, stdout, stderr) => {
if (err) {
// node couldn't execute the command
console.log(`${err}`);
return;
}
});
}
});
2 changes: 1 addition & 1 deletion src/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"lib": ["es6", "dom"],
"baseUrl": ".",
"paths": {
"*": ["./node_modules/tns-core-modules/*", "./node_modules/*"]
"*": ["./node_modules/tns-core-modules/*", "./node_modules/*", "demo/node_modules", "platforms"]
}
},
"files": ["cardview-common.ts", "cardview.android.ts", "cardview.ios.ts"],
Expand Down

0 comments on commit c76e1aa

Please sign in to comment.