@@ -218,6 +218,7 @@ export function overrideViewBase() {
218218 @cssProperty rippleColor : Color ;
219219 inkTouchController : MDCRippleTouchController ;
220220 shadowLayer : MDCShadowLayer ;
221+ // shadowView: UIView;
221222
222223 nativeViewProtected : UIView ;
223224
@@ -228,9 +229,10 @@ export function overrideViewBase() {
228229 // this.inkTouchController.addInkView();
229230 // const colorScheme = themer.getAppColorScheme();
230231 // 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+ // }
234236 }
235237 return this . inkTouchController ;
236238 }
@@ -239,28 +241,53 @@ export function overrideViewBase() {
239241 this . _shadowElevations = this . _shadowElevations || { } ;
240242
241243 // 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;
242249 const layer = ( this . shadowLayer = MDCShadowLayer . alloc ( ) . init ( ) ) ;
250+ // const layer = (this.shadowLayer = shadowView.layer);
243251 layer . shouldRasterize = true ;
244252 layer . rasterizationScale = UIScreen . mainScreen . scale ;
253+ // shadowView.frame = this.nativeViewProtected.layer.bounds;
245254 layer . frame = this . nativeViewProtected . layer . bounds ;
255+ // this.nativeViewProtected.addSubview(shadowView);
246256 this . nativeViewProtected . layer . addSublayer ( this . shadowLayer ) ;
247257 // we need to set clipToBounds to false. For now it overrides user choice.
248258 this [ 'clipToBounds' ] = false ;
249259 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+ // }
253265 if ( this . nativeViewProtected instanceof UIControl ) {
254266 this . startElevationStateChangeHandler ( ) ;
255267 }
256268 }
257269 return this . shadowLayer ;
258270 }
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 ;
262286 }
263287 }
288+ _onSizeChanged ( ) : void {
289+ this . updateLayers ( ) ;
290+ }
264291 _setNativeClipToBounds ( ) {
265292 if ( this . shadowLayer ) {
266293 this . nativeViewProtected . clipsToBounds = false ;
@@ -360,15 +387,21 @@ export function overrideViewBase() {
360387 this . _shadowElevations [ 'highlighted' ] = value + elevation ;
361388 }
362389
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 ;
368392 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 ;
370399 }
371400 }
401+
402+ _redrawNativeBackground ( value ) {
403+ this . updateLayers ( ) ;
404+ }
372405 }
373406 // we need mixins to be applied after (run default implementation first) because of _setNativeClipToBounds.
374407 // it needs to be applied after for shadows to be drawn correctly
0 commit comments