Skip to content

Commit

Permalink
Merge pull request #1 from ajubin/first-step
Browse files Browse the repository at this point in the history
remove useless style
  • Loading branch information
ajubin committed May 20, 2019
2 parents 56066ae + 30c6db6 commit ba7ec47
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
12 changes: 9 additions & 3 deletions App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<Props> {
Expand All @@ -29,17 +29,23 @@ export class App extends Component<Props> {
indexName={ALGOLIA_INDEX_NAME}
>
<SearchBox />
<ConnectedStats />
<InfiniteHits />
</InstantSearch>
</SafeAreaView>
);
}
}

const ConnectedStats = connectStats(({ nbHits }) => (
<Text style={{ paddingLeft: 16 }}>
{nbHits.toLocaleString()} wine matching !
</Text>
));

const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: "center",
justifyContent: "flex-start",
backgroundColor: "white",
},
Expand Down
1 change: 0 additions & 1 deletion src/components/InfiniteHits.tsx
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
29 changes: 12 additions & 17 deletions src/components/SearchBox.tsx
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -11,19 +11,17 @@ export const SearchBoxComponent: React.FC<Props> = ({
onChangeText,
value,
}) => (
<View style={styles.searchTextContainer}>
<TextInput
onChangeText={onChangeText}
value={value}
style={styles.textBox}
placeholder="fruity red and spicy"
placeholderTextColor="#BBBBBB"
clearButtonMode="always"
spellCheck={true}
autoCorrect={true}
autoFocus={true}
/>
</View>
<TextInput
onChangeText={onChangeText}
value={value}
style={styles.textBox}
placeholder="fruity red and spicy"
placeholderTextColor="#BBBBBB"
clearButtonMode="always"
spellCheck={true}
autoCorrect={true}
autoFocus={true}
/>
);

export const SearchBox = connectSearchBox(({ refine, currentRefinement }) => {
Expand All @@ -42,7 +40,4 @@ const styles = StyleSheet.create({
color: "#6E6E6E",
fontSize: 14,
},
searchTextContainer: {
alignSelf: "stretch",
},
});
2 changes: 1 addition & 1 deletion src/interfaces/algolia.ts → src/interfaces/Hit.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export interface Hit {
interface Hit {
points: number;
title: string;
description: string;
Expand Down

0 comments on commit ba7ec47

Please sign in to comment.