Skip to content

Activity Control

FUIActivityControl

open class FUIActivityControl: NibDesignable, FUIBackgroundSchemeSupporting

FUIActivityControl is a stand-alone component supporting user activities. By default, it supports phone, email, message, videoCall. FUIContactCell embed with a FUIActivityControl by default.

Code Usage

 //You can create your own activity object if you want.
 let myCustomActivity = FUIActivityItem(icon: UIImage(named: "asset"), identifier: "mycustomer.twilio")
 let activities: [FUIActivityItem] = [FUIActivityItem.phone, FUIActivityItem.message, myCustomActivity]

 //Create a FUIActivityControl object.
 let activityControl = FUIActivityControl()
 activityControl.addActivities(activities)
 activityControl.delegate = self

 //Optionally, set an item size (if nil, intrinsic size of image will be used)
 activityControl.itemSize = CGSize(width: 44.0, height: 44.0)

 //Optionally, set a limit to visible items (useful for hiding items in `.compact` horizontal mode)
 activityControl.maxVisibleItems = 3

 //Optionally, set the inter-item spacing (useful for showing more items in `.compact` horizontal mode)
 activityControl.spacing = 10.0

 //Implement this method in your class to handle action.
 func activityControl(_ activityControl: FUIActivityControl, didSelectActivity activityItem: FUIActivityItem) {
     switch activityItem {
         case FUIActivityItem.phone:
            //do something
         case FUIActivityItem.message:
            //do something
         case myCustomActivity:
            //do something
         default:
            break
     }
 }

Attention

The delegate object with type FUIActivityControlDelegate is declared as a weak reference. So on deallocation it will be automatically set to nil. To keep it alive as expected, developer should retain the delegate object during its whole execution scope.


Last update: April 14, 2021