Skip to content

Feat/change tab controller center selected logic #1103

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 22 commits into from
Jan 21, 2021

Conversation

M-i-k-e-l
Copy link
Collaborator

Depends on

#1098

Description

Change TabController center selected logic (and move all the focusItems logic to a helper class)

Changelog

Change TabController center selected logic (and move all the focusItems logic to a helper class)

…-component-2

* master:
  export Button enums
  fix typings
  Fix lint issues
  Fix Switch color based props to use ColorValue typing
  Fix manual placeholderTextColor typing for ChipsInput
  Fix manualy typing of ChipsInput for selectionColor prop
  fix @types/react-native version to 0.63.4
  Fix rn63 typings (#1100)
  Revert "fix for tabbar types for scrollbar"
  fix for tabbar types for scrollbar
  ScrollBar - TS migration (#1078)
  TabBar refactor (#1076)
  Update reanimated and gesture-handler to their latest version
  cleanup Cards example screen
  upgraded expo demo app to expo v40 (#1096)
  Update RNN version

# Conflicts:
#	src/components/tabController/TabBar.tsx
@ethanshar
Copy link
Collaborator

@M-i-k-e-l
I think there are conflicts because of the changes we did in #1098

@M-i-k-e-l
Copy link
Collaborator Author

Reminder:

This is a little out of scope.
But what's nice about hooks (as long you work with function components) is that they are great alternative for HOC.
For example in this case, you can create hooks for useScrollReached and useScrollEnabler that do calculation and return the relevant info which you can pass on to your ScrollView.
Maybe it's a good opportunity to create an equivalent hooks for these HOCs

…-logic

* master:
  Fix lint error
  cleanup eslintrc file
  Infra/useDidUpdate (#1112)
  Support UI presets for Incubator.TextField and set a 'default' preset (#1111)
  Fix lint issues
  fix radioButton lint errors and generate types
  Fix/imageSource deprecation (#1115)
  Typescript/tab controller move to function component (#1098)
  Feat/radio button customize styling (#1092)
  bug fixes for TabBar refactor (#1106)
  Update ios target to 11
  prettify file
  Fix icon size in badges example screen (#1104)
  icon prop - fix type to be both number and object. (#1086)
  enable eslint on both ts and js files (#1101)
  fix eslint (#1107)

# Conflicts:
#	demo/src/screens/componentScreens/FaderScreen.tsx
#	src/components/fader/index.tsx
#	src/components/tabController/FadedScrollView.tsx
#	src/components/tabController/TabBar.tsx
@M-i-k-e-l
Copy link
Collaborator Author

Reminder:

This is a little out of scope.
But what's nice about hooks (as long you work with function components) is that they are great alternative for HOC.
For example in this case, you can create hooks for useScrollReached and useScrollEnabler that do calculation and return the relevant info which you can pass on to your ScrollView.
Maybe it's a good opportunity to create an equivalent hooks for these HOCs

Done

@M-i-k-e-l
Copy link
Collaborator Author

@M-i-k-e-l
I think there are conflicts because of the changes we did in #1098

Fixed and added the new hooks

Copy link
Collaborator

@ethanshar ethanshar left a comment

Choose a reason for hiding this comment

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

Looks great. Good job!
I wrote a few comments..

@@ -0,0 +1,171 @@
import _ from 'lodash';
Copy link
Collaborator

Choose a reason for hiding this comment

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

Few comments on this..

  • Is this hook really a common one or mainly for TabController purpose?
    I assume you want to use it in FilterChips as well, in that case, consider moving it to Hooks folder.
  • The name of the hook needs a little work in my opinion ..Helper doesn't really say much, clearly it's a hook that helps doing something (: Let's try to find a better name.

Copy link
Collaborator Author

@M-i-k-e-l M-i-k-e-l Jan 6, 2021

Choose a reason for hiding this comment

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

Moved to hooks.

useFocusItem
useScrollToItem

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think useScrollIToItem hints better what the hook does..

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

},
[setSnapBreakpoints]);

const scroll = (scrollTo: number, animated: boolean) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this in order to support ScrollView, FlatList and SectionList?
I think I have a similar code somewhere.. (:

Maybe we should add a specific hook for that (:
Anyway, not for this scope - just FYI

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No time like the present.
I'm just not sure it's a hook, maybe a helper function, since it doesn't need useState, useRef etc, WDYT?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Technically you can have this hook to create the scrollView ref and provide (and also use it internally for the scrollTo)
something like that..

const [scrollRef, scrollTo] = useScrollTo()

and maybe if someone already has the ref we can support passing it

const myOwnRef = useRef();
const [scrollRef, scrollTo] = useScrollTo(myOwnRef)

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.

Done

M-i-k-e-l and others added 6 commits January 6, 2021 12:10
…-logic

* master:
  Add missing functionality for Incubator.TextField (#1121)
  Update all app icons sizes for iOS project
  Adding 'defaultSource' for image source in case of an error (#1116)
  DateTimePicker - adding 'headerStyle' prop to adjust iOS dialog header style (#1117)
  add prepush script
  Infra/use did update (#1119)
  SettingsScreen - rename to UNSAFE (#1118)
  Create a middleware TextField migrator to migrate people to the new TextField implementation (#1113)
  Fix issue with missing selected indicator in Picker items (#1065)
  Fix issue for Android on rn63 - when passing null as tintColor to an image, the image is not displayed (#1055)
  Fix issue #1052 - PickerItem ignore renderItem prop (#1054)
  Dialog - RN63 broke Modal's onDismiss method, this fixes our API (#1026)
  pass containerStyle to checkbox when there's no label
  render checkbox container only if there's label (#1039)
Co-authored-by: Ethan Sharabi <[email protected]>
@M-i-k-e-l M-i-k-e-l requested a review from ethanshar January 6, 2021 11:20
M-i-k-e-l and others added 6 commits January 18, 2021 12:27
…-logic

* master:
  update uilib-docs to v1.0.6
  Read site metadata from gatsby-config gile
  Remove animatable from FloatingButton component (#1134)
  Stop using AnimatableManager in Hint (#1125)
  Change setTimeout's time from 50 to 100
  Update generated types
  push expo stuff
  Update wiki links
  Fix/dialog swiping does not trigger on dialog dismissed (#1093)
  remove github token
  Create colors.md
  CardsScreen - fix backgrounds and remove obsolete examples (#1124)
  trigger build
@ethanshar ethanshar merged commit 1ce4ff3 into master Jan 21, 2021
@ethanshar ethanshar deleted the feat/change-tab-controller-center-selected-logic branch July 26, 2021 09:08
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