All Projects → spring-media → LazyPages

spring-media / LazyPages

Licence: MIT License
A highly customizable library that helps you to show a scrollable list of view controllers synchronized with an index. It is written in Swift 5 for iOS 8+.

Programming Languages

swift
15916 projects

Labels

Projects that are alternatives of or similar to LazyPages

perfect-ubuntu
js dev setup, just for fun
Stars: ✭ 14 (-39.13%)
Mutual labels:  apps
vagas
💼 É dev? É devops? É bom? Quer mexer com muita tecnologia e desafios? Vem pro match!
Stars: ✭ 21 (-8.7%)
Mutual labels:  apps
Ionic-ElastiChat-with-Images
Ionic Magic Chat with Angular Elastic, Autolinker.js and more!
Stars: ✭ 66 (+186.96%)
Mutual labels:  apps
ionic4-angular8-crud-mobileapps-example
Ionic 4 Angular 8 Tutorial: Learn to Build CRUD Mobile Apps
Stars: ✭ 20 (-13.04%)
Mutual labels:  apps
Port-Able-Suite
🌐 Manager for portable applications
Stars: ✭ 35 (+52.17%)
Mutual labels:  apps
material-kit-react
React Material Kit - Built with Automation Tools | AppSeed App Generator
Stars: ✭ 18 (-21.74%)
Mutual labels:  apps
foss-apps
a list of 100+ awesome open source android apps 📱
Stars: ✭ 289 (+1156.52%)
Mutual labels:  apps
oh-my-foss-android
个人收集的实用、良心开源安卓软件
Stars: ✭ 37 (+60.87%)
Mutual labels:  apps
awesome-earth-engine-apps
A collection of all public Google Earth Engine Apps.
Stars: ✭ 78 (+239.13%)
Mutual labels:  apps
workbox-microsite
Workbox Microsite
Stars: ✭ 24 (+4.35%)
Mutual labels:  apps
MCW-Template-Cloud-Workshop
Official Microsoft Cloud Workshop Template
Stars: ✭ 36 (+56.52%)
Mutual labels:  apps
dr scaffold
scaffold django rest apis like a champion 🚀
Stars: ✭ 116 (+404.35%)
Mutual labels:  apps
gestion
baimard.github.io/gestion
Stars: ✭ 37 (+60.87%)
Mutual labels:  apps
toolkit
Opera Web UI Toolkit
Stars: ✭ 20 (-13.04%)
Mutual labels:  apps
shopify-development-resources
A List of resources for Shopify development
Stars: ✭ 56 (+143.48%)
Mutual labels:  apps
Mimir
📱 A simple & efficient iOS logging framework for high usage apps
Stars: ✭ 13 (-43.48%)
Mutual labels:  apps
ad-alexatalkingclock
Alexa (or other Smart Speakers) tell you the time without asking every hour. Please ⭐️if you like my app :)
Stars: ✭ 30 (+30.43%)
Mutual labels:  apps
my-linux-setup
My Fedora Linux list of installed applications and Ansible provision scripts
Stars: ✭ 40 (+73.91%)
Mutual labels:  apps
Clean-macOS
💻 A simple script to setup a clean environment on macOS
Stars: ✭ 155 (+573.91%)
Mutual labels:  apps
Awesome-Black-Friday-Cyber-Monday-deals
2021 - Black Friday & Cyber Monday, Christmas & Holidays Deals for Developers, Techies, & Entrepreneurs,
Stars: ✭ 151 (+556.52%)
Mutual labels:  apps

LazyPages

CI Status License Platform swift5 Carthage compatible Version

MacDown Screenshot

LazyPages is a highly customizable library that helps you to show a scrollable list of view controllers synchronized with an index. It is written in Swift 5 for iOS 11+.

Requirements

  • iOS 11+
  • Xcode 12.2+

Features

  • Lazy load of view controllers, that allow us not to have all of them in memory when initialazing LazyPages. Furthermore, we can also initialise it with all the UIViewController instances or with closures that provides them.
  • View controllers are cached, and freed when memory is low. The number of cached view controllers can be customized.
  • View controllers can be instances of different subclasses of UIViewController.
  • Highly customizable, we can place the index and pages views as we wish, as well as desigining the index cells, with the help of Storyboard. Scroll directions could be set as wished.
  • Public API to go to a desired page.
  • Usage of UIViewController, not UIView.

Usage

An instance of LazyPages can be created from the storyboard or just programmatically.

To create it from the storyboard:

  • Add an instance of UIViewController to it. It will be the container of the Page Controller.
  • Add two container views, one for the index and one for the page controller.
  • Linked to these container views we have now two view controllers. In the desired index view controller set the class to PageIndexCollectionViewController, and in the PageController to PageController. Set their module to LazyPages.
  • Inside the Index View Controller drag and drop an instance of UICollectionView and link it through an outlet to the collectionView property of the class. This collection view will represent the index; we will be able to customize the cells inside the Storyboard.

In the code of our view controller, we have to link both view controllers together and set the proper data source. We can do that in the prepareForSegue method:

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    guard let identifier = segue.identifier else {
      return
    }

    guard let segueEnum = Segue(rawValue: identifier) else {
      return
    }

    switch segueEnum {
    case .PageController:
      guard let pageController = segue.destinationViewController as? PageController else {
        break
      }

      self.pageController = pageController
      pageController.dataSource = self
    case .PageIndex:
      guard let pageIndex = segue.destinationViewController as? PageIndexCollectionViewController else {
        break
      }

      self.pageIndex = pageIndex
      pageIndex.dataSource = self
    }
  }

If you want to implement it programmatically, you have to create and instance of UICollectionView and assign it to the property of PageIndexCollectionViewController as we explained in the storyboard case. As specified before we have to link them together in both cases:

pageController?.pageIndexController = self.pageIndex
pageIndex?.pageController = self.pageController

To populate the views, we assign the data source properties for both the index and the Page Controller. For the Page Controller we can implement the data source ourselves, or use the provided data source classes (PageControllerArrayDataSource and PageControllerClosureDataSource) that respectively require an array of UIViewController or closures. We can easily define a visual state for selection in the index view by overriding the selected property in the UICollectionViewCell subclass that we provide in the PageIndexCollectionViewController data source:

override var isSelected: Bool {
    didSet {
      if isSelected {
        backgroundColor = UIColor.gray
        indexLabel.textColor = UIColor.white
      } else {
        backgroundColor = UIColor.white
        indexLabel.textColor = UIColor.black
      }
    }
  }

If you want to customize the amount of view controllers you cache, customize the cachingNeighborsCount property of PageController according to your needs.

Installation

Swift Package Manager

Add LazyPages to your project through the Xcode or add the following line to your package dependencies:

.package("https://github.com/spring-media/LazyPages", from: "1.0.0")

License

LazyPages is available under the MIT license.

Authors

LazyPages was made in-house by Spring-Media

Contributors

César Vargas Casaseca, [email protected], @toupper on Github, @VargasCasaseca on Twitter

Vittorio Monaco, @vittoriom on Github, @Vittorio_Monaco on Twitter

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].