Skip to content

Commit

Permalink
Merge pull request #149 from fga-eps-mds/dev
Browse files Browse the repository at this point in the history
Update master
  • Loading branch information
heronsousa authored Nov 27, 2018
2 parents 3947641 + 45ffa0b commit 9f182fa
Show file tree
Hide file tree
Showing 12 changed files with 92 additions and 70 deletions.
3 changes: 1 addition & 2 deletions mobile/screens/TabHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { TabNavigator } from 'react-navigation';
import TabHandlerVendasApp from './tab_navigator/vendas/TabHandlerVendasApp';
import TabHandlerIndicaAi from './tab_navigator/indica_ai/TabHandlerIndicaAi';
import RolesApp from './tab_navigator/roles/RolesApp';
import CarDefenseApp from './tab_navigator/car_defense/CarDefenseApp';
import SettingScreen from './tab_navigator/settings/SettingScreen';
import RolesTabHandler from './tab_navigator/roles/RolesTabHandler';

Expand Down Expand Up @@ -109,4 +108,4 @@ const TabHandler = new TabNavigator({
animationEnabled: true,
});

export default TabHandler;
export default TabHandler;
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ exports[`renders correctly 1`] = `
style={
Object {
"backgroundColor": "transparent",
"color": "rgba(28, 189, 36, 1)",
"color": "rgba(0, 0, 0, 1)",
"fontSize": 11,
"marginBottom": 1.5,
"textAlign": "center",
Expand Down
25 changes: 0 additions & 25 deletions mobile/screens/tab_navigator/car_defense/CarDefenseApp.js

This file was deleted.

5 changes: 1 addition & 4 deletions mobile/screens/tab_navigator/indica_ai/TabHandlerIndicaAi.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@ const TabHandlerIndicaAI = new TabNavigator({
activeTintColor: 'black',
inactiveTintColor: '#5A5A5A',
labelStyle: {
fontSize: 12,
},
tabStyle: {
height: 40,
fontSize: 11,
},
style: {
backgroundColor: 'white',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ export default class UserMap extends React.Component {

this.state = {
newLatitude: null,
newLongitude: null
newLongitude: null,
markLatitude: this.props.markLat,
markLongitude: this.props.markLong
}
};

Expand All @@ -42,21 +44,26 @@ export default class UserMap extends React.Component {
longitude: this.props.longitude,
latitudeDelta: 0.0004,
longitudeDelta: 0.003,
}}>
}}
onRegionChangeComplete = {(event) =>{
this.props.sendNewCoods(event['latitude'],event['longitude'])
this.setState({
newLatitude: event['latitude'],
newLongitude: event['longitude']
})}}
onRegionChange = {(event) => {
this.setState({
markLatitude: event['latitude'],
markLongitude: event['longitude']
})
}}
>
<MapView.Marker
coordinate={{
latitude: this.props.markLat,
longitude:this.props.markLong,}}
latitude: this.state.markLatitude,
longitude:this.state.markLongitude,}}
title = {this.props.name}
image = {icon}
draggable
onDragEnd={(event) =>{
this.props.sendNewCoods(event.nativeEvent.coordinate['latitude'],event.nativeEvent.coordinate['longitude'])
this.setState({
newLatitude: event.nativeEvent.coordinate['latitude'],
newLongitude: event.nativeEvent.coordinate['longitude']
})}}

>
<MapView.Callout
tooltip={true}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,26 @@ class FavoriteContainer extends React.Component {
errorModalVisible: false,
token: this.props.token,
local_id: this.props.id,
favorites: this.props.favorites
favorites: this.props.favorites,
liked: false
}
componentWillReceiveProps(newProps) {
if (newProps.favorites) {
this.setState({ favorites: newProps.favorites })
}
}

componentWillMount(){
const { favorites, local_id } = this.state
if(favorites){
favorites.forEach(favorite => {
if(favorite.local_id === local_id){
this.setState({liked: true})
}
})
}
}

_updateFunction = async () => {
const { token } = this.state
const user = jwt_decode(token)
Expand Down Expand Up @@ -113,17 +126,16 @@ class FavoriteContainer extends React.Component {
}
}
render() {
const { favorites, local_id } = this.state
return (
<View>
<FavoriteIcon
favMessageIcon={this.favMessageIcon}
// liked={favorites.some(favorite => favorite.local_id === local_id)}
liked={this.state.liked}
/>
<ErrorModal
onCancel={() => this.setState({ errorModalVisible: false })}
visible={this.state.errorModalVisible}
message="Ocorreu um erro, tente novamente mais tarde"
message="Ocorreu um erro"
/>
</View>
)
Expand Down
23 changes: 19 additions & 4 deletions mobile/screens/tab_navigator/indica_ai/containers/ListFavorites.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
ScrollView,
TouchableHighlight,
ImageBackground,
RefreshControl
} from "react-native";
import {
Content,
Expand All @@ -28,7 +29,8 @@ class ListFavorites extends Component {
super(props);
this.state = {
favorites: props ? props.favorites : [],
locals: props ? props.locals : []
locals: props ? props.locals : [],
refreshing: false,
};
}

Expand Down Expand Up @@ -69,7 +71,12 @@ class ListFavorites extends Component {
this.setState({ locals: newProps.locals })
}
}

_onRefresh = () => {
this.setState({refreshing: true});
this.fetchFavoritesList().then(() => {
this.setState({refreshing: false});
});
}
render() {
const { favorites } = this.state
const { locals } = this.state
Expand All @@ -86,7 +93,15 @@ class ListFavorites extends Component {
} else {

return (
<ScrollView style={styles.Container}>
<ScrollView style={styles.Container}
refreshControl={
<RefreshControl
refreshing={this.state.refreshing}
onRefresh={this._onRefresh}
/>
}
>

{favorites.map(favorite =>
<View key={favorite.id}>
<FavoriteCard key={favorite.id}
Expand Down Expand Up @@ -121,4 +136,4 @@ const styles = StyleSheet.create({
flexDirection: "column",
width: "100%"
},
});
});
42 changes: 31 additions & 11 deletions mobile/screens/tab_navigator/indica_ai/containers/ListLocals.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import {
Text,
StyleSheet,
ScrollView,
TouchableHighlight
TouchableHighlight,
RefreshControl
} from "react-native";
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
Expand All @@ -16,14 +17,21 @@ import { withNavigation } from 'react-navigation';

class ListLocals extends Component {

state = {
locals: []
};
constructor(props) {
super(props);
this.state = {
refreshing: false,
locals: []
};
}

// Fucntion responsable to load all places before mount
// the component by setting the state equal to result from fetch
componentWillMount() {
const url = fetch(`${process.env.INDICA_AI_API}/locals/`, {
componentDidMount() {
this.getData();
}
getData = async () => {
fetch(`${process.env.INDICA_AI_API}/locals/`, {
method: "GET",
headers: {
Accept: "application/json",
Expand All @@ -38,18 +46,23 @@ class ListLocals extends Component {
console.log(error);
});
}

// Function responsable update the component
// when the state is diferent from parent props (locals.locals[0])
componentWillReceiveProps(newProps) {
if (newProps.locals !== undefined) {
this.setState({ locals: newProps.locals })
}
}
_onRefresh = () => {
this.setState({refreshing: true});
this.getData().then(() => {
this.setState({refreshing: false});
});
}

render() {
const { locals } = this.state

locals.reverse()
if (locals.length == 0) {
return (
<IconMessage
Expand All @@ -60,9 +73,16 @@ class ListLocals extends Component {
} else {
return (

<ScrollView
showsVerticalScrollIndicator={false}
keyboardDismissMode='on-drag'

<ScrollView
showsVerticalScrollIndicator={false}
keyboardDismissMode='on-drag'
refreshControl={
<RefreshControl
refreshing={this.state.refreshing}
onRefresh={this._onRefresh}
/>
}
>

{locals.map(local =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class SearchBar extends Component {
console.log(error);
});
} else {
const url = fetch(`https://dev-indicaai.herokuapp.com/locals/`, {
const url = fetch(`${process.env.INDICA_AI_API}/locals/`, {
method: "GET",
headers: {
Accept: "application/json",
Expand Down
2 changes: 1 addition & 1 deletion mobile/screens/tab_navigator/roles/RolesTabHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const RolesTabHandler = TabNavigator(
{
tabBarOptions: {
showLabel: true,
activeTintColor: "#1CBD24", // Color of tab when pressed
activeTintColor: 'black',
inactiveTintColor: "gray", // Color of tab when not pressed
labelStyle: {
fontSize: 11
Expand Down
5 changes: 1 addition & 4 deletions mobile/screens/tab_navigator/vendas/TabHandlerVendasApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@ const TabHandlerVendasApp = new TabNavigator({
activeTintColor: 'black',
inactiveTintColor: '#5A5A5A',
labelStyle: {
fontSize: 10,
},
tabStyle: {
height: 40,
fontSize: 11,
},
style: {
backgroundColor: 'white',
Expand Down
2 changes: 1 addition & 1 deletion mobile/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7539,7 +7539,7 @@ react-native-image-view@^2.0.12:
version "2.1.1"
resolved "https://registry.yarnpkg.com/react-native-image-view/-/react-native-image-view-2.1.1.tgz#ae3254751cddc5d5044f815da4e4cb7b79bd0874"

react-native-iphone-x-helper@^1.0.1:
react-native-iphone-x-helper@^1.0.1, react-native-iphone-x-helper@^1.0.3:
version "1.2.0"
resolved "https://registry.yarnpkg.com/react-native-iphone-x-helper/-/react-native-iphone-x-helper-1.2.0.tgz#9f8a376eb00bc712115abff4420318a0063fa796"

Expand Down

0 comments on commit 9f182fa

Please sign in to comment.