|
1 | | -import { Application, Background, Button, Color, Length, View, androidDynamicElevationOffsetProperty, androidElevationProperty, backgroundInternalProperty, profile } from '@nativescript/core'; |
| 1 | +import { Application, Background, Button, Color, Length, View, androidDynamicElevationOffsetProperty, androidElevationProperty, backgroundInternalProperty, profile, PercentLength } from '@nativescript/core'; |
2 | 2 | import { createRippleDrawable, createStateListAnimator, getAttrColor, getColorStateList, handleClearFocus, isPostLollipop, isPostLollipopMR1, isPostMarshmallow } from './android/utils'; |
3 | 3 | import { CornerFamily, applyMixins } from './index.common'; |
4 | 4 | import { cssProperty, dynamicElevationOffsetProperty, elevationProperty, rippleColorProperty } from './cssproperties'; |
@@ -127,35 +127,55 @@ export class Themer { |
127 | 127 | } |
128 | 128 | if (options.cornerSize !== undefined) { |
129 | 129 | if (typeof options.cornerSize === 'object') { |
130 | | - builder.setAllCornerSizes(new com.google.android.material.shape.RelativeCornerSize(options.cornerSize.value)); |
| 130 | + if (options.cornerSize.unit === '%') { |
| 131 | + builder.setAllCornerSizes(new com.google.android.material.shape.RelativeCornerSize(options.cornerSize.value)); |
| 132 | + } else { |
| 133 | + builder.setAllCornerSizes(PercentLength.toDevicePixels(options.cornerSize)); |
| 134 | + } |
131 | 135 | } else { |
132 | 136 | builder.setAllCornerSizes(options.cornerSize); |
133 | 137 | } |
134 | 138 | } |
135 | 139 | if (options.cornerSizeBottomLeft !== undefined) { |
136 | 140 | if (typeof options.cornerSizeBottomLeft === 'object') { |
137 | | - builder.setBottomLeftCornerSize(new com.google.android.material.shape.RelativeCornerSize(options.cornerSizeBottomLeft.value)); |
| 141 | + if (options.cornerSizeBottomLeft.unit === '%') { |
| 142 | + builder.setBottomLeftCornerSize(new com.google.android.material.shape.RelativeCornerSize(options.cornerSizeBottomLeft.value)); |
| 143 | + } else { |
| 144 | + builder.setBottomLeftCornerSize(PercentLength.toDevicePixels(options.cornerSizeBottomLeft)); |
| 145 | + } |
138 | 146 | } else { |
139 | 147 | builder.setBottomLeftCornerSize(options.cornerSizeBottomLeft); |
140 | 148 | } |
141 | 149 | } |
142 | 150 | if (options.cornerSizeBottomRight !== undefined) { |
143 | 151 | if (typeof options.cornerSizeBottomRight === 'object') { |
144 | | - builder.setBottomRightCornerSize(new com.google.android.material.shape.RelativeCornerSize(options.cornerSizeBottomRight.value)); |
| 152 | + if (options.cornerSizeBottomRight.unit === '%') { |
| 153 | + builder.setBottomRightCornerSize(new com.google.android.material.shape.RelativeCornerSize(options.cornerSizeBottomRight.value)); |
| 154 | + } else { |
| 155 | + builder.setBottomRightCornerSize(PercentLength.toDevicePixels(options.cornerSizeBottomRight)); |
| 156 | + } |
145 | 157 | } else { |
146 | 158 | builder.setBottomRightCornerSize(options.cornerSizeBottomRight); |
147 | 159 | } |
148 | 160 | } |
149 | 161 | if (options.cornerSizeTopRight !== undefined) { |
150 | 162 | if (typeof options.cornerSizeTopRight === 'object') { |
151 | | - builder.setTopRightCornerSize(new com.google.android.material.shape.RelativeCornerSize(options.cornerSizeTopRight.value)); |
| 163 | + if (options.cornerSizeTopRight.unit === '%') { |
| 164 | + builder.setTopRightCornerSize(new com.google.android.material.shape.RelativeCornerSize(options.cornerSizeTopRight.value)); |
| 165 | + } else { |
| 166 | + builder.setTopRightCornerSize(PercentLength.toDevicePixels(options.cornerSizeTopRight)); |
| 167 | + } |
152 | 168 | } else { |
153 | 169 | builder.setTopRightCornerSize(options.cornerSizeTopRight); |
154 | 170 | } |
155 | 171 | } |
156 | 172 | if (options.cornerSizeTopLeft !== undefined) { |
157 | 173 | if (typeof options.cornerSizeTopLeft === 'object') { |
158 | | - builder.setTopLeftCornerSize(new com.google.android.material.shape.RelativeCornerSize(options.cornerSizeTopLeft.value)); |
| 174 | + if (options.cornerSizeTopLeft.unit === '%') { |
| 175 | + builder.setTopLeftCornerSize(new com.google.android.material.shape.RelativeCornerSize(options.cornerSizeTopLeft.value)); |
| 176 | + } else { |
| 177 | + builder.setTopLeftCornerSize(PercentLength.toDevicePixels(options.cornerSizeTopLeft)); |
| 178 | + } |
159 | 179 | } else { |
160 | 180 | builder.setTopLeftCornerSize(options.cornerSizeTopLeft); |
161 | 181 | } |
|
0 commit comments