diff --git a/App.tsx b/App.tsx index 832b2cdbb114c770b89f412d1059fe853b2c5c95..9f385c33277ef922d536097822694cb0667e81e8 100644 --- a/App.tsx +++ b/App.tsx @@ -1,9 +1,9 @@ import React from "react"; import {ApolloProvider} from "@apollo/client"; import {ApolloClient, InMemoryCache, NormalizedCacheObject} from "@apollo/client"; - -import {StyleProvider} from "native-base"; import Menu from "./components/Menu/Menu"; +import {LogBox} from "react-native"; +LogBox.ignoreAllLogs(); const client: ApolloClient<NormalizedCacheObject> = new ApolloClient({ uri: "http://it2810-23.idi.ntnu.no:3000/", diff --git a/components/MovieContainer/MovieContainer.tsx b/components/MovieContainer/MovieContainer.tsx index 8cc121015a9184eb5f943d4c34db472e5ab8e0b7..c2a91bcbfab530577ac505e7e803a6730f121147 100644 --- a/components/MovieContainer/MovieContainer.tsx +++ b/components/MovieContainer/MovieContainer.tsx @@ -14,8 +14,21 @@ const styles = StyleSheet.create({ alignItems: "center" }, loader: { - backgroundColor: "#101010", - margin: 15 + backgroundColor: "#101010" + }, + feedback: { + height: 60, + marginTop: 20 + }, + danger: { + color: "#d9534f", + marginLeft: "auto", + marginRight: "auto" + }, + endText: { + color: "#d4a600", + marginLeft: "auto", + marginRight: "auto" } }); @@ -171,15 +184,37 @@ function MovieContainer() { return ( <Content style={styles.bg} contentContainerStyle={{flex: 1}}> - <FlatList - data={movies} - renderItem={renderItem} - extraData={currentPage < pageCount} - onEndReached={nextPage} - numColumns={2} - contentContainerStyle={styles.container} - /> - {queryLoading && <ActivityIndicator size="large" color="#d4a600" style={styles.loader} />} + {movies && movies.length !== 0 ? ( + // Movies + <FlatList + data={movies} + renderItem={renderItem} + extraData={currentPage < pageCount} + onEndReached={nextPage} + numColumns={2} + ListFooterComponent={ + <View style={styles.feedback}> + {queryLoading && <ActivityIndicator size="large" color="#d4a600" style={styles.loader} />} + {!queryLoading && pageLoaded && pageCount !== 0 && movies.length > 0 && ( + <Text style={styles.endText}> + {movies.length} {movies.length === 1 ? "RESULT" : "RESULTS"} + </Text> + )} + </View> + } + contentContainerStyle={styles.container} + /> + ) : moviesData && moviesData.movies.movies.length === 0 ? ( + // No results + <View style={styles.feedback}> + <Text style={styles.danger}>NO RESULTS</Text> + </View> + ) : ( + // Loading + <View style={styles.feedback}> + {queryLoading && <ActivityIndicator size="large" color="#d4a600" style={styles.loader} />} + </View> + )} </Content> ); }