@@ -2,29 +2,31 @@ import * as React from 'react';
22import { View } from 'react-native' ;
33import { animated , useTrail } from 'react-spring/native.cjs' ;
44
5+ import { useForceUpdate } from '../../hooks' ;
6+ import { useTheme } from '../../theme' ;
7+
58const AnimatedView = animated ( View ) ;
69
7- export interface LoadingDotsProps {
10+ export interface DotsProps {
811 color ?: string ;
912 size ?: number ;
1013}
1114
12- const items = [ '1' , '2' , '3' ] ;
13-
14- export const LoadingDots = ( props : LoadingDotsProps ) => {
15- const { size = 10 , color = '#aaa' } = props ;
15+ export const Dots = ( props : DotsProps ) => {
16+ const theme = useTheme ( ) ;
17+ const { size = 10 , color = theme . colors . text . primary } = props ;
18+ const forceUpdate = useForceUpdate ( ) ;
1619
17- const trail = useTrail ( items . length , {
20+ const trail = useTrail ( 3 , {
1821 config : { duration : 800 } ,
1922 from : { opacity : 0 } ,
23+ onRest : forceUpdate ,
2024 reset : true ,
2125 to : async next => {
22- while ( true ) {
23- // tslint:disable-next-line
24- await next ( { opacity : 1 } ) ;
25- // tslint:disable-next-line
26- await next ( { opacity : 0 } ) ;
27- }
26+ // tslint:disable-next-line
27+ await next ( { opacity : 1 } ) ;
28+ // tslint:disable-next-line
29+ await next ( { opacity : 0 } ) ;
2830 } ,
2931 } ) ;
3032
@@ -38,7 +40,7 @@ export const LoadingDots = (props: LoadingDotsProps) => {
3840 >
3941 { trail . map ( ( style , index ) => (
4042 < AnimatedView
41- key = { items [ index ] }
43+ key = { index }
4244 // @ts -ignore
4345 style = { {
4446 backgroundColor : color ,
0 commit comments