1.0.0 β€’ Published 2 years ago

rn-scrolling-fab v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

React Native Scrolling FAB

Scrollable Float action button for React Native with NativeDriver for high-performance animations.

Table of Content:

How it looks

Installation

npm i rn-scrolling-fab --save

or

yarn add rn-scrolling-fab

Example

Take a look into example folder

To execute the example using Expo run the following command:

yarn run run:example

How to use it

Step 1: Import the FloatingAction component:

import { FloatingAction } from "rn-scrolling-fab";

Second step: define the buttons

const actions = [
  {
     key: "bt_home",
     icon: require("./images/ic_home_white.png"),
  },
  {
     key: "bt_favorite",
     icon: require("./images/ic_favorite_white.png"),
  },
  {
     key: "bt_news",
     icon: require("./images/ic_news_white.png"),
  },
  {
     key: "bt_video",
    icon: require("./images/ic_video_white.png"),
  }
];

or pass icon as component

const actions = [
  {
     key: "UK",
     icon: <Text>πŸ‡¬πŸ‡§</Text>,
  },
  {
     key: "CA",
     icon: <Text>πŸ‡¨πŸ‡¦</Text>,
  },
  {
     key: "DE",
     icon: <Text>πŸ‡©πŸ‡ͺ</Text>,
  },
  {
     key: "USA",
     icon: <Text>πŸ‡ΊπŸ‡Έ</Text>,
  }
];

Third step: use it

<View style={styles.container}>
  <Text style={styles.example}>Floating Action example</Text>
  <FloatingAction
    actions={actions}
    onPressItem={key => {
      console.log(`selected button: ${key}`);
    }}
  />
</View>

Reference

Props

actions: Array<ActionsProps>

  • Default: []

    Actions to be displayed when the main Floating Action Button is pressed. See ActionsProps section for more information about the ActionsProps keys and values.

size: number

  • Default: screenWidth * 0.13

    The size of the Floating Action Button.

isVertical: boolean

  • Default: false

    Determines whether the actions are displayed vertically as a Vertical Fab or horizontally. By default, it is set to display horizontally.

isHidden: boolean

  • Default: false

    Determines whether the Floating Action Button is hidden. By default, it is visible.

tintColor: ColorValue

  • Default: rgba(24,24,24,0.5)

    The color of the Floating Action Button. Pass this ColorValue as a hexadecimal color respecting the default format.

overlayColor: ColorValue

  • Default: rgba(0,0,0,0.1)

    The overlay color of the Floating Action Button. Pass this ColorValue as a hexadecimal color respecting the default format.

hideOverlay: boolean

  • Default: false

    Determines whether the overlay is hidden. By default, the overlay is visible.

position: Position

  • Default: right

    The position of the Floating Action Button, either Position.LEFT or Position.RIGHT.

bottomSpace: DimensionValue

  • Default: PixelRatio.get() * 10

    The bottom space of the Floating Action Button.

horizontalSpace: DimensionValue

  • Default: PixelRatio.get() * 10

    The horizontal space of the Floating Action Button. If the position is left, then the space from the left edge of the screen.

floatingIcon: ReactElement | ImageSourcePropType | null

  • Default: null

    The icon of the Floating Action Button. It can be a React element, an image source, or null. By default, the icon is a plus icon.

floatingIconSize: number between 0 and 1

  • Default: 0.5

    The size of the Floating Action Button icon. It can be a value between 0 and 1.

floatingIconColor: ColorValue

  • Default: #f5f5f5

    The color of the Floating Action Button icon.

onPressItem: (key: string) => void

  • Default: undefined

    Callback function to be called when an action item is pressed.

    • @param key: The key of the pressed action item.

rippleColor: ColorValue

  • Default: rgba(245,245,245,0.1)

    The color of the ripple effect for Android and opacity effect for iOS when an action item is pressed.

onPressMain: (actionType: FloatingIconPressActions) => void

  • Default: undefined

    Callback function to be called when the main Floating Action Button is pressed.

    • @param actionType: The type of the Floating Action Button press action.

dismissKeyboardOnPress: boolean

  • Default: false

    Determines if the keyboard should be dismissed when an action item is pressed.

shadow: ViewStyle

