iOS custom view to display books on shelf

Overview

ShelfView (iOS)

iOS custom view to display books on shelf (Android version is available here)

Requirements

  • iOS 10.0+
  • Swift 4.2

Installation

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

pod 'ShelfView'

Note

Because of book covers whose URLs are http, update your info.plist as follows:

  • add App Transport Security Settings to the list
  • add Allow Arbitrary Loads to the security settings added above; set it to YES.

Plain Shelf

import ShelfView

class PlainShelfController: UIViewController, PlainShelfViewDelegate {
    var shelfView: PlainShelfView!

    override func viewDidLoad() {
        super.viewDidLoad()
        
        let books = [
            BookModel(bookCoverSource: "https://files.kerching.raywenderlich.com/covers/d5693015-46b6-44f8-bf7b-7a222b28d9fe.png",
                      bookId: "0",
                      bookTitle: "Realm: Building Modern Swift Apps with Realm"),
            BookModel(bookCoverSource: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTYEkCQ_wu8HoGJzzs_gUH_FVusgI2RhntBKQ-WkmqnDJZnriwY6Q",
                      bookId: "1",
                      bookTitle: "iOS 10 by Tutorials: Learning the new iOS APIs with Swift 3")
        ]        
        
        shelfView = PlainShelfView(frame: CGRect(x: 0, y: 0, width: 350, height: 500),
                                   bookModel: books, bookSource: PlainShelfView.BOOK_SOURCE_URL)

        shelfView.delegate = self
        self.view.addSubview(shelfView)
    }

    func onBookClicked(_ shelfView: PlainShelfView, index: Int, bookId: String, bookTitle: String) {
        print("I just clicked \"\(bookTitle)\" with bookId \(bookId), at index \(index)")
    }

}

Section Shelf

import ShelfView

class SectionShelfController: UIViewController, SectionShelfViewDelegate {
    var shelfView: SectionShelfView!

    override func viewDidLoad() {
        super.viewDidLoad()

        let books = [
            BookModel(bookCoverSource: "https://files.kerching.raywenderlich.com/covers/d5693015-46b6-44f8-bf7b-7a222b28d9fe.png",
                      bookId: "0",
                      bookTitle: "Realm: Building Modern Swift Apps with Realm"),
            BookModel(bookCoverSource: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTYEkCQ_wu8HoGJzzs_gUH_FVusgI2RhntBKQ-WkmqnDJZnriwY6Q",
                      bookId: "1",
                      bookTitle: "iOS 10 by Tutorials: Learning the new iOS APIs with Swift 3")
        ]
        let bookModelSectionArray = [BookModelSection(sectionName: "RAYWENDERLICH",
                                                      sectionId: "0",
                                                      sectionBooks: books)]

        shelfView = SectionShelfView(frame: CGRect(x: 0, y: 0, width: 350, height: 500),
                                     bookModelSection: bookModelSectionArray,
                                     bookSource: SectionShelfView.BOOK_SOURCE_URL)

        shelfView.delegate = self
        self.view.addSubview(shelfView)
    }

    func onBookClicked(_ shelfView: SectionShelfView, section: Int, index: Int,
                       sectionId: String, sectionTitle: String, bookId: String,
                       bookTitle: String) {
        print("I just clicked \"\(bookTitle)\" with bookId \(bookId), at index \(index). Section details --> section \(section), sectionId \(sectionId), sectionTitle \(sectionTitle)")
    }

}

Add more books to ShelfView

  • Plain Shelf
addBooks(bookModel: [BookModel])
  • Section Shelf
addBooks(bookModelSection: [BookModelSection])

Reload books on ShelfView

  • Plain Shelf
reloadBooks(bookModel: [BookModel])
  • Section Shelf
reloadBooks(bookModelSection: [BookModelSection])

Loading book covers from other sources

  • iPhone/iPad document directory
let books = [
    BookModel(bookCoverSource: "bookcover0.png", bookId: "0", bookTitle: "Book Title 0"),
    BookModel(bookCoverSource: "bookcover1.png", bookId: "1", bookTitle: "Book Title 1")
        ]
shelfView = PlainShelfView(frame: CGRect(x: 0, y: 0, width: 350, height: 500),
                           bookModel: books, bookSource: PlainShelfView.BOOK_SOURCE_DEVICE_DOCUMENTS)
  • iPhone/iPad library directory
let books = [
    BookModel(bookCoverSource: "bookcover0.png", bookId: "0", bookTitle: "Book Title 0"),
    BookModel(bookCoverSource: "bookcover1.png", bookId: "1", bookTitle: "Book Title 1")
        ]
