Back to animated nav-bar

This commit is contained in:
vakrilov
2017-01-20 17:05:49 +02:00
parent ee1d33ca29
commit 93ba30c94d
9 changed files with 51 additions and 57 deletions

View File

@@ -10,7 +10,7 @@ export function applyTap(args) {
let css = "#test-element { " + args.object.tag + " }";
page.css = css;
}
}
export function applyTapOnStyledActionBar(args) {
let page = <page.Page>(<view.View>args.object).page;
@@ -18,8 +18,7 @@ export function applyTapOnStyledActionBar(args) {
reset(page);
page.actionBar.backgroundColor = new color.Color("#5DFC0A");
var css = "#test-element { " + args.object.tag + " }";
page.css = css;
page.css = "#test-element { " + args.object.tag + " }";
}
export function applyTapWithHiddenActionBar(args) {
@@ -28,8 +27,7 @@ export function applyTapWithHiddenActionBar(args) {
reset(page);
page.actionBarHidden = true;
var css = "#test-element { " + args.object.tag + " }";
page.css = css;
page.css = "#test-element { " + args.object.tag + " }";
}
export function applyTapWithSpan(args) {
@@ -38,8 +36,7 @@ export function applyTapWithSpan(args) {
reset(page);
page.backgroundSpanUnderStatusBar = true;
var css = "#test-element { " + args.object.tag + " }";
page.css = css;
page.css = "#test-element { " + args.object.tag + " }";
}
export function applyTapOnStyledActionBarAndSpan(args) {
@@ -49,8 +46,7 @@ export function applyTapOnStyledActionBarAndSpan(args) {
page.backgroundSpanUnderStatusBar = true;
page.actionBar.backgroundColor = new color.Color("#E0115F");
var css = "#test-element { " + args.object.tag + " }";
page.css = css;
page.css = "#test-element { " + args.object.tag + " }";
}
export function applyTapWithActionBarHiddenAndSpan(args) {
@@ -59,9 +55,8 @@ export function applyTapWithActionBarHiddenAndSpan(args) {
reset(page);
page.backgroundSpanUnderStatusBar = true;
page.actionBarHidden = true;;
var css = "#test-element { " + args.object.tag + " }";
page.css = css;
page.actionBarHidden = true;
page.css = "#test-element { " + args.object.tag + " }";
}
function reset(page: page.Page) {

View File

@@ -142,9 +142,6 @@ export class FileNameResolver implements definition.FileNameResolver {
var candidates = this.getFileCandidatesFromFolder(path, ext);
result = _findFileMatch(path, ext, candidates, this._context);
if (trace.enabled) {
trace.write("Resolved file name for \"" + path + ext + "\" result: " + (result ? result : "no match found"), trace.categories.Navigation);
}
return result;
}
@@ -179,9 +176,6 @@ export function _findFileMatch(path: string, ext: string, candidates: Array<stri
var bestValue = -1
var result: string = null;
if (trace.enabled) {
trace.write("Candidates for " + path + ext + ": " + candidates.join(", "), trace.categories.Navigation);
}
for (var i = 0; i < candidates.length; i++) {
var filePath = candidates[i];
var qualifiersStr: string = filePath.substr(path.length, filePath.length - path.length - ext.length);

View File

@@ -30,7 +30,7 @@ export class NavigationButton extends ActionItem {
export class ActionBar extends common.ActionBar {
get ios(): UIView {
get ios(): UIView {
if (!(this.page && this.page.parent)) {
return;
@@ -41,9 +41,9 @@ export class ActionBar extends common.ActionBar {
return viewController.navigationController.navigationBar;
}
return null;
}
}
public update() {
public update() {
// Page should be attached to frame to update the action bar.
if (!(this.page && this.page.parent)) {
return;
@@ -51,7 +51,7 @@ export class ActionBar extends common.ActionBar {
var viewController = (<UIViewController>this.page.ios);
var navigationItem: UINavigationItem = viewController.navigationItem;
var navController = frameModule.topmost().ios.controller;
var navController = frameModule.topmost().ios.controller;
var navigationBar = navController ? <UINavigationBar>navController.navigationBar : null;
var previousController: UIViewController;
@@ -229,7 +229,7 @@ export class ActionBar extends common.ActionBar {
this.actionItems.getItems().forEach((actionItem) => {
if (actionItem.actionView) {
view.View.measureChild(this, actionItem.actionView,
view.View.measureChild(this, actionItem.actionView,
utils.layout.makeMeasureSpec(width, utils.layout.AT_MOST),
utils.layout.makeMeasureSpec(navBarHeight, utils.layout.AT_MOST));
}

View File

@@ -1,9 +1,9 @@
import * as definition from "ui/frame";
import {View, CustomLayoutView} from "ui/core/view";
import {Page} from "ui/page";
import {isString, isFunction, isDefined} from "utils/types";
import { View, CustomLayoutView } from "ui/core/view";
import { Page } from "ui/page";
import { isString, isFunction, isDefined } from "utils/types";
import * as trace from "trace";
import {resolveFileName} from "file-system/file-name-resolver";
import { resolveFileName } from "file-system/file-name-resolver";
import * as fs from "file-system";
import * as builderModule from "ui/builder";
import * as platform from "platform";
@@ -222,7 +222,7 @@ export class Frame extends CustomLayoutView implements definition.Frame {
// if (!this._currentEntry){
// return;
// }
// let currentPage = this._currentEntry.resolvedPage;
// let currentNavigationEntry = this._currentEntry.entry;
// if (currentPage["isBiOrientational"] && currentNavigationEntry.moduleName) {
@@ -321,7 +321,7 @@ export class Frame extends CustomLayoutView implements definition.Frame {
return !backstackHidden;
}
public _updateActionBar(page?: Page) {
public _updateActionBar(page?: Page, disableNavBarAnimation?: boolean) {
//trace.write("calling _updateActionBar on Frame", trace.categories.Navigation);
}
@@ -408,7 +408,7 @@ export class Frame extends CustomLayoutView implements definition.Frame {
if (this._currentEntry) {
return this._currentEntry.entry;
}
return null;
}

View File

@@ -104,7 +104,7 @@ declare module "ui/frame" {
navigationQueueIsEmpty(): boolean;
navigationBarHeight: number;
_processNavigationQueue(page: pages.Page);
_updateActionBar(page?: pages.Page);
_updateActionBar(page?: pages.Page, disableNavBarAnimation?: boolean);
_getNavBarVisible(page: pages.Page): boolean;
//@endprivate

View File

@@ -1,10 +1,10 @@
import frameCommon = require("./frame-common");
import definition = require("ui/frame");
import trace = require("trace");
import {Page} from "ui/page";
import {NavigationBarVisibility, AnimationCurve} from "ui/enums";
import { Page } from "ui/page";
import { NavigationBarVisibility, AnimationCurve } from "ui/enums";
import utils = require("utils/utils");
import {View} from "ui/core/view";
import { View } from "ui/core/view";
import uiUtils = require("ui/utils");
import * as types from "utils/types";
import application = require("application");
@@ -109,10 +109,10 @@ export class Frame extends frameCommon.Frame {
backstackEntry[NAV_DEPTH] = navDepth;
viewController[ENTRY] = backstackEntry;
this._updateActionBar(backstackEntry.resolvedPage);
// First navigation.
if (!this._currentEntry) {
// Update action-bar with disabled animations before the initial navigation.
this._updateActionBar(backstackEntry.resolvedPage, true);
this._ios.controller.pushViewControllerAnimated(viewController, animated);
if (trace.enabled) {
trace.write(`${this}.pushViewControllerAnimated(${viewController}, ${animated}); depth = ${navDepth}`, trace.categories.Navigation);
@@ -189,16 +189,23 @@ export class Frame extends frameCommon.Frame {
}
}
public _updateActionBar(page?: Page): void {
public _updateActionBar(page?: Page, disableNavBarAnimation: boolean = false): void {
super._updateActionBar(page);
page = page || this.currentPage;
let newValue = this._getNavBarVisible(page);
var disableNavBarAnimation = this._ios._disableNavBarAnimation;
this._ios._disableNavBarAnimation = true;
let disableNavBarAnimationCache = this._ios._disableNavBarAnimation;
if (disableNavBarAnimation) {
this._ios._disableNavBarAnimation = true;
}
this._ios.showNavigationBar = newValue;
this._ios._disableNavBarAnimation = disableNavBarAnimation;
if (disableNavBarAnimation) {
this._ios._disableNavBarAnimation = disableNavBarAnimationCache;
}
if (this._ios.controller.navigationBar) {
this._ios.controller.navigationBar.userInteractionEnabled = this.navigationQueueIsEmpty();
@@ -260,7 +267,7 @@ export class Frame extends frameCommon.Frame {
}
public onMeasure(widthMeasureSpec: number, heightMeasureSpec: number): void {
View.adjustChildLayoutParams(this.currentPage, widthMeasureSpec, heightMeasureSpec);
View.adjustChildLayoutParams(this.currentPage, widthMeasureSpec, heightMeasureSpec);
let width = utils.layout.getMeasureSpecSize(widthMeasureSpec);
let widthMode = utils.layout.getMeasureSpecMode(widthMeasureSpec);
@@ -693,7 +700,6 @@ class iOSFrame implements definition.iOSFrame {
this._frame = frame;
this._controller = UINavigationControllerImpl.initWithOwner(new WeakRef(frame));
this._controller.automaticallyAdjustsScrollViewInsets = false;
//this.showNavigationBar = false;
this._navBarVisibility = NavigationBarVisibility.auto;
}

View File

@@ -10,7 +10,7 @@ import * as frameModule from "ui/frame";
import proxy = require("ui/core/proxy");
import keyframeAnimation = require("ui/animation/keyframe-animation");
import types = require("utils/types");
import {Color} from "color";
import { Color } from "color";
let fs: typeof fileSystemModule;
function ensureFS() {
@@ -47,7 +47,8 @@ const actionBarHiddenProperty = new Property("actionBarHidden", "Page", new prox
function onActionBarHiddenPropertyChanged(data: PropertyChangeData) {
const page = <Page>data.object;
if (page.isLoaded) {
page._updateActionBar(data.newValue);
// Update with disabled animation when setting visibility
page._updateActionBar(true);
}
}
@@ -101,7 +102,7 @@ export class Page extends ContentView implements dts.Page {
this._applyCss();
if (this.actionBarHidden !== undefined) {
this._updateActionBar(this.actionBarHidden);
this._updateActionBar();
}
this._updateStatusBar();
@@ -148,7 +149,7 @@ export class Page extends ContentView implements dts.Page {
this._setValue(Page.iosSwipeBackNavigationEnabledProperty, value);
}
public _updateActionBar(hidden: boolean) {
public _updateActionBar(disableNavBarAnimation?: boolean) {
//
}

View File

@@ -187,7 +187,7 @@ export class Page extends pageCommon.Page {
super._hideNativeModalView(parent);
}
public _updateActionBar(hidden: boolean) {
public _updateActionBar() {
this.actionBar.update();
}

View File

@@ -145,9 +145,7 @@ class UIViewControllerImpl extends UIViewController {
this.shown = false;
let page = this._owner.get();
if (trace.enabled) {
if (trace.enabled) {
trace.write(page + " viewWillAppear", trace.categories.Navigation);
}
trace.write(page + " viewWillAppear", trace.categories.Navigation);
}
if (!page) {
return;
@@ -349,7 +347,7 @@ export class Page extends pageCommon.Page {
if (this._enableLoadedEvents) {
super.onLoaded();
}
this._updateActionBar(false);
this._updateActionBar();
}
public onUnloaded() {
@@ -433,10 +431,10 @@ export class Page extends pageCommon.Page {
super._hideNativeModalView(parent);
}
public _updateActionBar(hidden: boolean) {
public _updateActionBar(disableNavBarAnimation: boolean = false) {
const frame = this.frame;
if (frame) {
frame._updateActionBar(this);
frame._updateActionBar(this, disableNavBarAnimation);
}
}
@@ -449,7 +447,7 @@ export class Page extends pageCommon.Page {
if (this.frame && value) {
let navigationController = frame.ios.controller;
let navigationBar = navigationController.navigationBar;
navigationBar.barStyle = value === "dark" ? 1 : 0;
}
}
@@ -554,7 +552,7 @@ export class Page extends pageCommon.Page {
export class PageStyler implements style.Styler {
// statusBarStyle
private static setStatusBarStyleProperty(v: View, newValue: any) {
private static setStatusBarStyleProperty(v: View, newValue: any) {
let page = <Page>v;
page._updateStatusBarStyle(newValue);
}
@@ -570,11 +568,11 @@ export class PageStyler implements style.Styler {
}
public static registerHandlers() {
style.registerHandler(style.statusBarStyleProperty, new style.StylePropertyChangedHandler(
style.registerHandler(style.statusBarStyleProperty, new style.StylePropertyChangedHandler(
PageStyler.setStatusBarStyleProperty,
PageStyler.resetStatusBarStyleProperty,
PageStyler.getStatusBarStyleProperty), "Page");
}
}
PageStyler.registerHandlers();
PageStyler.registerHandlers();