55 * Converted to Functional component. on 21/09/2021
66 */
77import React , { useCallback , useEffect , useMemo , useRef } from 'react' ;
8- import { ScrollView , View , ViewStyle , StyleProp } from 'react-native' ;
8+ import {
9+ ScrollView ,
10+ View ,
11+ ViewStyle ,
12+ StyleProp ,
13+ StyleSheet ,
14+ } from 'react-native' ;
915import Dot from './component/Dot' ;
1016import EmptyDot , { defaultEmptyDotSize } from './component/EmptyDot' ;
1117import usePrevious from 'react-use/lib/usePrevious' ;
@@ -15,6 +21,7 @@ export interface IDotContainerProps {
1521 maxPage : number ;
1622 sizeRatio ?: number ;
1723 activeDotColor : string ;
24+ inactiveDotColor ?: string ;
1825 vertical ?: boolean ;
1926}
2027
@@ -79,7 +86,7 @@ const DotContainer: React.FC<IDotContainerProps> = (props) => {
7986 scrollTo ( props . curPage ) ;
8087 } , [ prevPage , props . curPage , props . maxPage , scrollTo ] ) ;
8188
82- const { curPage, maxPage, activeDotColor } = props ;
89+ const { curPage, maxPage, activeDotColor, inactiveDotColor } = props ;
8390 const list = useMemo ( ( ) => [ ...Array ( maxPage ) . keys ( ) ] , [ maxPage ] ) ;
8491
8592 let normalizedPage = curPage ;
@@ -106,6 +113,7 @@ const DotContainer: React.FC<IDotContainerProps> = (props) => {
106113 curPage = { normalizedPage }
107114 maxPage = { maxPage }
108115 activeColor = { activeDotColor }
116+ inactiveColor = { inactiveDotColor }
109117 />
110118 ) ;
111119 } ) }
@@ -123,9 +131,7 @@ const DotContainer: React.FC<IDotContainerProps> = (props) => {
123131 >
124132 < ScrollView
125133 ref = { refScrollView }
126- contentContainerStyle = { {
127- alignItems : 'center' ,
128- } }
134+ contentContainerStyle = { styles . scrollViewContainer }
129135 bounces = { false }
130136 horizontal = { ! props . vertical }
131137 scrollEnabled = { false }
@@ -145,6 +151,7 @@ const DotContainer: React.FC<IDotContainerProps> = (props) => {
145151 curPage = { normalizedPage }
146152 maxPage = { maxPage }
147153 activeColor = { activeDotColor }
154+ inactiveColor = { inactiveDotColor }
148155 />
149156 ) ;
150157 } ) }
@@ -157,4 +164,10 @@ const DotContainer: React.FC<IDotContainerProps> = (props) => {
157164 ) ;
158165} ;
159166
167+ const styles = StyleSheet . create ( {
168+ scrollViewContainer : {
169+ alignItems : 'center' ,
170+ } ,
171+ } ) ;
172+
160173export default DotContainer ;
0 commit comments