|
1 | | -# NativeScript-FloatingActionButton |
2 | | -XML widget to create the Material Design Floating Action Button for Android NativeScript apps |
3 | | - |
4 | | -[Material Design Floating Action Button Spec](https://www.google.com/design/spec/components/buttons-floating-action-button.html) |
5 | | - |
6 | | -## Installation |
7 | | -`npm install nativescript-floatingactionbutton` |
8 | | - |
9 | | -### Screenshot |
10 | | ---------------- |
11 | | - |
12 | | - |
13 | | -## Usage |
14 | | - |
15 | | -#### XML |
16 | | -##### **NOTE** The sample XML here will position the FAB on top of the ListView. There is no need for absolute positioning. |
17 | | -```XML |
18 | | -<Page xmlns="http://schemas.nativescript.org/tns.xsd" loaded="pageLoaded" |
19 | | - xmlns:FAB="nativescript-floatingactionbutton"> |
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> |
38 | | -</Page> |
39 | | -``` |
40 | | - |
41 | | -#### CSS |
42 | | -I recommend the following CSS styles. |
43 | | -```CSS |
44 | | -.fab-button { |
45 | | - height: 70; |
46 | | - horizontal-align: right; |
47 | | - vertical-align: bottom; |
48 | | - margin: 15; |
49 | | -} |
50 | | -``` |
51 | | - |
52 | | -#### JS |
53 | | - |
54 | | -```JS |
55 | | -function fabTap(args) { |
| 1 | +# NativeScript-FloatingActionButton |
| 2 | +XML widget to create the Material Design Floating Action Button for Android NativeScript apps |
| 3 | + |
| 4 | +[Material Design Floating Action Button Spec](https://www.google.com/design/spec/components/buttons-floating-action-button.html) |
| 5 | + |
| 6 | +## Installation |
| 7 | +`npm install nativescript-floatingactionbutton` |
| 8 | + |
| 9 | +### Screenshot |
| 10 | +--------------- |
| 11 | + |
| 12 | + |
| 13 | + |
| 14 | +## Usage |
| 15 | + |
| 16 | +#### XML |
| 17 | +##### **NOTE** The sample XML here will position the FAB on top of the ListView. There is no need for absolute positioning. |
| 18 | +```XML |
| 19 | +<Page xmlns="http://schemas.nativescript.org/tns.xsd" loaded="pageLoaded" |
| 20 | + xmlns:FAB="nativescript-floatingactionbutton"> |
| 21 | + <Page.actionBar> |
| 22 | + <ActionBar title="Native FAB" backgroundColor="#3F51B5" color="#fff" /> |
| 23 | + </Page.actionBar> |
| 24 | + <grid-layout rows="auto, *"> |
| 25 | + <list-view row="1" items="{{ users }}"> |
| 26 | + <list-view.itemTemplate> |
| 27 | + <label text="{{ name }}" textWrap="true" fontSize="18" margin="20" /> |
| 28 | + </list-view.itemTemplate> |
| 29 | + </list-view> |
| 30 | + <FAB:fab tap="fabTap" |
| 31 | + row="1" |
| 32 | + icon="res://ic_add_white" |
| 33 | + rippleColor="#f1f1f1" |
| 34 | + class="fab-button" /> |
| 35 | + </grid-layout> |
| 36 | +</Page> |
| 37 | +``` |
| 38 | +PLEASE NOTE: The fab is on the same **row number** as the listview |
| 39 | +*** |
| 40 | + |
| 41 | +#### CSS |
| 42 | +I recommend the following CSS styles. |
| 43 | +```CSS |
| 44 | +.fab-button { |
| 45 | + height: 70; |
| 46 | + margin: 15; |
| 47 | + background-color: #ff4081; |
| 48 | + horizontal-align: right; /* Android Only */ |
| 49 | + vertical-align: bottom; /* Android Only */ |
| 50 | + color: #fff; /* iOS Only */ |
| 51 | +} |
| 52 | +``` |
| 53 | + |
| 54 | +*** |
| 55 | + |
| 56 | +#### JS |
| 57 | + |
| 58 | +```JS |
| 59 | +exports.fabTap = function(args) { |
56 | 60 | console.log('tapped'); |
57 | 61 | } |
58 | | -exports.fabTap = fabTap; |
59 | | -``` |
60 | | - |
61 | | -#### Attributes |
62 | | -**backColor** - optional |
63 | | - |
64 | | -Attribute to specify the background color of the FAB |
65 | | - |
66 | | -**rippleColor** - optional |
67 | | - |
68 | | -Attribute to set the ripple color on lollipop devices, it will fill the FAB on pre-lollipop devices |
69 | | - |
70 | | -**icon** - required |
71 | | - |
72 | | -Attribute to specify which icon to use for the FAB button, supports the same image source options that NativeScript images support. |
73 | | - |
74 | | -### Contributors |
75 | | - |
76 | | -- L�zaro Danillo [lazaromenezes](https://github.com/lazaromenezes) |
| 62 | +``` |
| 63 | + |
| 64 | +*** |
| 65 | + |
| 66 | +## Attributes |
| 67 | +| Property | Android | iOS | Description | Note | |
| 68 | +|----------|:-------------:|------:|--|--| |
| 69 | +| backColor | X | X | Sets the background color of the button | None |
| 70 | +| icon | X | | Supports the same image source options that NativeScript images support | Required on android |
| 71 | +| rippleColor | X | |Ripple color on lollipop devices, it will fill the FAB on pre-lollipop devices | None |
| 72 | + |
| 73 | + |
| 74 | +## iOS Notes |
| 75 | +Since iOS doesn't have a native FAB, we're using the amazing [KCFloatingActionButton](https://cocoapods.org/pods/KCFloatingActionButton) by [Lee Sun-Hyoup](https://github.com/kciter) |
| 76 | +As of this publish, it does not yet support images, however this is an Issue open. |
| 77 | + |
| 78 | +### Contributors |
| 79 | + |
| 80 | +- L�zaro Danillo [lazaromenezes](https://github.com/lazaromenezes) |
| 81 | +- Steve McNiven-Scott [sitefinitysteve](https://github.com/sitefinitysteve) - iOS |
0 commit comments