Skip to content

Commit f85d1e8

Browse files
committed
resolve conflicts
2 parents 15fc178 + 16d61c7 commit f85d1e8

File tree

5 files changed

+64
-6
lines changed

5 files changed

+64
-6
lines changed

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,15 @@ exports.fabTap = function(args) {
6969
| backColor | X | X | Sets the background color of the button | None
7070
| icon | X | X | Supports the same image source options that NativeScript images support | Required on android
7171
| rippleColor| X | | Ripple color on lollipop devices, it will fill the FAB on pre-lollipop devices | None
72-
72+
| hideOnSwipeOfView| X | X | Directs the fab to animate itself in and out on scroll | Pass it the name of the view to monitor for a scroll event example: hideOnSwipeOfView="userListView"
73+
| hideAnimationDuration| X | X | How many milliseconds it takes for the button to hide. | Default of not set: 300ms
74+
75+
## NativeScript Compatibility
76+
77+
| NativeScript Version | FloatingActionButton Plugin Version |
78+
|----------------------|-------------------------------------|
79+
| 1.6 | 2.+ |
80+
| 1.5 | 1.91 |
7381

7482
## iOS Notes
7583
- We're using [MNFloatingActionButton](http://cocoapods.org/pods/MNFloatingActionButton) by [Matt Nydam](https://github.com/mattnydam)

demo/app/main-page.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ var platformModule = require("platform");
55
var color = require("color");
66

77
var users = [
8+
{ name: 'Billy Bob' },
9+
{ name: 'Tweeder' },
10+
{ name: 'Mox' },
11+
{ name: 'Coach' },
12+
{ name: 'Lance' },
13+
{ name: 'Johnson' },
14+
{ name: 'William' },
15+
{ name: 'Franklin' },
816
{ name: 'Billy Bob' },
917
{ name: 'Tweeder' },
1018
{ name: 'Mox' },
@@ -32,5 +40,5 @@ function pageLoaded(args) {
3240
exports.pageLoaded = pageLoaded;
3341

3442
exports.fabTap = function(args){
35-
viewModel.users.push({ name: "Gary"});
43+
viewModel.users.unshift({ name: "Gary"});
3644
}

demo/app/main-page.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<ActionBar title="Native FAB" backgroundColor="#3F51B5" color="#fff" />
55
</Page.actionBar>
66
<grid-layout rows="auto, *">
7-
<list-view row="1" items="{{ users }}">
7+
<list-view id="userList" row="1" items="{{ users }}">
88
<list-view.itemTemplate>
99
<label text="{{ name }}" textWrap="true" fontSize="15" margin="20" />
1010
</list-view.itemTemplate>
@@ -15,6 +15,7 @@
1515
icon="res://ic_add_white"
1616
tap="fabTap"
1717
rippleColor="#ffffff"
18-
class="fab-button" />
18+
class="fab-button"
19+
hideOnSwipeOfView="userList" />
1920
</grid-layout>
2021
</Page>

fab-common.js

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,54 @@
11
var view = require("ui/core/view");
22
var color = require("color");
3+
var frameModule = require("ui/frame");
34
var dObservable = require("ui/core/dependency-observable");
45
var proxy = require("ui/core/proxy");
5-
6+
var swipeLoaded = false;
7+
68
var FloatingActionButton = (function (_super) {
79
global.__extends(FloatingActionButton, _super);
810

911
function FloatingActionButton() {
1012
_super.call(this);
1113
}
14+
15+
16+
FloatingActionButton.prototype.onLoaded = function () {
17+
_super.prototype.onLoaded.call(this);
18+
19+
if(swipeLoaded === false){
20+
var fab = this;
21+
var viewToAttachTo = this.hideOnSwipeOfView;
22+
if(viewToAttachTo !== undefined){
23+
var swipeItem = this.page.getViewById(viewToAttachTo);
24+
25+
if(swipeItem !== undefined){
26+
console.log("Wiring up swipe");
27+
var duration = (this.hideAnimationDuration == undefined) ? 300 : this.hideAnimationDuration;
28+
swipeItem.on("swipe", function (args) {
29+
//Swipe up
30+
if (args.direction === 4) {
31+
fab.animate({
32+
translate: { x: 0, y: 200 },
33+
opacity: 0,
34+
duration: duration
35+
});
36+
}
37+
//Swipe Down
38+
else if (args.direction === 8) {
39+
fab.animate({
40+
translate: { x: 0, y: 0 },
41+
opacity: 1,
42+
duration: duration
43+
});
44+
};
45+
});
46+
47+
swipeLoaded = true;
48+
}
49+
}
50+
}
51+
};
1252

1353
Object.defineProperty(FloatingActionButton.prototype, "rippleColor", {
1454
get: function () {
@@ -41,6 +81,7 @@ var FloatingActionButton = (function (_super) {
4181
FloatingActionButton.iconProperty = new dObservable.Property("icon", "FloatingActionButton", new proxy.PropertyMetadata(0, dObservable.PropertyMetadataSettings.AffectsLayout));
4282
FloatingActionButton.rippleColorProperty = new dObservable.Property("rippleColor", "FloatingActionButton", new proxy.PropertyMetadata(0, dObservable.PropertyMetadataSettings.AffectsLayout));
4383

84+
4485
return FloatingActionButton;
4586
})(view.View);
4687

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": "2.1.2",
3+
"version": "2.1.2",
44
"description": "A NativeScript plugin to provide an XML widget to implement the Material Design Floating Action Button in NativeScript apps.",
55
"main": "fab.js",
66
"nativescript": {

0 commit comments

Comments
 (0)