djett41 / ionic-filter-bar

Filter Bar plugin for the Ionic Framework
MIT License
362 stars 112 forks source link

Ionic Filter Bar

A platform specific search filter plugin for the Ionic Framework (iOS / Android)

Table of Contents

Demo

SportScoop

Ionic Filter Bar

Run the following ommands:

npm install
bower install
gulp

Setup

Install

bower install ionic-filter-bar

Cordova Keyboard config (config.xml)

In order for Ionic Filter Bar to autofocus for iOS and bring the keyboard up when the filter bar animates in, you will need to add the following to your config.xml

<platform name="ios">
    <preference name="KeyboardDisplayRequiresUserAction" value="false"/>
</platform>

I also recommend using the ionic-plugin-keyboard and disabling scroll for the keyboard as well. See the app.js in the Demo for an example on how to configure the Ionic Keyboard in your module's run section.

JS/CSS Imports (index.html)

Include the following JavaScript/CSS file imports in your index.html. Remember to import the ionic libraries first! The example below assumes your 3rd party bower dependencies are located in the default bower_components folder.

<link rel="stylesheet" href="https://github.com/djett41/ionic-filter-bar/blob/master/bower_components/ionic-filter-bar/dist/ionic.filter.bar.css">
<script src="https://github.com/djett41/ionic-filter-bar/raw/master/bower_components/ionic-filter-bar/dist/ionic.filter.bar.js"></script>

Angular Dependency (app.js)

Add jett.ionic.filter.bar as a module dependency of your app module.

angular.module('Demo', ['ionic', 'jett.ionic.filter.bar'])
  .config(function () {..});

SASS Import (main.scss)

Include the scss/ionic.filter.bar.scss file at the top of your main.scss file as shown below. Import any custom filter bar scss styles below the ionic and ionic.filter.bar scss.

@import
  "path_to_bower_components/ionic/scss/ionic",
  "path_to_bower_components/ionic-filter-bar/scss/ionic.filter.bar";

Usage

$ionicFilterBarConfigProvider

A provider you can inject into your module config that provides a way to customize the filter bar template.

$ionicFilterBarConfigProvider.theme

Allows you to override the ionic theme and color options used to style the filter bar.

@param {string} value Ionic color option.

By default the theme inherits the theme and color options of the ion-nav-bar (defaults to light theme). For example, if you define a bar-positive class on you ion-nav-bar (see demo for example) then the filter bar will automatically have the filter-bar-positive styles. You can override the default behavior by setting the theme to one of the following default Ionic themes listed below.

$ionicFilterBarConfigProvider.clear

filterBar Clear button icon used to clear filter input

@param {string} value Android defaults to ion-android-close and iOS defaults to ion-ios-close.

@returns {string}

$ionicFilterBarConfigProvider.search

filterBar Search placeholder icon shown inside input only for iOS

@param {string} value iOS defaults to ion-ios-search-strong. Android doesn't show placeholder icons

@returns {string}

$ionicFilterBarConfigProvider.backdrop

filterBar backdrop which is shown when filter text is empty

@param {boolean} value Android defaults to false and iOS defaults to true.

@returns {boolean}

$ionicFilterBarConfigProvider.transition

transition used when filterBar is shown over the header bar

@param {string} value Android defaults to horizontal and iOS defaults to vertical.

platform: Dynamically choose the correct transition depending on the platform the app is running from. If the platform is ios, it will default to vertical. If the platform is android, it will default to horizontal. If the platform is not ios or android, it will default to vertical.

@returns {string}

$ionicFilterBarConfigProvider.placeholder

filterBar placeholder text shown inside input.

@param {string} value defaults to Search.

@returns {string}

$ionicFilterBarConfigProvider.favorite

Icon shown in the input filed when favoritesEnabled is true and filter text is empty (same spot as clear button)

@param {string} Android defaults to ion-android-star and iOS defaults to ion-ios-star.

@returns {string}

$ionicFilterBarConfigProvider.close

Icon used for button to close the modal

@param {string} Android defaults to ion-android-close and iOS defaults to ion-ios-close-empty.

@returns {string}

$ionicFilterBarConfigProvider.done

Icon used to when a user is done reordering filter bar favorites

@param {string} Android defaults to ion-android-done and iOS defaults to ion-ios-checkmark-empty.

@returns {string}

$ionicFilterBarConfigProvider.remove

Icon for the item options delete button used to delete a favorite

@param {string} Android defaults to ion-android-delete and iOS defaults to ion-ios-trash-outline.

@returns {string}

$ionicFilterBarConfigProvider.reorder

Icon used for the reorder button

@param {string} Both platforms default to ion-drag.

@returns {string}

$ionicFilterBarConfigProvider.add

Icon used for the add button

@param {string} Both platforms default to ion-ios-plus-outline.

@returns {string}

$ionicFilterBar

A service you can inject in your controller to show the filter bar

$ionicFilterBar.show

Load and return a new filter bar. A new isolated scope will be created for the filter bar and the new filter bar will be appended to the body, covering the header bar.

@returns {function} hideFilterBar A function which, when called, hides & cancels the filter bar.

@param {object} options The options for the filterBar. Properties:

NOTE: The favorites feature is not stable. There is a bug with the keyboard/input focus that needs to be resolved

Screenshots