Protocols

The following protocols are available globally.

  • Subspec: Utility/KeyboardObserver

    override func viewDidLoad() {
        super.viewDidLoad()
        addRecognizerForKeyboardDismissal()
    }
    

    To hide the keyboard when the user taps on the view add the addRecognizerForKeyboardDismissal to the viewDidLoad function.

    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        addKeyboardObservers()
    }
    
    override func viewWillDisappear(_ animated: Bool) {
        super.viewWillDisappear(animated)
        removeKeyboardObservers()
    }
    

    Add the keyboard observer functions to viewWillAppear and viewWillDisappear respectively. Adding them will allow the view controller to call the functions below when the keyboard is shown or hidden.

    override func keyboardWillShow(notification: Notification) {
        // Handle keyboard will show action
    }
    
    override func keyboardWillHide(notification: Notification) {
        // Handle keyboard will hide action
    }
    

    The functions above will be called when the keyboard is shown or hidden.

    See more

    Declaration

    Swift

    public protocol KeyboardObserver
  • Defines a reusable collection or table view cell.

    Subspec: Utility/ReusableView

    func registerCell<T: ReusableView>(cellClass: T.Type) {
        register(T.self, forCellWithReuseIdentifier: T.reuseIdentifier)
    }
    

    Used when registering and dequeuing reuseable cells and the identifier is the same as the class name.

    See more

    Declaration

    Swift

    public protocol ReusableView : AnyObject
  • Delegate of the CalendarPermissionsValidator

    Subspec: Utility/CalendarPermissionsValidator

    extension UIViewController: CalendarPermissionsValidatorDelegate {
    
        public func calendarEventAdded(eventInfo: EventCalendarInfo) {
            let message = "\(eventInfo.title)\("HAPPENING_ADDED_MESSAGE".localized(comment: "Happening added message"))"
            let title = "HAPPENING_ADDED_TITLE".localized(comment: "Happening Added")
            let alert = UIAlertController.singleActionAlertController(title: title, message: message)
            alert.present()
        }
    
        public func calendarPermissionsDenied() {
            let title = "CALENDAR_ACCESS_TITLE".localized(comment: "Calendar Access Title")
            let message = "CALENDAR_ACCESS_MESSAGE".localized(comment: "Calendar Access Message")
            let cancel = "CANCEL_TITLE".localized(comment: "Cancel")
            let settings = "SETTINGS".localized(comment: "Settings")
            let alert = UIAlertController.doubleActionAlertController(title: title,
                                                                      message: message,
                                                                      actionOneTitle: cancel,
                                                                      actionTwoTitle: settings,
                                                                      actionOne: nil) {
                                                                        UIApplication.shared.openSettings()
            }
            alert.present()
        }
    
    }
    

    The CalendarPermissionsValidatorDelegate is used to handler the interactions with the CalendarPermissionsValidator. In the example above we present an alert view to handle when the event is added successfully or when its denied.

    See more

    Declaration

    Swift

    public protocol CalendarPermissionsValidatorDelegate : AnyObject
  • Image Picker Delegate that adopts both UIImagePickerControllerDelegate and UINavigationControllerDelegate.

    Declaration

    Swift

    public protocol ImagePickerDelegate : AnyObject, UIImagePickerControllerDelegate, UINavigationControllerDelegate