Fun GridScrollView written in SwiftUI + Combine, bridging between UIKit

Overview

BSZoomGridScrollView

BSZoomGridScrollView is a powerful, pure swift iOS UI framework that provides the awesome grid scrollview containing your image array that are able to zoom, tracking your touch area.

Screenshots

Click to watch how it works in youtube


Alt Text

BSZoomGridScrollView Screenshot

At a Glance

var body: some View {
    /// ๐Ÿ˜Š That's it.
    BSZoomGridScrollView(imagesToZoom: imagesToZoom,
                         powerOfZoomBounce: .regular,
                         numberOfColumns: 200,
                         numberOfRows: 10,
                         didLongPressItem: { selectedImage in
                            print("on long press : ", selectedImage)
                            /// Grab an image user end up choosing.
                            self.selectedImage = selectedImage
                            
                            /// Present!
                            self.showSelectedImageView.toggle()
                         },
                         didFinishDraggingOnItem: { selectedImage in
                            print("on drag finish : ", selectedImage)
    })
    .edgesIgnoringSafeArea(.all)
    .sheet(isPresented:self.$showSelectedImageView) {
        /// The example view showing a picked up image.
        ShowingSelectedImageView(selectedImage: self.selectedImage)
    }
}

Features

  • Designed for SwiftUI, SwiftUI 100% is supported.
  • Complex grid ScrollView UI is provided out of box.
  • Tracking user touch area on the grid scrollview, Zooming items is done out of box.
  • BSZoomGridScrollView will return an image selected by a user, detected by the internal long press and pan gesture inside out of box.
  • Grid UI can be styled for number of columns, rows, zoom effect and images you would like to input to show in the grid.

Example

To run the example project, clone the repo, and run pod install from the Example directory first. It includes examples for UIKit as well as SwiftUI.

Requirements

  • iOS 13.0 or later
  • Swift 5.0 or later
  • Xcode 11.0 or later

Getting Started

  • SwiftUI
import SwiftUI

/// ๐Ÿฅณ # Step1: let's import!
import BSZoomGridScrollView

struct ContentView: View {
    var itemsToZoom: [UIImage] = {
        var images = [UIImage]()
        for i in 0...29 {
            images.append(UIImage(named: "yourImage\(i)") ?? UIImage())
        }
        return images
    }()
    
    var body: some View {
        /// ๐Ÿ˜Š # Step2. That's it. completed!
        BSZoomGridScrollView(itemsToZoom: itemsToZoom,
                             powerOfZoomBounce: .regular,
                             isBeingDraggingOnItem:{ selectedImage in
                                ///
                             },
                             didLongPressItem: { selectedImage in
                                /// Grab an image user ends up choosing.
                             },
                             didFinishDraggingOnItem: { selectedImage in
                                /// Grab an image user ends up choosing.
        })
        .edgesIgnoringSafeArea(.all)
    }
}
  • UIKit
///
/// To use BSZoomGridScrollView,
/// Please, Follow steps written in the comments with icon like ๐Ÿ˜€.
///

import SwiftUI
import UIKit

///
// ๐Ÿ˜š #Step1: import BSZoomGridScrollView!
///
import BSZoomGridScrollView

class ViewController: UIViewController {
    
    ///
    // ๐Ÿ˜‹ #Step2: declare BSZoomGridScrollView
    ///
    private lazy var zoomGridScrollViewController: BSZoomGridScrollViewController = { [unowned self] in
        ///
        /// It can be used on both SwiftUI and UIKit.
        /// To see how it works on SwiftUI,
        /// please refer to comments in SwiftUI directory -> ContentView.swift
        ///
        return BSZoomGridScrollViewController(itemsToZoom: self.itemsToZoom,
                                              powerOfZoomBounce: .regular,
                                              scrollEnableButtonTintColor: .black,
                                              scrollEnableButtonBackgroundColor: .white,
                                              isBeingDraggingOnItem:{ [unowned self] selectedImage in
                                                 ///
                                              },
                                              didLongPressItem: { [unowned self] selectedImage in
                                                /// Grab an image user end up choosing.
                                              },
                                              didFinishDraggingOnItem: { [unowned self] selectedImage in
                                                /// on drag finished
                                              })
    }()
    