The shadow style of the floating action button.

  • Default:
    {
      shadowColor: 'rgba(0,0,0, 0.6)',
      shadowOffset: {
        width: 7,
        height: 7
      },
      shadowOpacity: 1,
      shadowRadius: 17,
      elevation: size / 3
    }

ActionsProps

icon: ReactElement | ImageSourcePropType | null

The icon of the action item. It can be a React element, an image source, or null.

key: string

The key of the action item.

TODO

  • first implementation
  • example
  • change plus icon to be customizable
  • migrate to TypeScript
  • add more positions.
  • support hide or show the component with an animation
  • open on mounting
acceptsabort-controllerabbrevJSONStreamacornacorn-jsxacorn-walkaggregate-erroragent-baseadd-streamajvanseransi-escapesansi-alignansi-fragmentsansi-regexansi-stylesargargparsearray-includesarray-ifyarray-unionarray-buffer-byte-lengtharray.prototype.flatarray.prototype.maparray.prototype.flatmaparraybuffer.prototype.slicearray.prototype.tosortedarrifyasyncastral-regexast-typesasync-limiterasynciterator.prototypebabel-coreavailable-typed-arraysasync-retryanymatchbabel-jestbabel-plugin-jest-hoistbabel-plugin-syntax-trailing-function-commasbabel-plugin-istanbulbabel-plugin-polyfill-corejs2babel-plugin-polyfill-corejs3babel-plugin-polyfill-regeneratorbabel-preset-fbjsbabel-plugin-transform-flow-enumsbabel-preset-current-node-syntaxbabel-preset-jestbase64-jsasapbalanced-matchbasic-ftpbefore-after-hookbig-integerboxenbplist-parserbrace-expansionbracesbrowserslistappdirsjsbuffer-frombsercacachecacheable-lookupbytescacheable-requestbundle-namecaller-callsitecaller-pathcall-bindcamelcasechalkcallsitescaniuse-litecamelcase-keyschardetchar-regexcjs-module-lexerchownrcli-cursorcli-spinnersclean-stackcli-widthcli-boxesbufferclonecliuiclone-deepci-infocolor-convertcoblcolor-namecollect-v8-coveragecompare-funccommondircommandercommand-existsconcat-mapcompressioncompressibleconnectconcat-streamconfigstoreconfig-chainconventional-changelogconventional-changelog-angularconventional-changelog-codemirrorconventional-changelog-atomconventional-changelog-conventionalcommitsconventional-changelog-coreconventional-changelog-emberconventional-changelog-eslintconventional-changelog-expressconventional-changelog-jqueryconventional-changelog-jshintconventional-changelog-preset-loaderconventional-changelog-writerconventional-recommended-bumpconventional-commits-filterconventional-commits-parsercore-js-compatconvert-source-mapcosmiconfigcreate-requirecore-util-iscsstypecosmiconfig-typescript-loadercross-spawndargsdateformatcrypto-random-stringdata-uri-to-bufferdebugdecamelizedecamelize-keysdecompress-responsedeep-isdedentdeep-extenddeepmergedefault-browser-iddefault-browserdefaultsdefer-to-connectdefine-data-propertydefine-propertiesdefine-lazy-propcolorettedegeneratordeldeprecated-react-native-prop-typesdepddestroydeprecationdiffdot-propdiff-sequenceseastasianwidthdetect-newlinedir-globelectron-to-chromiumemoji-regexemitteryencodeurlee-firstenv-pathsencodingend-of-streamdayjsdoctrineerror-exdenodeifyerr-codeenvinfoerrorhandleres-array-method-boxes-properlyes-abstractes-get-iteratores-set-tostringtages-iterator-helperses-to-primitivees-shim-unscopablesescaladeescape-goatescape-htmlescape-string-regexpescodegeneslint-plugin-eslint-commentseslint-plugin-reacteslint-plugin-ft-floweslint-plugin-jesteslint-plugin-react-hookseslint-plugin-react-nativeeslint-plugin-react-native-globalseslint-scopeeslint-visitor-keysesprimaespreeestraverseesrecurseesutilsesqueryetagexpectevent-target-shimexponential-backoffexecaexitexternal-editorfast-deep-equalfast-json-stable-stringifyfast-difffastqfiguresfast-globfast-levenshteinfetch-blobfill-rangefb-watchmanfinalhandlerfind-upfile-entry-cacheflat-cachefind-cache-dirforeground-childflattedflow-enums-runtimefor-eachflow-parsererror-stack-parserform-data-encoderformdata-polyfillfs-extrafs-minipassfs.realpathfseventsfunction-bindfreshfunction.prototype.nameget-intrinsicfunctions-have-namesgensyncget-caller-fileget-package-typeget-pkg-repoget-uriget-symbol-descriptionget-streamgit-raw-commitsgit-semver-tagsgit-remote-origin-urlgit-url-parsegit-upgitconfiglocalglobglobal-dirsglob-parentglobalthisglobalsgopdglobbygraceful-fsgothandlebarsgraphemerhas-bigintshas-property-descriptorshas-flaghas-protohas-symbolshard-rejectionfast-xml-parserhas-yarnhasownhermes-estreehermes-profile-transformerhas-tostringtaghermes-parserhosted-git-infohtml-escaperhttp-cache-semanticshttp2-wrapperhttp-errorshttp-proxy-agentieee754iconv-litehttps-proxy-agenthuman-signalsimport-freshimage-sizeimport-localignoreimport-lazyimurmurhashinheritsinflightindent-stringinternal-slotiniinquirerinvariantis-absoluteinterpretipis-argumentsis-array-bufferis-arrayishis-async-functionis-callableis-boolean-objectis-bigintis-ciis-date-objectis-extglobis-directoryis-core-moduleis-finalizationregistryis-fullwidth-code-pointis-generator-functionis-globis-git-repositoryis-generator-fnis-git-dirtyis-lambdais-installed-globallyis-inside-containeris-interactiveis-npmis-negative-zerois-mapis-numberis-path-cwdis-path-insideis-number-objectis-plain-objis-objis-regexis-relativeis-plain-objectis-shared-array-bufferis-setis-streamis-sshis-text-pathis-symbolis-typed-arrayis-stringis-typedarrayis-unc-pathis-unicode-supportedis-weakrefis-weaksetis-weakmapis-windowsis-yarn-globalisarrayisobjectisexeistanbul-lib-coverageistanbul-lib-instrumentistanbul-lib-reportistanbul-lib-source-mapsissue-parseristanbul-reportsiterate-iteratoriterator.prototypejackspeakjest-diffiterate-valuejest-circusjest-clijest-eachjest-changed-filesis-dockerjest-docblockis-wsljest-matcher-utilsjest-mockjest-environment-nodejest-haste-mapjest-pnp-resolverjest-leak-detectorjest-configjest-resolve-dependenciesjest-runnerjest-resolvejest-runtimejest-validatejest-snapshotjest-watcherjs-tokensjest-workerjetifierjest-utiljoijs-yamljest-get-typejsc-safe-urljsescjson-bufferjscodeshiftjson-parse-even-better-errorsjest-message-utiljest-regex-utiljson-parse-better-errorsjson-schema-traversejson-stable-stringify-without-jsonifyjson5jsonfilekind-ofjsx-ast-utilsjsonparsekleurlatest-versionkeyvjson-stringify-safelevenlevnlines-and-columnsload-json-filelocate-pathlodashlodash.capitalizelodash.camelcaselodash.debouncelodash.isfunctionlodash.ismatchlodash.isplainobjectlodash.mergelodash.escaperegexplodash.isstringlodash.kebabcaselodash.snakecaselodash.throttlelodash.uniqbylodash.startcaselodash.mergewithlodash.upperfirstlodash.uniqlogkittyloose-envifylog-symbolsjsc-androidmacos-releaselru-cachemake-dirlowercase-keysmakeerrormake-fetch-happenmake-errormap-objmeowmetromerge2memoize-onemetro-coremetro-babel-transformermerge-streammetro-cachemetro-file-mapmetro-configmetro-react-native-babel-presetmetro-cache-keymetro-react-native-babel-transformermetro-minify-tersermetro-minify-uglifymetro-resolvermicromatchmetro-transform-workermetro-inspector-proxymetro-source-mapmetro-transform-pluginsmime-dbmetro-runtimemin-indentmime-typesmimic-responseminimistmimic-fnminipassminimist-optionsminipass-collectminimatchmetro-symbolicateminipass-flushminipass-fetchminipass-pipelinemodify-valuesminipass-sizedminizlibmute-streamnetmasknatural-compare-litenatural-compareneo-asyncmsmimenegotiatornew-github-release-urlnode-abort-controllernode-domexceptionnocachenode-fetchnode-dirnode-int64node-gypnode-releasesnoptnode-stream-zipnormalize-pathnormalize-package-datanormalize-urlnpm-run-pathnullthrowsobject-assignobject-keysobject-inspectob1object.entriesobject.assignobject.fromentrieson-headersobject.valueson-finishedobject.hasownonetimeonceos-nameopenoptionatoros-tmpdirmkdirpp-locatep-cancelablep-limitp-mapp-trypac-proxy-agentparent-modulepac-resolverpackage-jsonparseurlparse-jsonparse-pathparse-urlpath-existspath-parsepath-typepath-scurrypath-is-absolutepifypicocolorspath-keypicomatchpretty-formatpiratesprelude-lspkg-diroraproc-logprocess-nextick-argsprettier-linter-helpersprop-typespromisepromise.allsettledpromptsproto-listpromise-retryprotocolsproxy-agentproxy-from-envqpunycodepumpqueuepupaqueue-microtaskrange-parserquick-lrurcreact-isread-pkgreact-shallow-rendererread-pkg-upreadable-streamreadlinereact-refreshrecastreflect.getprototypeofredentrechoirregenerate-unicode-propertiesregenerateregenerator-runtimeregenerator-transformregexp.prototype.flagsregistry-auth-tokenreact-devtools-coreregexpu-coreregistry-urlregjsparserrequire-main-filenamerequire-directoryresolveresolve-alpnrequire-from-stringresolve-cwdresolve.exportsresolve-fromresponselikerestore-cursorrimrafreusifyresolve-globalretryrun-asyncrun-applescriptsafe-array-concatschedulerrxjsrun-parallelsafe-buffersemversemver-diffsafe-regex-testsafer-buffersendset-function-lengthset-blockingserve-staticshebang-commandsetprototypeofshallow-cloneshelljsshebang-regexset-function-namesignal-exitsisteransiside-channelsockssource-mapserialize-errorslashsmart-buffersource-map-supportsocks-proxy-agentspdx-exceptionsspdx-correctsplitsplit2spdx-license-idssprintf-jsspdx-expression-parsestack-utilsslice-ansistdin-discarderssristring-lengthstring-natural-comparestatusesstring-widthstacktrace-parserstring-width-cjsstop-iteration-iteratorstring.prototype.trimstring.prototype.trimendstring_decoderstrip-ansistring.prototype.trimstartstring.prototype.matchallshell-quotestrip-ansi-cjsstrip-final-newlinestrip-bomstrip-indentsudo-promptsupports-colorstrip-json-commentssupports-preserve-symlinks-flagtartemptersersupports-hyperlinksterminal-linkthroattext-tabletest-excludetext-extensionsstackframethrough2tmptoidentifierthroughto-regex-rangetmplto-fast-propertiestrim-newlinests-nodetslibtype-checktr46type-detecttsutilstype-festtyped-array-byte-lengthtyped-array-buffertyped-array-byte-offsettitleizetypedarray-to-buffertypedarraytyped-array-lengthuglify-esuglify-jsstrnumunbox-primitiveundici-typesunc-path-regexunicode-match-property-ecmascriptunicode-property-aliases-ecmascriptunicode-canonical-property-names-ecmascriptunicode-match-property-value-ecmascriptunique-filenameunique-sluguniversalifyunique-stringunpipeuntildifyuniversal-user-agenturi-jsurl-joinupdate-browserslist-dbutil-deprecateupdate-notifieruse-sync-external-storeutils-mergev8-compile-cache-libvalidate-npm-package-licensewcwidthvaryvm2webidl-conversionsvlqwhatwg-fetchweb-streams-polyfillwhatwg-urlwhich-builtin-typewhich-boxed-primitivewhich-collectionwhichwildcard-matchwhich-modulewhich-typed-arraywidest-linewordwrapwrap-ansiwrap-ansi-cjswindows-releaseword-wrapwrappywsxdg-basedirxtendy18nyallistyamlyargsyargs-parserwalkerynyocto-queuev8-to-istanbulwrite-file-atomic
1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago