forked from react-native-community/directory
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpopular.tsx
99 lines (93 loc) · 2.49 KB
/
popular.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import fetch from 'isomorphic-fetch';
import { NextPageContext } from 'next';
import React from 'react';
import { StyleSheet } from 'react-native';
import ContentContainer from '../components/ContentContainer';
import ExploreSection from '../components/Explore/ExploreSection';
import {
PlatformAndroid,
PlatformIOS,
PlatformMacOS,
PlatformWeb,
PlatformWindows,
PlatformExpo,
ReactLogo,
} from '../components/Icons';
import Navigation from '../components/Navigation';
import getApiUrl from '../util/getApiUrl';
import urlWithQuery from '../util/urlWithQuery';
const Popular = ({ data }) => {
return (
<>
<Navigation
title="Popular libraries"
description="Browse most popular recently libraries by platform."
/>
<ContentContainer style={styles.container}>
<ExploreSection
title="Core platforms"
icon={ReactLogo}
data={data}
filter={lib => lib.android === true && lib.ios === true}
count={8}
queryParams={{ android: 'true', ios: 'true' }}
/>
<ExploreSection
title="Android"
icon={PlatformAndroid}
data={data}
filter={lib => lib.android === true && !lib.ios}
/>
<ExploreSection
title="iOS"
icon={PlatformIOS}
data={data}
filter={lib => lib.ios === true && !lib.android}
/>
<ExploreSection
title="Expo Go"
icon={PlatformExpo}
data={data}
filter={lib => lib.expo === true}
/>
<ExploreSection
title="macOS"
icon={PlatformMacOS}
data={data}
filter={lib => lib.macos === true}
/>
<ExploreSection
title="Web"
icon={PlatformWeb}
data={data}
filter={lib => lib.web === true}
/>
<ExploreSection
title="Windows"
icon={PlatformWindows}
data={data}
filter={lib => lib.windows === true}
/>
</ContentContainer>
</>
);
};
Popular.getInitialProps = async (ctx: NextPageContext) => {
const url = getApiUrl(
urlWithQuery('/libraries', { limit: 9999, minPopularity: 0, order: 'popularity' }),
ctx
);
const response = await fetch(url);
const result = await response.json();
return {
data: result.libraries,
query: ctx.query,
};
};
const styles = StyleSheet.create({
container: {
paddingHorizontal: 16,
paddingBottom: 12,
},
});
export default Popular;