|
1 | 1 | import { ControlStateChangeListener } from '../core/control-state-change'; |
2 | 2 | import { ButtonBase } from './button-common'; |
3 | 3 | import { View, PseudoClassHandler } from '../core/view'; |
4 | | -import { borderTopWidthProperty, borderRightWidthProperty, borderBottomWidthProperty, borderLeftWidthProperty, directionProperty, paddingInternalProperty, paddingTopProperty, paddingRightProperty, paddingBottomProperty, paddingLeftProperty, _hasPaddingSetNativeOverrides } from '../styling/style-properties'; |
| 4 | +import { borderTopWidthProperty, borderRightWidthProperty, borderBottomWidthProperty, borderLeftWidthProperty, directionProperty, paddingInternalProperty } from '../styling/style-properties'; |
5 | 5 | import { textAlignmentProperty, whiteSpaceProperty, textOverflowProperty } from '../text-base'; |
6 | 6 | import { layout } from '../../utils'; |
7 | 7 | import { CoreTypes } from '../../core-types'; |
@@ -147,115 +147,13 @@ export class Button extends ButtonBase { |
147 | 147 | }); |
148 | 148 | } |
149 | 149 |
|
150 | | - // When no subclass overrides the per-side handlers, they stage into |
151 | | - // _pendingPadding - which only exists while [paddingInternalProperty.setNative] |
152 | | - // runs - and all sides commit in one native write. An override takes ownership: |
153 | | - // the consolidated write stands down and each side applies individually, so an |
154 | | - // override that does not chain to super suppresses that side entirely. |
155 | | - private _pendingPadding: { top: number; right: number; bottom: number; left: number }; |
156 | | - |
157 | | - [paddingTopProperty.getDefault](): CoreTypes.LengthType { |
158 | | - return { |
159 | | - value: this.nativeViewProtected.contentEdgeInsets.top, |
160 | | - unit: 'px', |
161 | | - }; |
162 | | - } |
163 | | - |
164 | | - [paddingTopProperty.setNative](_value: CoreTypes.LengthType) { |
165 | | - if (this._pendingPadding) { |
166 | | - this._pendingPadding.top = layout.toDeviceIndependentPixels(this.effectivePaddingTop + this.effectiveBorderTopWidth); |
167 | | - } else if (_hasPaddingSetNativeOverrides(this, Button.prototype)) { |
168 | | - const nativeView = this.nativeViewProtected; |
169 | | - const inset = nativeView.contentEdgeInsets; |
170 | | - nativeView.contentEdgeInsets = new UIEdgeInsets({ |
171 | | - top: layout.toDeviceIndependentPixels(this.effectivePaddingTop + this.effectiveBorderTopWidth), |
172 | | - right: inset.right, |
173 | | - bottom: inset.bottom, |
174 | | - left: inset.left, |
175 | | - }); |
176 | | - } |
177 | | - } |
178 | | - |
179 | | - [paddingRightProperty.getDefault](): CoreTypes.LengthType { |
180 | | - return { |
181 | | - value: this.nativeViewProtected.contentEdgeInsets.right, |
182 | | - unit: 'px', |
183 | | - }; |
184 | | - } |
185 | | - |
186 | | - [paddingRightProperty.setNative](_value: CoreTypes.LengthType) { |
187 | | - if (this._pendingPadding) { |
188 | | - this._pendingPadding.right = layout.toDeviceIndependentPixels(this.effectivePaddingRight + this.effectiveBorderRightWidth); |
189 | | - } else if (_hasPaddingSetNativeOverrides(this, Button.prototype)) { |
190 | | - const nativeView = this.nativeViewProtected; |
191 | | - const inset = nativeView.contentEdgeInsets; |
192 | | - nativeView.contentEdgeInsets = new UIEdgeInsets({ |
193 | | - top: inset.top, |
194 | | - right: layout.toDeviceIndependentPixels(this.effectivePaddingRight + this.effectiveBorderRightWidth), |
195 | | - bottom: inset.bottom, |
196 | | - left: inset.left, |
197 | | - }); |
198 | | - } |
199 | | - } |
200 | | - |
201 | | - [paddingBottomProperty.getDefault](): CoreTypes.LengthType { |
202 | | - return { |
203 | | - value: this.nativeViewProtected.contentEdgeInsets.bottom, |
204 | | - unit: 'px', |
205 | | - }; |
206 | | - } |
207 | | - |
208 | | - [paddingBottomProperty.setNative](_value: CoreTypes.LengthType) { |
209 | | - if (this._pendingPadding) { |
210 | | - this._pendingPadding.bottom = layout.toDeviceIndependentPixels(this.effectivePaddingBottom + this.effectiveBorderBottomWidth); |
211 | | - } else if (_hasPaddingSetNativeOverrides(this, Button.prototype)) { |
212 | | - const nativeView = this.nativeViewProtected; |
213 | | - const inset = nativeView.contentEdgeInsets; |
214 | | - nativeView.contentEdgeInsets = new UIEdgeInsets({ |
215 | | - top: inset.top, |
216 | | - right: inset.right, |
217 | | - bottom: layout.toDeviceIndependentPixels(this.effectivePaddingBottom + this.effectiveBorderBottomWidth), |
218 | | - left: inset.left, |
219 | | - }); |
220 | | - } |
221 | | - } |
222 | | - |
223 | | - [paddingLeftProperty.getDefault](): CoreTypes.LengthType { |
224 | | - return { |
225 | | - value: this.nativeViewProtected.contentEdgeInsets.left, |
226 | | - unit: 'px', |
227 | | - }; |
228 | | - } |
229 | | - |
230 | | - [paddingLeftProperty.setNative](_value: CoreTypes.LengthType) { |
231 | | - if (this._pendingPadding) { |
232 | | - this._pendingPadding.left = layout.toDeviceIndependentPixels(this.effectivePaddingLeft + this.effectiveBorderLeftWidth); |
233 | | - } else if (_hasPaddingSetNativeOverrides(this, Button.prototype)) { |
234 | | - const nativeView = this.nativeViewProtected; |
235 | | - const inset = nativeView.contentEdgeInsets; |
236 | | - nativeView.contentEdgeInsets = new UIEdgeInsets({ |
237 | | - top: inset.top, |
238 | | - right: inset.right, |
239 | | - bottom: inset.bottom, |
240 | | - left: layout.toDeviceIndependentPixels(this.effectivePaddingLeft + this.effectiveBorderLeftWidth), |
241 | | - }); |
242 | | - } |
243 | | - } |
244 | | - |
245 | 150 | [paddingInternalProperty.setNative](_value: string) { |
246 | | - if (_hasPaddingSetNativeOverrides(this, Button.prototype)) { |
247 | | - // An override owns padding application; each side applies through its own handler. |
248 | | - return; |
249 | | - } |
250 | | - const nativeView = this.nativeViewProtected; |
251 | | - const inset = nativeView.contentEdgeInsets; |
252 | | - this._pendingPadding = { top: inset.top, right: inset.right, bottom: inset.bottom, left: inset.left }; |
253 | | - (<any>this)[paddingTopProperty.setNative](this.style.paddingTop); |
254 | | - (<any>this)[paddingRightProperty.setNative](this.style.paddingRight); |
255 | | - (<any>this)[paddingBottomProperty.setNative](this.style.paddingBottom); |
256 | | - (<any>this)[paddingLeftProperty.setNative](this.style.paddingLeft); |
257 | | - nativeView.contentEdgeInsets = new UIEdgeInsets(this._pendingPadding); |
258 | | - this._pendingPadding = null; |
| 151 | + this.nativeViewProtected.contentEdgeInsets = new UIEdgeInsets({ |
| 152 | + top: layout.toDeviceIndependentPixels(this.effectivePaddingTop + this.effectiveBorderTopWidth), |
| 153 | + left: layout.toDeviceIndependentPixels(this.effectivePaddingLeft + this.effectiveBorderLeftWidth), |
| 154 | + bottom: layout.toDeviceIndependentPixels(this.effectivePaddingBottom + this.effectiveBorderBottomWidth), |
| 155 | + right: layout.toDeviceIndependentPixels(this.effectivePaddingRight + this.effectiveBorderRightWidth), |
| 156 | + }); |
259 | 157 | } |
260 | 158 |
|
261 | 159 | [textAlignmentProperty.setNative](value: CoreTypes.TextAlignmentType) { |
|
0 commit comments