- Made a selection for the coupon selected, also added no coupon found when coupon is not there - Added Masila view in more section - Added Play trailer from Manila in more section - Gave other connectivity
125 lines
4.4 KiB
Swift
125 lines
4.4 KiB
Swift
//
|
|
// CartPaymentOptionsVC.swift
|
|
// WOKA
|
|
//
|
|
// Created by MacBook Pro on 23/07/24.
|
|
//
|
|
|
|
import UIKit
|
|
|
|
class CartPaymentOptionsVC: UIViewController {
|
|
|
|
@IBOutlet weak var cartTableView: UITableView!
|
|
@IBOutlet weak var cartTableHeight: NSLayoutConstraint!
|
|
@IBOutlet weak var couponTableView: UITableView!
|
|
@IBOutlet weak var couponTableHeght: NSLayoutConstraint!
|
|
@IBOutlet weak var confirmBtn: LocalisedElementsButton!
|
|
@IBOutlet weak var couponCodeTF: TextFieldShadow!
|
|
@IBOutlet weak var totalCartPrice: LocalisedElementsLabel!
|
|
@IBOutlet weak var scrollView: UIScrollView!
|
|
@IBOutlet weak var applyBtn: UIButton!
|
|
|
|
@IBOutlet weak var couponAplliedStack: UIStackView!
|
|
@IBOutlet weak var subtotalPrice: LocalisedElementsLabel!
|
|
@IBOutlet weak var discountPrice: LocalisedElementsLabel!
|
|
@IBOutlet weak var noCouponFound: LocalisedElementsLabel!
|
|
|
|
var vm = CartPaymentOptionsVM()
|
|
|
|
override func viewDidLoad() {
|
|
super.viewDidLoad()
|
|
vm.vc = self
|
|
vm.initView()
|
|
navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default)
|
|
navigationController?.navigationBar.shadowImage = UIImage()
|
|
}
|
|
|
|
override func viewWillAppear(_ animated: Bool) {
|
|
super.viewWillAppear(animated)
|
|
navigationController?.setNavigationBarHidden(false, animated: animated)
|
|
}
|
|
|
|
override func viewDidAppear(_ animated: Bool) {
|
|
self.navigationController?.setColor(color: .white)
|
|
|
|
}
|
|
|
|
override func viewWillDisappear(_ animated: Bool) {
|
|
super.viewWillDisappear(animated)
|
|
self.navigationController?.setNavigationBarHidden(true, animated: animated)
|
|
}
|
|
|
|
override func viewDidDisappear(_ animated: Bool) {
|
|
super.viewDidDisappear(animated)
|
|
|
|
// Customize the navigation bar's appearance
|
|
self.navigationController?.setColor(color: .black)
|
|
}
|
|
|
|
@IBAction func offerCouponBtnTapped(_ sender: UIButton) {
|
|
vm.isExpanded.toggle()
|
|
|
|
if vm.isExpanded{
|
|
sender.setImage(UIImage(systemName: "chevron.down.circle.fill"), for: .normal)
|
|
self.couponTableView.isHidden = false
|
|
}else{
|
|
sender.setImage(UIImage(systemName: "chevron.forward.circle.fill"), for: .normal)
|
|
self.couponTableView.isHidden = true
|
|
}
|
|
}
|
|
|
|
@IBAction func confirmBtnTapped(_ sender: LocalisedElementsButton) {
|
|
}
|
|
|
|
@IBAction func applyBtnTapped(_ sender: UIButton) {
|
|
if self.couponCodeTF.text == "" {
|
|
Utilities.alertWithBtn(title: "", msgBody: "Please enter coupon code", okBtnStr: "OK", vc: self)
|
|
return
|
|
}
|
|
vm.applyCoupon(code: self.couponCodeTF.text!)
|
|
}
|
|
}
|
|
// MARK: - TableView DataSource , Delegates
|
|
|
|
extension CartPaymentOptionsVC : TableViewSRC{
|
|
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
|
if tableView == cartTableView{
|
|
return vm.cartListData.count
|
|
}else{
|
|
return vm.couponData.count
|
|
}
|
|
}
|
|
|
|
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
|
if tableView == cartTableView{
|
|
let cell = tableView.dequeueReusableCell(withIdentifier: K.CellIdentifier.Cart.cartPaymentOptionsCell) as! CartPaymentOptionsCell
|
|
let data = vm.cartListData[indexPath.row]
|
|
cell.setData(data: data)
|
|
return cell
|
|
}else{
|
|
let cell = tableView.dequeueReusableCell(withIdentifier: K.CellIdentifier.Cart.couponCell) as! CouponCell
|
|
let data = vm.couponData[indexPath.row]
|
|
cell.setData(data: data, isSelected: vm.couponCodeSelected == data.couponCode ? true : false)
|
|
return cell
|
|
}
|
|
}
|
|
|
|
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
|
|
if tableView == couponTableView{
|
|
return 60
|
|
}else{
|
|
return UITableView.automaticDimension
|
|
}
|
|
}
|
|
|
|
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
|
if tableView == couponTableView{
|
|
let couponCode = vm.couponData[indexPath.row].couponCode
|
|
vm.couponCodeSelected = vm.couponData[indexPath.row].couponCode ?? ""
|
|
self.couponCodeTF.text = couponCode
|
|
tableView.reloadData()
|
|
}
|
|
}
|
|
}
|
|
|