-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: use UIDatePickerStyle value for dimension measurements #1
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,8 +14,7 @@ import {sharedPropsValidation, toMilliseconds} from './utils'; | |
import {IOS_DISPLAY, ANDROID_MODE, EVENT_TYPE_SET} from './constants'; | ||
import invariant from 'invariant'; | ||
import * as React from 'react'; | ||
import {getPickerHeightStyle} from './layoutUtilsIOS'; | ||
import {Platform, StyleSheet} from 'react-native'; | ||
import {Platform} from 'react-native'; | ||
|
||
import type { | ||
NativeEventIOS, | ||
|
@@ -61,7 +60,6 @@ export default function Picker({ | |
}: IOSNativeProps): React.Node { | ||
sharedPropsValidation({value}); | ||
|
||
const [heightStyle, setHeightStyle] = React.useState(undefined); | ||
const _picker: NativeRef = React.useRef(null); | ||
const display = getDisplaySafe(providedDisplay); | ||
|
||
|
@@ -80,18 +78,6 @@ export default function Picker({ | |
[onChange, value], | ||
); | ||
|
||
React.useEffect( | ||
function ensureCorrectHeight() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the old architecture, we definitely don't need this, good catch 👍 However, I have not tested my PR with the New Architecture PR. I think the shadow view implementation I've done is only for the old architecture given the rendering on the New Architecture is done in C++. But I am not 100 % sure. @alfonsocj, would you be able to check if this library still works on the New Architecture if you'd merge the changes from here? |
||
const height = getPickerHeightStyle(display, mode); | ||
if (height instanceof Promise) { | ||
height.then(setHeightStyle); | ||
} else { | ||
setHeightStyle(height); | ||
} | ||
}, | ||
[display, mode], | ||
); | ||
|
||
const _onChange = (event: NativeEventIOS) => { | ||
const timestamp = event.nativeEvent.timestamp; | ||
// $FlowFixMe Cannot assign object literal to `unifiedEvent` because number [1] is incompatible with undefined [2] in property `nativeEvent.timestamp`. | ||
|
@@ -104,11 +90,6 @@ export default function Picker({ | |
|
||
invariant(value, 'A date or time should be specified as `value`.'); | ||
|
||
if (!heightStyle) { | ||
// wait for height to be available in state | ||
return null; | ||
} | ||
|
||
const dates: DatePickerOptions = {value, maximumDate, minimumDate}; | ||
toMilliseconds(dates, 'value', 'minimumDate', 'maximumDate'); | ||
|
||
|
@@ -117,7 +98,7 @@ export default function Picker({ | |
<RNDateTimePicker | ||
testID={testID} | ||
ref={_picker} | ||
style={StyleSheet.compose(heightStyle, style)} | ||
style={style} | ||
date={dates.value} | ||
locale={locale !== null && locale !== '' ? locale : undefined} | ||
maximumDate={dates.maximumDate} | ||
|
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is perfect 👌 I have not realized we can remove this logic.