-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
894 additions
and
15 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,42 @@ | ||
// | ||
// API+Wishes.swift | ||
// appdb | ||
// | ||
// Created by ned on 07/07/2019. | ||
// Copyright © 2019 ned. All rights reserved. | ||
// | ||
|
||
import Alamofire | ||
import SwiftyJSON | ||
|
||
extension API { | ||
|
||
static func createPublishRequest(appStoreUrl: String, type: String = "ios", completion:@escaping (_ error: String?) -> Void) { | ||
Alamofire.request(endpoint, parameters: ["action": Actions.createPublishRequest.rawValue, "url": appStoreUrl, "type": type], headers: headersWithCookie) | ||
.responseJSON { response in | ||
switch response.result { | ||
case .success(let value): | ||
let json = JSON(value) | ||
if !json["success"].boolValue { | ||
completion(json["errors"][0].stringValue) | ||
} else { | ||
completion(nil) | ||
} | ||
case .failure(let error): | ||
completion(error.localizedDescription) | ||
} | ||
} | ||
} | ||
|
||
static func getPublishRequests(includeAll: Bool, page: Int = 1, success:@escaping (_ items: [WishApp]) -> Void, fail:@escaping (_ error: String) -> Void) { | ||
Alamofire.request(endpoint, parameters: ["action": Actions.getPublishRequests.rawValue, "type": "ios", "include_all": includeAll ? 1 : 0, "page": page], headers: headers) | ||
.responseArray(keyPath: "data") { (response: DataResponse<[WishApp]>) in | ||
switch response.result { | ||
case .success(let results): | ||
success(results) | ||
case .failure(let error): | ||
fail(error.localizedDescription) | ||
} | ||
} | ||
} | ||
} |
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,67 @@ | ||
// | ||
// WishApp.swift | ||
// appdb | ||
// | ||
// Created by ned on 07/07/2019. | ||
// Copyright © 2019 ned. All rights reserved. | ||
// | ||
|
||
import ObjectMapper | ||
import Localize_Swift | ||
|
||
struct WishApp: Mappable { | ||
|
||
init?(map: Map) { } | ||
|
||
var id: String = "" | ||
var trackid: String = "" | ||
var version: String = "" | ||
var image: String = "" | ||
var name: String = "" | ||
var requestersAmount: String = "" | ||
var price: String = "" | ||
var statusString: String = "" | ||
var status: Status = .new | ||
var statusChangedAt: String = "" | ||
var bundleId: String = "" | ||
|
||
enum Status: String { | ||
case cracking, fulfilled, failed, new | ||
|
||
// todo localize | ||
var prettified: String { | ||
switch self { | ||
case .new: return "New".localized() | ||
case .cracking: return "⚙︎ " + "Processing".localized() | ||
case .failed: return "𐄂 " + "Failed".localized() | ||
case .fulfilled: return "✓ " + "Fulfilled".localized() | ||
} | ||
} | ||
} | ||
|
||
mutating func mapping(map: Map) { | ||
id <- map["id"] | ||
trackid <- map["trackid"] | ||
version <- map["version"] | ||
image <- map["image"] | ||
name <- map["name"] | ||
requestersAmount <- map["requesters_amount"] | ||
price <- map["price"] | ||
statusString <- map["status"] | ||
statusChangedAt <- map["status_changed_at"] | ||
bundleId <- map["bundle_id"] | ||
|
||
name = name.decoded | ||
|
||
price = price == "0.00" ? "Free".localized() : price | ||
|
||
status = Status(rawValue: statusString) ?? .new | ||
|
||
let date = statusChangedAt.unixToDate | ||
let dateFormatter = DateFormatter() | ||
dateFormatter.locale = Locale(identifier: Localize.currentLanguage()) | ||
dateFormatter.dateStyle = .medium | ||
dateFormatter.timeStyle = .short | ||
statusChangedAt = dateFormatter.string(from: date) | ||
} | ||
} |
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,26 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "universal", | ||
"filename" : "Untitled.png", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"filename" : "[email protected]", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"filename" : "[email protected]", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
}, | ||
"properties" : { | ||
"template-rendering-intent" : "template" | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
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,110 @@ | ||
// | ||
// WishAppCell.swift | ||
// appdb | ||
// | ||
// Created by ned on 26/07/2019. | ||
// Copyright © 2019 ned. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
import Cartography | ||
|
||
class WishAppCell: UITableViewCell { | ||
|
||
var nameLabel: UILabel! | ||
var infoLabel: UILabel! | ||
var statusLabel: UILabel! | ||
var icon: UIImageView! | ||
|
||
func configure(with app: WishApp) { | ||
nameLabel.text = app.name | ||
infoLabel.text = "Price: %@".localizedFormat(app.price) + Global.bulletPoint + "Version: %@".localizedFormat(app.version) | ||
if app.status == .new { | ||
statusLabel.text = "↑\(app.requestersAmount)" + Global.bulletPoint + app.statusChangedAt | ||
} else { | ||
statusLabel.text = app.status.prettified + Global.bulletPoint + app.statusChangedAt | ||
} | ||
if let url = URL(string: app.image) { | ||
icon.af_setImage(withURL: url, placeholderImage: #imageLiteral(resourceName: "placeholderIcon"), | ||
filter: Global.roundedFilter(from: 80 ~~ 60), | ||
imageTransition: .crossDissolve(0.2)) | ||
} | ||
} | ||
|
||
required init?(coder aDecoder: NSCoder) { | ||
super.init(coder: aDecoder) | ||
} | ||
|
||
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { | ||
super.init(style: .default, reuseIdentifier: reuseIdentifier) | ||
|
||
setup() | ||
setConstraints() | ||
} | ||
|
||
private func setup() { | ||
|
||
//UI | ||
theme_backgroundColor = Color.veryVeryLightGray | ||
setBackgroundColor(Color.veryVeryLightGray) | ||
let bgColorView = UIView() | ||
bgColorView.theme_backgroundColor = Color.cellSelectionColor | ||
selectedBackgroundView = bgColorView | ||
accessoryType = .disclosureIndicator | ||
|
||
// Name | ||
nameLabel = UILabel() | ||
nameLabel.theme_textColor = Color.title | ||
nameLabel.font = .systemFont(ofSize: 15 ~~ 14) | ||
nameLabel.numberOfLines = 1 | ||
nameLabel.makeDynamicFont() | ||
|
||
// Info Label | ||
infoLabel = UILabel() | ||
infoLabel.theme_textColor = Color.darkGray | ||
infoLabel.font = .systemFont(ofSize: 13 ~~ 12) | ||
infoLabel.numberOfLines = 1 | ||
infoLabel.makeDynamicFont() | ||
|
||
// Status Label | ||
statusLabel = UILabel() | ||
statusLabel.theme_textColor = Color.darkGray | ||
statusLabel.font = .systemFont(ofSize: 13 ~~ 12) | ||
statusLabel.numberOfLines = 1 | ||
statusLabel.makeDynamicFont() | ||
|
||
// Icon | ||
icon = UIImageView() | ||
icon.layer.borderWidth = 1 / UIScreen.main.scale | ||
icon.layer.theme_borderColor = Color.borderCgColor | ||
|
||
icon.layer.cornerRadius = Global.cornerRadius(from: (80 ~~ 60)) | ||
|
||
contentView.addSubview(nameLabel) | ||
contentView.addSubview(infoLabel) | ||
contentView.addSubview(statusLabel) | ||
contentView.addSubview(icon) | ||
} | ||
|
||
// Set constraints | ||
private func setConstraints() { | ||
constrain(icon, nameLabel, infoLabel, statusLabel) { icon, name, info, status in | ||
icon.width ~== (80 ~~ 60) | ||
icon.height ~== icon.width | ||
icon.leading ~== icon.superview!.layoutMarginsGuide.leading | ||
icon.centerY ~== icon.superview!.centerY | ||
|
||
name.leading ~== icon.trailing ~+ (15 ~~ 12) | ||
name.trailing ~== name.superview!.trailing ~- Global.Size.margin.value | ||
name.centerY ~== name.superview!.centerY ~- (22 ~~ 20) | ||
|
||
info.top ~== name.bottom ~+ (5 ~~ 4) | ||
info.leading ~== name.leading | ||
info.trailing ~== name.trailing | ||
|
||
status.leading ~== info.leading | ||
status.trailing ~<= status.superview!.trailing ~- Global.Size.margin.value | ||
status.top ~== info.bottom ~+ (5 ~~ 4) | ||
} | ||
} | ||
} |
Oops, something went wrong.