IOS-1716 shows alert with new value when easteregg is triggered IOS-1716
authorbuff <andreas@pep-project.org>
Tue, 13 Aug 2019 14:26:26 +0200
branchIOS-1716
changeset 9665a739423ea8bb
parent 9664 b5270087022b
child 9666 12ee11079879
IOS-1716 shows alert with new value when easteregg is triggered
pEpForiOS/UI/Settings/SettingsTableViewController.swift
pEpForiOS/UI/Settings/ViewModel/SettingsViewModel.swift
     1.1 --- a/pEpForiOS/UI/Settings/SettingsTableViewController.swift	Tue Aug 13 14:14:17 2019 +0200
     1.2 +++ b/pEpForiOS/UI/Settings/SettingsTableViewController.swift	Tue Aug 13 14:26:26 2019 +0200
     1.3 @@ -38,7 +38,9 @@
     1.4          }
     1.5          self.navigationController?.setToolbarHidden(true, animated: false)
     1.6  
     1.7 -        if MiscUtil.isUnitTest() {
     1.8 +        viewModel.delegate = self
     1.9 +
    1.10 +        if MiscUtil.isUnitTest() { //!!!: must go away. Check if it is needless already and rm.
    1.11              super.viewWillAppear(animated)
    1.12              return
    1.13          }
    1.14 @@ -336,3 +338,14 @@
    1.15          }
    1.16      }
    1.17  }
    1.18 +
    1.19 +// MARK: - SettingsViewModelDelegate
    1.20 +
    1.21 +extension SettingsTableViewController: SettingsViewModelDelegate {
    1.22 +
    1.23 +    func showExtraKeyEditabilityStateChangeAlert(newValue: String) {
    1.24 +        UIUtils.showAlertWithOnlyPositiveButton(title: "Extra Keys Editable",
    1.25 +                                                message: newValue,
    1.26 +                                                inViewController: self)
    1.27 +    }
    1.28 +}
     2.1 --- a/pEpForiOS/UI/Settings/ViewModel/SettingsViewModel.swift	Tue Aug 13 14:14:17 2019 +0200
     2.2 +++ b/pEpForiOS/UI/Settings/ViewModel/SettingsViewModel.swift	Tue Aug 13 14:26:26 2019 +0200
     2.3 @@ -10,21 +10,21 @@
     2.4  import MessageModel
     2.5  
     2.6  protocol SettingsViewModelDelegate: class {
     2.7 -    func showExtraKeyEditabilityStateChangeAlert(newValue: Bool)
     2.8 +    func showExtraKeyEditabilityStateChangeAlert(newValue: String)
     2.9  }
    2.10  
    2.11  final class SettingsViewModel {
    2.12 -    weak var deletage: SettingsViewModelDelegate?
    2.13 +    weak var delegate: SettingsViewModelDelegate?
    2.14      var sections = [SettingsSectionViewModel]()
    2.15      private let keySyncDeviceGroupService: KeySyncDeviceGroupServiceProtocol?
    2.16      private let messageModelService: MessageModelServiceProtocol
    2.17  
    2.18      init(_ messageModelService: MessageModelServiceProtocol,
    2.19           _ keySyncDeviceGroupService: KeySyncDeviceGroupServiceProtocol = KeySyncDeviceGroupService(),
    2.20 -         deletage: SettingsViewModelDelegate? = nil) {
    2.21 +         delegate: SettingsViewModelDelegate? = nil) {
    2.22          self.keySyncDeviceGroupService = keySyncDeviceGroupService
    2.23          self.messageModelService = messageModelService
    2.24 -        self.deletage = deletage
    2.25 +        self.delegate = delegate
    2.26          generateSections()
    2.27      }
    2.28  
    2.29 @@ -103,8 +103,10 @@
    2.30  // MARK: - ExtryKeysEditability
    2.31  
    2.32  extension SettingsViewModel {
    2.33 +
    2.34      func handleExtryKeysEditabilityGestureTriggered() {
    2.35 -        fatalError("BUFF: unimplemented stub")
    2.36 -//        deletage?.showExtraKeyEditabilityStateChangeAlert(newValue: <#T##Bool#>)
    2.37 +        let newValue = !AppSettings.extraKeysEditable
    2.38 +        AppSettings.extraKeysEditable = newValue
    2.39 +        delegate?.showExtraKeyEditabilityStateChangeAlert(newValue: newValue ? "ON" : "OFF")
    2.40      }
    2.41  }