Skip to content

Commit ecf8da4

Browse files
authored
Merge pull request #373 from wavect/OF-531-App-loading-indicator-on-open-of-encounter-tab
OF-531 - Fixed refresh indicator during initial load
2 parents 40515a8 + 0a27b13 commit ecf8da4

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

mobile/components/OEncounterList/OEncounterList.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import * as Sentry from "@sentry/react-native";
1414
import * as React from "react";
1515
import { useCallback, useEffect, useState } from "react";
1616
import {
17+
ActivityIndicator,
1718
RefreshControl,
1819
ScrollView,
1920
StyleSheet,
@@ -33,7 +34,7 @@ export const OEncounterList = (props: IOEncounterListProps) => {
3334
const navigation = useNavigation();
3435
const { state: encounterState, dispatch } = useEncountersContext();
3536
const { state: userState } = useUserContext();
36-
const [refreshing, setRefreshing] = useState(false);
37+
const [refreshing, setRefreshing] = useState(true);
3738

3839
const fetchEncounters = useCallback(async () => {
3940
try {
@@ -143,7 +144,13 @@ export const OEncounterList = (props: IOEncounterListProps) => {
143144
styles.emptyListContainer
144145
}
145146
>
146-
{getEncounterList()}
147+
{refreshing && encounterState.encounters.length === 0 ? (
148+
<View style={styles.loadingContainer}>
149+
<ActivityIndicator size="large" color={Color.gray} />
150+
</View>
151+
) : (
152+
getEncounterList()
153+
)}
147154
</ScrollView>
148155
);
149156
};
@@ -180,4 +187,9 @@ const styles = StyleSheet.create({
180187
height: "100%",
181188
minHeight: 400,
182189
},
190+
loadingContainer: {
191+
flex: 1,
192+
justifyContent: "center",
193+
alignItems: "center",
194+
},
183195
});

0 commit comments

Comments
 (0)