@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.
@@ -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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mB,CAAC,CAAC;aAC/E;SACJ;IACL,CAAC;CACJ"}
package/ripple.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Material Ripple component
3
+ * @module @nativescript-community/ui-material-ripple
4
+ */
5
+
6
+ import { RippleBase } from './ripple-common';
7
+
8
+ export class Ripple extends RippleBase {}
@@ -0,0 +1,5 @@
1
+ import { RippleBase } from './ripple-common';
2
+ export declare class Ripple extends RippleBase {
3
+ inkTouchController: MDCRippleTouchController;
4
+ createNativeView(): UIView;
5
+ }
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
@@ -0,0 +1,4 @@
1
+ declare const _default: {
2
+ install(Vue: any): void;
3
+ };
4
+ export default _default;
package/vue/index.js ADDED
@@ -0,0 +1,11 @@
1
+ import { Ripple } from '../ripple';
2
+ let installed = false;
3
+ export default {
4
+ install(Vue) {
5
+ if (!installed) {
6
+ installed = true;
7
+ Vue.registerElement('MDRipple', () => Ripple, {});
8
+ }
9
+ }
10
+ };
11
+ //# sourceMappingURL=index.js.map
@@ -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"}