Manos Chorianopoulos

LoyaltyAnalysisViewController ui fixes

......@@ -30,13 +30,34 @@ class AnalysisHeaderMessageViewCell: UITableViewCell {
// message
messageLabel.textColor = UIColor(rgb: 0x435563)
messageLabel.layer.borderWidth = 1.0
messageLabel.layer.borderColor = UIColor(rgb: 0xB2CE69).cgColor
messageLabel.layer.borderColor = UIColor(rgb: 0x1DA6B9).cgColor
let totalCouponDiscount = Float(round(100 * loyaltyBadge._value) / 100)
var totalCouponDiscountString = "0"
totalCouponDiscountString = String(format: "%.2f", totalCouponDiscount).replacingOccurrences(of: ".", with: ",", options: .literal, range: nil)
messageLabel.text = "Μέχρι τώρα έχεις κερδίσει " + totalCouponDiscountString + "€ σε προσφορές από " + String(loyaltyBadge._couponCount) + " κουπόνια!"
// messageLabel.text = "Μέχρι τώρα έχεις κερδίσει " + totalCouponDiscountString + "€ σε προσφορές από " + String(loyaltyBadge._couponCount) + " κουπόνια!"
let coupNormalText1 = "Μέχρι τώρα έχεις κερδίσει "
let coupBoldText = totalCouponDiscountString + "€"
let coupNormalText2 = " σε προσφορές από "
let coupBoldText2 = String(loyaltyBadge._couponCount)
let coupNormalText3 = " κουπόνια!"
let attrRegular = [NSAttributedString.Key.font : UIFont.systemFont(ofSize: 16)]
let attrBold = [NSAttributedString.Key.font : UIFont.boldSystemFont(ofSize: 16)]
let coupAttributedString = NSMutableAttributedString(string:coupNormalText1, attributes:attrRegular)
let coupBoldString = NSMutableAttributedString(string: coupBoldText, attributes:attrBold)
let coupNormalString2 = NSMutableAttributedString(string:coupNormalText2, attributes:attrRegular)
let coupBoldString2 = NSMutableAttributedString(string: coupBoldText2, attributes:attrBold)
let coupNormalString3 = NSMutableAttributedString(string:coupNormalText3, attributes:attrRegular)
coupAttributedString.append(coupBoldString)
coupAttributedString.append(coupNormalString2)
coupAttributedString.append(coupBoldString2)
coupAttributedString.append(coupNormalString3)
messageLabel.attributedText = coupAttributedString
}
}
......
......@@ -11,9 +11,11 @@ import UIKit
@IBOutlet weak var leftButton: UIButton!
@IBOutlet weak var rightButton: UIButton!
@IBOutlet weak var lineView: UIView!
@IBOutlet weak var leftLineView: UIView!
@IBOutlet weak var rightLineView: UIView!
@IBOutlet weak var contentView: UIView!
var pageController: UIPageViewController!
var tabSelected = 0
public override func viewDidLoad() {
super.viewDidLoad()
......@@ -25,23 +27,21 @@ import UIKit
setNavigationTitle("Ανάλυση")
// tab
leftButton.titleLabel?.font = UIFont.systemFont(ofSize: 13, weight: .regular)
leftButton.setTitle("Εξαργυρωμένα", for:.normal)
leftButton.backgroundColor = . clear
leftButton.setTitleColor(UIColor(rgb: 0x2EAFB9), for:.normal)
rightButton.titleLabel?.font = UIFont.systemFont(ofSize: 13, weight: .regular)
rightButton.setTitle("Μοιρασμένα δώρα", for:.normal)
rightButton.backgroundColor = . clear
rightButton.setTitleColor(UIColor(rgb: 0x2EAFB9), for:.normal)
rightButton.setTitleColor(UIColor(rgb: 0x394A5B), for:.normal)
leftLineView.applyGradient(colours: [UIColor(rgb: 0x1DA6B9), UIColor(rgb: 0xB2CE69)], gradient: GradientOrientation.horizontal, cornerRadius: 0.0)
rightLineView.applyGradient(colours: [UIColor(rgb: 0x1DA6B9), UIColor(rgb: 0xB2CE69)], gradient: GradientOrientation.horizontal, cornerRadius: 0.0)
let gl = CAGradientLayer()
let colorLeft = UIColor(rgb: 0x1DA6B9).cgColor
let colorRight = UIColor(rgb: 0xB2CE69).cgColor
gl.colors = [colorLeft, colorRight]
gl.locations = [0.0, 1.0]
lineView.layer.addSublayer(gl)
let halfWidth = self.view.frame.width/2
lineView.frame = CGRect(x: 0, y: lineView.frame.minY, width: halfWidth, height: 2.0)
leftLineView.isHidden = false
rightLineView.isHidden = true
// pages
pageController = UIPageViewController(transitionStyle:.scroll, navigationOrientation:.horizontal)
......@@ -77,24 +77,38 @@ import UIKit
// MARK: - Handlers
@IBAction func handleLeft() {
if (tabSelected != 0) {
self.tabSelected = 0
UIView.animate(withDuration: 2.0, delay: 0.0) {
let halfWidth = self.view.frame.width/2
self.lineView.frame = CGRect(x: 0, y: self.lineView.frame.minY, width: halfWidth, height: 2.0)
self.leftLineView.isHidden = false
self.rightLineView.isHidden = true
self.leftButton.setTitleColor(UIColor(rgb: 0x2EAFB9), for:.normal)
self.rightButton.setTitleColor(UIColor(rgb: 0x394A5B), for:.normal)
}
let analysisVC = self.viewControllerAt(0)
pageController.setViewControllers([analysisVC!], direction:.reverse, animated:true)
}
}
@IBAction func handleRight() {
if (tabSelected != 1) {
self.tabSelected = 1
UIView.animate(withDuration: 2.0, delay: 0.0) {
let halfWidth = self.view.frame.width/2
self.lineView.frame = CGRect(x: halfWidth, y: self.lineView.frame.minY, width: halfWidth, height: 2.0)
self.leftLineView.isHidden = true
self.rightLineView.isHidden = false
self.rightButton.setTitleColor(UIColor(rgb: 0x2EAFB9), for:.normal)
self.leftButton.setTitleColor(UIColor(rgb: 0x394A5B), for:.normal)
}
let analysisVC = self.viewControllerAt(1)
pageController.setViewControllers([analysisVC!], direction:.forward, animated:true)
}
}
}
// MARK: - PageViewController
......@@ -104,11 +118,11 @@ extension LoyaltyAnalysisViewController: UIPageViewControllerDataSource, UIPageV
if let analysisVC = viewController as? AnalysisChildViewController {
var index = analysisVC.index
if (index == 1) {
if (index == 0) {
return nil;
}
index += 1;
index -= 1;
return viewControllerAt(index);
}
......@@ -119,11 +133,11 @@ extension LoyaltyAnalysisViewController: UIPageViewControllerDataSource, UIPageV
if let analysisVC = viewController as? AnalysisChildViewController {
var index = analysisVC.index
if (index == 0) {
if (index == 1) {
return nil;
}
index -= 1;
index += 1;
return viewControllerAt(index);
}
......@@ -141,11 +155,18 @@ extension LoyaltyAnalysisViewController: UIPageViewControllerDataSource, UIPageV
if let childVCs = pageViewController.viewControllers as? [AnalysisChildViewController] {
let currentIndex = childVCs[0].index
if (currentIndex == 0) {
leftButton.isSelected = true
rightButton.isSelected = false
self.leftButton.setTitleColor(UIColor(rgb: 0x2EAFB9), for:.normal)
self.rightButton.setTitleColor(UIColor(rgb: 0x394A5B), for:.normal)
self.tabSelected = 0
self.leftLineView.isHidden = false
self.rightLineView.isHidden = true
} else {
leftButton.isSelected = false
rightButton.isSelected = true
self.rightButton.setTitleColor(UIColor(rgb: 0x2EAFB9), for:.normal)
self.leftButton.setTitleColor(UIColor(rgb: 0x394A5B), for:.normal)
self.tabSelected = 1
self.leftLineView.isHidden = true
self.rightLineView.isHidden = false
}
}
}
......
......@@ -183,7 +183,7 @@ import SwiftEventBus
coupAttributedString.append(coupNormalString2)
coupAttributedString.append(coupBoldString2)
coupAttributedString.append(coupNormalString3)
couponEarnLabel.attributedText = attributedString
couponEarnLabel.attributedText = coupAttributedString
couponEarnAmountLabel.text = totalCouponDiscountString + "€"
......