Skip to content

Commit

Permalink
feat: Added content description prop to android items. (#482)
Browse files Browse the repository at this point in the history
  • Loading branch information
jesuscc1993 authored Jun 18, 2023
1 parent acf2375 commit 93ba0c4
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,15 @@ If set to false, the specific item will be disabled, i.e. the user will not be a
| boolean | no | Android |


### `contentDescription`

Sets the content description to the Picker Item

| Type | Required | Platform |
| ------ | -------- | -------- |
| string | No | Android |


### PickerIOS
### Props

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,10 @@ private View getView(int position, View convertView, ViewGroup parent, boolean i
textView.setTextColor(item.getInt("color"));
}

if (item.hasKey("contentDescription") && !item.isNull("contentDescription")) {
textView.setContentDescription(item.getString("contentDescription"));
}

if (item.hasKey("fontFamily") && !item.isNull("fontFamily")) {
Typeface face = Typeface.create(item.getString("fontFamily"), Typeface.NORMAL);
textView.setTypeface(face);
Expand Down
3 changes: 2 additions & 1 deletion js/PickerAndroid.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,13 @@ function PickerAndroid(props: PickerAndroidProps, ref: PickerRef): React.Node {

const {enabled = true} = child.props;

const {color, label, style = {}} = child.props;
const {color, contentDescription, label, style = {}} = child.props;

const processedColor = processColor(color);

return {
color: color == null ? null : processedColor,
contentDescription,
label,
enabled,
style: {
Expand Down
1 change: 1 addition & 0 deletions js/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export type PickerItem = $ReadOnly<{|
label: string,
value: ?(number | string),
color?: ?number,
contentDescription?: ?string,
fontFamily: ?string,
/**
* Style to apply to individual item labels.
Expand Down

0 comments on commit 93ba0c4

Please sign in to comment.