drawRect / Instagram_Stories

Inspired by Instagram Stories functionality. This source is similar to Instagram Stories, which is having both image and video support.
MIT License
414 stars 76 forks source link

[META] Where are all the instructions? #106

Closed Ludotrico closed 4 years ago

Ludotrico commented 4 years ago

I have read through the read-me but I have been unable to find how to use the library. The how-to-use section seems like it is missing instructions. Is there documentation elsewhere that explains how to implement the library properly and populate the views with our own JSON objects?

Extra: This library seems to not be on CocoaPods, why? Since it is not, how can one add the library to an existing application?

boominadhaprakash commented 4 years ago

Hi @Ludotrico

We have created Instagram Stories as a sample project. It has two main ViewControllers. One is IGHomeViewController and another one is IGStoryPreviewController. It is not a library. You can just follow what we have mentioned in the How To Use section.

Let us know the missing instructions and what difficulties you are facing when you use our code in your project. We will update our ReadMe file with missing instructions.

In future we will think about making it as library and will release as pods.

ranmyfriend commented 4 years ago

Hi @Ludotrico

Questions you were asked in the Mail-chain:

1) Is a video time limit imposed at all? If a video URL for a single snap is 60 seconds long what will happen? Do you expect that each snap is less than x seconds? 2) As of now, the code positions the collection views of stories so that it is pinned to the navigation bar. In my app's use case, I must have the collection view of stories (IGHomeView) in a specific location and size, how would you suggest relocating and resizing the IGHomeView without breaking anything?

Our Thoughts:

1)As we have given the create story functionality to the developer like you. If you want to keep some constraint from your side, you can limit your end-user to record video up to 60Sec. But from our side, The Instagram stories we did not keep any restrictions rite now. whatever the length of the video it will load with help of the snap.videoURL

2)It's up to you, first try to implement and go with your inputs and doubts and put all those things in real code. And if you are facing any issues then feel free to reply back to this thread

Ludotrico commented 4 years ago

I have spent the last hour attempting to reposition the collection view for my specific needs and each time the collection view disappears when you make any gesture on it. I have simplified an example so that it can be easily replicated. I have a TestVC that creates a rectangle in the middle of the screen. I then pin IGHomeController's view to that rectangle. I have tried every variation I could think of with no avail:

class TestVC: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        view.backgroundColor = UIColor.systemTeal

        setup()
    }

    func setup() {
        let rect = UIView()
        rect.backgroundColor = .blue
        rect.translatesAutoresizingMaskIntoConstraints = false

        //Create Blue rectangle in the middle of the screen (width x 100)
        view.addSubview(rect)
        rect.anchor(top: nil, left: nil, bottom: nil, right: nil, centerX: view.centerXAnchor, centerY: view.centerYAnchor, paddingTop: 0, paddingLeft: 0, paddingBottom: 0, paddingRight: 0, width: view.frame.width, height: 100)

        let homeView = IGHomeController()
        rect.addSubview(homeView.view)
        homeView.view.anchor(top: rect.topAnchor, left: rect.leftAnchor, bottom: rect.bottomAnchor, right: rect.rightAnchor, paddingTop: 0, paddingLeft: 0, paddingBottom: 0, paddingRight: 0)

    }
}

Any suggestions as to why the IGHomeController's view does not like to be repositioned?

boominadhaprakash commented 4 years ago

Hi @Ludotrico

Can you share the output screenshot of your existing code and what is the output you are expecting?

Ludotrico commented 4 years ago

Here you can clearly see the blue rectangle in the middle of the view. I anchored the IGHomeController to the blue rectangle. However the second I touch (swipe, tap) the collection view in any way, it simply disappears as you can see in the final picture.

Let me know if you understand how to correctly reposition the collection view anywhere on the screen (eg. the middle of the screen).

boominadhaprakash commented 4 years ago

Hi @Ludotrico

IGHomeViewController itself testVC. You can modify IGHomeViewController and achieve whatever you want.

Otherwise you can directly take IGHomeViewController's CollectionView and its delegate methods to your testVC.

Ludotrico commented 4 years ago

Got it working to my liking, thanks! Couple more questions:

1.) How extensive is the caching system? Is all media cached, including profile pictures, snap images, and snap videos? 2.) I see that there is a function that clears the cache. Does the existing cache implementation clean itself? If not, when should I call this function?

@boominadhaprakash @ranmyfriend

boominadhaprakash commented 4 years ago

Hi @Ludotrico

Caching: We have used our own logic for caching the images including profile pictures, snap images and snap videos.

Clear Cache: Currently we have set 100MB for Image Cache. For Video we didn't set any cache limit. You can check the Image cache limit in Source --> ImageStorer --> IGCache.swift. Video Cache functionality implemented in IGVideoCacheManager. Deleting the cache files completely depends on User's logic. Each story's snap life time is 24 hours. So, once the snap's life time gets over, you can implement clear cache functionality.

ranmyfriend commented 4 years ago

I hope we have given enough information regarding this library usage in your project. Am closing this issue it for now. If you need any help in future. feel free to open it.