Skip to content

Commit ee887f6

Browse files
committed
first commit
0 parents  commit ee887f6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+26707
-0
lines changed

.buckconfig

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
[android]
3+
target = Google Inc.:Google APIs:23
4+
5+
[maven_repositories]
6+
central = https://repo1.maven.org/maven2

.editorconfig

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Windows files
2+
[*.bat]
3+
end_of_line = crlf

.eslintrc.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
root: true,
3+
extends: '@react-native-community',
4+
};

.flowconfig

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
[ignore]
2+
; We fork some components by platform
3+
.*/*[.]android.js
4+
5+
; Ignore "BUCK" generated dirs
6+
<PROJECT_ROOT>/\.buckd/
7+
8+
; Ignore polyfills
9+
node_modules/react-native/Libraries/polyfills/.*
10+
11+
; Flow doesn't support platforms
12+
.*/Libraries/Utilities/LoadingView.js
13+
14+
[untyped]
15+
.*/node_modules/@react-native-community/cli/.*/.*
16+
17+
[include]
18+
19+
[libs]
20+
node_modules/react-native/interface.js
21+
node_modules/react-native/flow/
22+
23+
[options]
24+
emoji=true
25+
26+
exact_by_default=true
27+
28+
format.bracket_spacing=false
29+
30+
module.file_ext=.js
31+
module.file_ext=.json
32+
module.file_ext=.ios.js
33+
34+
munge_underscores=true
35+
36+
module.name_mapper='^react-native/\(.*\)$' -> '<PROJECT_ROOT>/node_modules/react-native/\1'
37+
module.name_mapper='^@?[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> '<PROJECT_ROOT>/node_modules/react-native/Libraries/Image/RelativeImageStub'
38+
39+
suppress_type=$FlowIssue
40+
suppress_type=$FlowFixMe
41+
suppress_type=$FlowFixMeProps
42+
suppress_type=$FlowFixMeState
43+
44+
[lints]
45+
sketchy-null-number=warn
46+
sketchy-null-mixed=warn
47+
sketchy-number=warn
48+
untyped-type-import=warn
49+
nonstrict-import=warn
50+
deprecated-type=warn
51+
unsafe-getters-setters=warn
52+
unnecessary-invariant=warn
53+
signature-verification-failure=warn
54+
55+
[strict]
56+
deprecated-type
57+
nonstrict-import
58+
sketchy-null
59+
unclear-type
60+
unsafe-getters-setters
61+
untyped-import
62+
untyped-type-import
63+
64+
[version]
65+
^0.158.0

.gitattributes

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Windows files should use crlf line endings
2+
# https://help.github.com/articles/dealing-with-line-endings/
3+
*.bat text eol=crlf

.gitignore

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# OSX
2+
#
3+
.DS_Store
4+
5+
# Xcode
6+
#
7+
build/
8+
*.pbxuser
9+
!default.pbxuser
10+
*.mode1v3
11+
!default.mode1v3
12+
*.mode2v3
13+
!default.mode2v3
14+
*.perspectivev3
15+
!default.perspectivev3
16+
xcuserdata
17+
*.xccheckout
18+
*.moved-aside
19+
DerivedData
20+
*.hmap
21+
*.ipa
22+
*.xcuserstate
23+
24+
# Android/IntelliJ
25+
#
26+
build/
27+
.idea
28+
.gradle
29+
local.properties
30+
*.iml
31+
*.hprof
32+
33+
# node.js
34+
#
35+
node_modules/
36+
npm-debug.log
37+
yarn-error.log
38+
39+
# BUCK
40+
buck-out/
41+
\.buckd/
42+
*.keystore
43+
!debug.keystore
44+
45+
# fastlane
46+
#
47+
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
48+
# screenshots whenever they are needed.
49+
# For more information about the recommended setup visit:
50+
# https://docs.fastlane.tools/best-practices/source-control/
51+
52+
*/fastlane/report.xml
53+
*/fastlane/Preview.html
54+
*/fastlane/screenshots
55+
56+
# Bundle artifact
57+
*.jsbundle
58+
59+
# CocoaPods
60+
/ios/Pods/

.prettierrc.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
bracketSpacing: false,
3+
jsxBracketSameLine: true,
4+
singleQuote: true,
5+
trailingComma: 'all',
6+
arrowParens: 'avoid',
7+
};

.watchmanconfig

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

App.js

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import React from 'react';
2+
import {NavigationContainer} from '@react-navigation/native';
3+
import {createNativeStackNavigator} from '@react-navigation/native-stack';
4+
import HomeScreen from './Screens/HomeScreen';
5+
import SearchScreen from './Screens/SearchScreen';
6+
7+
const App = () => {
8+
const Stack = createNativeStackNavigator();
9+
10+
return (
11+
<NavigationContainer>
12+
<Stack.Navigator initialRouteName="Home Screen">
13+
<Stack.Screen
14+
name="Home Screen"
15+
component={HomeScreen}
16+
options={{headerShown: false}}></Stack.Screen>
17+
<Stack.Screen
18+
name="Search Screen"
19+
component={SearchScreen}
20+
options={{headerShown: true}}></Stack.Screen>
21+
</Stack.Navigator>
22+
</NavigationContainer>
23+
);
24+
};
25+
export default App;

Screens/HomeScreen.js

