mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Merge pull request #3744 from NativeScript/status-bar-30
Status bar style for modules 3.0
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { Page as PageDefinition, NavigatedData, ShownModallyData } from "ui/page";
|
||||
import {
|
||||
ContentView, View, eachDescendant, Property, Color, isIOS, booleanConverter, resetCSSProperties
|
||||
ContentView, View, eachDescendant, Property, CssProperty, Color, isIOS,
|
||||
booleanConverter, resetCSSProperties, Style
|
||||
} from "ui/content-view";
|
||||
import { Frame, topmost as topmostFrame, resolvePageFromEntry } from "ui/frame";
|
||||
import { ActionBar } from "ui/action-bar";
|
||||
@@ -303,11 +304,12 @@ enableSwipeBackNavigationProperty.register(PageBase);
|
||||
/**
|
||||
* Property backing statusBarStyle.
|
||||
*/
|
||||
export const statusBarStyleProperty = new Property<PageBase, "light" | "dark">({ name: "statusBarStyle" });
|
||||
statusBarStyleProperty.register(PageBase);
|
||||
export const statusBarStyleProperty = new CssProperty<Style, "light" | "dark">({ name: "statusBarStyle", cssName: "status-bar-style" });
|
||||
statusBarStyleProperty.register(Style);
|
||||
|
||||
/**
|
||||
* Property backing androidStatusBarBackground.
|
||||
*/
|
||||
export const androidStatusBarBackgroundProperty = new Property<PageBase, Color>({ name: "androidStatusBarBackground", equalityComparer: Color.equals, valueConverter: (v) => new Color(v) });
|
||||
androidStatusBarBackgroundProperty.register(PageBase);
|
||||
export const androidStatusBarBackgroundProperty = new CssProperty<Style, Color>({ name: "androidStatusBarBackground", cssName:"android-status-bar-background",
|
||||
equalityComparer: Color.equals, valueConverter: (v) => new Color(v) });
|
||||
androidStatusBarBackgroundProperty.register(Style);
|
||||
@@ -17,7 +17,7 @@ export module ad {
|
||||
return SDK;
|
||||
}
|
||||
|
||||
let _defaultBackgrounds = new Map<string, android.graphics.drawable.Drawable>();
|
||||
let _defaultBackgrounds = new Map<string, android.graphics.drawable.Drawable.ConstantState>();
|
||||
|
||||
function isSetColorFilterOnlyWidget(nativeView: android.view.View): boolean {
|
||||
return (
|
||||
@@ -37,6 +37,12 @@ export module ad {
|
||||
let background = view.style.backgroundInternal;
|
||||
let backgroundDrawable = nativeView.getBackground();
|
||||
let cache = <CacheLayerType>view._nativeView;
|
||||
let viewClass = getClass(view);
|
||||
|
||||
// always cache the default background constant state.
|
||||
if (!_defaultBackgrounds.has(viewClass) && !isNullOrUndefined(backgroundDrawable)) {
|
||||
_defaultBackgrounds.set(viewClass, backgroundDrawable.getConstantState());
|
||||
}
|
||||
|
||||
if (isSetColorFilterOnlyWidget(nativeView)
|
||||
&& !isNullOrUndefined(backgroundDrawable)
|
||||
@@ -54,19 +60,9 @@ export module ad {
|
||||
}
|
||||
else if (!background.isEmpty()) {
|
||||
if (!(backgroundDrawable instanceof org.nativescript.widgets.BorderDrawable)) {
|
||||
let viewClass = getClass(view);
|
||||
if (!isSetColorFilterOnlyWidget(nativeView) && !_defaultBackgrounds.has(viewClass)) {
|
||||
_defaultBackgrounds.set(viewClass, nativeView.getBackground());
|
||||
}
|
||||
|
||||
backgroundDrawable = new org.nativescript.widgets.BorderDrawable(layout.getDisplayDensity(), view.toString());
|
||||
refreshBorderDrawable(view, <org.nativescript.widgets.BorderDrawable>backgroundDrawable);
|
||||
|
||||
if (getSDK() >= 16) {
|
||||
nativeView.setBackground(backgroundDrawable);
|
||||
} else {
|
||||
nativeView.setBackgroundDrawable(backgroundDrawable);
|
||||
}
|
||||
org.nativescript.widgets.ViewHelper.setBackground(nativeView, backgroundDrawable);
|
||||
}
|
||||
else {
|
||||
refreshBorderDrawable(view, <org.nativescript.widgets.BorderDrawable>backgroundDrawable);
|
||||
@@ -83,16 +79,8 @@ export module ad {
|
||||
}
|
||||
}
|
||||
else {
|
||||
// reset the value with the default native value
|
||||
if (nativeView instanceof android.widget.Button) {
|
||||
let nativeButton = new android.widget.Button(nativeView.getContext());
|
||||
org.nativescript.widgets.ViewHelper.setBackground(nativeView, nativeButton.getBackground());
|
||||
}
|
||||
else {
|
||||
let viewClass = getClass(view);
|
||||
if (_defaultBackgrounds.has(viewClass)) {
|
||||
org.nativescript.widgets.ViewHelper.setBackground(nativeView, _defaultBackgrounds.get(viewClass));
|
||||
}
|
||||
if (_defaultBackgrounds.has(viewClass)) {
|
||||
org.nativescript.widgets.ViewHelper.setBackground(nativeView, _defaultBackgrounds.get(viewClass).newDrawable());
|
||||
}
|
||||
|
||||
if (cache.layerType !== undefined) {
|
||||
|
||||
Reference in New Issue
Block a user