@nativescript-community/ui-pulltorefresh 2.5.0 → 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,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
+ ## [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
+
6
14
  # [2.5.0](https://github.com/nativescript-community/ui-pulltorefresh/compare/v2.4.9...v2.5.0) (2021-10-21)
7
15
 
8
16
 
package/README.md CHANGED
@@ -18,7 +18,7 @@ NativeScript plugin to use Pull to Refresh on any view.
18
18
 
19
19
  ## Installation
20
20
 
21
- `tns plugin add @nativescript-community/ui-pulltorefresh`
21
+ `ns plugin add @nativescript-community/ui-pulltorefresh`
22
22
 
23
23
  #### [Android - _SwipeRefreshLayout_](http://developer.android.com/reference/android/support/v4/widget/SwipeRefreshLayout.html)
24
24
 
@@ -43,7 +43,7 @@ NativeScript plugin to use Pull to Refresh on any view.
43
43
  <PullRefresh:PullToRefresh refresh="refreshList">
44
44
  <list-view items="{{ users }}">
45
45
  <list-view.itemTemplate>
46
- <label text="{{ name }}" row="0" col="1"textWrap="true" class="message" />
46
+ <label text="{{ name }}" row="0" col="1" textWrap="true" class="message" />
47
47
  </list-view.itemTemplate>
48
48
  </list-view>
49
49
  </PullRefresh:PullToRefresh>
@@ -146,6 +146,8 @@ export default {
146
146
  - **refresh : function** _required_
147
147
  - **refreshing: boolean** - Notifies the widget that the refresh state has
148
148
  changed.
149
+ - **indicatorColor: Color** - The color of the indicator icon.
150
+ - **indicatorFillColor: Color** - The background color of the indicator.
149
151
 
150
152
  ## [Changelog](./CHANGELOG.md)
151
153
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nativescript-community/ui-pulltorefresh",
3
- "version": "2.5.0",
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": "893ed66ace9018dfbfefeae57adb91dfd8b76b6a"
45
+ "gitHead": "05bcd5d022fbd29e5fe0952fba50ed1a6138637f"
46
46
  }
