Skip to content

Add styling prop for iOS picker - #120

Merged
vonovak merged 11 commits into
react-native-datetimepicker:masterfrom
lochness42:feature/add-styling-prop-for-ios-picker
Mar 4, 2020
Merged

vonovak merged 11 commits into
react-native-datetimepicker:masterfrom
lochness42:feature/add-styling-prop-for-ios-picker

Conversation

@lochness42

@lochness42 lochness42 commented Feb 28, 2020 •

Copy link
Copy Markdown

Summary

At the moment on iOS picker has fixed height of 216px, this PR exposes a new style property which is passed down to picker itself (style property is only propagated to internal View container and picker can overflow it)
If this style is not defined, we will fall back to height of 216px so it won't break existing apps.

Test Plan

What's required for testing (prerequisites)?

What are the steps to reproduce (after prerequisites)?

Compatibility

OS Implemented
iOS ✅
Android ❌

Checklist

  • I have tested this on a device and a simulator
  • I added the documentation in README.md
  • I mentioned this change in CHANGELOG.md
  • I updated the typed files (TS and Flow)
  • I added a sample use of the API in the example project (example/App.js)

Comment thread src/datetimepicker.ios.js Resolved
@lochness42
lochness42 requested a review from luancurti March 2, 2020 08:23
Comment thread src/datetimepicker.ios.js Outdated
mode,
minuteInterval,
timeZoneOffsetInMinutes,
iOsPickerStyle = {},

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd vote for this prop to be named just style. There are several other props such as timeZoneOffsetInMinutes that only work on one platform, and we never use any ios/android suffix/prefix to distinguish those.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you suggest to use same styles on outer container and also DatePicker?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

huh I didn't know that! (it's not documented). That brings me to a question - why is RNDateTimePicker wrapped in a View? Would it make sense to remove that wrapping view?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can remove it, I've tested it and it works without the external View.
I just wonder whether there will be breaking change in case someone had a hack to get around inability to change height of the datepicker.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright added it to example to App.js and has documentation in Readme.md. I've kept it as iOS only due to the fact that you can't really style Android pickers this way.

@vonovak vonovak Mar 3, 2020 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can remove it, I've tested it and it works without the external View.

in that case I'd remove it, and if folks really need to wrap it (I don't see any necessity for that), they can do it themselves

I checked https://github.com/facebook/react-native/blame/master/Libraries/Components/DatePicker/DatePickerIOS.ios.js and from the blame, it doesn't seem like there was specific reason for adding the wrapping view

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok done

Comment thread src/types.js Resolved
Pavel Balint and others added 2 commits March 3, 2020 08:08
@lochness42
lochness42 requested a review from vonovak March 3, 2020 08:33
Comment thread test/index.test.js Resolved
@vonovak

vonovak commented Mar 4, 2020

Copy link
Copy Markdown
Member

@lochness42 I'm also wondering - just because people may try to use various styling options - what are the limitations as to what styling props people can use here? I see the motivation was to change picker size. Is it possible to change background color or border for example? Thanks!

@lochness42

Copy link
Copy Markdown
Author

@vonovak background color and border does work
Simulator Screen Shot - iPhone X - 2020-03-04 at 09 45 46
You can't style things like text color in the picker itself, but that has nothing to do with the original View styling.

@vonovak
vonovak merged commit d60bff6 into react-native-datetimepicker:master Mar 4, 2020
@vonovak

vonovak commented Mar 4, 2020

Copy link
Copy Markdown
Member

I'll release in the evening. Which reminds we need a changelog entry - would you be willing to write that @lochness42 ? Question now is, should the be a major or minor bump?

@lochness42
lochness42 deleted the feature/add-styling-prop-for-ios-picker branch March 4, 2020 09:58
@lochness42

Copy link
Copy Markdown
Author

I would say minor as it fixes bug where height couldn't be readjusted, styling should be preserved from before. So no real new behaviour apart from bug fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants