A deep copy of Pinterest in Swift

Overview

alt text

Demo

YouTube: Demo (2 minutes)
优酷:http://v.youku.com/v_show/id_XMzE3OTc5NDY2MA==.html?spm=a2h3j.8428770.3416059.1

The app is actually smoother than shown in the video. Download the zip file and do a build-and-run on real device. The simulator could get laggy sometimes.

Purpose

This project copies Pinterest's Home and Discover modules, without any third-party library just for the purpose of practicing my iOS fundamentals.

I use a random data generator for random size pictures because I want more controls of the data and simplicity.

The "layout" I mentioned below is referred to UICollectionViewLayout or its subclass, not the "AutoLayout" haha.

Further Optimization

I found there’s a little bit frame dropped when first load a AHDetailVC(after selecting a pin cell) then immediately scroll.

  1. A more sophisticated networking tool and an image rendering method are needed. I saw some developers literally draw their cell's content on a graphics image context asynchronously in order to reduce layers in the cell and increase rendering speed, which is awesome.

  2. Pinterest uses Texture(or AsyncDisplayKit) to render graphics. I will dig into this monster framework later.

  3. Make all methods and properties have more specific access control in order to get the most out of the Whole Module Optimization under Swift

  4. Use Realm or Firebase for Discover search feature which I didn't implement. But I think I did a good job demonstrating Pinterest's most beautiful designs and I should stop from here.

Final Words

I give myself a B+ for this project because it doesn’t support media which could a bit trickier for performance and I cheated a little bit by caching the same sizes' images (I didn’t wanna get throttled by placeholder sites) -- this makes the networking less busy. And in real app, most images are different and have to be downloaded first.

And I like my layout router idea — one collectionView has multiple different layouts. Each custom layout has its own section. And in each section, regular cell attributes, supplement attributes as well as decoration attributes are all relative to their own section. You can always start layout attributes from point(0,0) and the layoutRouter will normalized all those attributes later. This means each custom layout is relatively independent and plugabble.

If you have a more simple solution than this router one, let me know. I’ll buy you a lunch ;)

Some Important Class Descriptions

1. Most important components for the Home view controller(AHPinVC):

AHCollectionVC: A UICollectionViewController with a layout router and some associated methods to make multiple layouts in the same collectionView possible.

AHPinVC: A subclass of AHCollectionVC and it handles cell selections and data loadings. It’s added with features like header/footer refresh controls, water fall layout, option popup animation when long press a cell. All those features are all modular. You can turn them on and off. And when a cell is selected, this VC pushes a AHDetailVC into the navigation stack.

AHDetailVC: A page view controller acting as a detail pin gallery, written with a collectionView attached a flowLayout. This VC has only AHPageCell — a placeholder cell for other VCs.

AHPinContentVC: A subclass of AHPinVC. It lives within a AHPageCell. It’s added a AHPinContentLayout before the inherited water fall layout, to show the large image of the pin cell which was selected then pushed from AHPinVC. The VC also has a drag-to-dismiss transition animation along with the long press popup animation.

2. Most important components for the Discover view controller:

AHDiscoverVC: It’s also a page VC written in collectionView like AHDetailVC. And it has a category navBar and a AHDiscoverCategoryVC.

AHDiscoverCategoryVC: A subclass of AHPinVC, added a native UICollectionViewFlowLayout-liked layout before the water fall layout.

You might also like...
 ZPPRouter 组件化路由 swift
ZPPRouter 组件化路由 swift

ZPPRouter 面向组件协议 组件获取实例为协议类型 注: SPM 每一个组件最终生成的都是 framwork库 意味着组件存在命名空间(优点) Example To run the example project, clone the repo, and run pod install fro

RoutingKit - Routing library With Swift

