Skip to content

MZStoryPreviewer is a simple reusable component for previewing users stories in an elegant way.

License

Notifications You must be signed in to change notification settings

mhmdzaid/MZStoryPreviewer

Repository files navigation

MZStoryPreviewer

CI Status Version License Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

GIF

Requirements

Installation

MZStoryPreviewer is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'MZStoryPreviewer'

Usage

In your storyboard file give your UIView class MZStoryPreviewer and make it inherite from MZStoryPreviewer doc

Then drag outlet of your view and import MZStoryPreviewer After that conform your ViewController to MZStoryPreviewerDataSource and MZStoryPreviewerDelegate

extension ViewController: MZStoryPreviewerDataSource, MZStoryPreviewerDelegate {
    
    func mzStoryPreviewer(_ previewer: MZStoryPreviewer, didSelectItemAt: Int) {
        
    }
    func mzStoryPreviewer(storyUsersFor previewer: MZStoryPreviewer) -> [MZStoryUser] {
        return users
    }
}

By assuming that each user have an array of stories and each story has a type , you have two Protocols create your custom models for User and Story DataModel and conform to MZStoryUser for user and MZStoryItem for the story

public protocol MZStoryUser{
    var userName : String{get}
    var userImageURLPath : String?{get}
    var userStoryItems : [MZStoryItem]{get}
}
//-----------------------------------
public protocol MZStoryItem {
    var type: MZStoryItemType { get set }
    var image: UIImage? { get }
    var url: URL? { get }
    var duration  : TimeInterval {get set}
}

Author

mozead1996, mohamedzead2021@gmail.com

License

MZStoryPreviewer is available under the MIT license. See the LICENSE file for more info.

About

MZStoryPreviewer is a simple reusable component for previewing users stories in an elegant way.

Resources

License

Stars

Watchers

Forks

Packages

No packages published