adding features deleted from rebase

This commit is contained in:
Hristo Hristov
2016-12-07 22:18:32 +02:00
parent 1202cb7288
commit fac4f42503
7 changed files with 117 additions and 24 deletions

View File

@ -1,4 +1,4 @@
import { ListPickerBase, selectedIndexProperty, itemsProperty } from "./list-picker-common";
import { ListPickerBase, selectedIndexProperty, itemsProperty, colorProperty } from "./list-picker-common";
import { ItemsSource } from "ui/list-picker";
export * from "./list-picker-common";
@ -121,4 +121,8 @@ export class ListPicker extends ListPickerBase {
this.itemsSet = true;
}
}
}
get [colorProperty.native](): number {
return
}
}

View File

@ -370,17 +370,16 @@ export class ListView extends ListViewBase {
}
get [separatorColor.native](): UIColor {
return null;
return this._ios.separatorColor;
}
set [separatorColor.native](value: Color) {
this._ios.separatorColor = value ? value.ios : null;
set [separatorColor.native](value: Color | UIColor) {
this._ios.separatorColor = value instanceof Color ? value.ios : value;
}
get [itemTemplatesProperty.native](): KeyedTemplate[] {
return null;
}
set [itemTemplatesProperty.native](value: KeyedTemplate[]) {
this._itemTemplatesInternal = new Array<KeyedTemplate>(this._defaultTemplate);
this._itemTemplatesInternal = new Array<KeyedTemplate>(this._defaultTemplate);
if (value) {
for (let i = 0, length = value.length; i < length; i++) {
@ -388,6 +387,7 @@ export class ListView extends ListViewBase {
}
this._itemTemplatesInternal = this._itemTemplatesInternal.concat(value);
}
this.refresh();
}
}
}

View File

