@nativescript-community/ui-activityindicator 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/index.android.d.ts +6 -1
- package/index.android.js +49 -8
- package/index.android.js.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.0.4](https://github.com/nativescript-community/ui-native-components/compare/v1.0.3...v1.0.4) (2026-10-22)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @nativescript-community/ui-activityindicator
|
|
9
|
+
|
|
10
|
+
## [1.0.3](https://github.com/nativescript-community/ui-native-components/compare/v1.0.2...v1.0.3) (2026-10-22)
|
|
11
|
+
|
|
12
|
+
**Note:** Version bump only for package @nativescript-community/ui-activityindicator
|
|
13
|
+
|
|
6
14
|
## [1.0.2](https://github.com/nativescript-community/ui-native-components/compare/v1.0.1...v1.0.2) (2026-10-20)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @nativescript-community/ui-activityindicator
|
package/index.android.d.ts
CHANGED
|
@@ -7,6 +7,11 @@ export declare class ActivityIndicator extends ActivityIndicatorBase {
|
|
|
7
7
|
[maxValueProperty.setNative]: (value: number) => void;
|
|
8
8
|
[indeterminateProperty.setNative]: (value: boolean) => void;
|
|
9
9
|
nativeViewProtected: com.google.android.material.progressindicator.CircularProgressIndicator;
|
|
10
|
+
private defaults?;
|
|
10
11
|
createNativeView(): com.google.android.material.progressindicator.CircularProgressIndicator;
|
|
11
|
-
|
|
12
|
+
initNativeView(): void;
|
|
13
|
+
disposeNativeView(): void;
|
|
14
|
+
private getRequestedSize;
|
|
15
|
+
private fitIndicatorSize;
|
|
16
|
+
private applyIndicatorSize;
|
|
12
17
|
}
|
package/index.android.js
CHANGED
|
@@ -2,18 +2,59 @@ import { inflateLayout } from '@nativescript-community/ui-core/android/utils';
|
|
|
2
2
|
import { Utils } from '@nativescript/core';
|
|
3
3
|
import { ActivityIndicatorBase, indeterminateProperty, maxValueProperty, valueProperty, wavyProperty } from './index-common';
|
|
4
4
|
export class ActivityIndicator extends ActivityIndicatorBase {
|
|
5
|
-
// The indicator draws at its own size (40dp, 48dp when wavy), whatever the size of the view
|
|
6
|
-
//
|
|
5
|
+
// The indicator draws at its own size (40dp, 48dp when wavy), whatever the size of the view. NativeScript lays out
|
|
6
|
+
// natively on Android, onMeasure/onLayout are never called in JS, and the Material indicator measures itself at its
|
|
7
|
+
// own size whatever the spec: the size asked for (the smallest side of width/height) is applied to it before the
|
|
8
|
+
// first measure, and again if the layout changes.
|
|
7
9
|
createNativeView() {
|
|
8
10
|
return inflateLayout(this._context, 'ns_ui_circular_progress');
|
|
9
11
|
}
|
|
10
|
-
|
|
11
|
-
super
|
|
12
|
+
initNativeView() {
|
|
13
|
+
// before super: that is where the native layout listener is installed, only if somebody listens by then
|
|
14
|
+
this.on('layoutChanged', this.fitIndicatorSize, this);
|
|
15
|
+
super.initNativeView();
|
|
16
|
+
// the first measure must already see the size: the indicator measures itself at its own size, whatever the spec
|
|
17
|
+
const requested = this.getRequestedSize();
|
|
18
|
+
if (requested !== Infinity) {
|
|
19
|
+
this.applyIndicatorSize(requested);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
disposeNativeView() {
|
|
23
|
+
this.off('layoutChanged', this.fitIndicatorSize, this);
|
|
24
|
+
super.disposeNativeView();
|
|
25
|
+
}
|
|
26
|
+
// the smallest side of the width/height asked for, in pixels, Infinity without any
|
|
27
|
+
getRequestedSize() {
|
|
28
|
+
const toPixels = (length) => {
|
|
29
|
+
if (typeof length === 'number') {
|
|
30
|
+
return Math.round(Utils.layout.toDevicePixels(length));
|
|
31
|
+
}
|
|
32
|
+
if (length && typeof length === 'object') {
|
|
33
|
+
return length.unit === 'dip' ? Math.round(Utils.layout.toDevicePixels(length.value)) : length.unit === 'px' ? length.value : Infinity;
|
|
34
|
+
}
|
|
35
|
+
return Infinity;
|
|
36
|
+
};
|
|
37
|
+
return Math.min(toPixels(this.width), toPixels(this.height));
|
|
38
|
+
}
|
|
39
|
+
fitIndicatorSize() {
|
|
40
|
+
const params = this.nativeViewProtected?.getLayoutParams();
|
|
41
|
+
const requested = params ? Math.min(params.width > 0 ? params.width : Infinity, params.height > 0 ? params.height : Infinity) : Infinity;
|
|
42
|
+
if (requested !== Infinity) {
|
|
43
|
+
this.applyIndicatorSize(requested);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
applyIndicatorSize(requested) {
|
|
12
47
|
const indicator = this.nativeViewProtected;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
48
|
+
// a smaller indicator gets a thinner track and a smaller inset, or it ends up a blob
|
|
49
|
+
this.defaults ?? (this.defaults = { inset: indicator.getIndicatorInset(), thickness: indicator.getTrackThickness(), outer: indicator.getIndicatorSize() + 2 * indicator.getIndicatorInset() });
|
|
50
|
+
const scale = Math.min(1, requested / this.defaults.outer);
|
|
51
|
+
const inset = Math.round(this.defaults.inset * scale);
|
|
52
|
+
const thickness = Math.max(1, Math.round(this.defaults.thickness * scale));
|
|
53
|
+
const indicatorSize = Math.max(0, requested - 2 * inset);
|
|
54
|
+
if (inset !== indicator.getIndicatorInset() || thickness !== indicator.getTrackThickness() || indicatorSize !== indicator.getIndicatorSize()) {
|
|
55
|
+
indicator.setIndicatorInset(inset);
|
|
56
|
+
indicator.setTrackThickness(thickness);
|
|
57
|
+
indicator.setIndicatorSize(indicatorSize);
|
|
17
58
|
}
|
|
18
59
|
}
|
|
19
60
|
[wavyProperty.setNative](value) {
|
package/index.android.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.android.js","sourceRoot":"","sources":["../../src/ui-activityindicator/index.android.ts"],"names":[],"mappings":"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QAC7D,MAAM,SAAS,GAAG,IAAI,CAAC,mBAA0B,CAAC;QAClD,MAAM,EAAE,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC;QACzE,oFAAoF;QACpF,SAAS,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAChD,SAAS,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC5C,IAAI,KAAK,EAAE,CAAC;YACR,SAAS,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC;QACnC,CAAC;IACL,CAAC;IAED,CAAC,aAAa,CAAC,UAAU,CAAC;QACtB,OAAO,CAAC,CAAC;IACb,CAAC;IACD,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,KAAa;QACnC,IAAI,CAAC,mBAAmB,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IAChD,CAAC;IAED,CAAC,gBAAgB,CAAC,UAAU,CAAC;QACzB,OAAO,GAAG,CAAC;IACf,CAAC;IACD,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC,KAAa;QACtC,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC3C,CAAC;IAED,CAAC,qBAAqB,CAAC,SAAS,CAAC,CAAC,KAAc;QAC5C,IAAI,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;IACrD,CAAC;CACJ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nativescript-community/ui-activityindicator",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "ActivityIndicator augmented with indeterminate/value/maxValue. Material on Android, native UIActivityIndicatorView on iOS.",
|
|
5
5
|
"main": "./index",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
},
|
|
45
45
|
"readmeFilename": "README.md",
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@nativescript-community/ui-core": "^1.0.
|
|
47
|
+
"@nativescript-community/ui-core": "^1.0.4"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "358aa6ead1f6155e4c2cfd4abe39c77c07431414"
|
|
50
50
|
}
|