Skip to content

WheelPicker - generic value #2959

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

Merged
merged 15 commits into from
Apr 3, 2024
Merged

WheelPicker - generic value #2959

merged 15 commits into from
Apr 3, 2024

Conversation

Inbal-Tish
Copy link
Collaborator

@Inbal-Tish Inbal-Tish commented Feb 20, 2024

Description

WheelPicker - generic value

Changelog

WheelPicker - generic value

Additional info

ticket 1844

@Inbal-Tish Inbal-Tish changed the title Infra/wheel picker generic WheelPicker - generic value Feb 20, 2024
@Inbal-Tish
Copy link
Collaborator Author

@M-i-k-e-l Ping

Copy link
Collaborator

@M-i-k-e-l M-i-k-e-l left a comment

Choose a reason for hiding this comment

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

Nice work, mostly recurring comments, I did not want to miss them if we make changes

import {WheelPickerAlign} from './types';

const AnimatedTouchableOpacity = Animated.createAnimatedComponent(TouchableOpacity);
const AnimatedText = Animated.createAnimatedComponent(Text);

export interface ItemProps {
export interface ItemProps<T> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since this is exported as well we should add a default value or users (including private) will get broken: <T = string | number>

TBH I'd really like it if the WheelPicker could get the default from here, but I am not sure how... Maybe we should add a type for it, type DefaultWheelPickerItemType = string | number but it feels clunky... WDYT?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm not sure how to pass the type from the Item either, I'll take a look.
Regarding the DefaultWheelPickerItemType we can use the existing ItemValueTypes, no?

Copy link
Collaborator

@M-i-k-e-l M-i-k-e-l Mar 27, 2024

Choose a reason for hiding this comment

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

No, because we should not remove the ItemProps yet; and also I feel like it should have default in it

if (_.isString(initialValue) || _.isNumber(initialValue)) {
return _.findIndex(items, {value: initialValue});
if (_.isObject(initialValue)) {
LogService.warn('UILib WheelPicker will stop supporting initialValue prop type as an object (ItemProps). Please pass string or number only');
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm assuming this is what this refers to: export type ItemValueTypes = /* ItemProps | */number | string;
If we're only starting this migration we should probably only remove the type in the next major when we remove it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We still support it so functionality won't break but they will get TS error that should force them to migrate or add ignore. WDYT?

Copy link
Collaborator

Choose a reason for hiding this comment

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

We don't usually do that IMO, we don't cause TS errors if we can avoid it

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's not related to the ItemValueTypes as I don't use it anymore. You mean I should defined initialValue as T & WheelPickerItemProps?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I remane it WheelPickerItemValue and defined it in types so I can export it from WheelPicker. I also exported outside

export const SectionsWheelPickerDriver = (props: ComponentProps) => {
const driver = useComponentDriver<SectionsWheelPickerProps>(props);
const sections = driver.getProps().children as SectionsWheelPickerProps;
export const SectionsWheelPickerDriver = <T extends string | number = number>(props: ComponentProps) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

We have this type here as well
Don't think we need the default = number

Copy link
Collaborator

Choose a reason for hiding this comment

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

Still have the default

…nto infra/WheelPicker_generic

# Conflicts:
#	src/components/WheelPicker/WheelPicker.driver.tsx
#	src/components/sectionsWheelPicker/SectionsWheelPicker.driver.tsx
@Inbal-Tish Inbal-Tish requested a review from M-i-k-e-l April 3, 2024 10:53
@Inbal-Tish Inbal-Tish merged commit d6f49e0 into master Apr 3, 2024
@Inbal-Tish Inbal-Tish deleted the infra/WheelPicker_generic branch April 3, 2024 11:22
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.

2 participants