@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 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
- `tns plugin add @nativescript-community/ui-pulltorefresh`
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 "nativescript-angular/element-registry";
94
- registerElement("PullToRefresh", () => require("@nativescript-community/ui-pulltorefresh").PullToRefresh);
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.4.8",
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": "724213523bd3702222b6a1c1c3c7d1853b5c601e"
45
+ "gitHead": "05bcd5d022fbd29e5fe0952fba50ed1a6138637f"
46
46
  }
@@ -0,0 +1,7 @@
1
+ {
2
+ "uses": [
3
+ "com.nativescript.swiperefreshlayout:CarouselFriendlySwipeRefreshLayout*",
4
+ "androidx.swiperefreshlayout.widget:SwipeRefreshLayout*",
5
+ "androidx.swiperefreshlayout.widget.SwipeRefreshLayout:OnRefreshListener*"
6
+ ]
7
+ }
@@ -1,15 +1,16 @@
1
- import { ContentView, CSSType, Property, View } from '@nativescript/core';
1
+ import { Color, ContentView, CssProperty, CSSType, Property, Style } from '@nativescript/core';
2
2
  let PullToRefreshBase = class PullToRefreshBase extends ContentView {
3
- _addChildFromBuilder(name, value) {
4
- // copy inheritable style property values
5
- const originalColor = value.style.color || null;
6
- const originaBackgroundColor = value.style.backgroundColor || null;
7
- if (value instanceof View) {
8
- this.content = value;
9
- }
10
- // reset inheritable style property values as we do not want those to be inherited
11
- value.style.color = originalColor;
12
- value.style.backgroundColor = originaBackgroundColor;
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
@@ -1,19 +1,12 @@
1
- import { backgroundColorProperty, colorProperty } from '@nativescript/core';
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
- nativeView.setOnRefreshListener(androidXListener);
27
- nativeView.refreshListener = androidXListener;
19
+ this.nativeViewProtected.setOnRefreshListener(androidXListener);
20
+ this.nativeViewProtected.refreshListener = androidXListener;
28
21
  }
29
22
  disposeNativeView() {
30
- const nativeView = this.nativeView;
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.nativeView.setRefreshing(value);
27
+ this.nativeViewProtected.setRefreshing(value);
39
28
  }
40
- [colorProperty.setNative](value) {
41
- const color = value instanceof Color ? value.android : value;
42
- this.nativeView.setColorSchemeColors([color]);
29
+ [indicatorColorProperty.setNative](value) {
30
+ const colors = [];
31
+ value && colors.push(value.android);
32
+ this.nativeViewProtected.setColorSchemeColors(colors);
43
33
  }
44
- [backgroundColorProperty.setNative](value) {
45
- const color = value instanceof Color ? value.android : value;
46
- this.nativeView.setProgressBackgroundColorSchemeColor(color);
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
@@ -1,6 +1,5 @@
1
- import { Color } from '@nativescript/core/color';
2
- import { backgroundColorProperty, colorProperty, Utils, } from '@nativescript/core';
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.refreshControl = UIRefreshControl.alloc().init();
33
- this._handler = PullToRefreshHandler.initWithOnwer(new WeakRef(this));
34
- this.refreshControl.addTargetActionForControlEvents(this._handler, 'handleRefresh', 4096 /* ValueChanged */);
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 nNewView = newView.nativeViewProtected;
45
- if (nNewView instanceof UIScrollView) {
43
+ const owner = newView.nativeViewProtected;
44
+ if (owner instanceof UIScrollView) {
46
45
  if (SUPPORT_REFRESH_CONTROL) {
47
- nNewView.refreshControl = this.refreshControl;
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
- nNewView.alwaysBounceVertical = true;
52
- nNewView.addSubview(this.refreshControl);
50
+ owner.alwaysBounceVertical = true;
51
+ owner.addSubview(this.mRefreshControl);
53
52
  }
54
53
  }
55
- else if (nNewView instanceof WKWebView) {
54
+ else if (owner instanceof WKWebView) {
56
55
  if (SUPPORT_REFRESH_CONTROL) {
57
- nNewView.scrollView.refreshControl = this.refreshControl;
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
- nNewView.scrollView.alwaysBounceVertical = true;
62
- nNewView.scrollView.addSubview(this.refreshControl);
60
+ owner.scrollView.alwaysBounceVertical = true;
61
+ owner.scrollView.addSubview(this.mRefreshControl);
63
62
  }
64
63
  }
65
64
  else if (typeof TKListView !== 'undefined' &&
66
- nNewView instanceof TKListView) {
65
+ owner instanceof TKListView) {
67
66
  if (SUPPORT_REFRESH_CONTROL) {
68
- nNewView.collectionView.refreshControl = this.refreshControl;
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
- nNewView.collectionView.alwaysBounceVertical = true;
73
- nNewView.collectionView.addSubview(this.refreshControl);
71
+ owner.collectionView.alwaysBounceVertical = true;
72
+ owner.collectionView.addSubview(this.mRefreshControl);
74
73
  }
75
74
  }
76
- else if (nNewView instanceof WKWebView) {
75
+ else if (owner instanceof WKWebView) {
77
76
  if (SUPPORT_REFRESH_CONTROL) {
78
- nNewView.scrollView.refreshControl = this.refreshControl;
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
- nNewView.scrollView.alwaysBounceVertical = true;
83
- nNewView.scrollView.addSubview(this.refreshControl);
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.refreshControl.beginRefreshing();
91
+ this.mRefreshControl.beginRefreshing();
96
92
  }
97
93
  else {
98
- this.refreshControl.endRefreshing();
94
+ this.mRefreshControl.endRefreshing();
99
95
  }
100
96
  }
101
- [colorProperty.getDefault]() {
102
- return this.refreshControl.tintColor;
97
+ [indicatorColorProperty.getDefault]() {
98
+ return this.mRefreshControl.tintColor;
103
99
  }
104
- [colorProperty.setNative](value) {
105
- const color = value instanceof Color ? value.ios : value;
106
- this.refreshControl.tintColor = color;
100
+ [indicatorColorProperty.setNative](value) {
101
+ const color = value ? value.ios : null;
102
+ this.mRefreshControl.tintColor = color;
107
103
  }
108
- [backgroundColorProperty.getDefault]() {
109
- return this.refreshControl.backgroundColor;
104
+ [indicatorFillColorProperty.getDefault]() {
105
+ return this.mRefreshControl.backgroundColor;
110
106
  }
111
- [backgroundColorProperty.setNative](value) {
112
- const color = value instanceof Color ? value.ios : value;
113
- this.refreshControl.backgroundColor = color;
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