shelfView = PlainShelfView(frame: CGRect(x: 0, y: 0, width: 350, height: 500),
                           bookModel: books, bookSource: PlainShelfView.BOOK_SOURCE_DEVICE_LIBRARY)
  • iPhone/iPad cache directory
let books = [
    BookModel(bookCoverSource: "bookcover0.png", bookId: "0", bookTitle: "Book Title 0"),
    BookModel(bookCoverSource: "bookcover1.png", bookId: "1", bookTitle: "Book Title 1")
        ]
shelfView = PlainShelfView(frame: CGRect(x: 0, y: 0, width: 350, height: 500),
                           bookModel: books, bookSource: PlainShelfView.BOOK_SOURCE_DEVICE_CACHE)
  • Directly from your project's source code
let books = [
    BookModel(bookCoverSource: "bookcover0.png", bookId: "0", bookTitle: "Book Title 0"),
    BookModel(bookCoverSource: "bookcover1.png", bookId: "1", bookTitle: "Book Title 1")
        ]
shelfView = PlainShelfView(frame: CGRect(x: 0, y: 0, width: 350, height: 500),
                           bookModel: books, bookSource: PlainShelfView.BOOK_SOURCE_RAW)

License

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

Author

Adeyinka Adediji ([email protected])

Contributions & Bug Reporting

[email protected]

Credits

You might also like...
Library that holds multiple books loaded from json in a scroll view where each book can be tapped on, favorited, rated, and opened to read
Library that holds multiple books loaded from json in a scroll view where each book can be tapped on, favorited, rated, and opened to read

Library that holds multiple books loaded from json in a scroll view where each book can be tapped on, favorited, rated, and opened to read. If a book is a favorite, an orange star appears on the book's cover. Page number, favorites, and ratings are saved for each session of the app.

Reading List is an iOS app for iPhone and iPad which helps users track and catalog the books they read
Reading List is an iOS app for iPhone and iPad which helps users track and catalog the books they read

Reading List Reading List is an iOS app for iPhone and iPad which helps users track and catalog the books they read. Reading List v2 As of version 2.0

iOS Open Source Application written in Swift. App to manage borrowed books at UFRGS using SABI.
iOS Open Source Application written in Swift. App to manage borrowed books at UFRGS using SABI.

RenovaLivrosUFRGS iOS Open Source Application written in Swift. App to manage borrowed books at UFRGS using SABI. App in portuguese, code and comments

Native iOS app built in SwiftUI, displays a collection of user's books.

Native iOS app built in SwiftUI, displays a collection of user's books.

Video mp4 record save display - How to Take , Save and Display a .mp4 Video

Technicalisto How to Take , Save and Display a .mp4 Video Add your design with v

🖥 Control your display's brightness & volume on your Mac as if it was a native Apple Display
🖥 Control your display's brightness & volume on your Mac as if it was a native Apple Display

🖥 Control your display's brightness & volume on your Mac as if it was a native Apple Display. Use Apple Keyboard keys or custom shortcuts. Shows the native macOS OSDs.

With the Coverless App, you can discover many books of various genres
With the Coverless App, you can discover many books of various genres

Coverless Não julgue um livro pela capa: use a sinopse! Com o App Coverless, você pode descobrir muitos livros de vários gêneros. Salve seus livros de

The Xcode playground labs from the Develop in Swift Fundamentals and Data Collections books.
The Xcode playground labs from the Develop in Swift Fundamentals and Data Collections books.

Develop in Swift Labs A repository with the student materials from the Xcode 12 version of Develop with Swift Fundamentals This repo contains the Swif

ReadMe app is here to list all of the physical books in your personal library
ReadMe app is here to list all of the physical books in your personal library

ReadMe App The ReadMe app is here to list all of the physical books in your personal library, mark books you still have to read review books after you

Uses Firestore to remotely store books that are sorted by genre locally.
Uses Firestore to remotely store books that are sorted by genre locally.

Uses Firestore to remotely store books that are sorted by genre locally. Books can be added, removed, or edited from within the app or on Firebase.

An ongoing curated list of frameworks, books, articles, talks, screencasts, recordings, libraries, learning tutorials and resources about Swift
Quillow is an elegant book management app on the App Store that allows you to search, add and track the books you've consumed.

Quillow Quillow is an elegant book management app on the App Store that allows you to search, add and track the books you've consumed. Please use the

