@nativescript-community/ui-material-ripple 6.0.0
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 +1542 -0
- package/LICENSE +201 -0
- package/README.md +114 -0
- package/angular/bundles/nativescript-community-ui-material-ripple-angular.umd.js +68 -0
- package/angular/bundles/nativescript-community-ui-material-ripple-angular.umd.js.map +1 -0
- package/angular/bundles/nativescript-community-ui-material-ripple-angular.umd.min.js +2 -0
- package/angular/bundles/nativescript-community-ui-material-ripple-angular.umd.min.js.map +1 -0
- package/angular/esm2015/index.js +27 -0
- package/angular/esm2015/nativescript-community-ui-material-ripple-angular.js +2 -0
- package/angular/fesm2015/nativescript-community-ui-material-ripple-angular.js +30 -0
- package/angular/fesm2015/nativescript-community-ui-material-ripple-angular.js.map +1 -0
- package/angular/index.d.ts +10 -0
- package/angular/nativescript-community-ui-material-ripple-angular.d.ts +2 -0
- package/angular/package.json +16 -0
- package/package.json +51 -0
- package/platforms/ios/Podfile +1 -0
- package/ripple-common.d.ts +4 -0
- package/ripple-common.js +13 -0
- package/ripple-common.js.map +1 -0
- package/ripple.android.d.ts +9 -0
- package/ripple.android.js +207 -0
- package/ripple.android.js.map +1 -0
- package/ripple.d.ts +8 -0
- package/ripple.ios.d.ts +5 -0
- package/ripple.ios.js +17 -0
- package/ripple.ios.js.map +1 -0
- package/vue/index.d.ts +4 -0
- package/vue/index.js +11 -0
- package/vue/index.js.map +1 -0
@@ -0,0 +1,207 @@
|
|
1
|
+
import { getRippleColor, rippleColorProperty, themer } from '@nativescript-community/ui-material-core';
|
2
|
+
import { backgroundInternalProperty } from '@nativescript/core';
|
3
|
+
import { createRippleDrawable, isPostLollipopMR1, isPostMarshmallow } from '@nativescript-community/ui-material-core/android/utils';
|
4
|
+
import { RippleBase } from './ripple-common';
|
5
|
+
let MDStackLayout;
|
6
|
+
const DEFAULT_STROKE_VALUE = -1;
|
7
|
+
function initMDStackLayout() {
|
8
|
+
if (!MDStackLayout) {
|
9
|
+
if (isPostLollipopMR1()) {
|
10
|
+
MDStackLayout = org.nativescript.widgets.StackLayout;
|
11
|
+
}
|
12
|
+
else {
|
13
|
+
initializePreLollipopStackLayout();
|
14
|
+
MDStackLayout = PreLollipopStackLayout;
|
15
|
+
}
|
16
|
+
}
|
17
|
+
}
|
18
|
+
let PreLollipopStackLayout;
|
19
|
+
function initializePreLollipopStackLayout() {
|
20
|
+
if (PreLollipopStackLayout) {
|
21
|
+
return;
|
22
|
+
}
|
23
|
+
var PreLollipopStackLayoutImpl = /** @class */ (function (_super) {
|
24
|
+
__extends(PreLollipopStackLayoutImpl, _super);
|
25
|
+
function PreLollipopStackLayoutImpl(context) {
|
26
|
+
var _this = _super.call(this, context) || this;
|
27
|
+
_this.mSelfBounds = new android.graphics.Rect();
|
28
|
+
_this.mOverlayBounds = new android.graphics.Rect();
|
29
|
+
_this.mForegroundGravity = android.view.Gravity.FILL;
|
30
|
+
_this.mForegroundInPadding = true;
|
31
|
+
_this.mForegroundBoundsChanged = false;
|
32
|
+
return global.__native(_this);
|
33
|
+
}
|
34
|
+
/**
|
35
|
+
* Describes how the foreground is positioned.
|
36
|
+
*
|
37
|
+
* @return foreground gravity.
|
38
|
+
* @see #setForegroundGravity(int)
|
39
|
+
*/
|
40
|
+
PreLollipopStackLayoutImpl.prototype.getForegroundGravity = function () {
|
41
|
+
return this.mForegroundGravity;
|
42
|
+
};
|
43
|
+
/**
|
44
|
+
* Describes how the foreground is positioned. Defaults to START and TOP.
|
45
|
+
*
|
46
|
+
* @param foregroundGravity See {@link android.view.Gravity}
|
47
|
+
* @see #getForegroundGravity()
|
48
|
+
*/
|
49
|
+
PreLollipopStackLayoutImpl.prototype.setForegroundGravity = function (foregroundGravity) {
|
50
|
+
if (this.mForegroundGravity !== foregroundGravity) {
|
51
|
+
if ((foregroundGravity & android.view.Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK) === 0) {
|
52
|
+
foregroundGravity |= android.view.Gravity.START;
|
53
|
+
}
|
54
|
+
if ((foregroundGravity & android.view.Gravity.VERTICAL_GRAVITY_MASK) === 0) {
|
55
|
+
foregroundGravity |= android.view.Gravity.TOP;
|
56
|
+
}
|
57
|
+
this.mForegroundGravity = foregroundGravity;
|
58
|
+
if (this.mForegroundGravity === android.view.Gravity.FILL && this.mForeground != null) {
|
59
|
+
var padding = new android.graphics.Rect();
|
60
|
+
this.mForeground.getPadding(padding);
|
61
|
+
}
|
62
|
+
this.requestLayout();
|
63
|
+
}
|
64
|
+
};
|
65
|
+
PreLollipopStackLayoutImpl.prototype.verifyDrawable = function (who) {
|
66
|
+
return _super.prototype.verifyDrawable.call(this, who) || who === this.mForeground;
|
67
|
+
};
|
68
|
+
PreLollipopStackLayoutImpl.prototype.jumpDrawablesToCurrentState = function () {
|
69
|
+
_super.prototype.jumpDrawablesToCurrentState.call(this);
|
70
|
+
if (this.mForeground != null) {
|
71
|
+
this.mForeground.jumpToCurrentState();
|
72
|
+
}
|
73
|
+
};
|
74
|
+
PreLollipopStackLayoutImpl.prototype.drawableStateChanged = function () {
|
75
|
+
_super.prototype.drawableStateChanged.call(this);
|
76
|
+
if (this.mForeground != null && this.mForeground.isStateful()) {
|
77
|
+
this.mForeground.setState(this.getDrawableState());
|
78
|
+
}
|
79
|
+
};
|
80
|
+
/**
|
81
|
+
* Supply a Drawable that is to be rendered on top of all of the child
|
82
|
+
* views in the frame Utils.layout. Any padding in the Drawable will be taken
|
83
|
+
* into account by ensuring that the children are inset to be placed
|
84
|
+
* inside of the padding area.
|
85
|
+
*
|
86
|
+
* @param drawable The Drawable to be drawn on top of the children.
|
87
|
+
*/
|
88
|
+
PreLollipopStackLayoutImpl.prototype.setForeground = function (drawable) {
|
89
|
+
if (this.mForeground !== drawable) {
|
90
|
+
if (this.mForeground != null) {
|
91
|
+
this.mForeground.setCallback(null);
|
92
|
+
this.unscheduleDrawable(this.mForeground);
|
93
|
+
}
|
94
|
+
this.mForeground = drawable;
|
95
|
+
if (drawable != null) {
|
96
|
+
this.setWillNotDraw(false);
|
97
|
+
drawable.setCallback(this);
|
98
|
+
if (drawable.isStateful()) {
|
99
|
+
drawable.setState(this.getDrawableState());
|
100
|
+
}
|
101
|
+
if (this.mForegroundGravity === android.view.Gravity.FILL) {
|
102
|
+
var padding = new android.graphics.Rect();
|
103
|
+
drawable.getPadding(padding);
|
104
|
+
}
|
105
|
+
}
|
106
|
+
else {
|
107
|
+
this.setWillNotDraw(true);
|
108
|
+
}
|
109
|
+
this.requestLayout();
|
110
|
+
this.invalidate();
|
111
|
+
}
|
112
|
+
};
|
113
|
+
/**
|
114
|
+
* Returns the drawable used as the foreground of this FrameLayout. The
|
115
|
+
* foreground drawable, if non-null, is always drawn on top of the children.
|
116
|
+
*
|
117
|
+
* @return A Drawable or null if no foreground was set.
|
118
|
+
*/
|
119
|
+
PreLollipopStackLayoutImpl.prototype.getForeground = function () {
|
120
|
+
return this.mForeground;
|
121
|
+
};
|
122
|
+
PreLollipopStackLayoutImpl.prototype.onLayout = function (changed, left, top, right, bottom) {
|
123
|
+
_super.prototype.onLayout.call(this, changed, left, top, right, bottom);
|
124
|
+
this.mForegroundBoundsChanged = this.mForegroundBoundsChanged || changed;
|
125
|
+
};
|
126
|
+
PreLollipopStackLayoutImpl.prototype.onSizeChanged = function (w, h, oldw, oldh) {
|
127
|
+
_super.prototype.onSizeChanged.call(this, w, h, oldw, oldh);
|
128
|
+
this.mForegroundBoundsChanged = true;
|
129
|
+
};
|
130
|
+
PreLollipopStackLayoutImpl.prototype.draw = function (canvas) {
|
131
|
+
_super.prototype.draw.call(this, canvas);
|
132
|
+
if (this.mForeground != null) {
|
133
|
+
var foreground = this.mForeground;
|
134
|
+
if (this.mForegroundBoundsChanged) {
|
135
|
+
this.mForegroundBoundsChanged = false;
|
136
|
+
var selfBounds = this.mSelfBounds;
|
137
|
+
var overlayBounds = this.mOverlayBounds;
|
138
|
+
var w = this.getRight() - this.getLeft();
|
139
|
+
var h = this.getBottom() - this.getTop();
|
140
|
+
if (this.mForegroundInPadding) {
|
141
|
+
selfBounds.set(0, 0, w, h);
|
142
|
+
}
|
143
|
+
else {
|
144
|
+
selfBounds.set(this.getPaddingLeft(), this.getPaddingTop(), w - this.getPaddingRight(), h - this.getPaddingBottom());
|
145
|
+
}
|
146
|
+
android.view.Gravity.apply(this.mForegroundGravity, foreground.getIntrinsicWidth(), foreground.getIntrinsicHeight(), selfBounds, overlayBounds);
|
147
|
+
foreground.setBounds(overlayBounds);
|
148
|
+
}
|
149
|
+
foreground.draw(canvas);
|
150
|
+
}
|
151
|
+
};
|
152
|
+
PreLollipopStackLayoutImpl.prototype.drawableHotspotChanged = function (x, y) {
|
153
|
+
_super.prototype.drawableHotspotChanged.call(this, x, y);
|
154
|
+
if (this.mForeground != null) {
|
155
|
+
this.mForeground.setHotspot(x, y);
|
156
|
+
}
|
157
|
+
};
|
158
|
+
return PreLollipopStackLayoutImpl;
|
159
|
+
}(org.nativescript.widgets.StackLayout));
|
160
|
+
PreLollipopStackLayout = PreLollipopStackLayoutImpl;
|
161
|
+
}
|
162
|
+
export class Ripple extends RippleBase {
|
163
|
+
createNativeView() {
|
164
|
+
const view = super.createNativeView();
|
165
|
+
this.setRippleDrawable(view);
|
166
|
+
return view;
|
167
|
+
}
|
168
|
+
getRippleColor() {
|
169
|
+
if (this.rippleColor) {
|
170
|
+
return getRippleColor(this.rippleColor);
|
171
|
+
}
|
172
|
+
return getRippleColor(themer.getAccentColor());
|
173
|
+
}
|
174
|
+
setRippleDrawable(view, radius = 0) {
|
175
|
+
if (!this.rippleDrawable) {
|
176
|
+
this.rippleDrawable = createRippleDrawable(this.getRippleColor(), radius);
|
177
|
+
if (isPostMarshmallow()) {
|
178
|
+
view.setForeground(this.rippleDrawable);
|
179
|
+
}
|
180
|
+
}
|
181
|
+
}
|
182
|
+
[rippleColorProperty.setNative](color) {
|
183
|
+
if (!this.rippleDrawable) {
|
184
|
+
this.setRippleDrawable(this.nativeViewProtected);
|
185
|
+
}
|
186
|
+
else {
|
187
|
+
if (isPostLollipopMR1()) {
|
188
|
+
this.rippleDrawable.setColor(android.content.res.ColorStateList.valueOf(color.android));
|
189
|
+
}
|
190
|
+
else {
|
191
|
+
this.rippleDrawable.rippleShape.getPaint().setColor(getRippleColor(color));
|
192
|
+
}
|
193
|
+
}
|
194
|
+
}
|
195
|
+
[backgroundInternalProperty.setNative](value) {
|
196
|
+
super[backgroundInternalProperty.setNative](value);
|
197
|
+
if (this.nativeViewProtected) {
|
198
|
+
if (value instanceof android.graphics.drawable.Drawable) {
|
199
|
+
}
|
200
|
+
else {
|
201
|
+
this.rippleDrawable = null;
|
202
|
+
this.setRippleDrawable(this.nativeViewProtected, value.borderTopLeftRadius);
|
203
|
+
}
|
204
|
+
}
|
205
|
+
}
|
206
|
+
}
|
207
|
+
//# sourceMappingURL=ripple.android.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ripple.android.js","sourceRoot":"../src/","sources":["ripple.android.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,0CAA0C,CAAC;AACvG,OAAO,EAAqB,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AACnF,OAAO,EAAE,oBAAoB,EAAgB,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,wDAAwD,CAAC;AAClJ,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,IAAI,aAA0D,CAAC;AAE/D,MAAM,oBAAoB,GAAG,CAAC,CAAC,CAAC;AAChC,SAAS,iBAAiB;IACtB,IAAI,CAAC,aAAa,EAAE;QAChB,IAAI,iBAAiB,EAAE,EAAE;YACrB,aAAa,GAAG,GAAG,CAAC,YAAY,CAAC,OAAO,CAAC,WAAW,CAAC;SACxD;aAAM;YACH,gCAAgC,EAAE,CAAC;YACnC,aAAa,GAAG,sBAA6B,CAAC;SACjD;KACJ;AACL,CAAC;AAOD,IAAI,sBAA8C,CAA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C,GAAG,CAAC,cAAc,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;aACzI;iBAAM;gBACF,IAAI,CAAC,cAAsB,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC;aACvF;SACJ;IACL,CAAC;IAED,CAAC,0BAA0B,CAAC,SAAS,CAAC,CAAC,KAAsD;QACzF,KAAK,CAAC,0BAA0B,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,CAAC;QACnD,IAAI,IAAI,CAAC,mBAAmB,EAAE;YAC1B,IAAI,KAAK,YAAY,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,EAAE;aACxD;iBAAM;gBACH,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;gBAC3B,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,mBAAmB,EAAE,KAAK,CAAC,mBAAmB,CAAC,CAAC;aAC/E;SACJ;IACL,CAAC;CACJ"}
|
package/ripple.d.ts
ADDED
package/ripple.ios.d.ts
ADDED
package/ripple.ios.js
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
import { getRippleColor, rippleColorProperty, themer } from '@nativescript-community/ui-material-core';
|
2
|
+
import { RippleBase } from './ripple-common';
|
3
|
+
export class Ripple extends RippleBase {
|
4
|
+
createNativeView() {
|
5
|
+
const view = UIView.alloc().init();
|
6
|
+
this.inkTouchController = MDCRippleTouchController.alloc().initWithView(view);
|
7
|
+
const colorScheme = themer.getAppColorScheme();
|
8
|
+
if (colorScheme && colorScheme.primaryColor) {
|
9
|
+
this.inkTouchController.rippleView.rippleColor = colorScheme.primaryColor.colorWithAlphaComponent(0.24);
|
10
|
+
}
|
11
|
+
return view;
|
12
|
+
}
|
13
|
+
[rippleColorProperty.setNative](color) {
|
14
|
+
this.inkTouchController.rippleView.rippleColor = getRippleColor(color);
|
15
|
+
}
|
16
|
+
}
|
17
|
+
//# sourceMappingURL=ripple.ios.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ripple.ios.js","sourceRoot":"../src/","sources":["ripple.ios.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,0CAA0C,CAAC;AAEvG,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,MAAM,OAAO,MAAO,SAAQ,UAAU;IAE3B,gBAAgB;QACnB,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,CAAC;QACnC,IAAI,CAAC,kBAAkB,GAAG,wBAAwB,CAAC,KAAK,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;QAE9E,MAAM,WAAW,GAAG,MAAM,CAAC,iBAAiB,EAA4B,CAAC;QACzE,IAAI,WAAW,IAAI,WAAW,CAAC,YAAY,EAAE;YACzC,IAAI,CAAC,kBAAkB,CAAC,UAAU,CAAC,WAAW,GAAE,WAAW,CAAC,YAAY,CAAC,uBAAuB,CAAC,IAAI,CAAC,CAAC;SAC1G;QAGD,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,CAAC,mBAAmB,CAAC,SAAS,CAAC,CAAC,KAAY;QACxC,IAAI,CAAC,kBAAkB,CAAC,UAAU,CAAC,WAAW,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC;IAC3E,CAAC;CACJ"}
|
package/vue/index.d.ts
ADDED
package/vue/index.js
ADDED
package/vue/index.js.map
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../src/","sources":["vue/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC,IAAI,SAAS,GAAG,KAAK,CAAC;AACtB,eAAe;IACX,OAAO,CAAC,GAAG;QACP,IAAI,CAAC,SAAS,EAAE;YACZ,SAAS,GAAG,IAAI,CAAC;YACjB,GAAG,CAAC,eAAe,CAAC,UAAU,EAAE,GAAG,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;SACrD;IACL,CAAC;CACJ,CAAC"}
|