|
| 1 | +import { getColorStateList } from '@nativescript-community/ui-material-core/android/utils'; |
1 | 2 | import { TextField } from '@nativescript-community/ui-material-textfield'; |
2 | 3 | import { |
3 | 4 | ActionOptions, |
@@ -61,8 +62,8 @@ function createAlertDialogBuilder(options?: DialogOptions & MDCAlertControlerOpt |
61 | 62 | options.view instanceof View |
62 | 63 | ? options.view |
63 | 64 | : Builder.createViewFromEntry({ |
64 | | - moduleName: options.view as string |
65 | | - }); |
| 65 | + moduleName: options.view as string |
| 66 | + }); |
66 | 67 |
|
67 | 68 | view.cssClasses.add(CSSUtils.MODAL_ROOT_VIEW_CSS_CLASS); |
68 | 69 | const modalRootViewCssClasses = CSSUtils.getSystemCssClasses(); |
@@ -127,19 +128,27 @@ function showDialog(dlg: androidx.appcompat.app.AlertDialog, options: DialogOpti |
127 | 128 |
|
128 | 129 | // let { color, backgroundColor } = getButtonColors(); |
129 | 130 |
|
| 131 | + |
| 132 | + |
130 | 133 | if (options.buttonInkColor || options.buttonTitleColor) { |
131 | | - const buttons: android.widget.Button[] = []; |
132 | | - for (let i = 0; i < 3; i++) { |
133 | | - const id = dlg |
134 | | - .getContext() |
135 | | - .getResources() |
136 | | - .getIdentifier('android:id/button' + i, null, null); |
137 | | - buttons[i] = dlg.findViewById(id) as android.widget.Button; |
| 134 | + dlg.create(); |
| 135 | + const buttons: com.google.android.material.button.MaterialButton[] = []; |
| 136 | + for (let i = -1; i > -4; i--) { |
| 137 | + buttons.push(dlg.getButton(i) as com.google.android.material.button.MaterialButton); |
138 | 138 | } |
139 | 139 |
|
| 140 | + const nInkColor = options.buttonInkColor && getColorStateList(options.buttonInkColor.android); |
| 141 | + const nTitleColor = options.buttonTitleColor && getColorStateList(options.buttonTitleColor.android); |
| 142 | + |
140 | 143 | buttons.forEach((button) => { |
141 | 144 | if (button) { |
142 | | - button.setTextColor((options.buttonInkColor || options.buttonTitleColor).android); |
| 145 | + if (nInkColor) { |
| 146 | + button.setRippleColor(nInkColor); |
| 147 | + } |
| 148 | + if (nTitleColor) { |
| 149 | + button.setTextColor(nTitleColor); |
| 150 | + button.setIconTint(nTitleColor); |
| 151 | + } |
143 | 152 | } |
144 | 153 | }); |
145 | 154 | } |
@@ -334,8 +343,8 @@ export function confirm(arg: any): Promise<boolean> { |
334 | 343 | defaultOptions, |
335 | 344 | !isDialogOptions(arg) |
336 | 345 | ? { |
337 | | - message: arg + '' |
338 | | - } |
| 346 | + message: arg + '' |
| 347 | + } |
339 | 348 | : arg |
340 | 349 | ); |
341 | 350 | const alert = createAlertDialogBuilder(options); |
|
0 commit comments