-
Notifications
You must be signed in to change notification settings - Fork 734
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
ethanshar
merged 22 commits into
master
from
feat/change-tab-controller-center-selected-logic
Jan 21, 2021
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
ca6b157
Move TabBar to functional component
M-i-k-e-l 2377b58
Fix Fader in RTL
M-i-k-e-l 6b907ce
Merge branch 'master' into typescript/tab-controller-move-to-function…
M-i-k-e-l ecbc6e0
change tab controller center selected logic (and move it to a helper…
M-i-k-e-l 3f268b1
Fix import (cycle) + generate types
M-i-k-e-l cd65641
Change the DYNAMIC logic (did not look good when scrolling pages)
M-i-k-e-l 8aaccdd
Merge branch 'master' into feat/change-tab-controller-center-selected…
M-i-k-e-l d79af43
Revert merging wrong commit
M-i-k-e-l 462647b
FocusItemsHelper --> useFocusItemsHelper
M-i-k-e-l 6b8c9ea
Add (and use) useScrollEnabler and useScrollReached hooks
M-i-k-e-l 57d42f0
Move hooks to the hooks folder
M-i-k-e-l ae027dc
Merge branch 'master' into feat/change-tab-controller-center-selected…
M-i-k-e-l c7a677e
sideSpacing --> outerSpacing
M-i-k-e-l 7d7c8e6
Fix typo
M-i-k-e-l c09acd8
renderSelectedIndicator --> selectedIndicator
M-i-k-e-l c2bf678
Move useFocusItemsHelper
M-i-k-e-l 7e25406
Merge branch 'master' into feat/change-tab-controller-center-selected…
M-i-k-e-l 60511a6
Rename useFocusItemsHelper --> useScrollIToItem
M-i-k-e-l 9ace954
Fix typo
M-i-k-e-l c3697e0
Create useScrollTo hook
M-i-k-e-l f9f5c97
Refactor Props and ResultProps --> better names
M-i-k-e-l a7a9d82
Merge branch 'master' into feat/change-tab-controller-center-selected…
ethanshar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
import React from 'react'; | ||
import { ViewProps, ScrollViewProps } from 'react-native'; | ||
import { ForwardRefInjectedProps } from '../../commons/forwardRef'; | ||
export declare type FadedScrollViewProps = ViewProps & ScrollViewProps & { | ||
children?: React.ReactNode | React.ReactNode[]; | ||
}; | ||
declare const _default: React.ComponentClass<FadedScrollViewProps, any> | React.FunctionComponent<FadedScrollViewProps>; | ||
declare type Props = FadedScrollViewProps & ForwardRefInjectedProps; | ||
declare const _default: React.ComponentType<Props>; | ||
export default _default; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
export { default as useToggleValue } from './useToggleValue'; | ||
export { default as useDidUpdate } from './useDidUpdate'; | ||
export { default as useScrollEnabler } from './useScrollEnabler'; | ||
export { default as useScrollReached } from './useScrollReached'; | ||
export { default as useScrollToItem } from './useScrollToItem'; | ||
export { default as useScrollTo } from './useScrollTo'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { LayoutChangeEvent } from 'react-native'; | ||
export declare type ScrollEnablerProps = { | ||
/** | ||
* Whether the scroll is horizontal (default is false). | ||
*/ | ||
horizontal?: boolean; | ||
}; | ||
export declare type ScrollEnablerResultProps = { | ||
/** | ||
* onContentSizeChange callback (should be set to your onContentSizeChange). | ||
*/ | ||
onContentSizeChange: (contentWidth: number, contentHeight: number) => void; | ||
/** | ||
* onLayout callback (should be set to your onLayout). | ||
*/ | ||
onLayout: (event: LayoutChangeEvent) => void; | ||
/** | ||
* Whether the scroll should be enabled (should be set to your scrollEnabled). | ||
*/ | ||
scrollEnabled: boolean; | ||
}; | ||
declare const useScrollEnabler: (props?: ScrollEnablerProps) => ScrollEnablerResultProps; | ||
export default useScrollEnabler; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { NativeSyntheticEvent, NativeScrollEvent } from 'react-native'; | ||
export declare type ScrollEnablerProps = { | ||
/** | ||
* Whether the scroll is horizontal (default is false). | ||
*/ | ||
horizontal?: boolean; | ||
/** | ||
* Allows to be notified prior to actually reaching the start \ end of the scroll (by the threshold). | ||
* Should be a positive value. | ||
*/ | ||
threshold?: number; | ||
}; | ||
export declare type ScrollEnablerResultProps = { | ||
/** | ||
* onScroll callback (should be set to your onScroll). | ||
*/ | ||
onScroll: (event: NativeSyntheticEvent<NativeScrollEvent>) => void; | ||
/** | ||
* Is the scroll at the start (or equal\smaller than the threshold if one was given) | ||
*/ | ||
isScrollAtStart?: boolean; | ||
/** | ||
* Is the scroll at the end (or equal\greater than the threshold if one was given) | ||
*/ | ||
isScrollAtEnd?: boolean; | ||
}; | ||
declare const useScrollReached: (props?: ScrollEnablerProps) => ScrollEnablerResultProps; | ||
export default useScrollReached; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { RefObject } from 'react'; | ||
import { ScrollView, FlatList } from 'react-native'; | ||
export declare type ScrollToSupportedViews = ScrollView | FlatList; | ||
export declare type ScrollToProps<T extends ScrollToSupportedViews> = { | ||
/** | ||
* A reference to the ScrollView (or FlatList) which the items are in | ||
*/ | ||
scrollViewRef?: RefObject<T>; | ||
/** | ||
* Is the scroll view horizontal (default is true) | ||
*/ | ||
horizontal?: boolean; | ||
}; | ||
export declare type ScrollToResultProps<T extends ScrollToSupportedViews> = { | ||
/** | ||
* A reference to the ScrollView (or FlatList) which the items are in (from the props or a created one) | ||
*/ | ||
scrollViewRef: RefObject<T>; | ||
/** | ||
* scrollTo callback. | ||
* scrollToOffset - the x or y to scroll to. | ||
* animated - should the scroll be animated (default is true) | ||
*/ | ||
scrollTo: (scrollToOffset: number, animated?: boolean) => void; | ||
}; | ||
declare const useScrollTo: <T extends ScrollToSupportedViews>(props: ScrollToProps<T>) => ScrollToResultProps<T>; | ||
export default useScrollTo; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { LayoutChangeEvent } from 'react-native'; | ||
import { ScrollToProps, ScrollToSupportedViews, ScrollToResultProps } from '../useScrollTo'; | ||
export declare enum OffsetType { | ||
CENTER = "CENTER", | ||
DYNAMIC = "DYNAMIC", | ||
LEFT = "LEFT", | ||
RIGHT = "RIGHT" | ||
} | ||
export declare type ScrollToItemProps<T extends ScrollToSupportedViews> = Pick<ScrollToProps<T>, 'scrollViewRef'> & { | ||
/** | ||
* The number of items | ||
*/ | ||
itemsCount: number; | ||
/** | ||
* The selected item's index | ||
*/ | ||
selectedIndex?: number; | ||
/** | ||
* Where would the item be located (default to CENTER) | ||
*/ | ||
offsetType?: OffsetType; | ||
/** | ||
* Add a margin to the offset (default to true) | ||
* This gives a better UX | ||
* Not relevant to OffsetType.CENTER | ||
*/ | ||
addOffsetMargin?: boolean; | ||
/** | ||
* How much space (padding \ margin) is there on the left\right of the items | ||
*/ | ||
outerSpacing?: number; | ||
/** | ||
* How much space (padding \ margin) is there between each item | ||
*/ | ||
innerSpacing?: number; | ||
}; | ||
export declare type ScrollToItemResultProps<T extends ScrollToSupportedViews> = Pick<ScrollToResultProps<T>, 'scrollViewRef'> & { | ||
/** | ||
* This should be called by each ot the items' onLayout | ||
*/ | ||
onItemLayout: (event: LayoutChangeEvent, index: number) => void; | ||
/** | ||
* The items' width | ||
*/ | ||
itemsWidths: number[]; | ||
/** | ||
* Use in order to focus the item with the specified index | ||
*/ | ||
focusIndex: (index: number, animated?: boolean) => void; | ||
}; | ||
declare const useScrollToItem: <T extends ScrollToSupportedViews>(props: ScrollToItemProps<T>) => ScrollToItemResultProps<T>; | ||
export default useScrollToItem; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.