File tree Expand file tree Collapse file tree 5 files changed +62
-21
lines changed Expand file tree Collapse file tree 5 files changed +62
-21
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ import RevealHeaderOnScroll from './RevealHeaderOnScroll'
32
32
import RevealHeaderOnScrollSnap from './RevealHeaderOnScrollSnap'
33
33
import ScrollOnHeader from './ScrollOnHeader'
34
34
import ScrollableTabs from './ScrollableTabs'
35
+ import SingleTab from './SingleTab'
35
36
import Snap from './Snap'
36
37
import StartOnSpecificTab from './StartOnSpecificTab'
37
38
import UndefinedHeaderHeight from './UndefinedHeaderHeight'
@@ -61,6 +62,7 @@ const EXAMPLE_COMPONENTS: ExampleComponentType[] = [
61
62
AnimatedHeader ,
62
63
AndroidSharedPullToRefresh ,
63
64
HeaderOverscrollExample ,
65
+ SingleTab ,
64
66
]
65
67
66
68
const ExampleList : React . FC < object > = ( ) => {
Original file line number Diff line number Diff line change @@ -13,18 +13,15 @@ import { HEADER_HEIGHT } from './Header'
13
13
14
14
type Props = {
15
15
emptyContacts ?: boolean
16
- hideArticleTab ?: boolean
17
16
} & Partial < CollapsibleProps >
18
17
19
18
const Example = React . forwardRef < CollapsibleRef , Props > (
20
19
( { emptyContacts, ...props } , ref ) => {
21
20
return (
22
21
< Tabs . Container ref = { ref } headerHeight = { HEADER_HEIGHT } lazy { ...props } >
23
- { props . hideArticleTab ? (
24
- < Tabs . Tab name = "article" label = "Article" >
25
- < Article />
26
- </ Tabs . Tab >
27
- ) : null }
22
+ < Tabs . Tab name = "article" label = "Article" >
23
+ < Article />
24
+ </ Tabs . Tab >
28
25
< Tabs . Tab name = "albums" label = "Albums" >
29
26
< Albums />
30
27
</ Tabs . Tab >
Original file line number Diff line number Diff line change @@ -13,18 +13,15 @@ import { HEADER_HEIGHT } from './Header'
13
13
14
14
type Props = {
15
15
emptyContacts ?: boolean
16
- hideArticleTab ?: boolean
17
16
} & Partial < CollapsibleProps >
18
17
19
18
const Example = React . forwardRef < CollapsibleRef , Props > (
20
19
( { emptyContacts, ...props } , ref ) => {
21
20
return (
22
21
< Tabs . Container ref = { ref } headerHeight = { HEADER_HEIGHT } lazy { ...props } >
23
- { props . hideArticleTab ? (
24
- < Tabs . Tab name = "article" label = "Article" >
25
- < Article />
26
- </ Tabs . Tab >
27
- ) : null }
22
+ < Tabs . Tab name = "article" label = "Article" >
23
+ < Article />
24
+ </ Tabs . Tab >
28
25
< Tabs . Tab name = "albums" label = "Albums" >
29
26
< Albums />
30
27
</ Tabs . Tab >
Original file line number Diff line number Diff line change
1
+ import React from 'react'
2
+ import { StyleSheet } from 'react-native'
3
+ import { Tabs , MaterialTabBar } from 'react-native-collapsible-tab-view'
4
+
5
+ import { ArticleContent } from './Shared/Article'
6
+ import { HEADER_HEIGHT , buildHeader } from './Shared/Header'
7
+ import { ExampleComponentType } from './types'
8
+
9
+ const title = 'Single Tab'
10
+
11
+ const Header = buildHeader ( title )
12
+
13
+ const SingleTabExample : ExampleComponentType = ( ) => {
14
+ return (
15
+ < Tabs . Container
16
+ renderHeader = { Header }
17
+ headerHeight = { HEADER_HEIGHT }
18
+ renderTabBar = { ( props ) => (
19
+ < MaterialTabBar
20
+ { ...props }
21
+ scrollEnabled
22
+ contentContainerStyle = { styles . padding }
23
+ />
24
+ ) }
25
+ >
26
+ < Tabs . Tab name = "article" label = "Article" >
27
+ < Tabs . ScrollView >
28
+ < ArticleContent />
29
+ </ Tabs . ScrollView >
30
+ </ Tabs . Tab >
31
+ </ Tabs . Container >
32
+ )
33
+ }
34
+
35
+ SingleTabExample . title = title
36
+
37
+ export default SingleTabExample
38
+
39
+ const styles = StyleSheet . create ( {
40
+ padding : { paddingHorizontal : 30 } ,
41
+ } )
Original file line number Diff line number Diff line change @@ -19,19 +19,23 @@ const Indicator: React.FC<IndicatorProps> = ({
19
19
const opacity = useSharedValue ( fadeIn ? 0 : 1 )
20
20
21
21
const stylez = useAnimatedStyle ( ( ) => {
22
- const transform =
23
- itemsLayout . length > 1
24
- ? [
25
- {
26
- translateX : interpolate (
22
+ const firstItemX = itemsLayout [ 0 ] ?. x ?? 0
23
+
24
+ const transform = [
25
+ {
26
+ translateX :
27
+ itemsLayout . length > 1
28
+ ? interpolate (
27
29
indexDecimal . value ,
28
30
itemsLayout . map ( ( _ , i ) => i ) ,
29
31
// when in RTL mode, the X value should be inverted
30
32
itemsLayout . map ( ( v ) => ( isRTL ? - 1 * v . x : v . x ) )
31
- ) ,
32
- } ,
33
- ]
34
- : undefined
33
+ )
34
+ : isRTL
35
+ ? - 1 * firstItemX
36
+ : firstItemX ,
37
+ } ,
38
+ ]
35
39
36
40
const width =
37
41
itemsLayout . length > 1
You can’t perform that action at this time.
0 commit comments