RoutingKit Usage struct MessageBody: Body { typealias Response = String

A simple, powerful and elegant implementation of the coordinator template in Swift for UIKit
A simple, powerful and elegant implementation of the coordinator template in Swift for UIKit

A simple, powerful and elegant implementation of the coordinator template in Swift for UIKit Installation Swift Package Manager https://github.com/bar

🔍 Awesome fully customize search view like Pinterest written in Swift 5.0 + Realm support!
🔍 Awesome fully customize search view like Pinterest written in Swift 5.0 + Realm support!

YNSearch + Realm Support Updates See CHANGELOG for details Intoduction 🔍 Awesome search view, written in Swift 5.0, appears search view like Pinteres

This is a Swift based demo project to show how to make the transition Pinterest liked.
This is a Swift based demo project to show how to make the transition Pinterest liked.

PinterestSwift Compatible with Xcode 11 / Swift 5.0 This is a Swift based demo project to show how to make the transition Pinterest 2.0+ liked. Refer

🔍 Awesome fully customize search view like Pinterest written in Swift 5.0 + Realm support!
🔍 Awesome fully customize search view like Pinterest written in Swift 5.0 + Realm support!

YNSearch + Realm Support Updates See CHANGELOG for details Intoduction 🔍 Awesome search view, written in Swift 5.0, appears search view like Pinteres

🥺Pinterest Layout Tutorial
🥺Pinterest Layout Tutorial

PinterestTutorial-iOS 🥺 Pinterest Layout Tutorial 이미지 크기에 따라서 동적으로 셀의 레이아웃을 설정하는 핀터레스트 레이아웃 구현해 보았다. 완성 코드 UICollectionViewDelegateFlowLayout 의 서브클래스

Context menu similar to the one in the Pinterest iOS app
Context menu similar to the one in the Pinterest iOS app

VLDContextSheet A clone of the Pinterest iOS app context menu. Example Usage VLDContextSheetItem *item1 = [[VLDContextSheetItem alloc] initWithTitle:

A Pinterest-like segment control with masking animation.
A Pinterest-like segment control with masking animation.

PinterestSegment A Pinterest-like segment control with masking animation. Requirements iOS 8.0+ Xcode 9.0 Swift 4.0 Installation CocoaPods You can use

The waterfall (i.e., Pinterest-like) layout for UICollectionView.
The waterfall (i.e., Pinterest-like) layout for UICollectionView.

CHTCollectionViewWaterfallLayout CHTCollectionViewWaterfallLayout is a subclass of UICollectionViewLayout, and it trys to imitate UICollectionViewFlow

SwiftUI views that arrange their children in a Pinterest-like layout
SwiftUI views that arrange their children in a Pinterest-like layout

SwiftUI Masonry SwiftUI views that arrange their children in a Pinterest-like layout. HMasonry A view that arranges its children in a horizontal mason

UI Component. This is a copy swipe-panel from app: Apple Maps, Stocks. Swift version
UI Component. This is a copy swipe-panel from app: Apple Maps, Stocks. Swift version

ContainerController UI Component. This is a copy swipe-panel from app: https://www.apple.com/ios/maps/ Preview Requirements Installation CocoaPods Swi

Swift UI Demo for an instagram copy

InstaFake-Swift-UI Swift UI Demo for an instagram copy @ WWDC 2019 Why? This is a quick attempt to replicate the UI of a particular photo sharing app.

This is my copy of the "Ultimate Portfolio Project" tutorial series in Hacking with Swift+.

UltimatePortfolio This is my version of the "Ultimate Portfolio Project" tutorial series in Hacking with Swift+. I What have I learned in this series?

ipatool is a command line tool that allows you to search for iOS apps on the App Store and download a copy of the app package, known as an ipa file.
ipatool is a command line tool that allows you to search for iOS apps on the App Store and download a copy of the app package, known as an ipa file.

ipatool is a command line tool that allows you to search for iOS apps on the App Store and download a copy of the app package, known as an ipa file.

CollectionComposer2 - Copy random image files from various sources to destination folder - ready to use

CollectionComposer2 This is a small tool to copy a random number of image files from different source folders to a destination folder. As an additiona

SocialDownloaderApp - An exact copy of Social Downloader App by Sulton Handaya For Pelorous

SocialDownloaderApp It is a copy of Social Downloader App by Sulton Handaya For

🧰  MacOS menubar for easy copy gitmoji
🧰 MacOS menubar for easy copy gitmoji

gitmojiBar Introdution 🔍 🧰 MacOS status bar for easy copy gitmoji emoticons, Written in Swift 5.0 Preview 👀 Requirements gitmoji-bar written in Swi

🧰 MacOS menubar for easy copy gitmoji

gitmojiBar Introdution 🔍 🧰 MacOS status bar for easy copy gitmoji emoticons, Written in Swift 5.0 Preview 👀 gitmojibar.mov AppStore Requirements gi

Owner
Andy Tong
Andy Tong
Eugene Kazaev 713 Dec 25, 2022
An open source library for building deep-linkable SwiftUI applications with composition, testing and ergonomics in mind

Composable Navigator An open source library for building deep-linkable SwiftUI applications with composition, testing and ergonomics in mind Vanilla S

Bahn-X 538 Dec 8, 2022
Appz 📱 Launch external apps, and deeplink, with ease using Swift!

Appz ?? Deeplinking to external applications made easy Highlights Web Fallback Support: In case the app can't open the external application, it will f

Kitz 1.1k May 5, 2021
LiteRoute is easy transition for your app. Written on Swift 4

LiteRoute Description LiteRoute is easy transition between VIPER modules, who implemented on pure Swift. We can transition between your modules very e

Vladislav Prusakov 90 Mar 12, 2021
🎯Linker Lightweight way to handle internal and external deeplinks in Swift for iOS

Linker Lightweight way to handle internal and external deeplinks in Swift for iOS. Installation Dependency Managers CocoaPods CocoaPods is a dependenc

Maksim Kurpa 128 May 20, 2021
Monarch Router is a Declarative URL- and state-based router written in Swift.

Monarch Router is a declarative routing handler that is capable of managing complex View Controllers hierarchy transitions automatically, decoupling View Controllers from each other via Coordinator and Presenters. It fits right in with Redux style state flow and reactive frameworks.

Eliah Snakin 31 May 19, 2021
SwiftRouter - A URL Router for iOS, written in Swift

SwiftRouter A URL Router for iOS, written in Swift, inspired by HHRouter and JLRoutes. Installation SwiftRouter Version Swift Version Note Before 1.0.

Chester Liu 259 Apr 16, 2021
📱📲 Navigate between view controllers with ease. 💫 🔜 More stable version (written in Swift 5) coming soon.

CoreNavigation ?? ?? Navigate between view controllers with ease. ?? ?? More stable version (written in Swift 5) coming soon. Getting Started API Refe

Aron Balog 69 Sep 21, 2022
Interface-oriented router for discovering modules, and injecting dependencies with protocol in Objective-C and Swift.

ZIKRouter An interface-oriented router for managing modules and injecting dependencies with protocol. The view router can perform all navigation types

Zuik 631 Dec 26, 2022
A library for managing complex workflows in Swift

Welcome SwiftCurrent is a library that lets you easily manage journeys through your Swift application. It comes with built-in support for UIKit and Sw

WWT 290 Jan 9, 2023