IOS-1716 adds easter egg gesture recognizer and skeletons for its handlers IOS-1716
authorbuff <andreas@pep-project.org>
Tue, 13 Aug 2019 13:41:21 +0200
branchIOS-1716
changeset 96636d18a1c2c1a7
parent 9662 4ed3346fde76
child 9664 b5270087022b
IOS-1716 adds easter egg gesture recognizer and skeletons for its handlers
pEpForiOS/UI/Settings/SettingsTableViewController.swift
pEpForiOS/UI/Settings/ViewModel/SettingsViewModel.swift
     1.1 --- a/pEpForiOS/UI/Settings/SettingsTableViewController.swift	Tue Aug 13 11:00:27 2019 +0200
     1.2 +++ b/pEpForiOS/UI/Settings/SettingsTableViewController.swift	Tue Aug 13 13:41:21 2019 +0200
     1.3 @@ -28,6 +28,7 @@
     1.4          super.viewDidLoad()
     1.5          title = NSLocalizedString("Settings", comment: "Settings view title")
     1.6          UIHelper.variableCellHeightsTableView(tableView)
     1.7 +        addExtraKeysEditabilityToggleGesture()
     1.8      }
     1.9  
    1.10      override func viewWillAppear(_ animated: Bool) {
    1.11 @@ -44,6 +45,24 @@
    1.12          updateModel()
    1.13      }
    1.14  
    1.15 +    //BUFF: move to extension
    1.16 +
    1.17 +    /// Adds easter egg gesture to [en|dis]able the editability of extra keys
    1.18 +    private func addExtraKeysEditabilityToggleGesture() {
    1.19 +        let gestureRecogniser =
    1.20 +            UITapGestureRecognizer(target: self,
    1.21 +                                   action: Selector(("extraKeysEditabilityToggleGestureTriggered")))
    1.22 +        gestureRecogniser.numberOfTapsRequired = 6
    1.23 +        gestureRecogniser.numberOfTouchesRequired = 3
    1.24 +        tableView.addGestureRecognizer(gestureRecogniser)
    1.25 +    }
    1.26 +
    1.27 +    private func extraKeysEditabilityToggleGestureTriggered() {
    1.28 +        viewModel.handleExtryKeysEditabilityGestureTriggered()
    1.29 +    }
    1.30 +
    1.31 +
    1.32 +
    1.33      override func viewWillDisappear(_ animated: Bool) {
    1.34          self.navigationController?.setToolbarHidden(oldToolbarStatus, animated: false)
    1.35          guard let isIphone = splitViewController?.isCollapsed else {
     2.1 --- a/pEpForiOS/UI/Settings/ViewModel/SettingsViewModel.swift	Tue Aug 13 11:00:27 2019 +0200
     2.2 +++ b/pEpForiOS/UI/Settings/ViewModel/SettingsViewModel.swift	Tue Aug 13 13:41:21 2019 +0200
     2.3 @@ -9,15 +9,22 @@
     2.4  import Foundation
     2.5  import MessageModel
     2.6  
     2.7 +protocol SettingsViewModelDelegate: class {
     2.8 +    func showExtraKeyEditabilityStateChangeAlert(newValue: Bool)
     2.9 +}
    2.10 +
    2.11  final class SettingsViewModel {
    2.12 +    weak var deletage: SettingsViewModelDelegate?
    2.13      var sections = [SettingsSectionViewModel]()
    2.14      private let keySyncDeviceGroupService: KeySyncDeviceGroupServiceProtocol?
    2.15      private let messageModelService: MessageModelServiceProtocol
    2.16  
    2.17      init(_ messageModelService: MessageModelServiceProtocol,
    2.18 -         _ keySyncDeviceGroupService: KeySyncDeviceGroupServiceProtocol = KeySyncDeviceGroupService()) {
    2.19 +         _ keySyncDeviceGroupService: KeySyncDeviceGroupServiceProtocol = KeySyncDeviceGroupService(),
    2.20 +         deletage: SettingsViewModelDelegate? = nil) {
    2.21          self.keySyncDeviceGroupService = keySyncDeviceGroupService
    2.22          self.messageModelService = messageModelService
    2.23 +        self.deletage = deletage
    2.24          generateSections()
    2.25      }
    2.26  
    2.27 @@ -77,6 +84,7 @@
    2.28  }
    2.29  
    2.30  // MARK: - Private
    2.31 +
    2.32  extension SettingsViewModel {
    2.33      private func sectionIsValid(section: Int) -> Bool {
    2.34          return section >= 0 && section < sections.count
    2.35 @@ -91,3 +99,12 @@
    2.36          }
    2.37      }
    2.38  }
    2.39 +
    2.40 +// MARK: - ExtryKeysEditability
    2.41 +
    2.42 +extension SettingsViewModel {
    2.43 +    func handleExtryKeysEditabilityGestureTriggered() {
    2.44 +        fatalError("BUFF: unimplemented stub")
    2.45 +//        deletage?.showExtraKeyEditabilityStateChangeAlert(newValue: <#T##Bool#>)
    2.46 +    }
    2.47 +}