Fix: refresh flat property on change in IOS (#4628)

* Fix: refresh flat property on change in IOS

* Fix typos
This commit is contained in:
Alexander Vakrilov
2017-08-01 10:40:51 +03:00
committed by SvetoslavTsenov
parent d949cc7128
commit 2dbd1b19ea
3 changed files with 21 additions and 12 deletions

View File

@@ -1,15 +1,17 @@
import { Label } from "tns-core-modules/ui/Label";
import { Page } from "tns-core-modules/ui/Page";
import { Label } from "tns-core-modules/ui/label";
import { Page } from "tns-core-modules/ui/page";
export function onNavigateTo(args) {
const actionBar = (<Page>args.object).actionBar;
args.object.flatPropertyValue = <Label>args.object.getViewById("flatPropertyValue");
actionBar.flat = true;
args.object.flatPropertyValue.text = "Action bar flat property is set to: " + actionBar.flat;
updateText(args.object);
}
export function changeFlatPropertyValue(args) {
const actionBar = (<Page>args.object.page).actionBar;
actionBar.flat = !actionBar.flat;
args.object.page.flatPropertyValue.text = "Action bar flat property is set to: " + actionBar.flat;
const page = <Page>args.object.page;
page.actionBar.flat = !page.actionBar.flat;
updateText(page);
}
function updateText(page: Page) {
const label = <Label>page.getViewById("flatPropertyValue");
label.text = "Action bar flat property is set to: " + page.actionBar.flat;
}

View File

@@ -1,6 +1,6 @@
<Page navigatedTo="onNavigateTo" >
<Page.actionBar>
<ActionBar title="Flat property" />
<ActionBar title="Flat property"/>
</Page.actionBar>
<StackLayout>
<Button margin="30" text="change flat property" tap="changeFlatPropertyValue"/>

View File

@@ -1,5 +1,5 @@
import { IOSActionItemSettings, ActionItem as ActionItemDefinition } from ".";
import { ActionItemBase, ActionBarBase, isVisible, View, colorProperty, backgroundColorProperty, backgroundInternalProperty, layout, Color } from "./action-bar-common";
import { ActionItemBase, ActionBarBase, isVisible, View, colorProperty, backgroundColorProperty, backgroundInternalProperty, flatProperty, layout, Color } from "./action-bar-common";
import { ImageSource, fromFileOrResource } from "../../image-source";
export * from "./action-bar-common";
@@ -359,4 +359,11 @@ export class ActionBar extends ActionBarBase {
}
[backgroundInternalProperty.setNative](value: UIColor) { // tslint:disable-line
}
[flatProperty.setNative](value: boolean) { // tslint:disable-line
let navBar = this.navBar;
if (navBar) {
this.updateFlatness(navBar);
}
}
}