@@ -218,6 +218,7 @@ export function overrideViewBase() {
218
218
@cssProperty rippleColor : Color ;
219
219
inkTouchController : MDCRippleTouchController ;
220
220
shadowLayer : MDCShadowLayer ;
221
+ // shadowView: UIView;
221
222
222
223
nativeViewProtected : UIView ;
223
224
@@ -228,9 +229,10 @@ export function overrideViewBase() {
228
229
// this.inkTouchController.addInkView();
229
230
// const colorScheme = themer.getAppColorScheme();
230
231
// MDCInkColorThemer.applyColorSchemeToInkView(colorScheme, this.inkTouchController.defaultInkView);
231
- if ( this . style . backgroundInternal ) {
232
- this . inkTouchController . rippleView . layer . cornerRadius = Utils . layout . toDeviceIndependentPixels ( this . style . backgroundInternal . borderTopLeftRadius ) ;
233
- }
232
+ this . inkTouchController . rippleView . usesSuperviewShadowLayerAsMask = true ;
233
+ // if (this.style.backgroundInternal) {
234
+ // this.inkTouchController.rippleView.layer.cornerRadius = Utils.layout.toDeviceIndependentPixels(this.style.backgroundInternal.borderTopLeftRadius);
235
+ // }
234
236
}
235
237
return this . inkTouchController ;
236
238
}
@@ -239,28 +241,53 @@ export function overrideViewBase() {
239
241
this . _shadowElevations = this . _shadowElevations || { } ;
240
242
241
243
// create the shadow Layer
244
+ //@ts -ignore
245
+ // const shadowView = ShadowView.alloc().init();
246
+ // this.shadowView = shadowView;
247
+ // this.shadowView.userInteractionEnabled = false;
248
+ // shadowView.clipsToBounds = false;
242
249
const layer = ( this . shadowLayer = MDCShadowLayer . alloc ( ) . init ( ) ) ;
250
+ // const layer = (this.shadowLayer = shadowView.layer);
243
251
layer . shouldRasterize = true ;
244
252
layer . rasterizationScale = UIScreen . mainScreen . scale ;
253
+ // shadowView.frame = this.nativeViewProtected.layer.bounds;
245
254
layer . frame = this . nativeViewProtected . layer . bounds ;
255
+ // this.nativeViewProtected.addSubview(shadowView);
246
256
this . nativeViewProtected . layer . addSublayer ( this . shadowLayer ) ;
247
257
// we need to set clipToBounds to false. For now it overrides user choice.
248
258
this [ 'clipToBounds' ] = false ;
249
259
this . nativeViewProtected . clipsToBounds = false ;
250
- if ( this . style . backgroundInternal ) {
251
- layer . cornerRadius = Utils . layout . toDeviceIndependentPixels ( this . style . backgroundInternal . borderTopLeftRadius ) ;
252
- }
260
+ layer . cornerRadius = this . nativeViewProtected . layer . cornerRadius ;
261
+ layer . mask = this . nativeViewProtected . layer . mask ;
262
+ // if (this.style.backgroundInternal) {
263
+ // layer.cornerRadius = Utils.layout.toDeviceIndependentPixels(this.style.backgroundInternal.borderTopLeftRadius);
264
+ // }
253
265
if ( this . nativeViewProtected instanceof UIControl ) {
254
266
this . startElevationStateChangeHandler ( ) ;
255
267
}
256
268
}
257
269
return this . shadowLayer ;
258
270
}
259
- _onSizeChanged ( ) : void {
260
- if ( this . nativeViewProtected && this . shadowLayer ) {
261
- this . shadowLayer . frame = this . nativeViewProtected . layer . bounds ;
271
+
272
+ updateLayers ( ) {
273
+ const layer = this . nativeViewProtected . layer ;
274
+ if ( layer ) {
275
+ const mask = layer . mask ;
276
+ if ( layer && this . inkTouchController ) {
277
+ this . inkTouchController . rippleView . layer . cornerRadius = layer . cornerRadius ;
278
+ this . inkTouchController . rippleView . layer . mask = layer . mask ;
279
+ }
280
+ if ( layer && this . shadowLayer ) {
281
+ this . shadowLayer . frame = this . nativeViewProtected . layer . bounds ;
282
+ this . shadowLayer . cornerRadius = layer . cornerRadius ;
283
+ this . shadowLayer . mask = layer . mask ;
284
+ }
285
+ layer . mask = mask ;
262
286
}
263
287
}
288
+ _onSizeChanged ( ) : void {
289
+ this . updateLayers ( ) ;
290
+ }
264
291
_setNativeClipToBounds ( ) {
265
292
if ( this . shadowLayer ) {
266
293
this . nativeViewProtected . clipsToBounds = false ;
@@ -360,15 +387,21 @@ export function overrideViewBase() {
360
387
this . _shadowElevations [ 'highlighted' ] = value + elevation ;
361
388
}
362
389
363
- [ backgroundInternalProperty . setNative ] ( value : Background ) {
364
- // base impl will be called before
365
- // if (this.shadowLayer) {
366
- // this.shadowLayer.cornerRadius = Utils.layout.toDeviceIndependentPixels(value.borderTopLeftRadius);
367
- // }
390
+ [ backgroundInternalProperty . setNative ] ( value ) {
391
+ const layer = this . nativeViewProtected . layer ;
368
392
if ( this . inkTouchController ) {
369
- this . inkTouchController . rippleView . layer . cornerRadius = Utils . layout . toDeviceIndependentPixels ( value . borderTopLeftRadius ) ;
393
+ this . inkTouchController . rippleView . layer . cornerRadius = layer . cornerRadius ;
394
+ this . inkTouchController . rippleView . layer . mask = layer . mask ;
395
+ }
396
+ if ( this . shadowLayer ) {
397
+ this . shadowLayer . cornerRadius = layer . cornerRadius ;
398
+ this . shadowLayer . mask = layer . mask ;
370
399
}
371
400
}
401
+
402
+ _redrawNativeBackground ( value ) {
403
+ this . updateLayers ( ) ;
404
+ }
372
405
}
373
406
// we need mixins to be applied after (run default implementation first) because of _setNativeClipToBounds.
374
407
// it needs to be applied after for shadows to be drawn correctly
0 commit comments