π―
This file contains hidden or 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
| import Foundation | |
| class Localization { | |
| static let instance: Localization = Localization() | |
| func getLocalizationBy(langCode: String, key: String) -> String? { | |
| guard let path = NSBundle.mainBundle().pathForResource(langCode, ofType: "lproj") else { return nil } | |
| let bundle = NSBundle(path: path) | |
| return bundle?.localizedStringForKey(key, value: nil, table: nil) | |
| } |
This file contains hidden or 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
| import React from 'react'; | |
| import { | |
| AppRegistry, | |
| } from 'react-native'; | |
| import { Provider } from 'react-redux'; | |
| import { createStore, applyMiddleware, compose } from 'redux'; | |
| import thunkMiddleware from 'redux-thunk'; | |
| import createLogger from 'redux-logger'; | |
| import reducer from './app/reducers'; | |
| import AppContainer from './app/containers/AppContainer'; |
This file contains hidden or 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
| import React, { Component } from 'react'; | |
| import { connect } from 'react-redux'; | |
| import { bindActionCreators } from 'redux'; | |
| import { ActionCreators } from '../actions'; | |
| import ApplicationTabs from '../components/ApplicationTabs'; | |
| class AppContainer extends Component { | |
| render() { | |
| return ( | |
| <ApplicationTabs {...this.props} /> |
This file contains hidden or 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
| class Api { | |
| static headers() { | |
| return { | |
| Accept: 'application/json', | |
| 'Content-Type': 'application/json', | |
| dataType: 'json', | |
| }; | |
| } | |
| static get(route) { |
This file contains hidden or 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
| import * as axios from 'axios'; | |
| const instance = axios.create(); | |
| instance.defaults.baseURL = 'http://www.recipepuppy.com'; | |
| instance.defaults.headers.common.Accept = 'application/json'; | |
| instance.defaults.headers.common['Content-Type'] = 'application/json'; | |
| instance.defaults.headers.common.dataType = 'json'; | |
| instance.defaults.headers.common.responseType = 'json'; | |
| instance.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded'; |
This file contains hidden or 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
| import makeActionCreator from './makeActionCreator'; | |
| export default function callAPIMiddleware({ dispatch, getState }) { | |
| return next => (action) => { | |
| const { | |
| types, | |
| callAPI, | |
| shouldCallAPI = () => true, | |
| payload = {} | |
| } = action; |
This file contains hidden or 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
| export default function createReducer(initialState, handlers) { | |
| return function reducer(state = initialState, action) { | |
| if (handlers.hasOwnProperty(action.type)) { | |
| return handlers[action.type](state, action); | |
| } | |
| return state; | |
| }; | |
| } |
This file contains hidden or 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
| export default function makeActionCreator(type, ...argNames) { | |
| return function (...args) { | |
| const action = { type }; | |
| argNames.forEach((arg, index) => { | |
| action[argNames[index]] = args[index]; | |
| }); | |
| return action; | |
| }; | |
| } |
This file contains hidden or 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
| // | |
| // SRCopyableLabel.swift | |
| // | |
| // Created by Stephen Radford on 08/09/2015. | |
| // Copyright (c) 2015 Cocoon Development Ltd. All rights reserved. | |
| // | |
| import UIKit | |
| class SRCopyableLabel: UILabel { |
This file contains hidden or 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
| extension UITabBarController { | |
| func setTabBarVisible(visible:Bool, animated:Bool) { | |
| let frame = self.tabBar.frame | |
| let height = frame.size.height | |
| let offsetY = (visible ? -height : height) | |
| UIView.animate(withDuration: animated ? 0.3 : 0.0) { | |
| self.tabBar.frame = frame.offsetBy(dx: 0, dy: offsetY) | |
| self.view.frame = CGRect(x: 0, y: 0, width: self.view.frame.width, height: self.view.frame.height + offsetY) |