Skip to content
This repository has been archived by the owner on Mar 18, 2018. It is now read-only.

Commit

Permalink
Reverted 1.5 change thanks to opacity fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
FokkeZB committed Aug 20, 2013
1 parent 03789ef commit 15ba03d
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 56 deletions.
13 changes: 5 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,13 @@ This is a widget for the [Alloy](http://projects.appcelerator.com/alloy/docs/All

The widget provides a simple loading mask that can be easily styled and configured.

### Android
On Android HeavyWeight windows don't support a backgroundColor with an alpha-channel. Before 1.5 this meant the loading mask had a solid grey background. Since 1.5 the widget falls back to `Ti.UI.Android.ProgressIndicator`, waiting for [this issue](https://jira.appcelerator.org/browse/TC-2774) to be solved.

## Screenshot
![Loading Mask](https://raw.github.com/FokkeZB/nl.fokkezb.loading/master/docs/screenshot.png) ![Android](https://raw.github.com/FokkeZB/nl.fokkezb.loading/master/docs/android.png)
![Loading Mask](https://raw.github.com/FokkeZB/nl.fokkezb.loading/master/docs/screenshot.png)

## Features
* Fully stylable via your `app.tss`.
* If enabled, hides and sends a `cancelled` event when tapped on by the user.
* Message and ability to be cancelled can be set any time, also in one call.
* Falls back on the new `Ti.UI.Android.ProgressIndicator` for Android.

## Quick Start
* Download the latest [release](https://github.com/FokkeZB/nl.fokkezb.loading/releases) of the widget.
Expand All @@ -23,7 +19,7 @@ On Android HeavyWeight windows don't support a backgroundColor with an alpha-cha

```javascript
"dependencies": {
"nl.fokkezb.loading":"1.5"
"nl.fokkezb.loading":"1.5.1"
}
```

Expand Down Expand Up @@ -64,7 +60,7 @@ The following parameters can be set either through `XML` or `TSS`:
| message | `string` | Loading | Sets the message to show |
| blocking | `boolean` | TRUE | Prevents users from cancelling by clicking on the mask |
| show | `boolean` | FALSE | Calls show() directly after init |
| images | `boolean` or `array` | FALSE | Shows default or given array of images as indicator (not for Android) |
| images | `boolean` or `array` | FALSE | Shows default or given array of images as indicator |

## Public properties

Expand Down Expand Up @@ -93,7 +89,7 @@ Shows default or given array of images as indicator instead of an ActivityIndica
### cancel
Fires when the loading mask was hidden by the user by either tapping the mask or using the Android hardware back-button.

## Styling (not for Android)
## Styling
You can style all views from your `app.tss`. The default styles can be found in [loading.tss](https://github.com/FokkeZB/nl.fokkezb.loading/blob/master/styles/loading.tss). Be aware that the default styles are applied to classses, but to override from your `app.tss` you need to following (identical) IDs:

* `#loadingMask`: The full-screen mask.
Expand All @@ -106,6 +102,7 @@ You can style all views from your `app.tss`. The default styles can be found in
You can override the default message (`Loading..`) by setting the `loadingMessage` in your `strings.xml` files.

## Changelog
* 1.5.1: Reverted 1.5 change thanks to `opacity` fix.
* 1.5: Falls back to `Ti.UI.Android.ProgressIndicator` for Android
* 1.4: Support for image indicator
* 1.3: Fully override widget style from `app.tss` and reset to default message upon show.
Expand Down
53 changes: 10 additions & 43 deletions controllers/loading.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,9 @@ function show(_message, _blocking) {
return;
}

if (OS_ANDROID) {
$.loadingProgressIndicator.show();
$.loadingMask.open();

} else {
$.loadingMask.open();

hasImages ? $.loadingImages.start() : $.loadingIndicator.show();
}
hasImages ? $.loadingImages.start() : $.loadingIndicator.show();

isShowing = true;

Expand All @@ -38,14 +33,9 @@ function hide() {
return;
}

if (OS_ANDROID) {
$.loadingProgressIndicator.hide();
hasImages ? $.loadingImages.stop() : $.loadingIndicator.hide();

} else {
hasImages ? $.loadingImages.stop() : $.loadingIndicator.hide();

$.loadingMask.close();
}
$.loadingMask.close();

isShowing = false;

Expand All @@ -60,9 +50,7 @@ function cancel() {

if (args.blocking === false) {

if (!OS_ANDROID) {
hide();
}
hide();

$.trigger('cancel');
}
Expand All @@ -74,28 +62,19 @@ function setMessage(_message) {

if (_message === false) {

if (hasMessage) {

if (OS_ANDROID) {
$.loadingProgressIndicator.message = null;
} else {
$.loadingInner.remove($.loadingMessage);
}
if (hasMessage) {
$.loadingInner.remove($.loadingMessage);

hasMessage = false;
}

} else {
var message = (_message === true) ? L('loadingMessage', 'Loading..') : _message;

if (OS_ANDROID) {
$.loadingProgressIndicator.message = message;
} else {
$.loadingMessage.text = message;
}
$.loadingMessage.text = message;

if (!hasMessage) {
OS_ANDROID || $.loadingInner.add($.loadingMessage);
$.loadingInner.add($.loadingMessage);

hasMessage = true;
}
Expand All @@ -106,19 +85,9 @@ function setMessage(_message) {

function setBlocking(_blocking) {
args.blocking = (_blocking !== false);

if (OS_ANDROID) {
$.loadingProgressIndicator.cancelable = !args.blocking;
}
}

function setImages(_images) {

if (OS_ANDROID) {
Ti.API.info('[LOADING] No image indicator on Android');
return;
}

var _newImages = _.isArray(_images);

if (_images === true || _newImages) {
Expand Down Expand Up @@ -158,9 +127,7 @@ function setImages(_images) {
return;
}

if (!OS_ANDROID) {
setImages(args.images);
}
setImages(args.images);

show(args.message, args.blocking);

Expand Down
Binary file removed docs/android.png
Binary file not shown.
3 changes: 2 additions & 1 deletion styles/loading.tss
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
".loadingMask": {
backgroundColor: "#5000",
backgroundImage: null // Prevent a app-wide Window-background to take over
backgroundImage: null, // Prevent a app-wide Window-background to take over
opacity: 1.0 // Or alpha channel in backgroundColor won't work
}

".loadingOuter": {
Expand Down
5 changes: 2 additions & 3 deletions views/loading.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<Alloy>
<Window id="loadingMask" class="loadingMask" onClick="cancel" platform="ios,mobileweb,blackberry">
<Window id="loadingMask" class="loadingMask" onClick="cancel">
<View id="loadingOuter" class="loadingOuter">
<View id="loadingInner" class="loadingInner">
<View id="loadingSpinner" class="loadingSpinner">
Expand All @@ -9,6 +9,5 @@
</View>
</View>
</Window>
<ImageView id="loadingImages" class="loadingImages" platform="ios,mobileweb,blackberry" />
<ProgressIndicator ns="Ti.UI.Android" platform="android" id="loadingProgressIndicator" location="Ti.UI.Android.PROGRESS_INDICATOR_DIALOG" type="Ti.UI.Android.PROGRESS_INDICATOR_INDETERMINANT" onCancel="cancel" />
<ImageView id="loadingImages" class="loadingImages" />
</Alloy>
2 changes: 1 addition & 1 deletion widget.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "nl.fokkezb.loading",
"description" : "Displays a simple loading mask.",
"author": "Fokke Zandbergen",
"version": "1.5",
"version": "1.5.1",
"copyright":"Copyright (c) 2013",
"license":"Apache License, Version 2.0",
"min-alloy-version": "1.0",
Expand Down

0 comments on commit 15ba03d

Please sign in to comment.