Skip to content

Commit cfda47a

Browse files
committed
fix: android fix for pre lollipop
1 parent b718cb9 commit cfda47a

File tree

6 files changed

+20
-12
lines changed

6 files changed

+20
-12
lines changed

demo-vue/app/examples/Buttons.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<Page>
2+
<Page backgroundColor="red">
33
<ActionBar :title="title">
44
<StackLayout orientation="horizontal" width="100%">
55
<MDButton v-show="isEditing" variant="flat" text="test" @tap="isEditing = !isEditing" />

demo-vue/app/views/Home.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export default {
2727
},
2828
goToModalExample(item) {
2929
console.log('goToModalExample');
30-
this.$showModal(item.component, { fullscreen: true });
30+
this.$showModal(item.component, { });
3131
}
3232
}
3333
};

src/button/button.android.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,15 @@ export class Button extends ButtonBase {
8787
createStateListAnimator(this, this.nativeViewProtected);
8888
} else {
8989
const newValue = Length.toDevicePixels(typeof value === 'string' ? Length.parse(value) : value, 0);
90-
this.nativeViewProtected.setElevation(newValue);
90+
androidx.core.view.ViewCompat.setElevation(this.nativeViewProtected, newValue);
9191
}
9292
}
9393
[dynamicElevationOffsetProperty.setNative](value: number) {
9494
if (isPostLollipop()) {
9595
createStateListAnimator(this, this.nativeViewProtected);
9696
} else {
9797
const newValue = Length.toDevicePixels(typeof value === 'string' ? Length.parse(value) : value, 0);
98-
this.nativeViewProtected.setTranslationZ(newValue);
98+
androidx.core.view.ViewCompat.setTranslationZ(this.nativeViewProtected, newValue);
9999
}
100100
}
101101
[androidElevationProperty.setNative](value: number) {

src/cardview/cardview.ios.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export class CardView extends CardViewBase {
7373
}
7474
this.nativeViewProtected.setBorderWidthForState(value.borderLeftWidth / scale, MDCCardCellState.Normal);
7575
this.nativeViewProtected.setBorderColorForState(value.borderTopColor ? value.borderTopColor.ios : null, MDCCardCellState.Normal);
76-
this.nativeViewProtected.layer.cornerRadius = value.borderTopLeftRadius / scale;
76+
this.nativeViewProtected.cornerRadius = value.borderTopLeftRadius / scale;
7777
}
7878
}
7979
[rippleColorProperty.setNative](color: Color) {

src/core/index.android.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ class ViewWithElevationAndRipple extends View {
169169
createStateListAnimator(this, this.nativeViewProtected);
170170
} else {
171171
const newValue = Length.toDevicePixels(typeof value === 'string' ? Length.parse(value) : value, 0);
172-
this.nativeViewProtected.setElevation(newValue);
172+
androidx.core.view.ViewCompat.setElevation(this.nativeViewProtected, newValue);
173173
}
174174
}
175175
// [dynamicElevationOffsetProperty.getDefault](): number {
@@ -181,7 +181,7 @@ class ViewWithElevationAndRipple extends View {
181181
createStateListAnimator(this, this.nativeViewProtected);
182182
} else {
183183
const newValue = Length.toDevicePixels(typeof value === 'string' ? Length.parse(value) : value, 0);
184-
this.nativeViewProtected.setTranslationZ(newValue);
184+
androidx.core.view.ViewCompat.setTranslationZ(this.nativeViewProtected, newValue);
185185
}
186186
}
187187
[androidElevationProperty.setNative](value: number) {

src/floatingactionbutton/floatingactionbutton.android.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { dynamicElevationOffsetProperty, elevationProperty, rippleColorProperty } from '@nativescript-community/ui-material-core';
2+
import { createStateListAnimator, isPostLollipop } from '@nativescript-community/ui-material-core/android/utils';
23
import { Background, Color, ImageSource, Length, backgroundInternalProperty, colorProperty } from '@nativescript/core';
34
import { textProperty } from '@nativescript/core/ui/text-base';
45
import { FloatingActionButtonBase, expandedProperty, imageSourceProperty, sizeProperty, srcProperty } from './floatingactionbutton-common';
@@ -38,13 +39,20 @@ export class FloatingActionButton extends FloatingActionButtonBase {
3839
}
3940

4041
[elevationProperty.setNative](value: number) {
41-
const newValue = Length.toDevicePixels(typeof value === 'string' ? Length.parse(value) : value, 0);
42-
this.nativeViewProtected.setElevation(newValue);
42+
if (isPostLollipop()) {
43+
createStateListAnimator(this, this.nativeViewProtected);
44+
} else {
45+
const newValue = Length.toDevicePixels(typeof value === 'string' ? Length.parse(value) : value, 0);
46+
androidx.core.view.ViewCompat.setElevation(this.nativeViewProtected, newValue);
47+
}
4348
}
44-
4549
[dynamicElevationOffsetProperty.setNative](value: number) {
46-
// const newValue = Length.toDevicePixels(typeof value === 'string' ? Length.parse(value) : value, 0);
47-
this.nativeViewProtected.setTranslationZ(value);
50+
if (isPostLollipop()) {
51+
createStateListAnimator(this, this.nativeViewProtected);
52+
} else {
53+
const newValue = Length.toDevicePixels(typeof value === 'string' ? Length.parse(value) : value, 0);
54+
androidx.core.view.ViewCompat.setTranslationZ(this.nativeViewProtected, newValue);
55+
}
4856
}
4957
[textProperty.setNative](value: string) {
5058
this.nativeViewProtected.setText(value);

0 commit comments

Comments
 (0)