8000 Animated nav-bar · jensWorkGit/NativeScript@d448f3d · GitHub
[go: up one dir, main page]

Skip to content

Commit d448f3d

Browse files
author
vakrilov
committed
Animated nav-bar
1 parent da4983c commit d448f3d

File tree

10 files changed

+47
-54
lines changed

10 files changed

+47
-54
lines changed

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

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,15 @@ export function applyTap(args) {
99

1010
let css = "#test-element { " + args.object.tag + " }";
1111
page.css = css;
12-
}
12+
}
1313

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

1717
reset(page);
1818

1919
page.actionBar.backgroundColor = new Color("#5DFC0A");
20-
var css = "#test-element { " + args.object.tag + " }";
21-
page.css = css;
20+
page.css = "#test-element { " + args.object.tag + " }";
2221
}
2322

2423
export function applyTapWithHiddenActionBar(args) {
@@ -27,8 +26,7 @@ export function applyTapWithHiddenActionBar(args) {
2726
reset(page);
2827

2928
page.actionBarHidden = true;
30-
var css = "#test-element { " + args.object.tag + " }";
31-
page.css = css;
29+
page.css = "#test-element { " + args.object.tag + " }";
3230
}
3331

3432
export function applyTapWithSpan(args) {
@@ -37,8 +35,7 @@ export function applyTapWithSpan(args) {
3735
reset(page);
3836

3937
page.backgroundSpanUnderStatusBar = true;
40-
var css = "#test-element { " + args.object.tag + " }";
41-
page.css = css;
38+
page.css = "#test-element { " + args.object.tag + " }";
4239
}
4340

4441
export function applyTapOnStyledActionBarAndSpan(args) {
@@ -48,8 +45,7 @@ export function applyTapOnStyledActionBarAndSpan(args) {
4845

4946
page.backgroundSpanUnderStatusBar = true;
5047
page.actionBar.backgroundColor = new Color("#E0115F");
51-
var css = "#test-element { " + args.object.tag + " }";
52-
page.css = css;
48+
page.css = "#test-element { " + args.object.tag + " }";
5349
}
5450

5551
export function applyTapWithActionBarHiddenAndSpan(args) {
@@ -59,8 +55,7 @@ export function applyTapWithActionBarHiddenAndSpan(args) {
5955

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

6661
function reset(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.isEnabled()) {
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.isEnabled()) {
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 & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ export class ActionBar extends ActionBarBase {
261261
View.layoutChild(this, this.titleView, 0, 0, right - left, this._navigationBarHeight);
262262
this.actionItems.getItems().forEach((actionItem) => {
263263
if (actionItem.actionView && actionItem.actionView.ios) {
264-
let measuredWidth = actionItem.actionView.getMeasuredWidth();
264+
let measuredWidth = actionItem.actionView.getMeasuredWidth(); 
265265
let measuredHeight = actionItem.actionView.getMeasuredHeight();
266266
View.layoutChild(this, actionItem.actionView, 0, 0, measuredWidth, measuredHeight);
267267
}
@@ -314,10 +314,11 @@ export class ActionBar extends ActionBarBase {
314314
}
315315
return null;
316316
}
317-
set [backgroundColorProperty.native](value: UIColor) {
317+
set [backgroundColorProperty.native](value: UIColor | Color) {
318318
let navBar = this.navBar;
319-
if (navBar) {
320-
navBar.barTintColor = value;
319+
if (navBar && value) {
320+
let color = value instanceof Color ? value.ios : value;
321+
navBar.barTintColor = color;
321322
}
322323
}
323324

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ export class FrameBase extends CustomLayoutView implements FrameDefinition {
211211
// if (!this._currentEntry){
212212
// return;
213213
// }
214-
214+
215215
// let currentPage = this._currentEntry.resolvedPage;
216216
// let currentNavigationEntry = this._currentEntry.entry;
217217
// if (currentPage["isBiOrientational"] && currentNavigationEntry.moduleName) {
@@ -310,7 +310,7 @@ export class FrameBase extends CustomLayoutView implements FrameDefinition {
310310
return !backstackHidden;
311311
}
312312

313-
public _updateActionBar(page?: Page) {
313+
public _updateActionBar(page?: Page, disableNavBarAnimation?: boolean) {
314314
//traceWrite("calling _updateActionBar on Frame", traceCategories.Navigation);
315315
}
316316

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: Page);
107-
_updateActionBar(page?: Page);
107+
_updateActionBar(page?: Page, disableNavBarAnimation?: boolean);
108108
_getNavBarVisible(page: Page): boolean;
109109
//@endprivate
110110

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

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,10 @@ export class Frame extends FrameBase {
114114
backstackEntry[NAV_DEPTH] = navDepth;
115115
viewController[ENTRY] = backstackEntry;
116116

117-
this._updateActionBar(backstackEntry.resolvedPage);
118-
119117
// First navigation.
120118
if (!this._currentEntry) {
119+
// Update action-bar with disabled animations before the initial navigation.
120+
this._updateActionBar(backstackEntry.resolvedPage, true);
121121
this._ios.controller.pushViewControllerAnimated(viewController, animated);
122122
if (traceEnabled()) {
123123
traceWrite(`${this}.pushViewControllerAnimated(${viewController}, ${animated}); depth = ${navDepth}`, traceCategories.Navigation);
@@ -194,16 +194,23 @@ export class Frame extends FrameBase {
194194
}
195195
}
196196

197-
public _updateActionBar(page?: Page): void {
197+
public _updateActionBar(page?: Page, disableNavBarAnimation: boolean = false): void {
198+
198199
super._updateActionBar(page);
199200

200201
page = page || this.currentPage;
201202
let newValue = this._getNavBarVisible(page);
203+
let disableNavBarAnimationCache = this._ios._disableNavBarAnimation;
204+
205+
if (disableNavBarAnimation) {
206+
this._ios._disableNavBarAnimation = true;
207+
}
202208

203-
var disableNavBarAnimation = this._ios._disableNavBarAnimation;
204-
this._ios._disableNavBarAnimation = true;
205209
this._ios.showNavigationBar = newValue;
206-
this._ios._disableNavBarAnimation = disableNavBarAnimation;
210+
211+
if (disableNavBarAnimation) {
212+
this._ios._disableNavBarAnimation = disableNavBarAnimationCache;
213+
}
207214

208215
if (this._ios.controller.navigationBar) {
209216
this._ios.controller.navigationBar.userInteractionEnabled = this.navigationQueueIsEmpty();
@@ -708,6 +715,7 @@ class iOSFrame implements iOSFrameDefinition {
708715
this._showNavigationBar = value;
709716

710717
let animated = !this._frame._isInitialNavigation && !this._disableNavBarAnimation;
718+
711719
this._controller.setNavigationBarHiddenAnimated(!value, animated);
712720

713721
let currentPage = this._controller.owner.currentPage;

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,6 @@ export class PageBase extends ContentView implements PageDefinition {
4242
this.actionBar = new ActionBar();
4343
}
4444

45-
// public onLoaded() {
46-
// this._applyCss();
47-
// super.onLoaded();
48-
// }
49-
5045
get navigationContext(): any {
5146
return this._navigationContext;
5247
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export class Page extends PageBase {
122122
public onLoaded() {
123123
super.onLoaded();
124124
if (this.actionBarHidden !== undefined) {
125-
this.updateActionBar(this.actionBarHidden);
125+
this.updateActionBar();
126126
}
127127
}
128128

@@ -170,15 +170,15 @@ export class Page extends PageBase {
170170
super._hideNativeModalView(parent);
171171
}
172172

173-
private updateActionBar(hidden: boolean) {
173+
private updateActionBar() {
174174
this.actionBar.update();
175175
}
176176

177177
get [actionBarHiddenProperty.native](): boolean {
178178
return undefined;
179179
}
180180
set [actionBarHiddenProperty.native](value: boolean) {
181-
this.updateActionBar(value);
181+
this.updateActionBar();
182182
}
183183

184184
get [statusBarStyleProperty.native](): { color: number, systemUiVisibility: number } {

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

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,11 @@ class UIViewControllerImpl extends UIViewController {
147147
super.viewWillAppear(animated);
148148
this.shown = false;
149149
let page = this._owner.get();
150-
if (traceEnabled()) {
151-
if (traceEnabled()) {
152-
traceWrite(page + " viewWillAppear", traceCategories.Navigation);
153-
}
150+
151+
if (traceEnabled) {
152+
traceWrite(page + " viewWillAppear", traceCategories.Navigation);
154153
}
154+
155155
if (!page) {
156156
return;
157157
}
@@ -249,6 +249,8 @@ class UIViewControllerImpl extends UIViewController {
249249
};
250250

251251
public viewWillDisappear(animated: boolean): void {
252+
super.viewWillDisappear(animated);
253+
252254
let page = this._owner.get();
253255
if (traceEnabled()) {
254256
traceWrite(page + " viewWillDisappear", traceCategories.Navigation);
@@ -275,6 +277,8 @@ class UIViewControllerImpl extends UIViewController {
275277
}
276278

277279
public viewDidDisappear(animated: boolean): void {
280+
super.viewDidDisappear(animated);
281+
278282
let page = this._owner.get();
279283
if (traceEnabled()) {
280284
traceWrite(page + " viewDidDisappear", traceCategories.Navigation);
@@ -362,9 +366,7 @@ export class Page extends PageBase {
362366
super.onLoaded();
363367
}
364368

365-
if (this.actionBarHidden !== undefined) {
366-
this.updateActionBar(this.actionBarHidden);
367-
}
369+
this.updateActionBar();
368370
}
369371

370372
public onUnloaded() {
@@ -448,10 +450,10 @@ export class Page extends PageBase {
448450
super._hideNativeModalView(parent);
449451
}
450452

451-
private updateActionBar(hidden: boolean) {
453+
private updateActionBar(disableNavBarAnimation: boolean = false) {
452454
const frame = this.frame;
453455
if (frame) {
454-
frame._updateActionBar(this);
456+
frame._updateActionBar(this, disableNavBarAnimation);
455457
}
456458
}
457459

@@ -585,7 +587,8 @@ export class Page extends PageBase {
585587
set [actionBarHiddenProperty.native](value: boolean) {
586588
this._updateEnableSwipeBackNavigation(value);
587589
if (this.isLoaded) {
588-
this.updateActionBar(value);
590+
// Update nav-bar visibility with disabled animations
591+
this.updateActionBar(true);
589592
}
590593
}
591594

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,9 @@ export class Progress extends ProgressBase {
4444
get [backgroundColorProperty.native](): UIColor {
4545
return this._ios.trackTintColor;
4646
}
47-
set [backgroundColorProperty.native](value: Color) {
48-
if (value instanceof Color) {
49-
this._ios.trackTintColor = value.ios;
50-
} else {
51-
this._ios.trackTintColor = value;
52-
}
47+
set [backgroundColorProperty.native](value: UIColor | Color) {
48+
let color = value instanceof Color ? value.ios : value;
49+
this._ios.trackTintColor = color;
5350
}
5451

5552
get [backgroundInternalProperty.native](): UIColor {

0 commit comments

Comments
 (0)
0