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
"hello" = "hello"; | |
"bye" = "bye %@"; | |
"progress" = "Finished %d of %d"; |
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
extension UILabel { | |
func set(key: LocalizationKey) { | |
localizationKey = key | |
text = key.string | |
} | |
private struct AssociatedKeys { | |
static var localizationKey = "nsh_localizationKey" | |
} |
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
class LocalizedLabel: UILabel { | |
var localizationKey: LocalizationKey? | |
func set(key: LocalizationKey) { | |
localizationKey = key | |
text = key.string | |
} | |
} |
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
func localized() -> String { | |
let localizedString = NSLocalizedString(self, comment: "") | |
return localizedString | |
} |
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
public enum HttpMethod: String { | |
case options = "OPTIONS" | |
case get = "GET" | |
case head = "HEAD" | |
case post = "POST" | |
case put = "PUT" | |
case patch = "PATCH" | |
case delete = "DELETE" | |
case trace = "TRACE" | |
case connect = "CONNECT" |
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
protocol HttpRequestProtocol { | |
init(method: HttpMethod, url: String, headers: [String: String], parameters: [String: Any], encoding: Encoding) | |
func run(completion: @escaping ((HttpResponse) -> Void)) | |
} |
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
struct PetReusableCellDataProvider: ReusableTableViewCellDataProvider { | |
let pet: Pet | |
var leftTitle: String? { | |
return pet.name | |
} | |
var leftSubtitle: String? { | |
return "Owner: " + pet.owner | |
} |
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
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | |
guard let cell = tableView.dequeueReusableCell(withIdentifier: "ReusableTableViewCell") as? ReusableTableViewCell, indexPath.row < users.count else { | |
return UITableViewCell() | |
} | |
let user = users[indexPath.row] | |
let dataProvider = UserReusableCellDataProvider(user: user) | |
cell.set(with: dataProvider) | |
return cell | |
} |
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
private func set(image: UIImage?) { | |
guard let image = image else { | |
hideImage() | |
return | |
} | |
showImage() | |
iconImageView.image = image | |
} |
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
func set(with dataProvider: ReusableTableViewCellDataProvider) { | |
leftTitleLabel.text = dataProvider.leftTitle | |
leftSubtitleLabel.text = dataProvider.leftSubtitle | |
rightTitleLabel.text = dataProvider.rightTitle | |
rightSubtitleLabel.text = dataProvider.rightSubtitle | |
set(image: dataProvider.image) | |
} |