-
Notifications
You must be signed in to change notification settings - Fork 734
Typescript/tab controller move to function component #1098
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 7 commits into
master
from
typescript/tab-controller-move-to-function-component-2
Jan 3, 2021
Merged
Changes from all commits
Commits
Show all changes
7 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 0bf3cc7
Fader - add START and END (deprecate LEFT and RIGHT)
M-i-k-e-l ccad848
Update src/components/tabController/TabBar.tsx
M-i-k-e-l aab1d2e
Rename getSnapBreakpoints to snapBreakpoints
M-i-k-e-l 4eff390
Remove _.memoize
M-i-k-e-l 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import React from 'react'; | ||
import { ViewProps, ScrollViewProps } from 'react-native'; | ||
export declare type FadedScrollViewProps = ViewProps & ScrollViewProps & { | ||
children?: React.ReactNode | React.ReactNode[]; | ||
}; | ||
declare const _default: React.ComponentClass<FadedScrollViewProps, any> | React.FunctionComponent<FadedScrollViewProps>; | ||
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 |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import React, {useCallback} from 'react'; | ||
import {ViewProps, ScrollView, ScrollViewProps, NativeSyntheticEvent, NativeScrollEvent} from 'react-native'; | ||
import Fader from '../fader'; | ||
import withScrollEnabler, {WithScrollEnablerProps} from '../../commons/withScrollEnabler'; | ||
import withScrollReached, {WithScrollReachedProps} from '../../commons/withScrollReached'; | ||
import forwardRef, {ForwardRefInjectedProps} from '../../commons/forwardRef'; | ||
|
||
export type FadedScrollViewProps = ViewProps & | ||
ScrollViewProps & { | ||
children?: React.ReactNode | React.ReactNode[]; | ||
}; | ||
|
||
type ScrollReachedProps = FadedScrollViewProps & WithScrollReachedProps; | ||
type ScrollEnabledProps = ScrollReachedProps & WithScrollEnablerProps; | ||
type Props = ScrollEnabledProps & ForwardRefInjectedProps; | ||
|
||
const FADER_SIZE = 76; | ||
|
||
const FadedScrollView = (props: Props) => { | ||
const {scrollEnablerProps, scrollReachedProps, children, onScroll: propsOnScroll, ...other} = props; | ||
const showStart = scrollEnablerProps.scrollEnabled && !scrollReachedProps.isScrollAtStart; | ||
const showEnd = scrollEnablerProps.scrollEnabled && !scrollReachedProps.isScrollAtEnd; | ||
|
||
const onScroll = useCallback((event: NativeSyntheticEvent<NativeScrollEvent>) => { | ||
scrollReachedProps.onScroll(event); | ||
propsOnScroll?.(event); | ||
}, | ||
[scrollReachedProps.onScroll, propsOnScroll]); | ||
|
||
if (children) { | ||
return ( | ||
<> | ||
<ScrollView | ||
horizontal | ||
showsHorizontalScrollIndicator={false} | ||
scrollEventThrottle={16} | ||
decelerationRate={'fast'} | ||
{...other} | ||
scrollEnabled={scrollEnablerProps.scrollEnabled} | ||
onContentSizeChange={scrollEnablerProps.onContentSizeChange} | ||
onLayout={scrollEnablerProps.onLayout} | ||
onScroll={onScroll} | ||
ref={props.forwardedRef} | ||
> | ||
{children} | ||
</ScrollView> | ||
<Fader visible={showStart} position={Fader.position.START} size={FADER_SIZE}/> | ||
<Fader visible={showEnd} position={Fader.position.END} size={FADER_SIZE}/> | ||
</> | ||
); | ||
} | ||
|
||
return null; | ||
}; | ||
|
||
// TODO: fix withScrollEnabler props (add <>) | ||
export default withScrollReached<FadedScrollViewProps>(withScrollEnabler(forwardRef<Props>(FadedScrollView)), { | ||
horizontal: true, | ||
threshold: 50 | ||
}); |
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.