@@ -1,15 +1,16 @@
1
- import { Color, ContentView, CssProperty, CSSType, Property, Style, 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,50 +23,18 @@ export const refreshingProperty = new Property({
22
23
  defaultValue: false,
23
24
  });
24
25
  refreshingProperty.register(PullToRefreshBase);
25
- export const indicatorColorProperty = new Property({
26
+ export const indicatorColorProperty = new CssProperty({
26
27
  name: 'indicatorColor',
27
- affectsLayout: true,
28
- valueConverter: (v) => {
29
- if (!Color.isValid(v)) {
30
- return null;
31
- }
32
- return new Color(v);
33
- },
34
- });
35
- indicatorColorProperty.register(PullToRefreshBase);
36
- export const indicatorColorStyleProperty = new CssProperty({
37
- name: 'indicatorColorStyle',
38
28
  cssName: 'indicator-color',
39
- affectsLayout: true,
40
- valueConverter: (v) => {
41
- if (!Color.isValid(v)) {
42
- return null;
43
- }
44
- return new Color(v);
45
- },
29
+ equalityComparer: Color.equals,
30
+ valueConverter: (v) => new Color(v),
46
31
  });
47
- indicatorColorStyleProperty.register(Style);
48
- export const indicatorFillColorProperty = new Property({
32
+ indicatorColorProperty.register(Style);
33
+ export const indicatorFillColorProperty = new CssProperty({
49
34
  name: 'indicatorFillColor',
50
- affectsLayout: true,
51
- valueConverter: (v) => {
52
- if (!Color.isValid(v)) {
53
- return null;
54
- }
55
- return new Color(v);
56
- },
57
- });
58
- indicatorFillColorProperty.register(PullToRefreshBase);
59
- export const indicatorFillColorStyleProperty = new CssProperty({
60
- name: 'indicatorFillColorStyle',
61
35
  cssName: 'indicator-fill-color',
62
- affectsLayout: true,
63
- valueConverter: (v) => {
64
- if (!Color.isValid(v)) {
65
- return null;
66
- }
67
- return new Color(v);
68
- },
36
+ equalityComparer: Color.equals,
37
+ valueConverter: (v) => new Color(v),
69
38
  });
70
- indicatorFillColorStyleProperty.register(Style);
39
+ indicatorFillColorProperty.register(Style);
71
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 { indicatorColorProperty, indicatorColorStyleProperty, indicatorFillColorProperty, indicatorFillColorStyleProperty, 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,51 +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);
39
- }
40
- [colorProperty.setNative](value) {
41
- const color = value instanceof Color ? value.android : value;
42
- this.nativeView.setColorSchemeColors([color]);
43
- }
44
- [backgroundColorProperty.setNative](value) {
45
- const color = value instanceof Color ? value.android : value;
46
- this.nativeView.setProgressBackgroundColorSchemeColor(color);
27
+ this.nativeViewProtected.setRefreshing(value);
47
28
  }
48
29
  [indicatorColorProperty.setNative](value) {
49
- const color = value ? value.android : this.color;
50
- this.nativeView.setColorSchemeColors([color]);
51
- }
52
- [indicatorColorStyleProperty.setNative](value) {
53
- // Inline property has priority
54
- if (this.indicatorColor) {
55
- return;
56
- }
57
- const color = value ? value.android : this.color;
58
- this.nativeView.setColorSchemeColors([color]);
30
+ const colors = [];
31
+ value && colors.push(value.android);
32
+ this.nativeViewProtected.setColorSchemeColors(colors);
59
33
  }
60
34
  [indicatorFillColorProperty.setNative](value) {
61
- const color = value ? value.android : this.backgroundColor;
62
- this.nativeView.setProgressBackgroundColorSchemeColor(color);
63
- }
64
- [indicatorFillColorStyleProperty.setNative](value) {
65
- // Inline property has priority
66
- if (this.indicatorFillColor) {
67
- return;
68
- }
69
- const color = value ? value.android : this.backgroundColor;
70
- this.nativeView.setProgressBackgroundColorSchemeColor(color);
35
+ const color = value ? value.android : null;
36
+ this.nativeViewProtected.setProgressBackgroundColorSchemeColor(color);
71
37
  }
72
38
  }
73
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 { indicatorColorProperty, indicatorColorStyleProperty, indicatorFillColorProperty, indicatorFillColorStyleProperty, 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,112 +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;
103
- }
104
- [colorProperty.setNative](value) {
105
- const color = value instanceof Color ? value.ios : value;
106
- this.refreshControl.tintColor = color;
107
- }
108
- [backgroundColorProperty.getDefault]() {
109
- return this.refreshControl.backgroundColor;
110
- }
111
- [backgroundColorProperty.setNative](value) {
112
- const color = value instanceof Color ? value.ios : value;
113
- this.refreshControl.backgroundColor = color;
114
- }
115
97
  [indicatorColorProperty.getDefault]() {
116
- return this.refreshControl.tintColor;
98
+ return this.mRefreshControl.tintColor;
117
99
  }
118
100
  [indicatorColorProperty.setNative](value) {
119
- const color = value ? value.ios : this.color;
120
- this.refreshControl.tintColor = color;
121
- }
122
- [indicatorColorStyleProperty.getDefault]() {
123
- return this.refreshControl.tintColor;
124
- }
125
- [indicatorColorStyleProperty.setNative](value) {
126
- // Inline property has priority
127
- if (this.indicatorColor) {
128
- return;
129
- }
130
- const color = value ? value.ios : this.color;
131
- this.refreshControl.tintColor = color;
101
+ const color = value ? value.ios : null;
102
+ this.mRefreshControl.tintColor = color;
132
103
  }
133
104
  [indicatorFillColorProperty.getDefault]() {
134
- return this.refreshControl.backgroundColor;
105
+ return this.mRefreshControl.backgroundColor;
135
106
  }
136
107
  [indicatorFillColorProperty.setNative](value) {
137
- const color = value ? value.ios : this.backgroundColor;
138
- this.refreshControl.backgroundColor = color;
139
- }
140
- [indicatorFillColorStyleProperty.getDefault]() {
141
- return this.refreshControl.backgroundColor;
142
- }
143
- [indicatorFillColorStyleProperty.setNative](value) {
144
- // Inline property has priority
145
- if (this.indicatorFillColor) {
146
- return;
147
- }
148
- const color = value ? value.ios : this.backgroundColor;
149
- this.refreshControl.backgroundColor = color;
108
+ const color = value ? value.ios : null;
109
+ this.mRefreshControl.backgroundColor = color;
150
110
  }
151
111
  }
152
112
  //# sourceMappingURL=pulltorefresh.ios.js.map