Merge pull request #3522 from NativeScript/status-bar-pick

Status bar pick
This commit is contained in:
Panayot Cankov
2017-01-24 17:49:59 +02:00
committed by GitHub
5 changed files with 79 additions and 41 deletions

View File

@@ -427,10 +427,34 @@ export class ActionBarStyler implements style.Styler {
(<android.support.v7.widget.Toolbar>v._nativeView).setTitleTextColor(nativeValue);
}
// background-color
private static getBackgroundColorProperty(view: view.View): any {
let toolbar = <android.support.v7.widget.Toolbar>view._nativeView;
return toolbar.getBackground();
}
private static setBackgroundColorProperty(v: view.View, newValue: any) {
var toolbar = (<android.support.v7.widget.Toolbar>v._nativeView);
if (toolbar) {
toolbar.setBackgroundColor(newValue);
}
}
private static resetBackgroundColorProperty(v: view.View, nativeValue: any) {
var toolbar = (<android.support.v7.widget.Toolbar>v._nativeView);
if (toolbar) {
toolbar.setBackgroundColor(nativeValue);
}
}
public static registerHandlers() {
style.registerHandler(style.colorProperty, new style.StylePropertyChangedHandler(
ActionBarStyler.setColorProperty,
ActionBarStyler.resetColorProperty), "ActionBar");
style.registerHandler(style.backgroundColorProperty, new style.StylePropertyChangedHandler(
ActionBarStyler.setBackgroundColorProperty,
ActionBarStyler.resetBackgroundColorProperty,
ActionBarStyler.getBackgroundColorProperty), "ActionBar");
}
}

View File

@@ -243,15 +243,19 @@ export class PageStyler implements style.Styler {
// android-status-bar-background-property
private static setAndroidStatusBarBackgroundProperty(v: view.View, newValue: any) {
let window = app.android.startActivity.getWindow();
let nativeColor = new colorModule.Color(newValue).android;
window.setStatusBarColor(nativeColor);
if (platform.device.sdkVersion >= "21") {
let window = app.android.startActivity.getWindow();
let nativeColor = new colorModule.Color(newValue).android;
window.setStatusBarColor(nativeColor);
}
}
private static resetAndroidStatusBarBackgroundProperty(v: view.View, nativeValue: any) {
let window = app.android.startActivity.getWindow();
let nativeColor = (nativeValue instanceof colorModule.Color) ? (<colorModule.Color>nativeValue).android : new colorModule.Color(nativeValue).android;
window.setStatusBarColor(nativeColor);
if (platform.device.sdkVersion >= "21") {
let window = app.android.startActivity.getWindow();
let nativeColor = (nativeValue instanceof colorModule.Color) ? (<colorModule.Color>nativeValue).android : new colorModule.Color(nativeValue).android;
window.setStatusBarColor(nativeColor);
}
}
private static getAndroidStatusBarBackgroundProperty(v: view.View): any {