Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Precisa rodar o npm install para as novas dependências Encapsulamento dos diretórios do app em mobile/src Configuração do Redux para a aplicação Em mobile/src/actions, adicionados esqueletos básicos de requisições de API Em mobile/src/reducers, adicionados esqueletos básicos do estado da aplicação O componente principal em mobile/App.js foi reescrito para suportar as alterações
- Loading branch information
1 parent
cb1b15a
commit de446e7
Showing
23 changed files
with
99 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,23 @@ | ||
// https://github.com/tleunen/babel-plugin-module-resolver/issues/341 | ||
module.exports = function(api) { | ||
api.cache(true); | ||
return { | ||
presets: ['babel-preset-expo'], | ||
}; | ||
presets: ['babel-preset-expo', 'module:metro-react-native-babel-preset', 'module:react-native-dotenv'], | ||
plugins: [ | ||
[ | ||
'module-resolver', { | ||
root: ['./src'], | ||
alias: { | ||
'~actions': './actions', | ||
'~assets': './assets', | ||
'~components': './components', | ||
'~constants': './constants', | ||
'~navigation': './navigation', | ||
'~reducers': './reducers', | ||
'~screens': './screens' | ||
} | ||
} | ||
] | ||
] | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import axios from "axios"; | ||
import { LOCAL_IP } from 'react-native-dotenv' | ||
|
||
export const apiClient = token => { | ||
const headers = token ? { Authorization: `Token ${token}` } : null; | ||
// https://www.freecodecamp.org/news/how-to-gracefully-use-environment-variables-in-a-react-native-app/ | ||
const baseURL = `http://${LOCAL_IP}:8000/api`; | ||
if (headers) { | ||
return axios.create({ baseURL, headers }); | ||
} | ||
return axios.create({ baseURL }); | ||
}; | ||
|
||
export const apiTypes = base => ({ | ||
request: `${base.toUpperCase()}_REQUEST`, | ||
success: `${base.toUpperCase()}_SUCCESS`, | ||
failure: `${base.toUpperCase()}_FAILURE` | ||
}); | ||
|
||
export const apiActionCreators = (dispatch, types) => ({ | ||
request: () => dispatch({ type: types.request }), | ||
success: payload => dispatch({ type: types.success, payload }), | ||
failure: payload => dispatch({ type: types.failure, payload }) | ||
}); |
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
mobile/components/TabBarIcon.js → mobile/src/components/TabBarIcon.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { combineReducers } from 'redux'; | ||
|
||
export default combineReducers({ | ||
user: (state = {}, action) => state | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
de446e7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@RMoroni bem importante:
É preciso criar um arquivo .env, na raiz da base do app (mobile/.env), com a chave LOCAL_IP=XXX.XXX.XXX.XXX
Isso é necessário para o app comunicar com a API durante o desenvolvimento (em produção, deve ser substituído pela URL do servidor). Essa variável de ambiente é acessada pelo pacote react-native-dotenv, e seu uso é exposto em mobile/src/actions/utils.js. Como o IP vai variar entre nossos ambientes, não faz sentido commitar esse arquivo.
A versão do SDK do Expo também foi atualizada, acabei esquecendo de colocar na mensagem do commit, mas precisaria explicar sobre isso, o processo para atualizar pode ser um pouco diferente. Entre no diretório /mobile e faça isso após dar um fetch no branch:
Referências para os passos acima: