From e4a3be1a3f8ebac00d0764c548993b61cfecdb5f Mon Sep 17 00:00:00 2001 From: Bruno Lemos Date: Tue, 27 Nov 2018 20:41:34 -0200 Subject: [PATCH] Show loading indicator --- .../src/components/cards/EmptyCards.tsx | 21 +++++++++++++------ .../src/components/cards/EventCards.tsx | 15 +++++++++---- .../components/cards/NotificationCards.tsx | 15 +++++++++---- .../src/components/common/Button.tsx | 17 +++++++++++++-- .../src/containers/EventCardsContainer.tsx | 20 +++++++++++++++--- .../containers/NotificationCardsContainer.tsx | 20 +++++++++++++++--- 6 files changed, 86 insertions(+), 22 deletions(-) diff --git a/packages/shared-components/src/components/cards/EmptyCards.tsx b/packages/shared-components/src/components/cards/EmptyCards.tsx index 43294ca8..4273b7a8 100644 --- a/packages/shared-components/src/components/cards/EmptyCards.tsx +++ b/packages/shared-components/src/components/cards/EmptyCards.tsx @@ -1,5 +1,5 @@ import React, { useContext } from 'react' -import { Text, View } from 'react-native' +import { ActivityIndicator, Text, View } from 'react-native' import { contentPadding } from '../../styles/variables' import { Button } from '../common/Button' @@ -33,11 +33,14 @@ const emoji = getRandomEmoji() export interface EmptyCardsProps { fetchNextPage: ((params?: { perPage?: number }) => void) | undefined + state: 'loading' | 'loading_first' | 'loading_more' | 'loaded' } export function EmptyCards(props: EmptyCardsProps) { const { theme } = useContext(ThemeContext) + const { fetchNextPage, state } = props + return ( - - {clearMessage} {emoji} - + {state === 'loading_first' ? ( + + ) : ( + + {clearMessage} {emoji} + + )} - {!!props.fetchNextPage && ( + {!!fetchNextPage && (