+114
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
import React from 'react';
2+
import {
3+
View,
4+
SafeAreaView,
5+
Text,
6+
TextInput,
7+
FlatList,
8+
Image,
9+
ScrollView,
10+
ActivityIndicator,
11+
} from 'react-native';
12+
import styles from '../styles';
13+
import {getGifs} from '../api/ApiManager';
14+
import {useIsFocused} from '@react-navigation/native';
15+
16+
const HomeScreen = props => {
17+
const [text, onChangeText] = React.useState('');
18+
const [data, setData] = React.useState([]);
19+
const [limit, setLimit] = React.useState(50);
20+
const [loading, setLoading] = React.useState(true);
21+
const isFocused = useIsFocused();
22+
React.useEffect(() => {
23+
if (data.length == 0) {
24+
getTrendingGifs();
25+
}
26+
onChangeText('');
27+
}, [isFocused]);
28+
29+
const getTrendingGifs = () => {
30+
getGifs(limit)
31+
.then(res => {
32+
if (res.meta.status == 200) {
33+
// console.log(res.data[0].images.original.url);
34+
setData(res?.data);
35+
setLoading(false);
36+
} else {
37+
setLoading(false);
38+
}
39+
})
40+
.catch(err => {
41+
console.log(err);
42+
setLoading(false);
43+
});
44+
};
45+
46+
const onFocus = () => {
47+
props.navigation.navigate('Search Screen');
48+
};
49+
50+
const loader = () => {
51+
return (
52+
<View style={[styles.loader, styles.horizontal]}>
53+
<ActivityIndicator color={'black'} />
54+
</View>
55+
);
56+
};
57+
58+
return (
59+
<SafeAreaView style={styles.container}>
60+
<View style={styles.header}>
61+
{/* <Text style={styles.headText}>VoloPay Task</Text> */}
62+
<TextInput
63+
onFocus={onFocus}
64+
style={styles.input}
65+
onChangeText={onChangeText}
66+
value={text}
67+
placeholder="Search"
68+
placeholderTextColor={'gray'}
69+
onChange={() => props.navigation.navigate('Search Screen')}
70+
/>
71+
</View>
72+
{loading ? (
73+
loader()
74+
) : (
75+
<View style={styles.subContainer}>
76+
<FlatList
77+
initialNumToRender={5}
78+
data={data}
79+
keyExtractor={(item, index) => index}
80+
renderItem={({item, index}) => {
81+
console.log(index);
82+
return (
83+
<View key={index} style={styles.item}>
84+
{
85+
<Image
86+
onLoadStart={() => console.log('start')}
87+
onLoadEnd={() => console.log('end')}
88+
resizeMode="stretch"
89+
style={styles.image}
90+
source={{uri: item?.images?.downsized?.url}}
91+
/>
92+
}
93+
<Text
94+
numberOfLines={1}
95+
ellipsizeMode="tail"
96+
style={styles.title}>
97+
{item?.title ? item.title : 'No Title'}
98+
</Text>
99+
</View>
100+
);
101+
}}
102+
/>
103+
{/* <ScrollView>
104+
{data.map((val, i) => {
105+
console.log(val.images.original.url+" "+i);
106+
return <Text key={i}>Manish</Text>;
107+
})}
108+
</ScrollView> */}
109+
</View>
110+
)}
111+
</SafeAreaView>
112+
);
113+
};
114+
export default HomeScreen;

Screens/SearchScreen.js

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
import React from 'react';
2+
import {
3+
Text,
4+
SafeAreaView,
5+
View,
6+
TextInput,
7+
FlatList,
8+
Image,
9+
} from 'react-native';
10+
import {getSearchResults} from '../api/ApiManager';
11+
import styles from '../styles';
12+
13+
const SearchScreen = props => {
14+
const [text, setText] = React.useState('');
15+
const [data, setData] = React.useState([]);
16+
const [limit, setLimit] = React.useState(25);
17+
18+
const onSearch = keyword => {
19+
setText(keyword);
20+
getSearchResults(keyword, limit)
21+
.then(res => {
22+
if (res.meta.status == 200) {
23+
setData(res?.data);
24+
} else {
25+
setData([]);
26+
}
27+
})
28+
.catch(err => {
29+
console.log(err);
30+
});
31+
};
32+
33+
return (
34+
<SafeAreaView style={styles.container}>
35+
<View style={styles.searchContainer}>
36+
<TextInput
37+
style={[styles.input]}
38+
placeholder="Enter Keyword"
39+
placeholderTextColor={'gray'}
40+
value={text}
41+
onChangeText={t => onSearch(t)}
42+
/>
43+
{data.length == 0 ? (
44+
<Text style={styles.text}>Enter Keyword to Search</Text>
45+
) : (
46+
<FlatList
47+
initialNumToRender={5}
48+
ListHeaderComponent={() => (
49+
<Text
50+
style={styles.headText}>{`Search Results For "${text}"`}</Text>
51+
)}
52+
style={styles.list}
53+
data={data}
54+
renderItem={({item, index}) => (
55+
<View key={index} style={styles.item}>
56+
<Image
57+
resizeMode="stretch"
58+
style={styles.image}
59+
source={{uri: item?.images?.downsized?.url}}
60+
/>
61+
<Text
62+
numberOfLines={1}
63+
ellipsizeMode="tail"
64+
style={styles.title}>
65+
{item?.title ? item.title : 'No Title'}
66+
</Text>
67+
</View>
68+
)}
69+
/>
70+
)}
71+
</View>
72+
</SafeAreaView>
73+
);
74+
};
75+
export default SearchScreen;

__tests__/App-test.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* @format
3+
*/
4+
5+
import 'react-native';
6+
import React from 'react';
7+
import App from '../App';
8+
9+
// Note: test renderer must be required after react-native.
10+
import renderer from 'react-test-renderer';
11+
12+
it('renders correctly', () => {
13+
renderer.create(<App />);
14+
});

0 commit comments

Comments
 (0)