Skip to content

Commit 4f48898

Browse files
committed
update
1 parent 750fe44 commit 4f48898

File tree

8 files changed

+62
-34
lines changed

8 files changed

+62
-34
lines changed

.npmignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ nativescript-fab.sln
55
.sln
66
*.sln
77
demo/
8-
sample1.png
9-
sample2.png
8+
screens/
9+

README.md

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,33 @@ XML widget to create the Material Design Floating Action Button for Android Nati
88

99
### Screenshot
1010
---------------
11-
![FAB Screenshot](sample.png)
11+
![FAB Screenshot](screens/fab.png)
1212

1313
## Usage
1414

1515
#### XML
1616
##### **NOTE** The sample XML here will position the FAB on top of the ListView. There is no need for absolute positioning.
1717
```XML
18-
<Page xmlns="http://schemas.nativescript.org/tns.xsd"
18+
<Page xmlns="http://schemas.nativescript.org/tns.xsd" loaded="pageLoaded"
1919
xmlns:FAB="nativescript-floatingactionbutton">
20-
<grid-layout rows="auto, *, auto">
21-
<list-view row="1">
22-
<list-view.itemTemplate>
23-
<label text="Hello" />
24-
</list-view.itemTemplate>
25-
</list-view>
26-
<android row="1">
27-
<FAB:fab tap="fabTap" icon="ic_menu_camera" backColor="#ff4081" rippleColor="#f1f1f1" class="fab-button" />
28-
</android>
29-
</grid-layout>
20+
<Page.actionBar>
21+
<ActionBar title="Native FAB" backgroundColor="#3F51B5" color="#fff" />
22+
</Page.actionBar>
23+
<grid-layout rows="auto, *">
24+
<list-view row="1" items="{{ users }}">
25+
<list-view.itemTemplate>
26+
<label text="{{ name }}" textWrap="true" fontSize="18" margin="20" />
27+
</list-view.itemTemplate>
28+
</list-view>
29+
<android row="1">
30+
<FAB:fab tap="fabTap"
31+
row="1"
32+
icon="res://ic_add_white"
33+
backColor="#ff4081"
34+
rippleColor="#f1f1f1"
35+
class="fab-button" />
36+
</android>
37+
</grid-layout>
3038
</Page>
3139
```
3240

demo/app/main-page.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
11
var app = require("application");
2+
var observable = require("data/observable");
23
var platformModule = require("platform");
34
var color = require("color");
5+
6+
var users = [
7+
{ name: 'Billy Bob' },
8+
{ name: 'Tweeder' },
9+
{ name: 'Mox' },
10+
{ name: 'Coach' },
11+
{ name: 'Lance' },
12+
{ name: 'Johnson' },
13+
{ name: 'William' },
14+
{ name: 'Franklin' },
15+
{ name: 'Napoleon' },
16+
];
17+
var viewModel = new observable.Observable({
18+
users: users
19+
});
420

521
function pageLoaded(args) {
622
var page = args.object;
@@ -9,5 +25,6 @@ function pageLoaded(args) {
925
var window = app.android.startActivity.getWindow();
1026
window.setStatusBarColor(new color.Color("#303F9F").android);
1127
}
28+
page.bindingContext = viewModel;
1229
}
1330
exports.pageLoaded = pageLoaded;

demo/app/main-page.xml

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
1-
<Page xmlns="http://schemas.nativescript.org/tns.xsd"
2-
xmlns:FAB="nativescript-floatingactionbutton" loaded="pageLoaded">
3-
<Page.actionBar>
4-
<ActionBar title="NativeScript-SignaturePad" color="#fff" backgroundColor="#3F51B5" />
5-
</Page.actionBar>
6-
<StackLayout>
7-
<grid-layout rows="auto, *" id="main-content">
8-
<label text="Native FAB down there..." class="title" row="0" />
9-
10-
<FAB:fab tap="fabTap"
11-
row="1"
12-
icon="res://ic_add_white"
13-
backColor="#ff4081"
14-
rippleColor="#f1f1f1"
15-
class="fab-button" />
16-
</grid-layout>
17-
</StackLayout>
18-
</Page>
1+
<Page xmlns="http://schemas.nativescript.org/tns.xsd" loaded="pageLoaded"
2+
xmlns:FAB="nativescript-floatingactionbutton">
3+
<Page.actionBar>
4+
<ActionBar title="Native FAB" backgroundColor="#3F51B5" color="#fff" />
5+
</Page.actionBar>
6+
<grid-layout rows="auto, *">
7+
<list-view row="1" items="{{ users }}">
8+
<list-view.itemTemplate>
9+
<label text="{{ name }}" textWrap="true" fontSize="18" margin="20" />
10+
</list-view.itemTemplate>
11+
</list-view>
12+
<android row="1">
13+
<FAB:fab tap="fabTap"
14+
row="1"
15+
icon="res://ic_add_white"
16+
backColor="#ff4081"
17+
rippleColor="#f1f1f1"
18+
class="fab-button" />
19+
</android>
20+
</grid-layout>
21+
</Page>

fab.android.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
this._android.setBackgroundTintList(android.content.res.ColorStateList.valueOf(this.backColor.android));
3131

3232
if(this.icon){
33-
iconDrawable = null;
33+
var iconDrawable = null;
3434

3535
if(ImageSource.isFileOrResourcePath(this.icon)){
3636
iconDrawable = ImageSource.fromFileOrResource(this.icon);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nativescript-floatingactionbutton",
3-
"version": "0.1.71",
3+
"version": "0.1.8",
44
"description": "A NativeScript plugin to provide an XML widget to implement the Material Design Floating Action Button in an Android app.",
55
"main": "fab.js",
66
"nativescript": {

sample.png

-83.8 KB
Binary file not shown.

screens/fab.PNG

14.3 KB
Loading

0 commit comments

Comments
 (0)