• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

nstudio/nativescript-floatingactionbutton: Material Design Floating Action Butto ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

nstudio/nativescript-floatingactionbutton

开源软件地址(OpenSource Url):

https://github.com/nstudio/nativescript-floatingactionbutton

开源编程语言(OpenSource Language):

TypeScript 88.7%

开源软件介绍(OpenSource Introduction):

NativeScript-FloatingActionButton

NativeScript plugin for Material Design Floating Action Button UI component.

Action Build npm npm

Installation

Nativescript 7+:

ns plugin add @nstudio/nativescript-floatingactionbutton

NativeScript lower than 7:

tns plugin add @nstudio/[email protected]

Screenshot


FAB Android Screenshot FAB iOS Screenshot

Multiple FAB/Swipe Animation Support

FAB Animations

Usage

The icon for the FAB can be a local image in your app or an image/icon from the App_Resources.

Plain NativeScript

<Page xmlns="http://schemas.nativescript.org/tns.xsd" loaded="pageLoaded"
      xmlns:FAB="@nstudio/nativescript-floatingactionbutton">
    <ActionBar title="Native FAB" />
    <grid-layout rows="auto, *">
        <list-view row="1" items="{{ users }}">
            <list-view.itemTemplate>
                <label text="{{ name }}" />
            </list-view.itemTemplate>
        </list-view>
            <FAB:fab tap="fabTap"
                     row="1"
                     icon="'~/assets/ic_add_white.png'"
                     rippleColor="#f1f1f1"
                     class="fab-button" />
    </grid-layout>
</Page>

NativeScript Angular

import { registerElement } from 'nativescript-angular/element-registry';
registerElement(
  'Fab',
  () => require('@nstudio/nativescript-floatingactionbutton').Fab
);

HTML

<StackLayout>
    <FAB (tap)="fabTap()" icon="~/assets/ic_add_white.png" rippleColor="#f1f1f1" class="fab-button"></FAB>
</StackLayout>

NativeScript Vue

import Vue from 'nativescript-vue';

Vue.registerElement(
  'Fab',
  () => require('@nstudio/nativescript-floatingactionbutton').Fab
);

Template

<template>
  <page>
    <grid-layout rows="auto, *">
      <list-view row="1" items="{{ users }}">
        <list-view.itemTemplate>
          <label text="{{ name }}" textWrap="true" />
        </list-view.itemTemplate>
      </list-view>
      <fab
        @tap="fabTap"
        row="1"
        icon="res://ic_add_white"
        rippleColor="#f1f1f1"
        class="fab-button"
      ></fab>
    </grid-layout>
  </page>
</template>

CSS

Recommended CSS styles.

.fab-button {
  height: 70;
  width: 70; /// this is required on iOS - Android does not require width so you might need to adjust styles
  margin: 15;
  background-color: #ff4081;
  horizontal-align: right;
  vertical-align: bottom;
}

Use Icon Fonts

First you need to setup icon fonts as described in NativeScript documentation.

After this, you can use icon fonts on FAB by specifiying the unicode as text and add the fas/far class:

<FAB:fab text="&#xf02a;" class="fab-button fas" />

API

Property Android iOS Description Note
backgroundColor X X Sets the background color of the button
icon X X Supports the same image source options that NativeScript images support Required on android
text X X Allows to use text instead of image Can be styled with font-* and color CSS properties
rippleColor X Ripple color on lollipop devices, it will fill the FAB on pre-lollipop devices None
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"
hideAnimationDuration X X How many milliseconds it takes for the button to hide. Default if not set: 300ms
swipeAnimation X X slideDown, slideUp, slideLeft, slideRight, scale Default is slideDown
androidScaleType X center, centerCrop, centerInside, fitCenter, fitEnd, fitStart, fitXY, matrix
for more details see Android-Docs
Default is center

iOS Notes

  • We're using MNFloatingActionButton by Matt Nydam
  • Width\Height are requried properties
  • icon is a required property, if left as empty string default will be shown

Running Demo Apps

npm run demo.android

// or

npm run demo.ios

Changelog

Contributors


Brad Martin

Steve McNiven-Scott

Nathanael Anderson

Gabriel Marinho

Alexander Vakrilov

Lázaro Danillo Menezes

Jofferson Ramirez Tiquez

Ravi

Samuel Ikechukwu

Stanimira Vlaeva



鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap