• Stars
    star
    112
  • Rank 312,240 (Top 7 %)
  • Language
    TypeScript
  • License
    Apache License 2.0
  • Created about 9 years ago
  • Updated over 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Progress/Loading indicator with options for NativeScript. iOS + Android.

** DEPRECATION NOTICE **

Package has been deprecated as of July 11th, 2019.

Please use the version published by nStudio.

Installation:

tns plugin add @nstudio/nativescript-loading-indicator


NativeScript Loading Indicator

NativeScript-Loading-Indicator is a plugin for NativeScript which overlays a loading indicator on the current page. Can be used, for example, to prevent the UI being interacted with while data is being fetched from an API, while informing the user that something is happening.

Installation

tns plugin add nativescript-loading-indicator

Example

TypeScript

import {
  LoadingIndicator,
  Mode,
  OptionsCommon
} from 'nativescript-loading-indicator';

const indicator = new LoadingIndicator();

const options: OptionsCommon = {
  message: 'Loading...',
  details: 'Additional detail note!',
  progress: 0.65,
  margin: 10,
  dimBackground: true,
  color: '#4B9ED6', // color of indicator and labels
  // background box around indicator
  // hideBezel will override this if true
  backgroundColor: 'yellow',
  userInteractionEnabled: false, // default true. Set false so that the touches will fall through it.
  hideBezel: true, // default false, can hide the surrounding bezel
  mode: Mode.AnnularDeterminate, // see options below
  android: {
    view: someStackLayout.android, // Target view to show on top of (Defaults to entire window)
    cancelable: true,
    cancelListener: function(dialog) {
      console.log('Loading cancelled');
    }
  },
  ios: {
    view: someButton.ios, // Target view to show on top of (Defaults to entire window)
    square: false
  }
};

indicator.show(options);

// after some async event maybe or a timeout hide the indicator
indicator.hide();

javascript

const LoadingIndicator = require('nativescript-loading-indicator')
  .LoadingIndicator;
const Mode = require('nativescript-loading-indicator').Mode;

const loader = new LoadingIndicator();

// optional options
// android and ios have some platform specific options
const options = {
  message: 'Loading...',
  details: 'Additional detail note!',
  progress: 0.65,
  margin: 10,
  dimBackground: true,
  color: '#4B9ED6', // color of indicator and labels
  // background box around indicator
  // hideBezel will override this if true
  backgroundColor: 'yellow',
  userInteractionEnabled: false, // default true. Set false so that the touches will fall through it.
  hideBezel: true, // default false, can hide the surrounding bezel
  mode: Mode.AnnularDeterminate, // see options below
  android: {
    view: android.view.View, // Target view to show on top of (Defaults to entire window)
    cancelable: true,
    cancelListener: function(dialog) {
      console.log('Loading cancelled');
    }
  },
  ios: {
    view: UIView // Target view to show on top of (Defaults to entire window)
  }
};

loader.show(options); // options is optional

// Do whatever it is you want to do while the loader is showing, then

loader.hide();

Common Options

export interface OptionsCommon {
  /**
   * Message in the loading indicator.
   */
  message?: string;

  /**
   * Details message in the loading indicator.
   */
  details?: string;

  /**
   * Color of the message text.
   */
  color?: string;

  /**
   * Background color of the loading indicator.
   */
  backgroundColor?: string;

  /**
   * Progress of the indicator when not using CustomView or Text Mode.
   */
  progress?: number;

  /**
   * Margin for the message/indicator to the edge of the bezel.
   */
  margin?: number;

  /**
   * Set true to allow user interaction.
   */
  userInteractionEnabled?: boolean;

  /**
   * Dim the background behind the indicator.
   */
  dimBackground?: boolean;

  /**
   * Hide bezel around indicator
   */
  hideBezel?: boolean;

  /**
   * The mode of the loading indicator.
   */
  mode?: Mode;

  /**
   * If `mode` is set to CustomView, then you can pass an image or view to show in the loading indicator.
   */
  customView?: any;

  /**
   * iOS specific configuration options.
   */
  ios?: OptionsIOS;

  /**
   * Android specific configuration options.
   */
  android?: OptionsAndroid;
}

Android Specific

export interface OptionsAndroid {
  /**
   * Native View instance to anchor the loading indicator to.
   */
  view?: android.view.View;
  max?: number;
  progressNumberFormat?: string;
  progressPercentFormat?: number;
  progressStyle?: number;
  secondaryProgress?: number;
  cancelable?: boolean;
  cancelListener?: (dialog: any) => void;
  elevation?: number;
}

iOS Specific

export interface OptionsIOS {
  /**
   * Native View instance to anchor the loading indicator to.
   */
  view?: UIView;
  square?: boolean;
}

Mode Enum

export enum Mode {
  Indeterminate = 0,
  Determinate = 1,
  DeterminateHorizontalBar = 2,
  AnnularDeterminate = 3,
  CustomView = 4,
  Text = 5
}

More Repositories

1

angular-seed-advanced

Advanced Angular seed project with support for ngrx/store, ngrx/effects, ngx-translate, angulartics2, lodash, NativeScript (*native* mobile), Electron (Mac, Windows and Linux desktop) and more.
TypeScript
2,262
star
2

ng2-image-lazy-load

Angular2 image lazy loader library.
TypeScript
161
star
3

nativescript-fancyalert

Fancy alerts for NativeScript.
TypeScript
149
star
4

nativescript-angular-web-components

Experimental: Render NativeScript views on the web.
TypeScript
100
star
5

