-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Description
Hi!
Would it be more consistent to pass the alert context to the elements, especially given the theme parameter in the alert component? Using this parameter implies that the theme defined in styles.xml should also apply to nested elements.
index b1128bd..d7db28d 100644
--- a/node_modules/@nativescript/core/ui/dialogs/index.android.js
+++ b/node_modules/@nativescript/core/ui/dialogs/index.android.js
@@ -1,6 +1,5 @@
import { getLabelColor, getButtonColors, isDialogOptions, inputType, capitalizationType, DialogStrings, parseLoginOptions } from './dialogs-common';
import { android as androidUtils } from '../../utils/native-helper';
-import { getNativeApp } from '../../application/helpers-common';
export * from './dialogs-common';
function isString(value) {
return typeof value === 'string';
@@ -162,7 +161,7 @@ export function prompt(...args) {
return new Promise((resolve, reject) => {
try {
const alert = createAlertDialog(options);
- const input = new android.widget.EditText(androidUtils.getCurrentActivity());
+ const input = new android.widget.EditText(alert.getContext());
if (options) {
if (options.inputType === inputType.password) {
input.setInputType(android.text.InputType.TYPE_CLASS_TEXT | android.text.InputType.TYPE_TEXT_VARIATION_PASSWORD);
@@ -214,15 +213,15 @@ export function login(...args) {
return new Promise((resolve, reject) => {
try {
const alert = createAlertDialog(options);
- const userNameInput = new android.widget.EditText(getNativeApp().getApplicationContext());
+ const userNameInput = new android.widget.EditText(alert.getContext());
userNameInput.setHint(options.userNameHint ? options.userNameHint : '');
userNameInput.setText(options.userName ? options.userName : '');
- const passwordInput = new android.widget.EditText(getNativeApp().getApplicationContext());
+ const passwordInput = new android.widget.EditText(alert.getContext());
passwordInput.setInputType(android.text.InputType.TYPE_CLASS_TEXT | android.text.InputType.TYPE_TEXT_VARIATION_PASSWORD);
passwordInput.setTypeface(android.graphics.Typeface.DEFAULT);
passwordInput.setHint(options.passwordHint ? options.passwordHint : '');
passwordInput.setText(options.password ? options.password : '');
- const layout = new android.widget.LinearLayout(getNativeApp().getApplicationContext());
+ const layout = new android.widget.LinearLayout(alert.getContext());
layout.setOrientation(1);
layout.addView(userNameInput);
layout.addView(passwordInput);
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels