mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 11:42:04 +08:00
adding features deleted from rebase
This commit is contained in:
@ -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";
|
import { ItemsSource } from "ui/list-picker";
|
||||||
|
|
||||||
export * from "./list-picker-common";
|
export * from "./list-picker-common";
|
||||||
@ -121,4 +121,8 @@ export class ListPicker extends ListPickerBase {
|
|||||||
this.itemsSet = true;
|
this.itemsSet = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
get [colorProperty.native](): number {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
@ -370,17 +370,16 @@ export class ListView extends ListViewBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get [separatorColor.native](): UIColor {
|
get [separatorColor.native](): UIColor {
|
||||||
return null;
|
return this._ios.separatorColor;
|
||||||
}
|
}
|
||||||
set [separatorColor.native](value: Color) {
|
set [separatorColor.native](value: Color | UIColor) {
|
||||||
this._ios.separatorColor = value ? value.ios : null;
|
this._ios.separatorColor = value instanceof Color ? value.ios : value;
|
||||||
}
|
}
|
||||||
|
|
||||||
get [itemTemplatesProperty.native](): KeyedTemplate[] {
|
get [itemTemplatesProperty.native](): KeyedTemplate[] {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
set [itemTemplatesProperty.native](value: KeyedTemplate[]) {
|
set [itemTemplatesProperty.native](value: KeyedTemplate[]) {
|
||||||
this._itemTemplatesInternal = new Array<KeyedTemplate>(this._defaultTemplate);
|
|
||||||
this._itemTemplatesInternal = new Array<KeyedTemplate>(this._defaultTemplate);
|
this._itemTemplatesInternal = new Array<KeyedTemplate>(this._defaultTemplate);
|
||||||
if (value) {
|
if (value) {
|
||||||
for (let i = 0, length = value.length; i < length; i++) {
|
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._itemTemplatesInternal = this._itemTemplatesInternal.concat(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.refresh();
|
this.refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -35,6 +35,8 @@ export class PageBase extends ContentView implements PageDefinition {
|
|||||||
public actionBarHidden: boolean;
|
public actionBarHidden: boolean;
|
||||||
public enableSwipeBackNavigation: boolean;
|
public enableSwipeBackNavigation: boolean;
|
||||||
public backgroundSpanUnderStatusBar: boolean;
|
public backgroundSpanUnderStatusBar: boolean;
|
||||||
|
public statusBarStyle: "light" | "dark";
|
||||||
|
public androidStatusBarBackground: Color;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
@ -307,3 +309,15 @@ backgroundSpanUnderStatusBarProperty.register(PageBase);
|
|||||||
*/
|
*/
|
||||||
export const enableSwipeBackNavigationProperty = new Property<PageBase, boolean>({ name: "enableSwipeBackNavigation", defaultValue: true, valueConverter: booleanConverter });
|
export const enableSwipeBackNavigationProperty = new Property<PageBase, boolean>({ name: "enableSwipeBackNavigation", defaultValue: true, valueConverter: booleanConverter });
|
||||||
enableSwipeBackNavigationProperty.register(PageBase);
|
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);
|
@ -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 { ActionBar } from "ui/action-bar";
|
||||||
import { GridLayout } from "ui/layouts/grid-layout";
|
import { GridLayout } from "ui/layouts/grid-layout";
|
||||||
import { DIALOG_FRAGMENT_TAG } from "./constants";
|
import { DIALOG_FRAGMENT_TAG } from "./constants";
|
||||||
|
import { device } from "platform";
|
||||||
import * as trace from "trace";
|
import * as trace from "trace";
|
||||||
|
|
||||||
export * from "./page-common";
|
export * from "./page-common";
|
||||||
|
|
||||||
const SYSTEM_UI_FLAG_LIGHT_STATUS_BAR = 0x00002000;
|
const SYSTEM_UI_FLAG_LIGHT_STATUS_BAR = 0x00002000;
|
||||||
const STATUS_BAR_LIGHT_BCKG = "#F5F5F5";
|
const STATUS_BAR_LIGHT_BCKG = -657931;
|
||||||
const STATUS_BAR_DARK_BCKG = "#66000000";
|
const STATUS_BAR_DARK_BCKG = 1711276032;
|
||||||
|
|
||||||
interface DialogFragmentClass {
|
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;
|
var DialogFragmentClass: DialogFragmentClass;
|
||||||
|
|
||||||
@ -55,7 +56,7 @@ function ensureDialogFragmentClass() {
|
|||||||
super.onStart();
|
super.onStart();
|
||||||
if (!this._owner.isLoaded) {
|
if (!this._owner.isLoaded) {
|
||||||
this._owner.onLoaded();
|
this._owner.onLoaded();
|
||||||
}
|
}
|
||||||
this._shownCallback();
|
this._shownCallback();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,7 +161,7 @@ export class Page extends PageBase {
|
|||||||
|
|
||||||
super._raiseShowingModallyEvent();
|
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) {
|
protected _hideNativeModalView(parent: Page) {
|
||||||
@ -182,4 +183,52 @@ export class Page extends PageBase {
|
|||||||
set [actionBarHiddenProperty.native](value: boolean) {
|
set [actionBarHiddenProperty.native](value: boolean) {
|
||||||
this.updateActionBar(value);
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
12
tns-core-modules/ui/page/page.d.ts
vendored
12
tns-core-modules/ui/page/page.d.ts
vendored
@ -87,7 +87,7 @@ declare module "ui/page" {
|
|||||||
/**
|
/**
|
||||||
* Gets or sets the style of the status bar.
|
* 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.
|
* 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
|
* This property is iOS sepecific. Default value: true
|
||||||
*/
|
*/
|
||||||
export const enableSwipeBackNavigationProperty: Property<Page, boolean>;
|
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>;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { PageBase, actionBarHiddenProperty, enableSwipeBackNavigationProperty,
|
import { PageBase, View, layout, Color,
|
||||||
View, layout, Color } from "./page-common";
|
actionBarHiddenProperty, enableSwipeBackNavigationProperty, statusBarStyleProperty
|
||||||
|
} from "./page-common";
|
||||||
import { ios as iosApp } from "application";
|
import { ios as iosApp } from "application";
|
||||||
import { device } from "platform";
|
import { device } from "platform";
|
||||||
import { ActionBar } from "ui/action-bar";
|
import { ActionBar } from "ui/action-bar";
|
||||||
@ -559,4 +560,19 @@ export class Page extends PageBase {
|
|||||||
set [actionBarHiddenProperty.native](value: boolean) {
|
set [actionBarHiddenProperty.native](value: boolean) {
|
||||||
this._updateEnableSwipeBackNavigation(value);
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -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";
|
export * from "./text-field-common";
|
||||||
|
|
||||||
@ -175,12 +175,12 @@ export class TextField extends TextFieldBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get [placeholderColorProperty.native](): UIColor {
|
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 nativeView = this.nativeView;
|
||||||
let colorAttibutes = NSMutableDictionary.alloc().init();
|
let colorAttibutes = NSMutableDictionary.new<string, any>();
|
||||||
colorAttibutes.setValueForKey(value, NSForegroundColorAttributeName);
|
colorAttibutes.setValueForKey(value instanceof Color ? value.ios : value, NSForegroundColorAttributeName);
|
||||||
nativeView.attributedPlaceholder = NSAttributedString.alloc().initWithStringAttributes(nativeView.placeholder, colorAttibutes.copy());
|
nativeView.attributedPlaceholder = NSAttributedString.alloc().initWithStringAttributes(nativeView.placeholder || "", colorAttibutes);
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user