@nativescript-community/ui-pulltorefresh 2.4.8 → 2.5.1
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 +27 -0
- package/README.md +7 -18
- package/package.json +2 -2
- package/platforms/android/native-api-usage.json +7 -0
- package/platforms/android/ui_pulltorefresh.aar +0 -0
- package/pulltorefresh-common.js +26 -11
- package/pulltorefresh.android.js +12 -22
- package/pulltorefresh.ios.js +34 -38
package/CHANGELOG.md
CHANGED
@@ -3,6 +3,33 @@
|
|
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
|
+
## [2.5.1](https://github.com/nativescript-community/ui-pulltorefresh/compare/v2.5.0...v2.5.1) (2022-05-09)
|
7
|
+
|
8
|
+
**Note:** Version bump only for package @nativescript-community/ui-pulltorefresh
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
# [2.5.0](https://github.com/nativescript-community/ui-pulltorefresh/compare/v2.4.9...v2.5.0) (2021-10-21)
|
15
|
+
|
16
|
+
|
17
|
+
### Features
|
18
|
+
|
19
|
+
* **android:** native-api-usage ([19397fd](https://github.com/nativescript-community/ui-pulltorefresh/commit/19397fdb8b11ac2f6b47a31c8958a8fa92bf97bf))
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
## [2.4.9](https://github.com/nativescript-community/ui-pulltorefresh/compare/v2.4.8...v2.4.9) (2021-09-27)
|
26
|
+
|
27
|
+
**Note:** Version bump only for package @nativescript-community/ui-pulltorefresh
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
|
32
|
+
|
6
33
|
## [2.4.8](https://github.com/nativescript-community/ui-pulltorefresh/compare/v2.4.7...v2.4.8) (2021-07-08)
|
7
34
|
|
8
35
|
**Note:** Version bump only for package @nativescript-community/ui-pulltorefresh
|
package/README.md
CHANGED
@@ -12,27 +12,13 @@ NativeScript plugin to use Pull to Refresh on any view.
|
|
12
12
|
<a href="https://www.npmjs.com/package/@nativescript-community/ui-pulltorefresh">
|
13
13
|
<img src="https://img.shields.io/npm/dt/@nativescript-community/ui-pulltorefresh.svg?label=npm%20downloads" alt="npm">
|
14
14
|
</a>
|
15
|
-
<a href="https://github.com/nativescript-community/ui-pulltorefresh/stargazers">
|
16
|
-
<img src="https://img.shields.io/github/stars/nativescript-community/ui-pulltorefresh.svg" alt="stars">
|
17
|
-
</a>
|
18
|
-
<a href="https://github.com/nativescript-community/ui-pulltorefresh/network">
|
19
|
-
<img src="https://img.shields.io/github/forks/nativescript-community/ui-pulltorefresh.svg" alt="forks">
|
20
|
-
</a>
|
21
|
-
<a href="https://github.com/nativescript-community/ui-pulltorefresh/blob/master/LICENSE">
|
22
|
-
<img src="https://img.shields.io/github/license/nativescript-community/ui-pulltorefresh.svg" alt="license">
|
23
|
-
</a>
|
24
|
-
<a href="https://nstudio.io">
|
25
|
-
<img src="https://github.com/nstudio/media/blob/master/images/nstudio-banner.png?raw=true" alt="nStudio banner">
|
26
|
-
</a>
|
27
|
-
<h5 align="center">Do you need assistance on your project or plugin? Contact the nStudio team anytime at <a href="mailto:team@nstudio.io">team@nstudio.io</a> to get up to speed with the best practices in mobile and web app development.
|
28
|
-
</h5>
|
29
15
|
</p>
|
30
16
|
|
31
17
|
---
|
32
18
|
|
33
19
|
## Installation
|
34
20
|
|
35
|
-
`
|
21
|
+
`ns plugin add @nativescript-community/ui-pulltorefresh`
|
36
22
|
|
37
23
|
#### [Android - _SwipeRefreshLayout_](http://developer.android.com/reference/android/support/v4/widget/SwipeRefreshLayout.html)
|
38
24
|
|
@@ -57,7 +43,7 @@ NativeScript plugin to use Pull to Refresh on any view.
|
|
57
43
|
<PullRefresh:PullToRefresh refresh="refreshList">
|
58
44
|
<list-view items="{{ users }}">
|
59
45
|
<list-view.itemTemplate>
|
60
|
-
<label text="{{ name }}" row="0" col="1"textWrap="true" class="message" />
|
46
|
+
<label text="{{ name }}" row="0" col="1" textWrap="true" class="message" />
|
61
47
|
</list-view.itemTemplate>
|
62
48
|
</list-view>
|
63
49
|
</PullRefresh:PullToRefresh>
|
@@ -90,8 +76,9 @@ exports.refreshList = refreshList;
|
|
90
76
|
### Angular NativeScript
|
91
77
|
|
92
78
|
```typescript
|
93
|
-
import { registerElement } from
|
94
|
-
|
79
|
+
import { registerElement } from '@nativescript/angular';
|
80
|
+
import { PullToRefresh } from '@nativescript-community/ui-pulltorefresh';
|
81
|
+
registerElement('PullToRefresh', () => PullToRefresh);
|
95
82
|
|
96
83
|
refreshList(args) {
|
97
84
|
const pullRefresh = args.object;
|
@@ -159,6 +146,8 @@ export default {
|
|
159
146
|
- **refresh : function** _required_
|
160
147
|
- **refreshing: boolean** - Notifies the widget that the refresh state has
|
161
148
|
changed.
|
149
|
+
- **indicatorColor: Color** - The color of the indicator icon.
|
150
|
+
- **indicatorFillColor: Color** - The background color of the indicator.
|
162
151
|
|
163
152
|
## [Changelog](./CHANGELOG.md)
|
164
153
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@nativescript-community/ui-pulltorefresh",
|
3
|
-
"version": "2.
|
3
|
+
"version": "2.5.1",
|
4
4
|
"description": "A NativeScript plugin to provide the Pull to Refresh control on any view.",
|
5
5
|
"main": "pulltorefresh",
|
6
6
|
"typings": "index.d.ts",
|
@@ -42,5 +42,5 @@
|
|
42
42
|
"readmeFilename": "README.md",
|
43
43
|
"bugs": "https://github.com/nativescript-community/ui-pulltorefresh/issues",
|
44
44
|
"homepage": "https://github.com/nativescript-community/ui-pulltorefresh",
|
45
|
-
"gitHead": "
|
45
|
+
"gitHead": "05bcd5d022fbd29e5fe0952fba50ed1a6138637f"
|
46
46
|
}
|
Binary file
|
package/pulltorefresh-common.js
CHANGED
@@ -1,15 +1,16 @@
|
|
1
|
-
import { ContentView, CSSType, Property,
|
1
|
+
import { Color, ContentView, CssProperty, CSSType, Property, Style } from '@nativescript/core';
|
2
2
|
let PullToRefreshBase = class PullToRefreshBase extends ContentView {
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
3
|
+
get indicatorColor() {
|
4
|
+
return this.style.indicatorColor;
|
5
|
+
}
|
6
|
+
set indicatorColor(value) {
|
7
|
+
this.style.indicatorColor = value;
|
8
|
+
}
|
9
|
+
get indicatorFillColor() {
|
10
|
+
return this.style.indicatorFillColor;
|
11
|
+
}
|
12
|
+
set indicatorFillColor(value) {
|
13
|
+
this.style.indicatorFillColor = value;
|
13
14
|
}
|
14
15
|
};
|
15
16
|
PullToRefreshBase.refreshEvent = 'refresh';
|
@@ -22,4 +23,18 @@ export const refreshingProperty = new Property({
|
|
22
23
|
defaultValue: false,
|
23
24
|
});
|
24
25
|
refreshingProperty.register(PullToRefreshBase);
|
26
|
+
export const indicatorColorProperty = new CssProperty({
|
27
|
+
name: 'indicatorColor',
|
28
|
+
cssName: 'indicator-color',
|
29
|
+
equalityComparer: Color.equals,
|
30
|
+
valueConverter: (v) => new Color(v),
|
31
|
+
});
|
32
|
+
indicatorColorProperty.register(Style);
|
33
|
+
export const indicatorFillColorProperty = new CssProperty({
|
34
|
+
name: 'indicatorFillColor',
|
35
|
+
cssName: 'indicator-fill-color',
|
36
|
+
equalityComparer: Color.equals,
|
37
|
+
valueConverter: (v) => new Color(v),
|
38
|
+
});
|
39
|
+
indicatorFillColorProperty.register(Style);
|
25
40
|
//# sourceMappingURL=pulltorefresh-common.js.map
|
package/pulltorefresh.android.js
CHANGED
@@ -1,19 +1,12 @@
|
|
1
|
-
import {
|
2
|
-
import { Color } from '@nativescript/core/color';
|
3
|
-
import { PullToRefreshBase, refreshingProperty } from './pulltorefresh-common';
|
1
|
+
import { indicatorColorProperty, indicatorFillColorProperty, PullToRefreshBase, refreshingProperty } from './pulltorefresh-common';
|
4
2
|
export * from './pulltorefresh-common';
|
5
3
|
export class PullToRefresh extends PullToRefreshBase {
|
6
|
-
//@ts-ignore
|
7
|
-
get android() {
|
8
|
-
return this.nativeView;
|
9
|
-
}
|
10
4
|
createNativeView() {
|
11
5
|
const swipeRefreshLayout = new com.nativescript.swiperefreshlayout.CarouselFriendlySwipeRefreshLayout(this._context);
|
12
6
|
return swipeRefreshLayout;
|
13
7
|
}
|
14
8
|
initNativeView() {
|
15
9
|
super.initNativeView();
|
16
|
-
const nativeView = this.nativeView;
|
17
10
|
const androidXListener = new androidx.swiperefreshlayout.widget.SwipeRefreshLayout.OnRefreshListener({
|
18
11
|
onRefresh: () => {
|
19
12
|
this.refreshing = true;
|
@@ -23,27 +16,24 @@ export class PullToRefresh extends PullToRefreshBase {
|
|
23
16
|
});
|
24
17
|
},
|
25
18
|
});
|
26
|
-
|
27
|
-
|
19
|
+
this.nativeViewProtected.setOnRefreshListener(androidXListener);
|
20
|
+
this.nativeViewProtected.refreshListener = androidXListener;
|
28
21
|
}
|
29
22
|
disposeNativeView() {
|
30
|
-
|
31
|
-
nativeView.refreshListener = null;
|
23
|
+
this.nativeViewProtected.refreshListener = null;
|
32
24
|
super.disposeNativeView();
|
33
25
|
}
|
34
|
-
[refreshingProperty.getDefault]() {
|
35
|
-
return false;
|
36
|
-
}
|
37
26
|
[refreshingProperty.setNative](value) {
|
38
|
-
this.
|
27
|
+
this.nativeViewProtected.setRefreshing(value);
|
39
28
|
}
|
40
|
-
[
|
41
|
-
const
|
42
|
-
|
29
|
+
[indicatorColorProperty.setNative](value) {
|
30
|
+
const colors = [];
|
31
|
+
value && colors.push(value.android);
|
32
|
+
this.nativeViewProtected.setColorSchemeColors(colors);
|
43
33
|
}
|
44
|
-
[
|
45
|
-
const color = value
|
46
|
-
this.
|
34
|
+
[indicatorFillColorProperty.setNative](value) {
|
35
|
+
const color = value ? value.android : null;
|
36
|
+
this.nativeViewProtected.setProgressBackgroundColorSchemeColor(color);
|
47
37
|
}
|
48
38
|
}
|
49
39
|
//# sourceMappingURL=pulltorefresh.android.js.map
|
package/pulltorefresh.ios.js
CHANGED
@@ -1,6 +1,5 @@
|
|
1
|
-
import {
|
2
|
-
import {
|
3
|
-
import { PullToRefreshBase, refreshingProperty } from './pulltorefresh-common';
|
1
|
+
import { Utils, } from '@nativescript/core';
|
2
|
+
import { indicatorColorProperty, indicatorFillColorProperty, PullToRefreshBase, refreshingProperty } from './pulltorefresh-common';
|
4
3
|
export * from './pulltorefresh-common';
|
5
4
|
var PullToRefreshHandler = /** @class */ (function (_super) {
|
6
5
|
__extends(PullToRefreshHandler, _super);
|
@@ -29,9 +28,9 @@ const SUPPORT_REFRESH_CONTROL = Utils.ios.MajorVersion >= 10;
|
|
29
28
|
export class PullToRefresh extends PullToRefreshBase {
|
30
29
|
constructor() {
|
31
30
|
super();
|
32
|
-
this.
|
33
|
-
this.
|
34
|
-
this.
|
31
|
+
this.mRefreshControl = UIRefreshControl.alloc().init();
|
32
|
+
this.mHandler = PullToRefreshHandler.initWithOnwer(new WeakRef(this));
|
33
|
+
this.mRefreshControl.addTargetActionForControlEvents(this.mHandler, 'handleRefresh', 4096 /* ValueChanged */);
|
35
34
|
}
|
36
35
|
onLoaded() {
|
37
36
|
super.onLoaded();
|
@@ -41,76 +40,73 @@ export class PullToRefresh extends PullToRefreshBase {
|
|
41
40
|
if (!newView || !newView.nativeViewProtected) {
|
42
41
|
return;
|
43
42
|
}
|
44
|
-
const
|
45
|
-
if (
|
43
|
+
const owner = newView.nativeViewProtected;
|
44
|
+
if (owner instanceof UIScrollView) {
|
46
45
|
if (SUPPORT_REFRESH_CONTROL) {
|
47
|
-
|
46
|
+
owner.refreshControl = this.mRefreshControl;
|
48
47
|
}
|
49
48
|
else {
|
50
49
|
// ensure that we can trigger the refresh, even if the content is not large enough
|
51
|
-
|
52
|
-
|
50
|
+
owner.alwaysBounceVertical = true;
|
51
|
+
owner.addSubview(this.mRefreshControl);
|
53
52
|
}
|
54
53
|
}
|
55
|
-
else if (
|
54
|
+
else if (owner instanceof WKWebView) {
|
56
55
|
if (SUPPORT_REFRESH_CONTROL) {
|
57
|
-
|
56
|
+
owner.scrollView.refreshControl = this.mRefreshControl;
|
58
57
|
}
|
59
58
|
else {
|
60
59
|
// ensure that we can trigger the refresh, even if the content is not large enough
|
61
|
-
|
62
|
-
|
60
|
+
owner.scrollView.alwaysBounceVertical = true;
|
61
|
+
owner.scrollView.addSubview(this.mRefreshControl);
|
63
62
|
}
|
64
63
|
}
|
65
64
|
else if (typeof TKListView !== 'undefined' &&
|
66
|
-
|
65
|
+
owner instanceof TKListView) {
|
67
66
|
if (SUPPORT_REFRESH_CONTROL) {
|
68
|
-
|
67
|
+
owner.collectionView.refreshControl = this.mRefreshControl;
|
69
68
|
}
|
70
69
|
else {
|
71
70
|
// ensure that we can trigger the refresh, even if the content is not large enough
|
72
|
-
|
73
|
-
|
71
|
+
owner.collectionView.alwaysBounceVertical = true;
|
72
|
+
owner.collectionView.addSubview(this.mRefreshControl);
|
74
73
|
}
|
75
74
|
}
|
76
|
-
else if (
|
75
|
+
else if (owner instanceof WKWebView) {
|
77
76
|
if (SUPPORT_REFRESH_CONTROL) {
|
78
|
-
|
77
|
+
owner.scrollView.refreshControl = this.mRefreshControl;
|
79
78
|
}
|
80
79
|
else {
|
81
80
|
// ensure that we can trigger the refresh, even if the content is not large enough
|
82
|
-
|
83
|
-
|
81
|
+
owner.scrollView.alwaysBounceVertical = true;
|
82
|
+
owner.scrollView.addSubview(this.mRefreshControl);
|
84
83
|
}
|
85
84
|
}
|
86
85
|
else {
|
87
86
|
throw new Error('Content must inherit from either UIScrollView or WKWebView!');
|
88
87
|
}
|
89
88
|
}
|
90
|
-
[refreshingProperty.getDefault]() {
|
91
|
-
return false;
|
92
|
-
}
|
93
89
|
[refreshingProperty.setNative](value) {
|
94
90
|
if (value) {
|
95
|
-
this.
|
91
|
+
this.mRefreshControl.beginRefreshing();
|
96
92
|
}
|
97
93
|
else {
|
98
|
-
this.
|
94
|
+
this.mRefreshControl.endRefreshing();
|
99
95
|
}
|
100
96
|
}
|
101
|
-
[
|
102
|
-
return this.
|
97
|
+
[indicatorColorProperty.getDefault]() {
|
98
|
+
return this.mRefreshControl.tintColor;
|
103
99
|
}
|
104
|
-
[
|
105
|
-
const color = value
|
106
|
-
this.
|
100
|
+
[indicatorColorProperty.setNative](value) {
|
101
|
+
const color = value ? value.ios : null;
|
102
|
+
this.mRefreshControl.tintColor = color;
|
107
103
|
}
|
108
|
-
[
|
109
|
-
return this.
|
104
|
+
[indicatorFillColorProperty.getDefault]() {
|
105
|
+
return this.mRefreshControl.backgroundColor;
|
110
106
|
}
|
111
|
-
[
|
112
|
-
const color = value
|
113
|
-
this.
|
107
|
+
[indicatorFillColorProperty.setNative](value) {
|
108
|
+
const color = value ? value.ios : null;
|
109
|
+
this.mRefreshControl.backgroundColor = color;
|
114
110
|
}
|
115
111
|
}
|
116
112
|
//# sourceMappingURL=pulltorefresh.ios.js.map
|