react-native-picker / picker

Picker is a cross-platform UI component for selecting an item from a list of options.
MIT License
1.49k stars 280 forks source link

How to change the ellipsize mode on iOS ? #393

Open zabojad opened 2 years ago

zabojad commented 2 years ago

I'd like to change the ellipsize mode to "clip" instead of "tail" on iOS, is that possible?

zabojad commented 2 years ago

mmm, that would be easily feasible by adding a ellipsizeMode prop on the Picker component and set it there:

label.numberOfLines = _numberOfLines;
label.lineBreakMode = NSLineBreakByClipping; // here, or any value exposed to js

label.leftInset = 20.0;
label.rightInset = 20.0;

return view;
zabojad commented 2 years ago

In my case, I want to set numberOfLines to 0. Except some js code from this lib is preventing it:

PickerIOS.ios.js#L99

    let numberOfLines = Math.round(this.props.numberOfLines ?? 1);
    if (numberOfLines < 1) {
      numberOfLines = 1;
    }

This is wrong, we should allow a value of 0 to deactivate text truncating. I'll issue a PR for that.

oleksiy-nesterov commented 1 year ago

The same problem, switched to the last version, and now 2022 looks like 20... we need a way to disable ellipsize if it needed