@ -35,6 +35,8 @@ export class PageBase extends ContentView implements PageDefinition {
public actionBarHidden: boolean;
public enableSwipeBackNavigation: boolean;
public backgroundSpanUnderStatusBar: boolean;
public statusBarStyle: "light" | "dark";
public androidStatusBarBackground: Color;
constructor() {
super();
@ -307,3 +309,15 @@ backgroundSpanUnderStatusBarProperty.register(PageBase);
*/
export const enableSwipeBackNavigationProperty = new Property<PageBase, boolean>({ name: "enableSwipeBackNavigation", defaultValue: true, valueConverter: booleanConverter });
enableSwipeBackNavigationProperty.register(PageBase);
/**
* Property backing statusBarStyle.
*/
export const statusBarStyleProperty = new Property<PageBase, "light" | "dark">({ name: "statusBarStyle" });
statusBarStyleProperty.register(PageBase);
/**
* Property backing androidStatusBarBackground.
*/
export const androidStatusBarBackgroundProperty = new Property<PageBase, Color>({ name: "androidStatusBarBackground", equalityComparer: Color.equals, valueConverter: (v) => new Color(v) });
androidStatusBarBackgroundProperty.register(PageBase);

View File

@ -1,17 +1,18 @@
import { View, PageBase, actionBarHiddenProperty, enableSwipeBackNavigationProperty, Color } from "./page-common";
import { View, PageBase, Color, actionBarHiddenProperty, enableSwipeBackNavigationProperty, statusBarStyleProperty, androidStatusBarBackgroundProperty } from "./page-common";
import { ActionBar } from "ui/action-bar";
import { GridLayout } from "ui/layouts/grid-layout";
import { DIALOG_FRAGMENT_TAG } from "./constants";
import { device } from "platform";
import * as trace from "trace";
export * from "./page-common";
const SYSTEM_UI_FLAG_LIGHT_STATUS_BAR = 0x00002000;
const STATUS_BAR_LIGHT_BCKG = "#F5F5F5";
const STATUS_BAR_DARK_BCKG = "#66000000";
const STATUS_BAR_LIGHT_BCKG = -657931;
const STATUS_BAR_DARK_BCKG = 1711276032;
interface DialogFragmentClass {
new (owner: Page, fullscreen: boolean, shownCallback: () => void, dismissCallback: () => void): android.app.DialogFragment;
new (owner: Page, fullscreen: boolean, shownCallback: () => void, dismissCallback: () => void): android.app.DialogFragment;
}
var DialogFragmentClass: DialogFragmentClass;
@ -55,7 +56,7 @@ function ensureDialogFragmentClass() {
super.onStart();
if (!this._owner.isLoaded) {
this._owner.onLoaded();
}
}
this._shownCallback();
}
@ -160,7 +161,7 @@ export class Page extends PageBase {
super._raiseShowingModallyEvent();
this._dialogFragment.show(parent.frame.android.activity.getFragmentManager(), DIALOG_FRAGMENT_TAG);
this._dialogFragment.show(parent.frame.android.activity.getFragmentManager(), DIALOG_FRAGMENT_TAG);
}
protected _hideNativeModalView(parent: Page) {
@ -182,4 +183,52 @@ export class Page extends PageBase {
set [actionBarHiddenProperty.native](value: boolean) {
this.updateActionBar(value);
}
}
get [statusBarStyleProperty.native](): { color: number, systemUiVisibility: number } {
if (device.sdkVersion >= "21") {
let window = (<android.app.Activity>this._context).getWindow();
let decorView = window.getDecorView();
return {
color: (<any>window).getStatusBarColor(),
systemUiVisibility: decorView.getSystemUiVisibility()
}
}
return null;
}
set [statusBarStyleProperty.native](value: "dark" | "light" | { color: number, systemUiVisibility: number }) {
if (device.sdkVersion >= "21") {
let window = (<android.app.Activity>this._context).getWindow();
let decorView = window.getDecorView();
if (value === "light") {
(<any>window).setStatusBarColor(STATUS_BAR_LIGHT_BCKG);
decorView.setSystemUiVisibility(SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
} else if (value === "dark") {
(<any>window).setStatusBarColor(STATUS_BAR_DARK_BCKG);
decorView.setSystemUiVisibility(0);
} else {
(<any>window).setStatusBarColor(value.color);
decorView.setSystemUiVisibility(value.systemUiVisibility);
}
}
}
get [androidStatusBarBackgroundProperty.native](): number {
if (device.sdkVersion >= "21") {
let window = (<android.app.Activity>this._context).getWindow();
return (<any>window).getStatusBarColor();
}
return null;
}
set [androidStatusBarBackgroundProperty.native](value: number | Color) {
if (device.sdkVersion >= "21") {
let window = (<android.app.Activity>this._context).getWindow();
let color = value instanceof Color ? value.android : value;
(<any>window).setStatusBarColor(color);
}
}
}

View File

@ -87,7 +87,7 @@ declare module "ui/page" {
/**
* Gets or sets the style of the status bar.
*/
statusBarStyle: string;
statusBarStyle: "light" | "dark";
/**
* Gets or sets the color of the status bar in Android.
@ -265,4 +265,14 @@ declare module "ui/page" {
* This property is iOS sepecific. Default value: true
*/
export const enableSwipeBackNavigationProperty: Property<Page, boolean>;
/**
* Property backing statusBarStyle.
*/
export const statusBarStyleProperty: Property<Page, "light" | "dark">;
/**
* Property backing androidStatusBarBackground.
*/
export const androidStatusBarBackgroundProperty: Property<Page, Color>;
}

View File

@ -1,5 +1,6 @@
import { PageBase, actionBarHiddenProperty, enableSwipeBackNavigationProperty,
View, layout, Color } from "./page-common";
import { PageBase, View, layout, Color,
actionBarHiddenProperty, enableSwipeBackNavigationProperty, statusBarStyleProperty
} from "./page-common";
import { ios as iosApp } from "application";
import { device } from "platform";
import { ActionBar } from "ui/action-bar";
@ -559,4 +560,19 @@ export class Page extends PageBase {
set [actionBarHiddenProperty.native](value: boolean) {
this._updateEnableSwipeBackNavigation(value);
}
get [statusBarStyleProperty.native](): UIBarStyle {
return UIBarStyle.Default;
}
set [statusBarStyleProperty.native](value: string | UIBarStyle) {
let frame = this.frame;
if (frame) {
let navigationBar = (<UINavigationController>frame.ios.controller).navigationBar;
if (typeof value === "string") {
navigationBar.barStyle = value === "dark" ? UIBarStyle.Black : UIBarStyle.Default;
} else {
navigationBar.barStyle = value;
}
}
}
}

View File

@ -1,4 +1,4 @@
import { TextFieldBase, secureProperty, textProperty, hintProperty, colorProperty, placeholderColorProperty } from "./text-field-common";
import { TextFieldBase, Color, secureProperty, textProperty, hintProperty, colorProperty, placeholderColorProperty } from "./text-field-common";
export * from "./text-field-common";
@ -175,12 +175,12 @@ export class TextField extends TextFieldBase {
}
get [placeholderColorProperty.native](): UIColor {
return <UIColor>this.nativeView.attributedPlaceholder.attributeAtIndexEffectiveRange(NSForegroundColorAttributeName, 0, null);
return null;
}
set [placeholderColorProperty.native](value: UIColor) {
set [placeholderColorProperty.native](value: UIColor | Color) {
let nativeView = this.nativeView;
let colorAttibutes = NSMutableDictionary.alloc().init();
colorAttibutes.setValueForKey(value, NSForegroundColorAttributeName);
nativeView.attributedPlaceholder = NSAttributedString.alloc().initWithStringAttributes(nativeView.placeholder, colorAttibutes.copy());
let colorAttibutes = NSMutableDictionary.new<string, any>();
colorAttibutes.setValueForKey(value instanceof Color ? value.ios : value, NSForegroundColorAttributeName);
nativeView.attributedPlaceholder = NSAttributedString.alloc().initWithStringAttributes(nativeView.placeholder || "", colorAttibutes);
}
}
}