    ///
    // prepare any item array to feed to BSZoomGridScrollViewController.
    ///
    private var itemsToZoom: [Any] = {
        var images = [UIImage]()
        for i in 0...29 {
            images.append(UIImage(named: "s\(i)") ?? UIImage())
        }
        return images
    }()
    
    ///
    // ๐Ÿ˜ #Step3: Present it!
    ///
    @IBAction func goToBSZoomGridScrollView(_ sender: Any) {
        ///
        // ๐Ÿ˜Ž That's all. well done.
        ///
        
        self.present(UINavigationController(rootViewController: zoomGridScrollViewController),
                     animated: true,
                     completion: nil)
    }
    
    ///
    // MARK: - ViewController LifeCycle Methods
    ///
    override func viewDidLoad() {
        super.viewDidLoad()
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }
}

Installation

There are four ways to use BSZoomGridScrollView in your project:

  • using CocoaPods
  • using Swift Package Manager
  • manual install (build frameworks or embed Xcode Project)

Installation with CocoaPods

CocoaPods is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries in your projects. See the Get Started section for more details.

Podfile

First,

pod 'BSZoomGridScrollView'

then in your root project,

pod install

Installation with Swift Package Manager (Xcode 11+)

Swift Package Manager (SwiftPM) is a tool for managing the distribution of Swift code as well as C-family dependency. From Xcode 11, SwiftPM got natively integrated with Xcode.

BSZoomGridScrollView support SwiftPM from version 5.1.0. To use SwiftPM, you should use Xcode 11 to open your project. Click File -> Swift Packages -> Add Package Dependency, enter BSZoomGridScrollView repo's URL. Or you can login Xcode with your GitHub account and just type BSZoomGridScrollView to search.

After select the package, you can choose the dependency type (tagged version, branch or commit). Then Xcode will setup all the stuff for you.

If you're a framework author and use BSZoomGridScrollView as a dependency, update your Package.swift file:

let package = Package(
    dependencies: [
        .package(url: "https://github.com/boraseoksoon/BSZoomGridScrollView", from: "0.1.1")
    ],
    // ...
)

Disclamer

It was done for my fun.

Author

[email protected]

License

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

References

Observable : Photos browsing iOS app where you can download the photos for free as you like.

You might also like...
Agrume - ๐Ÿ‹ An iOS image viewer written in Swift with support for multiple images.
Agrume - ๐Ÿ‹ An iOS image viewer written in Swift with support for multiple images.

Agrume An iOS image viewer written in Swift with support for multiple images. Requirements Swift 5.0 iOS 9.0+ Xcode 10.2+ Installation Use Swift Packa

FacebookImagePicker is Facebook album photo picker written in Swift.
FacebookImagePicker is Facebook album photo picker written in Swift.

Features โ€ข Installation โ€ข Usage โ€ข Translation โ€ข License GBHFacebookImagePicker is Facebook's album photo picker written in Swift, built to provide a s

A lightweight generic cache for iOS written in Swift with extra love for images.
A lightweight generic cache for iOS written in Swift with extra love for images.

Haneke is a lightweight generic cache for iOS and tvOS written in Swift 4. It's designed to be super-simple to use. Here's how you would initalize a J

A lightweight and fast image loader for iOS written in Swift.

ImageLoader ImageLoader is an instrument for asynchronous image loading written in Swift. It is a lightweight and fast image loader for iOS. Features

An image download extension of the image view written in Swift for iOS, tvOS and macOS.
An image download extension of the image view written in Swift for iOS, tvOS and macOS.

