diff --git a/App.tsx b/App.tsx index 015afc5..630c45b 100644 --- a/App.tsx +++ b/App.tsx @@ -9,14 +9,14 @@ */ import React, { Component } from "react"; -import { StyleSheet, SafeAreaView } from "react-native"; +import { StyleSheet, SafeAreaView, Text } from "react-native"; import { SearchBox, InfiniteHits } from "./src/components"; import { ALGOLIA_APP_ID, ALGOLIA_INDEX_NAME, ALGOLIA_SEARCH_KEY, } from "react-native-dotenv"; -import { InstantSearch } from "react-instantsearch-native"; +import { InstantSearch, connectStats } from "react-instantsearch-native"; interface Props {} export class App extends Component { @@ -29,6 +29,7 @@ export class App extends Component { indexName={ALGOLIA_INDEX_NAME} > + @@ -36,10 +37,15 @@ export class App extends Component { } } +const ConnectedStats = connectStats(({ nbHits }) => ( + + {nbHits.toLocaleString()} wine matching ! + +)); + const styles = StyleSheet.create({ container: { flex: 1, - alignItems: "center", justifyContent: "flex-start", backgroundColor: "white", }, diff --git a/src/components/InfiniteHits.tsx b/src/components/InfiniteHits.tsx index a53e02b..367680a 100644 --- a/src/components/InfiniteHits.tsx +++ b/src/components/InfiniteHits.tsx @@ -1,6 +1,5 @@ import React from "react"; import { StyleSheet, Text, View, FlatList } from "react-native"; -import { Hit } from "../interfaces/algolia"; import { connectInfiniteHits } from "react-instantsearch-native"; interface Props { diff --git a/src/components/SearchBox.tsx b/src/components/SearchBox.tsx index 8170c99..baf7816 100644 --- a/src/components/SearchBox.tsx +++ b/src/components/SearchBox.tsx @@ -1,5 +1,5 @@ import React from "react"; -import { TextInput, StyleSheet, View } from "react-native"; +import { TextInput, StyleSheet } from "react-native"; import { connectSearchBox } from "react-instantsearch/connectors"; interface Props { @@ -11,19 +11,17 @@ export const SearchBoxComponent: React.FC = ({ onChangeText, value, }) => ( - - - + ); export const SearchBox = connectSearchBox(({ refine, currentRefinement }) => { @@ -42,7 +40,4 @@ const styles = StyleSheet.create({ color: "#6E6E6E", fontSize: 14, }, - searchTextContainer: { - alignSelf: "stretch", - }, }); diff --git a/src/interfaces/algolia.ts b/src/interfaces/Hit.d.ts similarity index 92% rename from src/interfaces/algolia.ts rename to src/interfaces/Hit.d.ts index 068dc20..d516239 100644 --- a/src/interfaces/algolia.ts +++ b/src/interfaces/Hit.d.ts @@ -1,4 +1,4 @@ -export interface Hit { +interface Hit { points: number; title: string; description: string;