FSSwitchDataSource.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #import <UIKit/UIKit.h>
  2. #import "FSSwitchState.h"
  3. @protocol FSSwitchDataSource <NSObject>
  4. @optional
  5. - (FSSwitchState)stateForSwitchIdentifier:(NSString *)switchIdentifier;
  6. // Gets the current state of the switch.
  7. // Must override if building a settings-like switch.
  8. // Return FSSwitchStateIndeterminate if switch is loading
  9. // By default returns FSSwitchStateIndeterminate
  10. - (void)applyState:(FSSwitchState)newState forSwitchIdentifier:(NSString *)switchIdentifier;
  11. // Sets the new state of the switch
  12. // Must override if building a settings-like switch.
  13. // By default calls through to applyActionForSwitchIdentifier: if newState is different from the current state
  14. - (void)applyActionForSwitchIdentifier:(NSString *)switchIdentifier;
  15. // Runs the default action for the switch.
  16. // Must override if building an action-like switch.
  17. // By default calls through to applyState:forSwitchIdentifier: if state is not indeterminate
  18. - (NSString *)titleForSwitchIdentifier:(NSString *)switchIdentifier;
  19. // Returns the localized title for the switch.
  20. // By default reads the CFBundleDisplayName out of the switch's bundle.
  21. - (BOOL)shouldShowSwitchIdentifier:(NSString *)switchIdentifier;
  22. // Returns wether the switch should be shown.
  23. // By default returns YES or the value from GraphicsServices for the capability specified in the "required-capability-key" of the switch's bundle
  24. // E.g. You would detect if the device has the required capability (3G, flash etc)
  25. - (id)glyphImageDescriptorOfState:(FSSwitchState)switchState size:(CGFloat)size scale:(CGFloat)scale forSwitchIdentifier:(NSString *)switchIdentifier;
  26. // Provide an image descriptor that best displays at the requested size and scale
  27. // By default looks through the bundle to find a glyph image
  28. - (NSBundle *)bundleForSwitchIdentifier:(NSString *)switchIdentifier;
  29. // Provides a bundle to look for localizations/images in
  30. // By default returns the bundle for the current class
  31. - (void)switchWasRegisteredForIdentifier:(NSString *)switchIdentifier;
  32. // Called when switch is first registered
  33. - (void)switchWasUnregisteredForIdentifier:(NSString *)switchIdentifier;
  34. // Called when switch is unregistered
  35. - (BOOL)hasAlternateActionForSwitchIdentifier:(NSString *)switchIdentifier;
  36. // Gets whether the switch supports an alternate or "hold" action
  37. // By default queries if switch responds to applyAlternateActionForSwitchIdentifier: or if it has a "alternate-action-url" key set
  38. - (void)applyAlternateActionForSwitchIdentifier:(NSString *)switchIdentifier;
  39. // Applies the alternate or "hold" action
  40. // By default launches the URL stored in the "alternate-action-url" key of the switch's bundle
  41. @end