Moa, an image downloader written in Swift for iOS, tvOS and macOS Moa is an image download library written in Swift. It allows to download and show an

Fast and simple OCR library written in Swift

โ›”๏ธ This Project is deprecated and no longer gets maintained! Please use Apple's Vision framework instead of SwiftOCR. It is very fast, accurate and mu

A beautiful and flexible text field control implementation of
A beautiful and flexible text field control implementation of "Float Label Pattern". Written in Swift.

SkyFloatingLabelTextField SkyFloatingLabelTextField is a beautiful, flexible and customizable implementation of the space saving "Float Label Pattern"

XAnimatedImage is a performant animated GIF engine for iOS written in Swift based on FLAnimatedImage
XAnimatedImage is a performant animated GIF engine for iOS written in Swift based on FLAnimatedImage

XAnimatedImage is a performant animated GIF engine for iOS written in Swift based on FLAnimatedImage. An illustration is shown below: Features Plays m

Rounded async imageview downloader lightly cached and written in Swift
Rounded async imageview downloader lightly cached and written in Swift

PASImageView ============ **Rounded async imageview downloader lightly cached and written in Swift 3 ** Objective-C version here Snapshot Usage //XIB

Owner
Jang Seoksoon
ํ† ๋ก ํ† ์˜ ํ”„๋กœ๊ทธ๋ž˜๋จธ
Jang Seoksoon
Same repository with SwiftUI&Combine

RSS Feed Reader SwiftUI&Combine This repository is an example iOS Application with SwiftUI & Combine & MVVM design pattern. Same example of this repos

null 3 Oct 10, 2022
NavigationCoordinator acts as a coordinator for NavigationView in SwiftUI. You can use pushView, popView, popToView, popToRootView as you can in traditional UIKit

NavigationCoordinator NavigationCoordinator acts as a coordinator for NavigationView. You can use pushView, popView, popToView, popToRootView in Swift

Shahriar Nasim Nafi 3 Aug 3, 2022
PrivateImage - DRM image view for UIKit and SwiftUI

SecretImage Image view with DRM protection for SwiftUI and UIKit. What? This vie

Pavel Serdziukou 27 Dec 17, 2022
Combine SnapshotTesting images into a single asset

An extension to SnapshotTesting which allows you to create images combining the output of multiple snapshot strategies, assuming they all output to UIImage.

James Sherlock 41 Nov 28, 2022
Applies filter to a selected image from the Gallery using Combine

CombinePhotoFiltering App CombinePhotoFiltering is an app that applies sepia and bloom to a selected picture from the Photos app. Highlights The app i

Mauricio Esteves 0 Nov 14, 2021
PublisherKit - An open source implementation of Apple's Combine framework for processing asynchronous events over time

Publisher Kit Overview PublisherKit provides a declarative Swift API for processing asynchronous events over time. It is an open source version of App

null 5 Feb 22, 2022
Gifu adds protocol-based, performance-aware animated GIF support to UIKit.

Gifu adds protocol-based, performance-aware animated GIF support to UIKit. (It's also a prefecture in Japan). Install Swift Package Manager Add the fo

Reda Lemeden 2.8k Jan 7, 2023
LoremPicsum - Simple UIKit based app for displaying grid of pictures

LoremPicsum - Simple UIKit based app for displaying grid of pictures

Paweล‚ Dziennik 0 Jan 20, 2022
Visualiser written in Swift, SwiftUI and Metal API

ModularMTL About Visualisation of modular multiplication on a circle. Written in Swift using Metal API and SwiftUI. Images Features Keyboard controls

Gracien 12 Dec 20, 2022
A Swift/SwiftUI utility for caching and displaying images in SwiftUI Views

A Swift/SwiftUI utility for caching and displaying images asynchronously. Built with Swift 5.5 and works with async/await.

็Ž‹้›ช้“ฎ Xuezheng Wang 1 May 5, 2022