nativescript-loading-indicator-ssi
A NativeScript 插件,用于显示覆盖的加载指示器。
npm i --save nativescript-loading-indicator-ssi

nativescript-loading-indicator

nativescript-loading-indicator 是一个 NativeScript 插件,可以在当前页面上覆盖显示加载指示器。可用于,例如,在从 API 获取数据时防止与 UI 进行交互,同时告知用户有操作正在进行。

安装

tns plugin add nativescript-loading-indicator

示例

var LoadingIndicator = require("nativescript-loading-indicator").LoadingIndicator;

// or with TypeScript:
// import {LoadingIndicator} from "nativescript-loading-indicator";

var loader = new LoadingIndicator();

// optional options
// android and ios have some platform specific options
var options = {
message: 'Loading...',
progress: 0.65,
android: {
indeterminate: true,
cancelable: false,
max: 100,
progressNumberFormat: "%1d/%2d",
progressPercentFormat: 0.53,
progressStyle: 1,
secondaryProgress: 1
},
ios: {
details: "Additional detail note!",
margin: 10,
dimBackground: true,
color: "#4B9ED6", // color of indicator and labels
// background box around indicator
// hideBezel will override this if true
backgroundColor: "yellow",
hideBezel: true, // default false, can hide the surrounding bezel
view: UIView, // Target view to show on top of (Defaults to entire window)
mode: // see iOS specific options below
}
};

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

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

loader.hide();

选项

  • message: string 您的消息!
  • progress: number 设置进度显示

Android 特定

  • 参考: https://android-docs.cn/intl/zh-tw/reference/android/app/ProgressDialog.html

iOS 特定

  • 参考: https://github.com/jdg/MBProgressHUD/blob/master/Demo/Classes/MBHudDemoViewController.m

快速 模式 参考

  • MBProgressHUDModeDeterminate
  • MBProgressHUDModeAnnularDeterminate
  • MBProgressHUDModeDeterminateHorizontalBar
  • MBProgressHUDModeText
  • MBProgressHUDModeCustomView
    • 使用 customView: string - 本地图片文件路径

屏幕截图

Loading indicator on iOS Loading indicator on Android