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
|
import React from 'react';
import {StyleSheet, View, TouchableOpacity, Text} from 'react-native';
import {GradientBackground, SocialMediaLinker} from '../../components';
import {LinkerType} from 'src/types';
import {SOCIAL_LIST} from '../../constants/';
/**
* Home Screen for displaying Tagg post suggestions
* for users to discover and browse
*/
const Home: React.FC = () => {
const linkers: Array<LinkerType> = [];
const [state, setState] = React.useState({
showMore: false,
});
let numSocials: Number = state.showMore ? 9 : 3;
for (let i = 0; i < numSocials; i++) {
let linker: LinkerType = {
label: SOCIAL_LIST[i],
};
linkers.push(linker);
}
const handleShowPress = () => {
setState({
...state,
showMore: !state.showMore,
});
};
return (
<GradientBackground>
<View style={styles.container}>
{linkers.map((linker, index) => (
<SocialMediaLinker key={index} social={linker} />
))}
<TouchableOpacity onPress={handleShowPress} style={styles.show}>
{state.showMore && <Text>Show Less 🔼</Text>}
{!state.showMore && <Text>Show More 🔽</Text>}
</TouchableOpacity>
</View>
</GradientBackground>
);
};
const styles = StyleSheet.create({
container: {
flexDirection: 'row',
height: '19%',
flexWrap: 'wrap',
justifyContent: 'center',
alignContent: 'center',
},
show: {
borderColor: '#fff',
borderWidth: 1,
borderRadius: 3,
paddingHorizontal: '2%',
paddingVertical: '1%',
marginVertical: '3%',
marginLeft: '65%',
},
});
export default Home;
|