fulldecent / FDTake

Easily take a photo or video or choose from library
MIT License
319 stars 121 forks source link

Rewrite library in Swift [NEED ASSISTANCE] #69

Closed fulldecent closed 8 years ago

fulldecent commented 8 years ago

This will bump up iOS requirement to 7.0.

fulldecent commented 8 years ago

Here is the interface I have so far:

public protocol FDTakeDelegate : class {

    /// Delegate method after the user has started a take operation but cancelled it
    public func takeController(controller: FDTakeController, didCancelAfterAttempting madeAttempt: Bool)

    /// Delegate method after the user has started a take operation but it failed
    public func takeController(controller: FDTakeController, didFailAfterAttempting madeAttempt: Bool)

    /// Delegate method after the user has successfully taken or selected a photo
    public func takeController(controller: FDTakeController, gotPhoto photo: UIImage, withInfo info: [NSObject : AnyObject])

    /// Delegate method after the user has successfully taken or selected a video
    public func takeController(controller: FDTakeController, gotVideo video: NSURL, withInfo info: [NSObject : AnyObject])
}

public class FDTakeController : NSObject {

    /// The delegate to receive updates from FDTake
    public weak var delegate: FDTakeDelegate?

    public var allowPhoto: Bool

    public var allowVideo: Bool

    public var allowTake: Bool

    public var allowSelectFromLibrary: Bool

    public var allowEditing: Bool

    public var defaultToFrontCamera: Bool

    public var presentingView: UIView?

    public var presentingRect: CGRect?

    public var presentingTabBar: UITabBar?

    public var presentingViewController: UIViewController?

    /// Custom UI text (skips localization)
    public var takePhotoText: String?

    /// Custom UI text (skips localization)
    public var takeVideoText: String?

    /// Custom UI text (skips localization)
    public var chooseFromLibraryText: String?

    /// Custom UI text (skips localization)
    public var chooseFromPhotoRollText: String?

    /// Custom UI text (skips localization)
    public var cancelText: String?

    /// Custom UI text (skips localization)
    public var noSourcesText: String?

    /**
     *  Presents the user with an option to take a photo or choose a photo from the library
     */
    public func present()

    /**
     *  Dismisses the displayed view (actionsheet or imagepicker).
     *  Especially handy if the sheet is displayed while suspending the app,
     *  and you want to go back to a default state of the UI.
     */
    public func dismiss()
}
fulldecent commented 8 years ago

Please see work in progress in #70

fulldecent commented 8 years ago

Please help in reviewing the PR if you can. This will be an API breaking change and I'm not afraid to break! Suggestions for the API are also welcome.