import { ControlStateChangeListener } from '../core/control-state-change'; import { ButtonBase } from './button-common'; import { View, PseudoClassHandler } from '../core/view'; import { borderTopWidthProperty, borderRightWidthProperty, borderBottomWidthProperty, borderLeftWidthProperty, paddingLeftProperty, paddingTopProperty, paddingRightProperty, paddingBottomProperty } from '../styling/style-properties'; import { textAlignmentProperty, whiteSpaceProperty, textOverflowProperty } from '../text-base'; import { layout } from '../../utils'; import { CoreTypes } from '../../core-types'; import { Color } from '../../color'; export * from './button-common'; const observableVisualStates = ['highlighted']; // States like :disabled are handled elsewhere export class Button extends ButtonBase { public nativeViewProtected: UIButton; private _tapHandler: NSObject; private _stateChangedHandler: ControlStateChangeListener; createNativeView() { return UIButton.buttonWithType(UIButtonType.System); } public initNativeView(): void { super.initNativeView(); this._tapHandler = TapHandlerImpl.initWithOwner(new WeakRef(this)); this.nativeViewProtected.addTargetActionForControlEvents(this._tapHandler, 'tap', UIControlEvents.TouchUpInside); } public disposeNativeView(): void { this._tapHandler = null; if (this._stateChangedHandler) { this._stateChangedHandler.stop(); this._stateChangedHandler = null; } super.disposeNativeView(); } // @ts-ignore get ios() { return this.nativeViewProtected; } @PseudoClassHandler('normal', 'highlighted', 'pressed', 'active') _updateButtonStateChangeHandler(subscribe: boolean) { if (subscribe) { if (!this._stateChangedHandler) { const viewRef = new WeakRef