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.

36 lines
854 B

5 years ago
  1. //
  2. // GMETextField.swift
  3. // GME Remit
  4. //
  5. // Created by InKwon Devik Kim on 08/07/2019.
  6. // Copyright © 2019 Gobal Money Express Co. Ltd. All rights reserved.
  7. //
  8. import UIKit
  9. class GMENumberTextField: UITextField {
  10. private var customerNativeCountry: String?
  11. var receiverNativeCountry: String = "" {
  12. didSet {
  13. selectKeyboardType()
  14. }
  15. }
  16. required init?(coder aDecoder: NSCoder) {
  17. super.init(coder: aDecoder)
  18. keyboardType = .numberPad
  19. customerNativeCountry = GMEDB.shared.user.string(.countryCode)
  20. selectKeyboardType()
  21. }
  22. private func selectKeyboardType() {
  23. guard let customerNativeCountry = customerNativeCountry else { return }
  24. if customerNativeCountry == "KH" || receiverNativeCountry == "KH" {
  25. keyboardType = .asciiCapable
  26. } else {
  27. keyboardType = .numberPad
  28. }
  29. }
  30. }