| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 7110753 commit 46705ee
48 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -345,19 +345,8 @@ class TestView extends LayoutBase { | |||
| 345 | 345 | (<any>this.style).customShortHand = value; | |
| 346 | 346 | } | |
| 347 | 347 | ||
| 348 | - private _nativeView; | ||
| 349 | 348 | constructor(public name: string) { | |
| 350 | 349 | super(); | |
| 351 | - this._nativeView = this.nativeViewProtected; | ||
| 352 | - this.nativeViewProtected = undefined; | ||
| 353 | - } | ||
| 354 | - | ||
| 355 | - public createNativeView() { | ||
| 356 | - if (isIOS) { | ||
| 357 | - return this._nativeView; | ||
| 358 | - } | ||
| 359 | - | ||
| 360 | - return super.createNativeView(); | ||
| 361 | 350 | } | |
| 362 | 351 | ||
| 363 | 352 | public toString() { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -226,10 +226,8 @@ class IOSApplication implements IOSApplicationDefinition { | |||
| 226 | 226 | // if we already have a root view, we reset it. | |
| 227 | 227 | this._rootView._onRootViewReset(); | |
| 228 | 228 | } | |
| 229 | - | ||
| 230 | 229 | const rootView = createRootView(view); | |
| 231 | 230 | this._rootView = rootView; | |
| 232 | - const controller = getViewController(rootView); | ||
| 233 | 231 | ||
| 234 | 232 | if (createRootFrame.value) { | |
| 235 | 233 | // Don't setup as styleScopeHost | |
@@ -238,7 +236,7 @@ class IOSApplication implements IOSApplicationDefinition { | |||
| 238 | 236 | // setup view as styleScopeHost | |
| 239 | 237 | rootView._setupAsRootView({}); | |
| 240 | 238 | } | |
| 241 | - | ||
| 239 | + const controller = getViewController(rootView); | ||
| 242 | 240 | const haveController = this._window.rootViewController !== null; | |
| 243 | 241 | this._window.rootViewController = controller; | |
| 244 | 242 | if (!haveController) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -131,17 +131,16 @@ export class ActionBar extends ActionBarBase { | |||
| 131 | 131 | } | |
| 132 | 132 | ||
| 133 | 133 | public createNativeView() { | |
| 134 | - initializeMenuItemClickListener(); | ||
| 135 | - const toolbar = new android.support.v7.widget.Toolbar(this._context); | ||
| 136 | - const menuItemClickListener = new MenuItemClickListener(this); | ||
| 137 | - toolbar.setOnMenuItemClickListener(menuItemClickListener); | ||
| 138 | - (<any>toolbar).menuItemClickListener = menuItemClickListener; | ||
| 139 | - return toolbar; | ||
| 134 | + return new android.support.v7.widget.Toolbar(this._context); | ||
| 140 | 135 | } | |
| 141 | 136 | ||
| 142 | 137 | public initNativeView(): void { | |
| 143 | 138 | super.initNativeView(); | |
| 144 | - (<any>this.nativeViewProtected).menuItemClickListener.owner = this; | ||
| 139 | + const nativeView = this.nativeViewProtected; | ||
| 140 | + initializeMenuItemClickListener(); | ||
| 141 | + const menuItemClickListener = new MenuItemClickListener(this); | ||
| 142 | + nativeView.setOnMenuItemClickListener(menuItemClickListener); | ||
| 143 | + (<any>nativeView).menuItemClickListener = menuItemClickListener; | ||
| 145 | 144 | } | |
| 146 | 145 | ||
| 147 | 146 | public disposeNativeView() { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,11 +4,11 @@ export * from "./activity-indicator-common"; | |||
| 4 | 4 | ||
| 5 | 5 | export class ActivityIndicator extends ActivityIndicatorBase { | |
| 6 | 6 | nativeViewProtected: UIActivityIndicatorView; | |
| 7 | - | ||
| 8 | - constructor() { | ||
| 9 | - super(); | ||
| 10 | - this.nativeViewProtected = UIActivityIndicatorView.alloc().initWithActivityIndicatorStyle(UIActivityIndicatorViewStyle.Gray); | ||
| 11 | - this.nativeViewProtected.hidesWhenStopped = true; | ||
| 7 | + | ||
| 8 | + createNativeView() { | ||
| 9 | + const view = UIActivityIndicatorView.alloc().initWithActivityIndicatorStyle(UIActivityIndicatorViewStyle.Gray); | ||
| 10 | + view.hidesWhenStopped = true; | ||
| 11 | + return view; | ||
| 12 | 12 | } | |
| 13 | 13 | ||
| 14 | 14 | get ios(): UIActivityIndicatorView { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -37,34 +37,42 @@ function initializeClickListener(): void { | |||
| 37 | 37 | } | |
| 38 | 38 | ||
| 39 | 39 | ClickListener = ClickListenerImpl; | |
| 40 | - APILEVEL = android.os.Build.VERSION.SDK_INT; | ||
| 41 | - AndroidButton = android.widget.Button; | ||
| 42 | 40 | } | |
| 43 | 41 | ||
| 44 | 42 | export class Button extends ButtonBase { | |
| 45 | 43 | nativeViewProtected: android.widget.Button; | |
| 46 | 44 | ||
| 45 | + constructor() { | ||
| 46 | + super(); | ||
| 47 | + if (!APILEVEL) { | ||
| 48 | + APILEVEL = android.os.Build.VERSION.SDK_INT; | ||
| 49 | + } | ||
| 50 | + } | ||
| 51 | + | ||
| 47 | 52 | private _stateListAnimator: any; | |
| 48 | 53 | private _highlightedHandler: (args: TouchGestureEventData) => void; | |
| 49 | 54 | ||
| 50 | 55 | @profile | |
| 51 | 56 | public createNativeView() { | |
| 52 | - initializeClickListener(); | ||
| 53 | - const button = new AndroidButton(this._context); | ||
| 54 | - const clickListener = new ClickListener(this); | ||
| 55 | - button.setOnClickListener(clickListener); | ||
| 56 | - (<any>button).clickListener = clickListener; | ||
| 57 | - return button; | ||
| 57 | + if (!AndroidButton) { | ||
| 58 | + AndroidButton = android.widget.Button; | ||
| 59 | + } | ||
| 60 | + return new AndroidButton(this._context); | ||
| 58 | 61 | } | |
| 59 | 62 | ||
| 60 | 63 | public initNativeView(): void { | |
| 61 | - const nativeView = this.nativeViewProtected; | ||
| 62 | - (<any>nativeView).clickListener.owner = this; | ||
| 63 | 64 | super.initNativeView(); | |
| 65 | + const nativeView = this.nativeViewProtected; | ||
| 66 | + initializeClickListener(); | ||
| 67 | + const clickListener = new ClickListener(this); | ||
| 68 | + nativeView.setOnClickListener(clickListener); | ||
| 69 | + (<any>nativeView).clickListener = clickListener; | ||
| 64 | 70 | } | |
| 65 | 71 | ||
| 66 | 72 | public disposeNativeView() { | |
| 67 | - (<any>this.nativeViewProtected).clickListener.owner = null; | ||
| 73 | + if (this.nativeViewProtected) { | ||
| 74 | + (<any>this.nativeViewProtected).clickListener.owner = null; | ||
| 75 | + } | ||
| 68 | 76 | super.disposeNativeView(); | |
| 69 | 77 | } | |
| 70 | 78 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,12 +14,20 @@ export class Button extends ButtonBase { | |||
| 14 | 14 | private _tapHandler: NSObject; | |
| 15 | 15 | private _stateChangedHandler: ControlStateChangeListener; | |
| 16 | 16 | ||
| 17 | - constructor() { | ||
| 18 | - super(); | ||
| 19 | - this.nativeViewProtected = UIButton.buttonWithType(UIButtonType.System); | ||
| 17 | + createNativeView() { | ||
| 18 | + return UIButton.buttonWithType(UIButtonType.System); | ||
| 19 | + } | ||
| 20 | 20 | ||
| 21 | + public initNativeView(): void { | ||
| 22 | + super.initNativeView(); | ||
| 23 | + const nativeView = this.nativeViewProtected; | ||
| 21 | 24 | this._tapHandler = TapHandlerImpl.initWithOwner(new WeakRef(this)); | |
| 22 | - this.nativeViewProtected.addTargetActionForControlEvents(this._tapHandler, "tap", UIControlEvents.TouchUpInside); | ||
| 25 | + nativeView.addTargetActionForControlEvents(this._tapHandler, "tap", UIControlEvents.TouchUpInside); | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | + public disposeNativeView(): void { | ||
| 29 | + this._tapHandler = null; | ||
| 30 | + super.disposeNativeView(); | ||
| 23 | 31 | } | |
| 24 | 32 | ||
| 25 | 33 | get ios() { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -687,17 +687,22 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition | |||
| 687 | 687 | } | |
| 688 | 688 | ||
| 689 | 689 | this._context = context; | |
| 690 | - let nativeView; | ||
| 691 | - if (isAndroid) { | ||
| 692 | - // const recycle = this.recycleNativeView; | ||
| 693 | - // if (recycle === "always" || (recycle === "auto" && !this._disableNativeViewRecycling)) { | ||
| 694 | - // nativeView = <android.view.View>getNativeView(context, this.typeName); | ||
| 695 | - // } | ||
| 696 | 690 | ||
| 697 | - if (!nativeView) { | ||
| 698 | - nativeView = this.createNativeView(); | ||
| 699 | - } | ||
| 691 | + // This will account for nativeView that is created in createNativeView, recycled | ||
| 692 | + // or for backward compatability - set before _setupUI in iOS contructor. | ||
| 693 | + let nativeView = this.nativeViewProtected; | ||
| 700 | 694 | ||
| 695 | + // if (isAndroid) { | ||
| 696 | + // const recycle = this.recycleNativeView; | ||
| 697 | + // if (recycle === "always" || (recycle === "auto" && !this._disableNativeViewRecycling)) { | ||
| 698 | + // nativeView = <android.view.View>getNativeView(context, this.typeName); | ||
| 699 | + // } | ||
| 700 | + // } | ||
| 701 | + if (!nativeView) { | ||
| 702 | + nativeView = this.createNativeView(); | ||
| 703 | + } | ||
| 704 | + | ||
| 705 | + if (isAndroid) { | ||
| 701 | 706 | this._androidView = nativeView; | |
| 702 | 707 | if (nativeView) { | |
| 703 | 708 | if (this._isPaddingRelative === undefined) { | |
@@ -730,14 +735,10 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition | |||
| 730 | 735 | } | |
| 731 | 736 | } | |
| 732 | 737 | } else { | |
| 733 | - // TODO: Implement _createNativeView for iOS | ||
| 734 | - nativeView = this.createNativeView(); | ||
| 735 | - this._iosView = nativeView || this.nativeViewProtected; | ||
| 738 | + this._iosView = nativeView; | ||
| 736 | 739 | } | |
| 737 | 740 | ||
| 738 | - // This will account for nativeView that is created in createNativeView, recycled | ||
| 739 | - // or for backward compatability - set before _setupUI in iOS contructor. | ||
| 740 | - this.setNativeView(nativeView || this.nativeViewProtected); | ||
| 741 | + this.setNativeView(nativeView); | ||
| 741 | 742 | ||
| 742 | 743 | if (this.parent) { | |
| 743 | 744 | const nativeIndex = this.parent._childIndexToNativeChildIndex(atIndex); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -74,7 +74,7 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition { | |||
| 74 | 74 | private _measuredWidth: number; | |
| 75 | 75 | private _measuredHeight: number; | |
| 76 | 76 | ||
| 77 | - private _isLayoutValid: boolean; | ||
| 77 | + protected _isLayoutValid: boolean; | ||
| 78 | 78 | private _cssType: string; | |
| 79 | 79 | ||
| 80 | 80 | private _localAnimations: Set<am.Animation>; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -169,6 +169,14 @@ export class View extends ViewCommon { | |||
| 169 | 169 | } | |
| 170 | 170 | } | |
| 171 | 171 | ||
| 172 | + get isLayoutValid(): boolean { | ||
| 173 | + if (this.nativeViewProtected) { | ||
| 174 | + return this._isLayoutValid; | ||
| 175 | + } | ||
| 176 | + | ||
| 177 | + return false; | ||
| 178 | + } | ||
| 179 | + | ||
| 172 | 180 | public layoutNativeView(left: number, top: number, right: number, bottom: number): void { | |
| 173 | 181 | if (!this.nativeViewProtected) { | |
| 174 | 182 | return; | |
@@ -323,6 +331,8 @@ export class View extends ViewCommon { | |||
| 323 | 331 | return; | |
| 324 | 332 | } | |
| 325 | 333 | ||
| 334 | + this._setupAsRootView({}); | ||
| 335 | + | ||
| 326 | 336 | super._showNativeModalView(parentWithController, context, closeCallback, fullscreen, stretched); | |
| 327 | 337 | let controller = this.viewController; | |
| 328 | 338 | if (!controller) { | |
@@ -336,8 +346,6 @@ export class View extends ViewCommon { | |||
| 336 | 346 | this.viewController = controller; | |
| 337 | 347 | } | |
| 338 | 348 | ||
| 339 | - this._setupAsRootView({}); | ||
| 340 | - | ||
| 341 | 349 | if (fullscreen) { | |
| 342 | 350 | controller.modalPresentationStyle = UIModalPresentationStyle.FullScreen; | |
| 343 | 351 | } else { | |
@@ -536,9 +544,8 @@ export class CustomLayoutView extends View { | |||
| 536 | 544 | ||
| 537 | 545 | nativeViewProtected: UIView; | |
| 538 | 546 | ||
| 539 | - constructor() { | ||
| 540 | - super(); | ||
| 541 | - this.nativeViewProtected = UIView.alloc().initWithFrame(iosUtils.getter(UIScreen, UIScreen.mainScreen).bounds); | ||
| 547 | + createNativeView() { | ||
| 548 | + return UIView.alloc().initWithFrame(iosUtils.getter(UIScreen, UIScreen.mainScreen).bounds); | ||
| 542 | 549 | } | |
| 543 | 550 | ||
| 544 | 551 | get ios(): UIView { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -54,19 +54,18 @@ export class DatePicker extends DatePickerBase { | |||
| 54 | 54 | nativeViewProtected: android.widget.DatePicker; | |
| 55 | 55 | ||
| 56 | 56 | public createNativeView() { | |
| 57 | - initializeDateChangedListener(); | ||
| 58 | 57 | const picker = new android.widget.DatePicker(this._context); | |
| 59 | 58 | picker.setCalendarViewShown(false); | |
| 60 | - const listener = new DateChangedListener(this); | ||
| 61 | - | ||
| 62 | - picker.init(this.year, this.month - 1, this.day, listener); | ||
| 63 | - (<any>picker).listener = listener; | ||
| 64 | 59 | return picker; | |
| 65 | 60 | } | |
| 66 | 61 | ||
| 67 | 62 | public initNativeView(): void { | |
| 68 | 63 | super.initNativeView(); | |
| 69 | - (<any>this.nativeViewProtected).listener.owner = this; | ||
| 64 | + initializeDateChangedListener(); | ||
| 65 | + const nativeView = this.nativeViewProtected; | ||
| 66 | + const listener = new DateChangedListener(this); | ||
| 67 | + nativeView.init(this.year, this.month - 1, this.day, listener); | ||
| 68 | + (<any>nativeView).listener = listener; | ||
| 70 | 69 | } | |
| 71 | 70 | ||
| 72 | 71 | public disposeNativeView() { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments