@@ -2,7 +2,7 @@ import { Background, Button, Color, Length, PercentLength, Utils, View, androidD
2
2
import { ad } from '@nativescript/core/utils' ;
3
3
import { ShapeProperties } from '.' ;
4
4
import { createRippleDrawable , createStateListAnimator , getAttrColor , getColorStateList , handleClearFocus , isPostLollipop , isPostMarshmallow } from './android/utils' ;
5
- import { cssProperty , dynamicElevationOffsetProperty , elevationProperty , rippleColorProperty } from './cssproperties' ;
5
+ import { cssProperty , dynamicElevationOffsetProperty , elevationProperty , rippleColorAlphaProperty , rippleColorProperty } from './cssproperties' ;
6
6
import { CornerFamily , applyMixins } from './index.common' ;
7
7
export * from './cssproperties' ;
8
8
export { applyMixins } ;
@@ -197,10 +197,13 @@ export const themer = new Themer();
197
197
198
198
export function install ( ) { }
199
199
200
- export function getRippleColor ( color : string | Color ) {
200
+ export function getRippleColor ( color : string | Color , alpha = 61.5 ) {
201
201
if ( color ) {
202
202
const temp = color instanceof Color ? color : new Color ( color ) ;
203
- return new Color ( temp . a !== 255 ? temp . a : 61.5 , temp . r , temp . g , temp . b ) . android ; // default alpha is 0.24
203
+ if ( temp . a !== 255 ) {
204
+ return temp . android ;
205
+ }
206
+ return temp . setAlpha ( alpha ) . android ;
204
207
}
205
208
return null ;
206
209
}
@@ -212,6 +215,7 @@ export function overrideViewBase() {
212
215
@cssProperty elevation = 0 ;
213
216
@cssProperty dynamicElevationOffset = 0 ;
214
217
@cssProperty rippleColor : Color ;
218
+ @cssProperty rippleColorAlpha : number ;
215
219
rippleDrawable : android . graphics . drawable . Drawable ;
216
220
getRippleColor ( ) {
217
221
if ( this . rippleColor ) {
@@ -229,7 +233,7 @@ export function overrideViewBase() {
229
233
}
230
234
}
231
235
[ rippleColorProperty . setNative ] ( color : Color ) {
232
- const rippleColor = getRippleColor ( color ) ;
236
+ const rippleColor = getRippleColor ( color , this . rippleColorAlpha ) ;
233
237
const nativeViewProtected = this . nativeViewProtected ;
234
238
const RippleDrawable = android . graphics . drawable . RippleDrawable ;
235
239
if ( this instanceof Button && isPostMarshmallow ) {
@@ -263,6 +267,13 @@ export function overrideViewBase() {
263
267
}
264
268
}
265
269
270
+ [ rippleColorAlphaProperty . setNative ] ( value : number ) {
271
+ const rippleColor = this . rippleColor ;
272
+ if ( rippleColor ) {
273
+ this [ rippleColorProperty . setNative ] ( rippleColor ) ;
274
+ }
275
+ }
276
+
266
277
[ backgroundInternalProperty . setNative ] ( value : android . graphics . drawable . Drawable | Background ) {
267
278
if ( this . nativeViewProtected ) {
268
279
if ( value instanceof android . graphics . drawable . Drawable ) {
0 commit comments