add style, to readme. and also added the properties i just added of h…#31
add style, to readme. and also added the properties i just added of h…#31Noitidart wants to merge 31 commits intoshimohq:masterfrom
Conversation
…ighlightColor, placeholderColor, color, and disableFullScreenUI
|
Just added |
also color neutral button if its there. tested, if the button is not there, it doesnt crash, cool.
|
Fixes #25 (prop of disableFullscreenUI is added, and also in both cases (disableFullscreenUI true/false) the keyboard works) and survives orientation changes. |
|
@greedbell this is ready to merge, may you please review. |
| } | ||
|
|
||
| @Override | ||
| public void onStart() { |
There was a problem hiding this comment.
I wanted to. I actually tried to put it on line 91 - https://github.com/Noitidart/react-native-prompt-android/blob/dd428a864880209114ff9708f76e21e9d1937aa5/android/src/main/java/im/shimo/react/prompt/RNPromptFragment.java#L91 - where we initially work with postive button. However d.getButton returns null until after dialog shows. :(
This person here also encountered same issue - https://tassioauad.com/2016/06/02/dialogfragmentalertdialog-dismiss-automatically-on-click-button/
He says:
You will need to set this in the onResume() method because getButton() will return null until after the dialog has been shown! This should cause your custom action method to only be called once, and the dialog won’t be dismissed by default.
I also tried to ask on Stackoverflow, and other people have the same issue:
There was a problem hiding this comment.
@greedbell @wsong910 would you rather i make the change before accpeting PR? or would you like to find null cases and work around it?
| public void onShow(final DialogInterface dialog) | ||
| { | ||
| input.requestFocus(); | ||
| ((InputMethodManager) alertDialog.getContext().getSystemService(Context.INPUT_METHOD_SERVICE)).showSoftInput(input, 0); |
There was a problem hiding this comment.
maybe below code behave better:
InputMethodManager imm = (InputMethodManager) alertDialog.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm != null) {
input.requestFocus();
imm.showSoftInput(view, 0);
}
There was a problem hiding this comment.
Is there chance that imm is null? If it is, is there a way to wait for it to not be null? Because we always want to show keyboard.
There was a problem hiding this comment.
@wsong910 - are you waiting on me to make this change before accepting this PR? Or are you researching when imm can be null so we can force get imm in that situation to ensure keyboard shows?
README.md
Outdated
| | defaultValue | Default input value | String | | | ||
| | placeholder | | String | | | ||
| | style | `'default', 'shimo', 'cust'` | String | 'default' | | ||
| | disableFullScreenUI | When in landscape mode, don't use fullscreen | Boolean | false | |
There was a problem hiding this comment.
Typo, should be disableFullscreenUI
There was a problem hiding this comment.
Thanks very much for going through this and catching it. Fixing right now.
| public void onStart() { | ||
| super.onStart(); | ||
|
|
||
| if (!mButtonColor.isEmpty()) { |
There was a problem hiding this comment.
I just tested this and it crashes as mButtonColor is null when not specifying this prop or when passed an empty string.
In JS buttonColor: options.buttonColor || null will set buttonColor to null if not specified or if it's an empty string.
There was a problem hiding this comment.
Oh shoot i forgot to test for null. Thanks so much on this right away.
|
Added android-with-options screenshot to readme. |
README.md
Outdated
| defaultValue | Default input value | String | '' | ||
| placeholder | | String | '' | ||
| ##### colorString | ||
| Is one of the following: `'red', 'blue', 'green', 'black', 'white', 'gray', 'cyan', 'magenta', 'yellow', 'lightgray', 'darkgray', 'grey', 'lightgrey', 'darkgrey', 'aqua', 'fuchsia', 'lime', 'maroon', 'navy', 'olive', 'purple', 'silver', and 'teal'` |
There was a problem hiding this comment.
You could actually support the full color format (named, rgb, rgba, hsl, etc) available in React Native by processing the color passed to the components like this:
import processColor from 'react-native/Libraries/StyleSheet/processColor';
highlightColor: processColor(options.highlightColor),
placeholderColor: processColor(options.placeholderColor),
color: processColor(options.color),
buttonColor: processColor(options.buttonColor)Then just don't call Color.parseColor in Java but just take the Int value.
There was a problem hiding this comment.
Oh sweet! Is it possible to process color on native side? Like RCTConvert in ios?
There was a problem hiding this comment.
No, RCTConvert on iOS just transforms the int to a UIColor, so it can be conveniently used.
But Android native views can directly deal with Int.
There was a problem hiding this comment.
Update to support full color format! Super awesome!! would be awesome to learn how to do this on native side too.
|
|
||
| if (mButtonColor != null && !mButtonColor.isEmpty()) { | ||
| AlertDialog d = (AlertDialog) getDialog(); | ||
| d.getButton(AlertDialog.BUTTON_POSITIVE).setTextColor(Color.parseColor(mButtonColor)); |
There was a problem hiding this comment.
Since you now use processColor on the JS side, you need to remove all Color.parseColor and just take the Int value from the arguments.
|
Tried your latest changes @Noitidart this works great! 👍 |
|
Super cool thanks @jeanregisser! :) I also learned a bunch thanks to you! |
|
Bum, is there anything I need to do to get this accepted? |
…ighlightColor, placeholderColor, color, and disableFullScreenUI