Manos Chorianopoulos

add WalletViewController

Showing 31 changed files with 341 additions and 8 deletions
......@@ -7,7 +7,7 @@
<key>Pods-SwiftWarplyFramework.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
<integer>0</integer>
</dict>
</dict>
</dict>
......
......@@ -7,7 +7,7 @@
<key>SwiftWarplyFramework.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
<integer>1</integer>
</dict>
</dict>
</dict>
......
{
"images" : [
{
"filename" : "active_code_logo.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "active_code_logo-1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "active_code_logo-2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "dfy_logo_white.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "dfy_logo_white-1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "dfy_logo_white-2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "heart.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "heart-1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "heart-2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "ic_background_circle.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "ic_background_circle-1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "ic_background_circle-2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "wallet_coupons.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "wallet_coupons-1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "wallet_coupons-2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "wallet_dfy_earn.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "wallet_dfy_earn-1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "wallet_dfy_earn-2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
......@@ -136,3 +136,55 @@ extension UIImageView {
}
}
}
typealias GradientPoints = (startPoint: CGPoint, endPoint: CGPoint)
enum GradientOrientation {
case topRightBottomLeft
case topLeftBottomRight
case horizontal
case vertical
var startPoint : CGPoint {
return points.startPoint
}
var endPoint : CGPoint {
return points.endPoint
}
var points : GradientPoints {
switch self {
case .topRightBottomLeft:
return (CGPoint(x: 0.0,y: 1.0), CGPoint(x: 1.0,y: 0.0))
case .topLeftBottomRight:
return (CGPoint(x: 0.0,y: 0.0), CGPoint(x: 1,y: 1))
case .horizontal:
return (CGPoint(x: 0.0,y: 0.5), CGPoint(x: 1.0,y: 0.5))
case .vertical:
return (CGPoint(x: 0.0,y: 0.0), CGPoint(x: 0.0,y: 1.0))
}
}
}
extension UIView {
func applyGradient(colours: [UIColor], locations: [NSNumber]? = nil, cornerRadius: CGFloat) {
let gradient = CAGradientLayer()
gradient.frame = self.bounds
gradient.colors = colours.map { $0.cgColor }
gradient.locations = locations
gradient.cornerRadius = cornerRadius
self.layer.insertSublayer(gradient, at: 0)
}
func applyGradient(colours: [UIColor], gradient orientation: GradientOrientation, cornerRadius: CGFloat) {
let gradient = CAGradientLayer()
gradient.frame = self.bounds
gradient.colors = colours.map { $0.cgColor }
gradient.startPoint = orientation.startPoint
gradient.endPoint = orientation.endPoint
gradient.cornerRadius = cornerRadius
self.layer.insertSublayer(gradient, at: 0)
}
}
......
......@@ -9,18 +9,161 @@ import Foundation
import UIKit
@objc public class WalletViewController: UIViewController {
@IBOutlet weak var headerImage: UIImageView!
@IBOutlet weak var profileImage: UIImageView!
@IBOutlet weak var profileNameLabel: UILabel!
@IBOutlet weak var questionnaireButton: UIButton!
@IBOutlet weak var dfyEarnView: UIView!
@IBOutlet weak var dfyEarnLabel: UILabel!
@IBOutlet weak var dfyEarnAmountLabel: UILabel!
@IBOutlet weak var dfyEarnImage: UIImageView!
@IBOutlet weak var couponEarnView: UIView!
@IBOutlet weak var couponEarnLabel: UILabel!
@IBOutlet weak var couponEarnAmountLabel: UILabel!
@IBOutlet weak var couponEarnImage: UIImageView!
@IBOutlet weak var dfyLogoImage: UIImageView!
@IBOutlet weak var activeCodeView: UIView!
@IBOutlet weak var activeCodeLabel: UILabel!
@IBOutlet weak var activeCodeExpirationLabel: UILabel!
@IBOutlet weak var tableView: UITableView!
@IBOutlet weak var activeCodeImage: UIImageView!
@IBOutlet weak var activeGiftsButton: UIButton!
public var coupons:Array<swiftApi.CouponItemModel> = []
public override func viewDidLoad() {
super.viewDidLoad()
getCouponsRequest()
public override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
setBackButton()
setNavigationTitle("My loyalty wallet")
setNavigationTitle("For You")
tableView.delegate = self
tableView.dataSource = self
headerImage.image = UIImage(named: "ic_background_circle", in: Bundle(for: MyEmptyClass.self), compatibleWith: nil)
dfyEarnImage.image = UIImage(named: "wallet_dfy_earn", in: Bundle(for: MyEmptyClass.self), compatibleWith: nil)
couponEarnImage.image = UIImage(named: "wallet_coupons", in: Bundle(for: MyEmptyClass.self), compatibleWith: nil)
dfyLogoImage.image = UIImage(named: "dfy_logo_white", in: Bundle(for: MyEmptyClass.self), compatibleWith: nil)
activeCodeImage.image = UIImage(named: "active_code_logo", in: Bundle(for: MyEmptyClass.self), compatibleWith: nil)
profileImage.layer.cornerRadius = 32.5
profileImage.layer.borderWidth = 1
profileImage.layer.borderColor = UIColor(red: 0.13, green: 0.66, blue: 0.71, alpha: 1.00).cgColor
// TODO: dynamic
// profileImage.load(link: profile_image ?? "", placeholder: UIImage(), cache: URLCache())
profileNameLabel.text = "Γιώργος Γεωργίου"
// TODO: dynamic
questionnaireButton.setTitle("Traveller", for: .normal)
questionnaireButton.titleLabel?.font = UIFont.systemFont(ofSize: 13, weight: .semibold)
// questionnaireButton.sizeToFit()
questionnaireButton.frame = CGRect(x: 0.0, y: 0.0, width: questionnaireButton.intrinsicContentSize.width, height: questionnaireButton.intrinsicContentSize.height)
questionnaireButton.applyGradient(colours: [UIColor(red: 0.40, green: 0.77, blue: 0.28, alpha: 1.00), UIColor(red: 0.10, green: 0.66, blue: 0.72, alpha: 1.00)], gradient: GradientOrientation.horizontal, cornerRadius: 7.0)
// Shadow Color and Radius
questionnaireButton.layer.shadowColor = UIColor(red: 0.33, green: 0.38, blue: 0.43, alpha: 1.00).cgColor
questionnaireButton.layer.shadowOffset = CGSize(width: 0.0, height: 2.0)
questionnaireButton.layer.shadowOpacity = 1.0
questionnaireButton.layer.shadowRadius = 0.0
questionnaireButton.layer.masksToBounds = false
questionnaireButton.layer.cornerRadius = 7.0
dfyEarnView.layer.cornerRadius = 5.0
dfyEarnView.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.16).cgColor
dfyEarnView.layer.shadowOffset = CGSize(width: 0.0, height: 3.0)
dfyEarnView.layer.shadowOpacity = 1.0
dfyEarnView.layer.shadowRadius = 3.0
// TODO: dynamic
dfyEarnLabel.text = "Μέχρι τώρα έχεις κερδίσει 18,00€ με το DEALS for YOU!"
dfyEarnAmountLabel.text = "18,00€"
couponEarnView.layer.cornerRadius = 5.0
couponEarnView.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.16).cgColor
couponEarnView.layer.shadowOffset = CGSize(width: 0.0, height: 3.0)
couponEarnView.layer.shadowOpacity = 1.0
couponEarnView.layer.shadowRadius = 3.0
// TODO: dynamic
couponEarnLabel.text = "Μέχρι τώρα έχεις κερδίσει 20,00€ σε προσφορές από 3 κουπόνια!"
couponEarnAmountLabel.text = "20,00€"
activeCodeView.layer.cornerRadius = 5.0
activeCodeView.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.16).cgColor
activeCodeView.layer.shadowOffset = CGSize(width: 0.0, height: 0.0)
activeCodeView.layer.shadowOpacity = 1.0
activeCodeView.layer.shadowRadius = 6.0
// TODO: dynamic
activeCodeLabel.text = "961544809"
activeCodeExpirationLabel.text = "Λήγει σε 4 ημέρες"
}
// MARK: - API Functions
func getCouponsRequest() {
swiftApi().getCouponsAsync(getCouponsCallback)
}
func getCouponsCallback (_ couponsData: Array<swiftApi.CouponItemModel>?) -> Void {
if (couponsData != nil) {
let activeCouponData = swiftApi().filterActiveCoupons(couponsData ?? [])
self.coupons = activeCouponData
DispatchQueue.main.async {
self.tableView.reloadData()
}
} else {
self.coupons = []
}
}
@IBAction func navigateToActiveGifts(_ sender: Any) {
// MARK: - Actions
@IBAction func qustionnaireButtonAction(_ sender: Any) {
swiftApi().openQuestionnaire(self);
}
@IBAction func dfyEarnButtonAction(_ sender: Any) {
// TODO: dfyEarnButtonAction
print("dfyEarnButtonAction Tapped!")
}
@IBAction func couponEarnButtonAction(_ sender: Any) {
// TODO: couponEarnButtonAction
print("couponEarnButtonAction Tapped!")
}
}
// MARK: - TableView
extension WalletViewController: UITableViewDelegate, UITableViewDataSource{
public func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.coupons.count
}
public func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 120.0 + 30.0
// return UITableViewAutomaticDimension
}
public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "CouponsTableViewCellId", for: indexPath) as! CouponsTableViewCell
cell.configureCell(coupon: coupons[indexPath.row])
return cell
}
public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
let vc = storyboard.instantiateViewController(withIdentifier: "ActiveGiftsViewController") as UIViewController
let vc = storyboard.instantiateViewController(withIdentifier: "CouponBarcodeViewController") as! CouponBarcodeViewController
vc.coupon = coupons[indexPath.row]
self.navigationController?.pushViewController(vc, animated: true)
}
}
......