This repository was archived by the owner on Sep 9, 2024. It is now read-only.
feat: add better typing for items and onValueChange#55
Open
jekel1818 wants to merge 1 commit intotalut:masterfrom
Open
feat: add better typing for items and onValueChange#55jekel1818 wants to merge 1 commit intotalut:masterfrom
items and onValueChange#55jekel1818 wants to merge 1 commit intotalut:masterfrom
Conversation
jekel1818
commented
Mar 15, 2023
| * @param value | ||
| */ | ||
| onValueChange: (value: any) => void | ||
| onValueChange: (value: string) => void |
Author
There was a problem hiding this comment.
Looking at the android code, I think the only possible value is a string
final String finalValue = value;
...
callback.invoke(finalValue);
jekel1818
commented
Mar 15, 2023
| hide: () => void, | ||
| } | ||
|
|
||
| export type Item = number | string | { label: string; value: number | string } |
Author
There was a problem hiding this comment.
Looking at the android code, I think items could have a more specific type than any
if (mDataset.getType(position) == ReadableType.Map) {
if (mDataset.getMap(position).getType("value") != ReadableType.Null) {
if (mDataset.getMap(position).getType("value") == ReadableType.String) {
value = mDataset.getMap(position).getString("value");
} else {
double number = mDataset.getMap(position).getDouble("value");
if (number == Math.rint(number)) {
value = String.valueOf((int) number);
} else {
value = String.valueOf(number);
}
}
if (mDataset.getMap(position).getType("label") == ReadableType.String) {
text = mDataset.getMap(position).getString("label");
} else {
double number = mDataset.getMap(position).getDouble("label");
if (number == Math.rint(number)) {
text = String.valueOf((int) number);
} else {
text = String.valueOf(number);
}
}
}
} else if (mDataset.getType(position) == ReadableType.String) {
text = mDataset.getString(position);
value = mDataset.getString(position);
} else if (mDataset.getType(position) == ReadableType.Number) {
double number = mDataset.getDouble(position);
if (number == Math.rint(number)) {
text = String.valueOf((int) number);
value = String.valueOf((int) number);
} else {
text = String.valueOf(number);
value = String.valueOf(number);
}
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.