78 lines
2.8 KiB
Swift
78 lines
2.8 KiB
Swift
//
|
|
// AccountViewSettings.swift
|
|
// Wallet
|
|
//
|
|
// Created by Igor Danich on 30.08.2020.
|
|
// Copyright © 2020 List. All rights reserved.
|
|
//
|
|
|
|
import UIKit
|
|
import Combine
|
|
|
|
final class AccountViewSettings: CommonViewCustom {
|
|
|
|
enum Action {
|
|
case password
|
|
case about
|
|
case changeInterfaceStyle
|
|
case changeProtection
|
|
}
|
|
|
|
@IBOutlet weak var notificationsEnabledLabel: UILabel!
|
|
|
|
@IBOutlet private weak var notificationsView: UIStackView!
|
|
@IBOutlet private weak var biometricksLbl: UILabel!
|
|
@IBOutlet private weak var biometricksSwitch: UISwitch!
|
|
@IBOutlet private weak var passwordTitlesLbl: UILabel!
|
|
@IBOutlet private weak var versionLbl: UILabel!
|
|
|
|
private let actionSubject = PassthroughSubject<Action, Never>()
|
|
lazy var actionPublisher: AnyPublisher<Action, Never> = self.actionSubject.eraseToAnyPublisher()
|
|
|
|
override func setup() {
|
|
super.setup()
|
|
|
|
self.notificationsView.isUserInteractionEnabled = true
|
|
self.notificationsView.addGestureRecognizer(UITapGestureRecognizer(target: self,
|
|
action: #selector(self.onNotifications)))
|
|
|
|
self.biometricksSwitch.isEnabled = Account.Service.isBiometricksAvailable
|
|
self.biometricksSwitch.isOn = Account.Service.isBiometricksEnabled
|
|
self.biometricksLbl.text = Account.Service.isFaceIdAvailable ? L10n.Account.Settings.faceId : L10n.Account.Settings.touchId
|
|
self.passwordTitlesLbl.text = UserDefaults.standard.bool(forKey: "isPinPwdMode") ? L10n.Account.Settings.pin : L10n.Account.Settings.password
|
|
self.versionLbl.text = "\(Bundle.main.major).\(Bundle.main.minor).\(Bundle.main.patch) (\(Bundle.main.buildNumber))"
|
|
}
|
|
|
|
@objc private func onNotifications() {
|
|
if let appSettings = URL(string: UIApplication.openSettingsURLString), UIApplication.shared.canOpenURL(appSettings) {
|
|
UIApplication.shared.open(appSettings)
|
|
}
|
|
}
|
|
|
|
@IBAction private func onBiometricks(_ : AnyObject?) {
|
|
if self.biometricksSwitch.isOn {
|
|
Account.Service.checkBiometricks { [weak self] (success) in
|
|
self?.biometricksSwitch.isOn = success
|
|
}
|
|
} else {
|
|
Account.Service.isBiometricksEnabled = false
|
|
}
|
|
}
|
|
|
|
@IBAction private func onPassword(_ : AnyObject?) {
|
|
self.actionSubject.send(.password)
|
|
}
|
|
|
|
@IBAction private func onAbout(_ : AnyObject?) {
|
|
self.actionSubject.send(.about)
|
|
}
|
|
|
|
@IBAction private func onChangeInterfaceStyle(_ sender: Any) {
|
|
self.actionSubject.send(.changeInterfaceStyle)
|
|
}
|
|
|
|
@IBAction private func onChangeProtection(_ sender: Any) {
|
|
self.actionSubject.send(.changeProtection)
|
|
}
|
|
}
|