Skip to content

Commit d80b44a

Browse files
author
vakrilov
committed
Back to animated nav-bar
1 parent def379b commit d80b44a

File tree

9 files changed

+53
-59
lines changed

9 files changed

+53
-59
lines changed

apps/app/ui-tests-app/page/page-status-bar-css.ts

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,15 @@ export function applyTap(args) {
1010

1111
let css = "#test-element { " + args.object.tag + " }";
1212
page.css = css;
13-
}
13+
}
1414

1515
export function applyTapOnStyledActionBar(args) {
1616
let page = <page.Page>(<view.View>args.object).page;
1717

1818
reset(page);
1919

2020
page.actionBar.backgroundColor = new color.Color("#5DFC0A");
21-
var css = "#test-element { " + args.object.tag + " }";
22-
page.css = css;
21+
page.css = "#test-element { " + args.object.tag + " }";
2322
}
2423

2524
export function applyTapWithHiddenActionBar(args) {
@@ -28,8 +27,7 @@ export function applyTapWithHiddenActionBar(args) {
2827
reset(page);
2928

3029
page.actionBarHidden = true;
31-
var css = "#test-element { " + args.object.tag + " }";
32-
page.css = css;
30+
page.css = "#test-element { " + args.object.tag + " }";
3331
}
3432

3533
export function applyTapWithSpan(args) {
@@ -38,8 +36,7 @@ export function applyTapWithSpan(args) {
3836
reset(page);
3937

4038
page.backgroundSpanUnderStatusBar = true;
41-
var css = "#test-element { " + args.object.tag + " }";
42-
page.css = css;
39+
page.css = "#test-element { " + args.object.tag + " }";
4340
}
4441

4542
export function applyTapOnStyledActionBarAndSpan(args) {
@@ -49,8 +46,7 @@ export function applyTapOnStyledActionBarAndSpan(args) {
4946

5047
page.backgroundSpanUnderStatusBar = true;
5148
page.actionBar.backgroundColor = new color.Color("#E0115F");
52-
var css = "#test-element { " + args.object.tag + " }";
53-
page.css = css;
49+
page.css = "#test-element { " + args.object.tag + " }";
5450
}
5551

5652
export function applyTapWithActionBarHiddenAndSpan(args) {
@@ -59,9 +55,8 @@ export function applyTapWithActionBarHiddenAndSpan(args) {
5955
reset(page);
6056

6157
page.backgroundSpanUnderStatusBar = true;
62-
page.actionBarHidden = true;;
63-
var css = "#test-element { " + args.object.tag + " }";
64-
page.css = css;
58+
page.actionBarHidden = true;
59+
page.css = "#test-element { " + args.object.tag + " }";
6560
}
6661

6762
function reset(page: page.Page) {

tns-core-modules/file-system/file-name-resolver.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,6 @@ export class FileNameResolver implements definition.FileNameResolver {
142142
var candidates = this.getFileCandidatesFromFolder(path, ext);
143143
result = _findFileMatch(path, ext, candidates, this._context);
144144

145-
if (trace.enabled) {
146-
trace.write("Resolved file name for \"" + path + ext + "\" result: " + (result ? result : "no match found"), trace.categories.Navigation);
147-
}
148145
return result;
149146
}
150147

@@ -179,9 +176,6 @@ export function _findFileMatch(path: string, ext: string, candidates: Array<stri
179176
var bestValue = -1
180177
var result: string = null;
181178

182-
if (trace.enabled) {
183-
trace.write("Candidates for " + path + ext + ": " + candidates.join(", "), trace.categories.Navigation);
184-
}
185179
for (var i = 0; i < candidates.length; i++) {
186180
var filePath = candidates[i];
187181
var qualifiersStr: string = filePath.substr(path.length, filePath.length - path.length - ext.length);

tns-core-modules/ui/action-bar/action-bar.ios.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export class NavigationButton extends ActionItem {
3030

3131
export class ActionBar extends common.ActionBar {
3232

33-
get ios(): UIView {
33+
get ios(): UIView {
3434

3535
if (!(this.page && this.page.parent)) {
3636
return;
@@ -41,17 +41,17 @@ export class ActionBar extends common.ActionBar {
4141
return viewController.navigationController.navigationBar;
4242
}
4343
return null;
44-
}
44+
}
4545

46-
public update() {
46+
public update() {
4747
// Page should be attached to frame to update the action bar.
4848
if (!(this.page && this.page.parent)) {
4949
return;
5050
}
5151

5252
var viewController = (<UIViewController>this.page.ios);
5353
var navigationItem: UINavigationItem = viewController.navigationItem;
54-
var navController = frameModule.topmost().ios.controller;
54+
var navController = frameModule.topmost().ios.controller;
5555
var navigationBar = navController ? <UINavigationBar>navController.navigationBar : null;
5656
var previousController: UIViewController;
5757

@@ -229,7 +229,7 @@ export class ActionBar extends common.ActionBar {
229229

230230
this.actionItems.getItems().forEach((actionItem) => {
231231
if (actionItem.actionView) {
232-
view.View.measureChild(this, actionItem.actionView,
232+
view.View.measureChild(this, actionItem.actionView,
233233
utils.layout.makeMeasureSpec(width, utils.layout.AT_MOST),
234234
utils.layout.makeMeasureSpec(navBarHeight, utils.layout.AT_MOST));
235235
}

tns-core-modules/ui/frame/frame-common.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import * as definition from "ui/frame";
2-
import {View, CustomLayoutView} from "ui/core/view";
3-
import {Page} from "ui/page";
4-
import {isString, isFunction, isDefined} from "utils/types";
2+
import { View, CustomLayoutView } from "ui/core/view";
3+
import { Page } from "ui/page";
4+
import { isString, isFunction, isDefined } from "utils/types";
55
import * as trace from "trace";
6-
import {resolveFileName} from "file-system/file-name-resolver";
6+
import { resolveFileName } from "file-system/file-name-resolver";
77
import * as fs from "file-system";
88
import * as builderModule from "ui/builder";
99
import * as platform from "platform";
@@ -222,7 +222,7 @@ export class Frame extends CustomLayoutView implements definition.Frame {
222222
// if (!this._currentEntry){
223223
// return;
224224
// }
225-
225+
226226
// let currentPage = this._currentEntry.resolvedPage;
227227
// let currentNavigationEntry = this._currentEntry.entry;
228228
// if (currentPage["isBiOrientational"] && currentNavigationEntry.moduleName) {
@@ -321,7 +321,7 @@ export class Frame extends CustomLayoutView implements definition.Frame {
321321
return !backstackHidden;
322322
}
323323

324-
public _updateActionBar(page?: Page) {
324+
public _updateActionBar(page?: Page, disableNavBarAnimation?: boolean) {
325325
//trace.write("calling _updateActionBar on Frame", trace.categories.Navigation);
326326
}
327327

@@ -408,7 +408,7 @@ export class Frame extends CustomLayoutView implements definition.Frame {
408408
if (this._currentEntry) {
409409
return this._currentEntry.entry;
410410
}
411-
411+
412412
return null;
413413
}
414414

tns-core-modules/ui/frame/frame.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ declare module "ui/frame" {
104104
navigationQueueIsEmpty(): boolean;
105105
navigationBarHeight: number;
106106
_processNavigationQueue(page: pages.Page);
107-
_updateActionBar(page?: pages.Page);
107+
_updateActionBar(page?: pages.Page, disableNavBarAnimation?: boolean);
108108
_getNavBarVisible(page: pages.Page): boolean;
109109
//@endprivate
110110

tns-core-modules/ui/frame/frame.ios.ts

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import frameCommon = require("./frame-common");
22
import definition = require("ui/frame");
33
import trace = require("trace");
4-
import {Page} from "ui/page";
5-
import {NavigationBarVisibility, AnimationCurve} from "ui/enums";
4+
import { Page } from "ui/page";
5+
import { NavigationBarVisibility, AnimationCurve } from "ui/enums";
66
import utils = require("utils/utils");
7-
import {View} from "ui/core/view";
7+
import { View } from "ui/core/view";
88
import uiUtils = require("ui/utils");
99
import * as types from "utils/types";
1010
import application = require("application");
@@ -109,10 +109,10 @@ export class Frame extends frameCommon.Frame {
109109
backstackEntry[NAV_DEPTH] = navDepth;
110110
viewController[ENTRY] = backstackEntry;
111111

112-
this._updateActionBar(backstackEntry.resolvedPage);
113-
114112
// First navigation.
115113
if (!this._currentEntry) {
114+
// Update action-bar with disabled animations before the initial navigation.
115+
this._updateActionBar(backstackEntry.resolvedPage, true);
116116
this._ios.controller.pushViewControllerAnimated(viewController, animated);
117117
if (trace.enabled) {
118118
trace.write(`${this}.pushViewControllerAnimated(${viewController}, ${animated}); depth = ${navDepth}`, trace.categories.Navigation);
@@ -189,16 +189,23 @@ export class Frame extends frameCommon.Frame {
189189
}
190190
}
191191

192-
public _updateActionBar(page?: Page): void {
192+
public _updateActionBar(page?: Page, disableNavBarAnimation: boolean = false): void {
193193
super._updateActionBar(page);
194194

195195
page = page || this.currentPage;
196196
let newValue = this._getNavBarVisible(page);
197197

198-
var disableNavBarAnimation = this._ios._disableNavBarAnimation;
199-
this._ios._disableNavBarAnimation = true;
198+
let disableNavBarAnimationCache = this._ios._disableNavBarAnimation;
199+
200+
if (disableNavBarAnimation) {
201+
this._ios._disableNavBarAnimation = true;
202+
}
203+
200204
this._ios.showNavigationBar = newValue;
201-
this._ios._disableNavBarAnimation = disableNavBarAnimation;
205+
206+
if (disableNavBarAnimation) {
207+
this._ios._disableNavBarAnimation = disableNavBarAnimationCache;
208+
}
202209

203210
if (this._ios.controller.navigationBar) {
204211
this._ios.controller.navigationBar.userInteractionEnabled = this.navigationQueueIsEmpty();
@@ -260,7 +267,7 @@ export class Frame extends frameCommon.Frame {
260267
}
261268

262269
public onMeasure(widthMeasureSpec: number, heightMeasureSpec: number): void {
263-
View.adjustChildLayoutParams(this.currentPage, widthMeasureSpec, heightMeasureSpec);
270+
View.adjustChildLayoutParams(this.currentPage, widthMeasureSpec, heightMeasureSpec);
264271

265272
let width = utils.layout.getMeasureSpecSize(widthMeasureSpec);
266273
let widthMode = utils.layout.getMeasureSpecMode(widthMeasureSpec);
@@ -693,7 +700,6 @@ class iOSFrame implements definition.iOSFrame {
693700
this._frame = frame;
694701
this._controller = UINavigationControllerImpl.initWithOwner(new WeakRef(frame));
695702
this._controller.automaticallyAdjustsScrollViewInsets = false;
696-
//this.showNavigationBar = false;
697703
this._navBarVisibility = NavigationBarVisibility.auto;
698704
}
699705

tns-core-modules/ui/page/page-common.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import * as frameModule from "ui/frame";
1010
import proxy = require("ui/core/proxy");
1111
import keyframeAnimation = require("ui/animation/keyframe-animation");
1212
import types = require("utils/types");
13-
import {Color} from "color";
13+
import { Color } from "color";
1414

1515
let fs: typeof fileSystemModule;
1616
function ensureFS() {
@@ -47,7 +47,8 @@ const actionBarHiddenProperty = new Property("actionBarHidden", "Page", new prox
4747
function onActionBarHiddenPropertyChanged(data: PropertyChangeData) {
4848
const page = <Page>data.object;
4949
if (page.isLoaded) {
50-
page._updateActionBar(data.newValue);
50+
// Update with disabled animation when setting visibility
51+
page._updateActionBar(true);
5152
}
5253
}
5354

@@ -101,7 +102,7 @@ export class Page extends ContentView implements dts.Page {
101102
this._applyCss();
102103

103104
if (this.actionBarHidden !== undefined) {
104-
this._updateActionBar(this.actionBarHidden);
105+
this._updateActionBar();
105106
}
106107

107108
this._updateStatusBar();
@@ -148,7 +149,7 @@ export class Page extends ContentView implements dts.Page {
148149
this._setValue(Page.iosSwipeBackNavigationEnabledProperty, value);
149150
}
150151

151-
public _updateActionBar(hidden: boolean) {
152+
public _updateActionBar(disableNavBarAnimation?: boolean) {
152153
//
153154
}
154155

tns-core-modules/ui/page/page.android.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ export class Page extends pageCommon.Page {
187187
super._hideNativeModalView(parent);
188188
}
189189

190-
public _updateActionBar(hidden: boolean) {
190+
public _updateActionBar() {
191191
this.actionBar.update();
192192
}
193193

tns-core-modules/ui/page/page.ios.ts

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,7 @@ class UIViewControllerImpl extends UIViewController {
145145
this.shown = false;
146146
let page = this._owner.get();
147147
if (trace.enabled) {
148-
if (trace.enabled) {
149-
trace.write(page + " viewWillAppear", trace.categories.Navigation);
150-
}
148+
trace.write(page + " viewWillAppear: " + page, trace.categories.Navigation);
151149
}
152150
if (!page) {
153151
return;
@@ -197,7 +195,7 @@ class UIViewControllerImpl extends UIViewController {
197195
this.shown = true;
198196
let page = this._owner.get();
199197
if (trace.enabled) {
200-
trace.write(page + " viewDidAppear", trace.categories.Navigation);
198+
trace.write(page + " viewDidAppear: " + page, trace.categories.Navigation);
201199
}
202200
if (!page) {
203201
return;
@@ -248,7 +246,7 @@ class UIViewControllerImpl extends UIViewController {
248246
public viewWillDisappear(animated: boolean): void {
249247
let page = this._owner.get();
250248
if (trace.enabled) {
251-
trace.write(page + " viewWillDisappear", trace.categories.Navigation);
249+
trace.write(page + " viewWillDisappear: " + page, trace.categories.Navigation);
252250
}
253251
if (!page) {
254252
return;
@@ -274,7 +272,7 @@ class UIViewControllerImpl extends UIViewController {
274272
public viewDidDisappear(animated: boolean): void {
275273
let page = this._owner.get();
276274
if (trace.enabled) {
277-
trace.write(page + " viewDidDisappear", trace.categories.Navigation);
275+
trace.write(page + " viewDidDisappear: " + page, trace.categories.Navigation);
278276
}
279277
// Exit if no page or page is hiding because it shows another page modally.
280278
if (!page || page.modal || page._presentedViewController) {
@@ -349,7 +347,7 @@ export class Page extends pageCommon.Page {
349347
if (this._enableLoadedEvents) {
350348
super.onLoaded();
351349
}
352-
this._updateActionBar(false);
350+
this._updateActionBar();
353351
}
354352

355353
public onUnloaded() {
@@ -433,10 +431,10 @@ export class Page extends pageCommon.Page {
433431
super._hideNativeModalView(parent);
434432
}
435433

436-
public _updateActionBar(hidden: boolean) {
434+
public _updateActionBar(disableNavBarAnimation: boolean = false) {
437435
const frame = this.frame;
438436
if (frame) {
439-
frame._updateActionBar(this);
437+
frame._updateActionBar(this, disableNavBarAnimation);
440438
}
441439
}
442440

@@ -449,7 +447,7 @@ export class Page extends pageCommon.Page {
449447
if (this.frame && value) {
450448
let navigationController = frame.ios.controller;
451449
let navigationBar = navigationController.navigationBar;
452-
450+
453451
navigationBar.barStyle = value === "dark" ? 1 : 0;
454452
}
455453
}
@@ -554,7 +552,7 @@ export class Page extends pageCommon.Page {
554552

555553
export class PageStyler implements style.Styler {
556554
// statusBarStyle
557-
private static setStatusBarStyleProperty(v: View, newValue: any) {
555+
private static setStatusBarStyleProperty(v: View, newValue: any) {
558556
let page = <Page>v;
559557
page._updateStatusBarStyle(newValue);
560558
}
@@ -570,7 +568,7 @@ export class PageStyler implements style.Styler {
570568
}
571569

572570
public static registerHandlers() {
573-
style.registerHandler(style.statusBarStyleProperty, new style.StylePropertyChangedHandler(
571+
style.registerHandler(style.statusBarStyleProperty, new style.StylePropertyChangedHandler(
574572
PageStyler.setStatusBarStyleProperty,
575573
PageStyler.resetStatusBarStyleProperty,
576574
PageStyler.getStatusBarStyleProperty), "Page");

0 commit comments

Comments
 (0)