mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Merge pull request #3211 from NativeScript/zhecheva/dialog-button-backgroundColor
Background of the buttons inside dialog can be modified with CSS
This commit is contained in:
@@ -60,6 +60,18 @@ export function getButtonColor(): color.Color {
|
||||
return buttonColor;
|
||||
}
|
||||
|
||||
var buttonBackgroundColor: color.Color;
|
||||
export function getButtonBackgroundColor(): color.Color {
|
||||
if (!buttonBackgroundColor) {
|
||||
var btn = new button.Button();
|
||||
applySelectors(btn);
|
||||
buttonBackgroundColor = btn.backgroundColor;
|
||||
btn.onUnloaded();
|
||||
}
|
||||
|
||||
return buttonBackgroundColor;
|
||||
}
|
||||
|
||||
var textFieldColor: color.Color;
|
||||
export function getTextFieldColor(): color.Color {
|
||||
if (!textFieldColor) {
|
||||
|
||||
@@ -41,15 +41,22 @@ function showDialog(builder: android.app.AlertDialog.Builder) {
|
||||
}
|
||||
|
||||
let buttonColor = dialogsCommon.getButtonColor();
|
||||
if (buttonColor) {
|
||||
let buttonBackgroundColor = dialogsCommon.getButtonBackgroundColor();
|
||||
if (buttonColor || buttonBackgroundColor) {
|
||||
let buttons : android.widget.Button[] = [];
|
||||
for (let i = 0; i < 3; i++) {
|
||||
let id = dlg.getContext().getResources().getIdentifier("android:id/button" + i, null, null);
|
||||
buttons[i] = <android.widget.Button>dlg.findViewById(id);
|
||||
}
|
||||
|
||||
buttons.forEach(button => {
|
||||
if (button) {
|
||||
button.setTextColor(buttonColor.android);
|
||||
if (buttonColor) {
|
||||
button.setTextColor(buttonColor.android);
|
||||
}
|
||||
if (buttonBackgroundColor) {
|
||||
button.setBackgroundColor(buttonBackgroundColor.android);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user