fix don't get news list when user don't have project id
This commit is contained in:
parent
0faf2abefd
commit
e26581d425
@ -334,14 +334,9 @@ const MainTitle = connect(state => ({
|
||||
userText = `${name[0]}`;
|
||||
projectName = props.user.project_name
|
||||
}
|
||||
return <View style={{display: 'flex', flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', width: '89%'}}>
|
||||
<View>
|
||||
<Text style={{ fontSize: 16, color: '#FFFFFF', marginLeft: 10, marginTop: 3, marginBottom: 5 }}>{t('charoensin_asset')} {projectName}</Text>
|
||||
</View>
|
||||
<View>
|
||||
<Text style={{color: 'white'}}>2.0</Text>
|
||||
</View>
|
||||
</View>
|
||||
return <View>
|
||||
<Text style={{ fontSize: 16, color: '#FFFFFF', marginLeft: 10, marginTop: 3, marginBottom: 5 }}>{t('charoensin_asset')} {projectName}</Text>
|
||||
</View>
|
||||
})
|
||||
|
||||
const MainHeader = ({ navigation }) => {
|
||||
@ -368,7 +363,7 @@ const MainHeader = ({ navigation }) => {
|
||||
}, [])
|
||||
return <View style={[{ flex: 1, alignItems: 'center', flexDirection: 'row', marginTop: 0, paddingLeft: 10, backgroundColor: server_mode === 'develop' ? '#ff0000' : 'transparent' }]}>
|
||||
<TouchableOpacity
|
||||
onPress={openSecretChamber}
|
||||
// onPress={openSecretChamber}
|
||||
activeOpacity={1}>
|
||||
<Image
|
||||
style={{ width: 35, height: 35, }}
|
||||
@ -457,6 +452,7 @@ const AppStack = createStackNavigator({
|
||||
},
|
||||
headerRight: (
|
||||
<View style={{marginRight: 0, justifyContent: 'center', alignItems: 'center', flexDirection: 'row'}}>
|
||||
<Text style={{color: 'white', marginRight: 3}}>2.0</Text>
|
||||
<TouchableOpacity onPress={() => navigation.navigate('LanguageSelect')} style={{marginRight: 8}}>
|
||||
<View style={{width: 30, height: 30, alignItems: 'center', justifyContent: 'center'}}>
|
||||
<Image style={{width: 25, height: 25}} source={langIcon}/></View>
|
||||
@ -467,7 +463,7 @@ const AppStack = createStackNavigator({
|
||||
</View>
|
||||
),
|
||||
headerLeftContainerStyle: {
|
||||
width: '80%',
|
||||
width: '75%',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
},
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { createSwitchNavigator, createAppContainer } from 'react-navigation'
|
||||
import { createSwitchNavigator, createAppContainer, SafeAreaView } from 'react-navigation'
|
||||
import AuthStack from './AuthStack'
|
||||
import AppStack from './AppStack'
|
||||
import React from 'react'
|
||||
@ -19,9 +19,9 @@ export class AppNavContainer extends React.Component {
|
||||
}
|
||||
|
||||
render () {
|
||||
return <View style={{ flex: 1 }}>
|
||||
return <SafeAreaView style={{ flex: 1 }}>
|
||||
<MainNav ref={navigatorRef => {NavigationService.setTopLevelNavigator(navigatorRef)}}/>
|
||||
</View>
|
||||
</SafeAreaView>
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -242,8 +242,24 @@ class NewsScreen extends Component {
|
||||
console.log('project id >>>> ', res.data.project_id)
|
||||
this.checkNotifiedPopup()
|
||||
if(res.data.project_id){
|
||||
await this.getAllNewsByProject(res.data.project_id)
|
||||
|
||||
this.setState({
|
||||
loadPage: 1,
|
||||
last_page: 1,
|
||||
news_head: [{
|
||||
title: t('loading_news'),
|
||||
content: t('loading_news'),
|
||||
date: t('loading_news'),
|
||||
is_new: false
|
||||
}],
|
||||
new_all: [{
|
||||
title: t('loading_news'),
|
||||
content: t('loading_news'),
|
||||
date: t('loading_news'),
|
||||
is_new: false
|
||||
}],
|
||||
},async () => {
|
||||
await this.getAllNewsByProject(res.data.project_id)
|
||||
})
|
||||
}
|
||||
this.setState({
|
||||
noti_count: res.data.count_noti,
|
||||
@ -328,20 +344,6 @@ class NewsScreen extends Component {
|
||||
console.log('initData >>> ')
|
||||
this.setState({
|
||||
isLoading: true,
|
||||
loadPage: 1,
|
||||
last_page: 1,
|
||||
news_head: [{
|
||||
title: t('loading_news'),
|
||||
content: t('loading_news'),
|
||||
date: t('loading_news'),
|
||||
is_new: false
|
||||
}],
|
||||
new_all: [{
|
||||
title: t('loading_news'),
|
||||
content: t('loading_news'),
|
||||
date: t('loading_news'),
|
||||
is_new: false
|
||||
}],
|
||||
}, () => {
|
||||
Promise.all([
|
||||
this.getUser(),
|
||||
@ -594,24 +596,28 @@ class NewsScreen extends Component {
|
||||
}
|
||||
}}
|
||||
>
|
||||
<View style={[styles.row]}>
|
||||
<FlatList
|
||||
data={this.state.news_head}
|
||||
renderItem={({ item }) => this.renderNativeItemImages(item)}
|
||||
horizontal={true}
|
||||
showsHorizontalScrollIndicator={false}
|
||||
pagingEnabled={true}
|
||||
keyExtractor={this._keyExtractorNewHead}
|
||||
onScroll={this._onCarouselScroll}
|
||||
/>
|
||||
<View style={{ position: 'absolute', bottom: 10, width: '100%', justifyContent: 'center', flexDirection: 'row' }}>
|
||||
{
|
||||
this.state.news_head ?
|
||||
(this.state.news_head).map((item, i) => <View key={'news_heade_' + i} style={[{ width: 10, height: 10, borderRadius: 5, backgroundColor: this.state.position == i ? '#269A21' : 'rgba(255,255,255,0.3)', marginHorizontal: 4 }]}></View>)
|
||||
: <View></View>
|
||||
}
|
||||
</View>
|
||||
</View>
|
||||
{
|
||||
this.state.user_project_id ?
|
||||
<View style={[styles.row]}>
|
||||
<FlatList
|
||||
data={this.state.news_head}
|
||||
renderItem={({ item }) => this.renderNativeItemImages(item)}
|
||||
horizontal={true}
|
||||
showsHorizontalScrollIndicator={false}
|
||||
pagingEnabled={true}
|
||||
keyExtractor={this._keyExtractorNewHead}
|
||||
onScroll={this._onCarouselScroll}
|
||||
/>
|
||||
<View style={{ position: 'absolute', bottom: 10, width: '100%', justifyContent: 'center', flexDirection: 'row' }}>
|
||||
{
|
||||
this.state.news_head ?
|
||||
(this.state.news_head).map((item, i) => <View key={'news_heade_' + i} style={[{ width: 10, height: 10, borderRadius: 5, backgroundColor: this.state.position == i ? '#269A21' : 'rgba(255,255,255,0.3)', marginHorizontal: 4 }]}></View>)
|
||||
: <View></View>
|
||||
}
|
||||
</View>
|
||||
</View> : <View></View>
|
||||
}
|
||||
|
||||
{
|
||||
this.state.auth !== null &&
|
||||
(
|
||||
@ -817,31 +823,36 @@ class NewsScreen extends Component {
|
||||
))
|
||||
|
||||
}
|
||||
<View style={{ padding: 10 }}>
|
||||
<FlatList
|
||||
extraData={this.state}
|
||||
contentContainerStyle={{
|
||||
height: '100%',
|
||||
width: '100%'
|
||||
}}
|
||||
// scrollEnabled={false}
|
||||
data={this.state.new_all}
|
||||
renderItem={this.renderNativeItem}
|
||||
keyExtractor={this._keyExtractorNewAll}
|
||||
// onEndReachedThreshold={0.01}
|
||||
// onEndReached={this.loadMoreData.bind(this)}
|
||||
ItemSeparatorComponent={() => {
|
||||
return <View style={{ width: '100%', height: 8 }}></View>
|
||||
}}
|
||||
ListFooterComponent={() => {
|
||||
if (!this.state.isLoadmore) return null
|
||||
return (<ActivityIndicator
|
||||
size="large"
|
||||
color={'white'}
|
||||
/>)
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
|
||||
{
|
||||
this.state.user_project_id ?
|
||||
<View style={{ padding: 10 }}>
|
||||
<FlatList
|
||||
extraData={this.state}
|
||||
contentContainerStyle={{
|
||||
height: '100%',
|
||||
width: '100%'
|
||||
}}
|
||||
// scrollEnabled={false}
|
||||
data={this.state.new_all}
|
||||
renderItem={this.renderNativeItem}
|
||||
keyExtractor={this._keyExtractorNewAll}
|
||||
// onEndReachedThreshold={0.01}
|
||||
// onEndReached={this.loadMoreData.bind(this)}
|
||||
ItemSeparatorComponent={() => {
|
||||
return <View style={{ width: '100%', height: 8 }}></View>
|
||||
}}
|
||||
ListFooterComponent={() => {
|
||||
if (!this.state.isLoadmore) return null
|
||||
return (<ActivityIndicator
|
||||
size="large"
|
||||
color={'white'}
|
||||
/>)
|
||||
}}
|
||||
/>
|
||||
</View> : <View></View>
|
||||
}
|
||||
|
||||
</ScrollView>
|
||||
</BackgroundImage>
|
||||
<IndicatorLoading loadingVisible={this.state.isLoading}/>
|
||||
|
@ -97,7 +97,7 @@ export default class NewsDetailScreen extends Component {
|
||||
source_webview = {
|
||||
baseUrl: '',
|
||||
// uri: `${Config.API_BASE_URL_POWER_CONDO_PROD}/news/${this.state.news_id}/detail`,
|
||||
uri: `${Config.API_BASE_URL_POWER_CONDO_DEV}/news/${this.state.news_id}/detail`
|
||||
uri: `${Config.API_BASE_URL_POWER_CONDO_PROD}/news/${this.state.news_id}/detail`
|
||||
}
|
||||
|
||||
// if(Platform.OS === 'android'){
|
||||
|
Loading…
Reference in New Issue
Block a user