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 {combineReducers} from 'redux'; | |
| import { LOGOUT } from '../common/constants'; | |
| import { UnauthorizedErrorReducer } from '../common/commonReducers'; | |
| import FirstReducer from './FirstReducer'; | |
| import SecondReducer from './SecondReducer'; | |
| import ThirdReducer from './ThirdReducer'; | |
| /* In order to reset all reducers back to their initial states when user logout, | |
| * rewrite rootReducer to assign 'undefined' to state when logout | |
| * |
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
| func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool { | |
| /* Allow integer only */ | |
| let invalidCharacters = CharacterSet.decimalDigits.inverted | |
| return string.rangeOfCharacter(from: invalidCharacters) == 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
| /* Get the height of ONE line text with given width and font */ | |
| func heightOfOneLineString(text: String, width: CGFloat, font: UIFont) -> CGFloat { | |
| let rectOneLine = NSString(string: text).boundingRect(with: CGSize(width: width, height: CGFloat(MAXFLOAT)), | |
| options: .truncatesLastVisibleLine, | |
| attributes: [ NSFontAttributeName: font ], | |
| context: nil) | |
| return rectOneLine.size.height | |
| } | |
| /* Get the height of MULTIPLE lines text with given width and font */ |
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
| override func viewDidLoad() { | |
| super.viewDidLoad() | |
| self.tableView.tableFooterView = UIView() | |
| } |
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
| /* Dismiss keyboard */ | |
| UIApplication.sharedApplication().sendAction(#selector(resignFirstResponder), to: nil, from: nil, forEvent: 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
| textField.addTarget(self, action: #selector(textFieldEditingChanged(_:)), | |
| forControlEvents: .EditingChanged) |
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
| func textViewDidBeginEditing(textView: UITextView) { | |
| /* Simulate the placeholder effect */ | |
| if textView.text == <Simulated placeholder> { | |
| textView.text = "" | |
| textView.textColor = UIColor.blackColor() | |
| } | |
| } | |
| func textViewDidEndEditing(textView: UITextView) { | |
| /* Simulate the placeholder effect */ |
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
| /* We call layoutIfNeeded() immediately after reloadData() | |
| * to force table view to perform layout immediately | |
| * This is required to let the setContentOffset() in dispatch block to be executed | |
| * after table view has completed performing its layout to scroll to the correct offset | |
| * For further explanations, please see: http://goo.gl/BpzlA5 and http://goo.gl/6CH64b | |
| */ | |
| self.tableView.reloadData() | |
| self.tableView.layoutIfNeeded() | |
| dispatch_async(dispatch_get_main_queue(), { |
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
| /* We call layoutIfNeeded() immediately after reloadData() | |
| * to force collection view to perform layout immediately | |
| * This is required to let the setContentOffset() in dispatch block to be executed | |
| * after collection view has completed performing its layout to scroll to the correct offset | |
| * For further explanations, please see: http://goo.gl/BpzlA5 and http://goo.gl/6CH64b | |
| */ | |
| self.collectionView.reloadData() | |
| self.collectionView.layoutIfNeeded() | |
| dispatch_async(dispatch_get_main_queue(), { |
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
| enum DetailInfoRowType: Int { | |
| case AddressRow | |
| case PhoneRow | |
| case OpeningHoursRow | |
| case DiscountHoursRow | |
| case PriceRangesRow | |
| case IntroRow | |
| } | |
| let detailInfoRow = detailInfoRows[indexPath.row] |