You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
146 lines
4.4 KiB
146 lines
4.4 KiB
//
|
|
// ConfirmViewController.swift
|
|
// GME Remit
|
|
//
|
|
// Created by InKwon Devik Kim on 07/05/2019.
|
|
// Copyright © 2019 Gobal Money Express Co. Ltd. All rights reserved.
|
|
//
|
|
|
|
import UIKit
|
|
|
|
protocol ConfirmViewControllerDelegate: class {
|
|
func confirm(_ viewController: ConfirmViewController)
|
|
func cancel(_ viewController: ConfirmViewController)
|
|
}
|
|
|
|
struct ConfirmViewControllerConfiguration {
|
|
var title: String? = "confirm_viewconroller_default_title_text".localized()
|
|
var content1: String? = ""
|
|
var content2: String? = ""
|
|
var multiLineContent: String? = ""
|
|
var confirmButtonTitle: String? = "Confirm"
|
|
var cancelButtonTitle: String? = "Cancel"
|
|
}
|
|
|
|
class ConfirmViewController: UIViewController {
|
|
|
|
weak var delegate: ConfirmViewControllerDelegate?
|
|
|
|
private var configure: ConfirmViewControllerConfiguration?
|
|
|
|
@IBOutlet private weak var titleLabel: UILabel!
|
|
@IBOutlet private weak var content1Label: UILabel!
|
|
@IBOutlet private weak var content2Label: UILabel!
|
|
@IBOutlet private weak var multiLineContentLabel: UILabel!
|
|
|
|
@IBOutlet private weak var mainView: UIView!
|
|
|
|
@IBOutlet private weak var confirmButton: UIButton!
|
|
@IBOutlet private weak var cancelButton: UIButton!
|
|
|
|
@IBOutlet weak var receiverTitleLabel: UILabel!
|
|
@IBOutlet weak var mobileNumberTitleLabel: UILabel!
|
|
@IBOutlet weak var branchTitleLabel: UILabel!
|
|
@IBOutlet weak var transparentView: UIView!
|
|
|
|
@IBAction private func touchCancel(_ sender: UIButton) {
|
|
cancel()
|
|
}
|
|
|
|
@IBAction private func touchConfirm(_ sender: UIButton) {
|
|
confirm()
|
|
}
|
|
|
|
override func viewDidLoad() {
|
|
super.viewDidLoad()
|
|
self.roundView()
|
|
|
|
self.titleLabel.text = self.configure?.title
|
|
self.content1Label.text = self.configure?.content1
|
|
self.content2Label.text = self.configure?.content2
|
|
self.multiLineContentLabel.text = self.configure?.multiLineContent
|
|
self.confirmButton.setTitle(self.configure?.confirmButtonTitle, for: .normal)
|
|
// self.cancelButton.setTitle(self.configure?.cancelButtonTitle, for: .normal)
|
|
|
|
setMultiLanguage()
|
|
|
|
self.mainView.invalidateIntrinsicContentSize()
|
|
|
|
let tapGestureRecognizer = UITapGestureRecognizer()
|
|
transparentView.addGestureRecognizer(tapGestureRecognizer)
|
|
|
|
tapGestureRecognizer.addTarget(self, action: #selector(tapGesture(_:)))
|
|
|
|
tapGestureRecognizer.delegate = self
|
|
|
|
confirmButton.backgroundColor = .themeRed
|
|
cancelButton.setTitleColor(.themeRed, for: .normal)
|
|
transparentView.backgroundColor = .themeBackgroundGray
|
|
}
|
|
|
|
@objc func tapGesture(_ sender: UITapGestureRecognizer) {
|
|
touchCancel(UIButton())
|
|
}
|
|
|
|
override func viewWillAppear(_ animated: Bool) {
|
|
super.viewWillAppear(animated)
|
|
mainView.bottomToOrigin()
|
|
}
|
|
|
|
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
|
|
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
|
|
|
|
self.modalPresentationStyle = UIModalPresentationStyle.overCurrentContext
|
|
self.modalTransitionStyle = UIModalTransitionStyle.crossDissolve
|
|
}
|
|
|
|
required init?(coder aDecoder: NSCoder) {
|
|
super.init(coder: aDecoder)
|
|
|
|
self.modalPresentationStyle = UIModalPresentationStyle.overCurrentContext
|
|
self.modalTransitionStyle = UIModalTransitionStyle.crossDissolve
|
|
}
|
|
|
|
func setConfigure(with configure: ConfirmViewControllerConfiguration) {
|
|
self.configure = configure
|
|
}
|
|
|
|
private func roundView() {
|
|
// mainView.layer.cornerRadius = 5
|
|
// confirmButton.layer.cornerRadius = 5
|
|
// cancelButton.layer.cornerRadius = 5
|
|
}
|
|
|
|
private func setMultiLanguage() {
|
|
receiverTitleLabel.text = "receiver_text".localized()
|
|
mobileNumberTitleLabel.text = "mobile_number_text".localized()
|
|
branchTitleLabel.text = "branch_text".localized()
|
|
|
|
// cancelButton.setTitle("cancel_text".localized(), for: .normal)
|
|
//
|
|
confirmButton.setTitle("confirm_text".localized(), for: .normal)
|
|
}
|
|
|
|
private func cancel() {
|
|
mainView.originToBottom {
|
|
self.dismiss(animated: true) {
|
|
self.delegate?.cancel(self)
|
|
}
|
|
}
|
|
}
|
|
|
|
private func confirm() {
|
|
mainView.originToBottom {
|
|
self.dismiss(animated: true) {
|
|
print("Touched Confirm!")
|
|
self.delegate?.confirm(self)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
extension ConfirmViewController: UIGestureRecognizerDelegate {
|
|
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldReceive touch: UITouch) -> Bool {
|
|
return touch.view == gestureRecognizer.view
|
|
}
|
|
}
|