Bookworm - Track which books you’ve read and what you thought of them
Bookworm - Track which books you’ve read and what you thought of them

Bookworm Description: Bookworm is an app I built while following 100 Days of Swi

BookShelf - an app for cataloguing and tracking your books
BookShelf - an app for cataloguing and tracking your books

BookShelf An app for cataloguing and tracking your books. Watch the talk » Report Bug · Request Feature Table of Contents About The Project Getting St

A fully customizable container view controller to display a set of ViewControllers in a horizontal scroll view. Written in Swift.
A fully customizable container view controller to display a set of ViewControllers in a horizontal scroll view. Written in Swift.

DTPagerController This is a control for iOS written in Swift. DTPagerController is simple to use and easy to customize. Screenshots Default segmented

A fully customizable container view controller to display a set of ViewControllers in a horizontal scroll view. Written in Swift.
A fully customizable container view controller to display a set of ViewControllers in a horizontal scroll view. Written in Swift.

DTPagerController This is a control for iOS written in Swift. DTPagerController is simple to use and easy to customize. Screenshots Default segmented

Custom-Transition - A repo about custom transition between two view controllers

Custom-Transition in SWIFT This is a repo about custom transition between two vi

Software Dummy Display Adapter for Apple Silicon Macs to Have Custom HiDPI Resolutions.
Software Dummy Display Adapter for Apple Silicon Macs to Have Custom HiDPI Resolutions.

BetterDummy Dummy Display for Apple Silicon Macs to achieve custom resolutions. About M1 macs tend to have issues with custom resolutions. Notoriously

Owner
Adeyinka Adediji
Mobile [Android & iOS] Developer
Adeyinka Adediji
OpenSwiftUIViews - A non gesture blocking, non clipping by default custom scroll view implementation with example code.

OpenSwiftUIViews - A non gesture blocking, non clipping by default custom scroll view implementation with example code.

Marco Boerner 11 Jan 4, 2023
SwiftUI ScrollView with custom pull to refresh & scroll to load-more implementations

PaginatedScrollView SwiftUI ScrollView with custom "pull to refresh" & "scroll to load-more" implementations. example usage PaginatedScrollView {

Aung Ko Min 7 Sep 20, 2022
Full configurable spreadsheet view user interfaces for iOS applications. With this framework, you can easily create complex layouts like schedule, gantt chart or timetable as if you are using Excel.

kishikawakatsumi/SpreadsheetView has moved! It is being actively maintained at bannzai/SpreadsheetView. This fork was created when the project was mov

Kishikawa Katsumi 34 Sep 26, 2022
ScrollingFollowView is a simple view which follows UIScrollView scrolling.

ScrollingFollowView ScrollingFollowView is a simple view which follows UIScrollView scrolling. ScrollingFollowView Sample Images SearchBarSample : Sea

Tanaka Kenji 186 Dec 21, 2022
App store style horizontal scroll view

ASHorizontalScrollView App store style horizontal scroll view It acts similar to apps sliding behaviours in App store. There are both Objective-C (do

Terence Chen 663 Nov 26, 2022
A scroll view with a sticky header which shrinks as you scroll. Written with SwiftUI.

Scaling Header Scroll View A scroll view with a sticky header which shrinks as you scroll. Written with SwiftUI. We are a development agency building

Exyte 395 Dec 31, 2022
↕️ VegaScroll is a lightweight animation flowlayout for UICollectionView completely written in Swift 4, compatible with iOS 11 and Xcode 9.

Made by Applikey Solutions Find this project on Dribbble Also check another flowlayout for UICollectionView: https://github.com/ApplikeySolutions/Grav

Applikey Solutions 2.8k Jan 7, 2023
iOS custom view to display books on shelf

ShelfView (iOS) iOS custom view to display books on shelf (Android version is available here) Requirements iOS 10.0+ Swift 4.2 Installation ShelfView

Adeyinka Adediji 268 Dec 10, 2022
Use any custom view as custom callout view for MKMapView with cool animations. Use any image as annotation view.

MapViewPlus About MapViewPlus gives you the missing methods of MapKit which are: imageForAnnotation and calloutViewForAnnotationView delegate methods.

Okhan Okbay 162 Nov 16, 2022
A simple iOS app similar to iTunes where you can view details of your favorite movies, songs and audio books.

Popcorn Adventure This is an iOS app developed by Arthur Tristan M. Ramos who has taken the Appetiser iOS Coding Challenge. Design Pattern The design

Arthur Tristan M. Ramos 0 Dec 11, 2021