nativescript-ngx-fonticon

Use custom font icon collections seamlessly with NativeScript + Angular.
TypeScript
77
star
6

nativescript-plugin-seed

66
star
7

nativescript-ng2-magic

Magically turn your Angular2 web app into a NativeScript app.
JavaScript
64
star
8

nativescript-fonticon

Use custom font icon collections seamlessly with NativeScript.
TypeScript
50
star
9

ngTunes

🎵 The Community Angular 2 Music Player. 🎵
JavaScript
48
star
10

template-nativescript-nx

NativeScript template for Nx workspace https://nrwl.io/nx
TypeScript
38
star
11

nativescript-coachmarks

Display user coach marks with shape cutouts over an existing UI for NativeScript.
TypeScript
30
star
12

ShoutOutPlay

The mobile app that allows you to create and record personal dedications using your favorite music playlists for corporate events, parties, weddings and get togethers.
TypeScript
30
star
13

nativescript-spotify

A NativeScript plugin for the Spotify iOS and Android SDK's.
Objective-C
25
star
14

solid-x-platforms

Solid running on Web, iOS, Android and Vision Pro.
Swift
23
star
15

lava-lamp

Credit to @Inncoder_, An Nx workspace with Angular, React, Solid, Svelte, TypeScript and Vue iOS apps all sharing the same SwiftUI files via NativeScript.
TypeScript
20
star
16

MaterialCard

iOS Material Design Card View.
Swift
15
star
17

nativescript-ng2-vscode-snippets

Snippets for NativeScript + Angular 2 Development.
14
star
18

nativescript-ng2-windchimes

A NativeScript + Angular2 wind chime app for iOS and Android.
TypeScript
12
star
19

ns-ultimate-tab-setup

An example repo for exploration into setting up standard mobile Tab navigation via NativeScript.
TypeScript
12
star
20

nativescript-shimmer

Facebook Shimmer effect for your NativeScript app - iOS and Android.
TypeScript
12
star
21

ios18-examples

iOS 18 Highlights with NativeScript
Swift
11
star
22

ionic-nativescript

Angular Ionic app built with Capacitor and NativeScript
TypeScript
10
star
23

nativescript-visionos-explore

Exploring Vision Pro with NativeScript.
TypeScript
10
star
24

nativescript-swiftui-examples

SwiftUI with NativeScript example
TypeScript
9
star
25

nativescript-ezaudio

A NativeScript plugin for EZAudio: the simple, intuitive audio framework for iOS.
TypeScript
9
star
26

raspberrypi-admin

Raspberry PI Web Administration
JavaScript
8
star
27

nx-javascriptisdead

Nx workspace delivering optimal UX across Web, iOS and Android via Analog and NativeScript.
TypeScript
8
star
28

nativescript-ios-metaballs

Metaballs with NativeScript and SwiftUI
Swift
6
star
29

nativescript-ng2-translate

Use ng2-translate with NativeScript + Angular2.
JavaScript
6
star
30

ng-native

TypeScript
6
star
31

nativescript-webpack-import-replace

NativeScript for Angular webpack plugin to rewrite various imports with target platform suffix to allow various Angular Components, Directives, or Pipes to properly AoT compile.
JavaScript
6
star
32

NativeScript-Flutter-Example

A NativeScript with Flutter example highlighting talented work from Roaa, whereby an Action Menu (Flutter) and Card Flipper (Flutter) are populated via an Angular service that interacts with iOS UIMenu and Android PopupMenu.
Dart
6
star
33

vision-pro-angular

Vision Pro 🥽 for Angular Developers
Swift
6
star
34

nativescript-theme-seed

Build a custom NativeScript theme quickly.
TypeScript
5
star
35

ng2-cli-test-lib

JavaScript
4
star
36

nativescript-theme-christmas

A Vintage Christmas theme for NativeScript apps.
TypeScript
4
star
37

SwiftyCam

Swift
3
star
38

ng2-img-pusher-gif

Easily implement native vertical responsive scaling by creating on-the-fly GIFs via base64.
TypeScript
3
star
39

nativescript-christmas-special

TypeScript
2
star
40

nativescript4angular-demo

Sample NativeScript for Angular app demonstrating some key concepts in as simplest way as possible.
TypeScript
2
star
41

PocketRave-App

NativeScript and Angular 2 App for Raves, Light Shows, and other Awesome Things
TypeScript
2
star
42

ioniconf2022

Ioniconf 2022 "Opening Doors with Portals"
TypeScript
2
star
43

todo-list

Simple todo list made in angular 2
JavaScript
1
star
44

nativescript-angular-formly

NativeScript powered forms for Angular. Based on ng2-formly.
TypeScript
1
star
45

ng-7-0-test-with-angular-react-latest

TypeScript
1
star
46

ns-text-stroke

TypeScript
1
star
47

tns-audiokit

Objective-C
1
star
48

nativescript-atom-snippets

Snippets for NativeScript + Angular 2 Development.
CoffeeScript
1
star
49

nx-ns-examples

TypeScript
1
star
50

nativescript-square

JavaScript
1
star
51

nativescript-webview-advanced

A rich webview for your NativeScript app.
TypeScript
1
star
52

ns-collection-view-extra

Blog series example repo highlighting CollectionView, a super powered list control with recycled rows providing you best of class on each platform suited to fit all sorts of needs.
TypeScript
1
star
53

nativescript-ng2-atom-snippets

Snippets for NativeScript + Angular 2 Development.
CoffeeScript
1
star