// // AccountViewProtectionLevel.swift // Wallet // // Created by Saveliy Stavitsky on 12/11/20. // Copyright © 2020 List. All rights reserved. // import UIKit import IQKeyboardManagerSwift final class AccountViewProtectionLevel: CommonViewCustom { @IBOutlet private weak var levelImgView: UIImageView! @IBOutlet private weak var levelTextLabel: UILabel! @IBOutlet private weak var levelSegment: UISegmentedControl! @IBOutlet private weak var submitBtn: UIButton! var didSubmit: ((Bool) -> Void)? override func setup() { super.setup() levelSegment.setTitle(L10n.Account.Settings.Protection.levelExtendedTitle, forSegmentAt: 0) levelSegment.setTitle(L10n.Account.Settings.Protection.levelSimpleTitle, forSegmentAt: 1) let paragraph = NSMutableParagraphStyle() paragraph.lineHeightMultiple = 1.15 paragraph.alignment = .center if UserDefaults.standard.bool(forKey: "isPinPwdMode") { levelImgView.image = Asset.accountSecurityOff.image levelTextLabel.text = L10n.Account.Settings.Protection.levelSimpleDescription levelSegment.selectedSegmentIndex = 1 } else { levelImgView.image = Asset.accountSecurityOn.image levelTextLabel.text = L10n.Account.Settings.Protection.levelExtendedDescription levelSegment.selectedSegmentIndex = 0 } } @IBAction private func onSubmit(_ : AnyObject?) { if (UserDefaults.standard.bool(forKey: "isPinPwdMode") && levelSegment.selectedSegmentIndex == 1) || (!UserDefaults.standard.bool(forKey: "isPinPwdMode") && levelSegment.selectedSegmentIndex == 0) { didSubmit?(false) } else { didSubmit?(true) } } @IBAction func valueChanged(_ sender: Any) { let paragraph = NSMutableParagraphStyle() paragraph.lineHeightMultiple = 1.15 paragraph.alignment = .center if levelSegment.selectedSegmentIndex == 0 { levelImgView.image = Asset.accountSecurityOn.image // levelTextLabel.text = L10n.Account.Settings.Protection.levelSimpleDescription levelTextLabel.text = L10n.Account.Settings.Protection.levelExtendedDescription } else { levelImgView.image = Asset.accountSecurityOff.image // llevelTextLabel.text = L10n.Account.Settings.Protection.levelExtendedDescription levelTextLabel.text = L10n.Account.Settings.Protection.levelSimpleDescription } } }