-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProjects.js
128 lines (116 loc) · 4.46 KB
/
Projects.js
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
import React, { Component } from "react";
import { Image, keyboard, AsyncStorage, Dimensions, StyleSheet, StatusBar, TouchableOpacity } from 'react-native';
import { Container, Header, Content, Spinner, Card,Item, Input, CardItem, Text, Body, View, Fab, Left, Right, Button, Icon, List, ListItem, Thumbnail } from "native-base";
import * as Font from 'expo-font';
import { Ionicons } from '@expo/vector-icons';
import api from './DbConfig';
StatusBar.setBackgroundColor('#0099ff',true);
const {width, height} = Dimensions.get("window");
export default class Projects extends Component {
constructor(props) {
super(props);
this.state = {
btnsnipper:1,
showfeed:[],
caption:'',
searchproject:'',
};
}
searchchecking = ()=>{
if(this.state.searchproject.length>1){
this.setState({btnsnipper:1});
this.projectsearching();
}
}
projectsearching=()=>{
var InsertAPI = api+'searchproject.php';
var Data={cat:this.props.tag, keyword:this.state.searchproject};
var headers={
'Accept':'application/json',
'Content-Type':'application.json'
}
fetch(InsertAPI,{
method:'POST',
headers:headers,
body:JSON.stringify(Data),
}).then((response)=>response.json()).then((response)=>{
if(response===null){
this.setState({caption:'No feed to show'});
this.setState({btnsnipper:0});
}
else{
this.setState({showfeed:response});
this.setState({btnsnipper:0});
}
})
.catch(err=>{
alert('Something went wrong');
this.setState({feedLoading:0});
})
}
allprojectfeed=()=>{
var InsertAPI = api+'projectfeed.php';
var Data={cat:this.props.tag};
var headers={
'Accept':'application/json',
'Content-Type':'application.json'
}
fetch(InsertAPI,{
method:'POST',
headers:headers,
body:JSON.stringify(Data),
}).then((response)=>response.json()).then((response)=>{
if(response===null){
this.setState({caption:'No feed to show'});
this.setState({btnsnipper:0});
}
else{
this.setState({showfeed:response});
this.setState({btnsnipper:0});
}
})
.catch(err=>{
alert('Something went wrong');
this.setState({feedLoading:0});
})
}
async componentDidMount() {
this.allprojectfeed();
await Font.loadAsync({
'Roboto': require('native-base/Fonts/Roboto.ttf'),
'Roboto_medium': require('native-base/Fonts/Roboto_medium.ttf'),
...Ionicons.font,
})
this.setState({ loading: false })
}
render() {
return (
<Container>
<View style={{padding:10}}>
<Item regular style={{height:40, backgroundColor:'#fff', borderRadius:20}}>
<Input placeholder='Search project...'
onChangeText={(searchproject) =>{this.setState({searchproject}); this.searchchecking()}}/>
<Icon name="search"/>
</Item>
</View>
{this.state.btnsnipper==0?
<View>
{this.state.showfeed==null?
<Text style={{textAlign:'center', marginTop:50}}>No Discussion found !</Text>:<List dataArray={this.state.showfeed} renderRow={(item) =>
<ListItem thumbnail onPress={()=>{this.props.navigation.navigate('Projectview', {title:item.title, userid:item.uid, userimg:item.userimg, username:item.username, tagname:item.tagname, projectid:item.id})}}>
<Left>
<Thumbnail source={require('./assets/projectlogo.png')}
style={{resizeMode:'contain'}} />
</Left>
<Body>
<Text numberOfLines={2}>{item.title}</Text>
<Text note>{item.username}</Text>
</Body>
</ListItem>}/>}
</View>:<Thumbnail source={require('./assets/searchprofile.gif')}
style={{height:height/3,width:width, resizeMode:'contain'}}
/>}
</Container>
);
}
}