GithubHelp home page GithubHelp logo

mediamonks / mmmcardmodal Goto Github PK

View Code? Open in Web Editor NEW
1.0 11.0 0.0 2.38 MB

An iOS 13 insipred modal card presentation that supports multiple stick positions

Home Page: https://mediamonks.github.io/MMMCardModal/

License: MIT License

Swift 98.73% Ruby 1.27%
ios swift

mmmcardmodal's Introduction

MMMCardModal

Build

An iOS 13 inspired modal card presentation, however you can specify multiple stick positions for the presented VC.

(This is a part of MMMTemple suite of iOS libraries we use at MediaMonks.)

Demo

Preview

Most basic example

class MyVC: CardModal.ViewController {

  init() {
      super.init(view: MyView())
  }

}

present(MyVC(), animated: true)

Installation

Podfile:

source 'https://github.com/mediamonks/MMMSpecs.git'
source 'https://cdn.cocoapods.org/'
...
pod 'MMMCardModal'

SPM:

.package(url: "https://github.com/mediamonks/MMMCardModal", .upToNextMajor(from: "0.2.13"))

More detailed example

Just checkout the code in /Example/ViewController.swift.

Details

Subclass the CardModal.ViewController for a single modal, or CardModal.NavigationHost to support navigation controllers. You can conform the controllers in your NavigationController to ChildControllerDelegate to get access to the NavigationHost and the delegate callbacks to detect closing & position changes.

Make sure to have the reference to the parent navigationHost defined as weak to avoid cyclic references.

It's possible to specify multiple StickPositions, this defaults to .top, but can be .center or a custom value. The first value in the stickPositions array is the position the modal will open to when presenting. E.g. .percentage(0.2) will open the modal 20% from the top of the screen.

More options are available and can be set after super.init(), for more info checkout CardModal.Options.swift.

Required:

  • If you implement cardModalWillDragToClose you will have to to close the presented controller yourself (and usually do some cleaning up). You can dismiss the presented controller with animation, because then the StatusBar will animate along nicely. If you use the NavigationHost you should close that instead of the controller, since that is presented. Get a reference to this by conforming to the protocol ChildControllerDelegate.
  • You should always supply at least one StickPosition in the stickPositions array.

Optional:

  • The cardModalDidDrag(_ to: ) callback is optional, but can be useful to alter the UI based on the currentPosition. The currentPosition is the StickPosition that is active.
  • Set custom options by modifying self.options after initializing. If you want to edit the options after the init call, you should override it with a new CardModal.Options object.

Ready for liftoff? 🚀

We're always looking for talent. Join one of the fastest-growing rocket ships in the business. Head over to our careers page for more info!

mmmcardmodal's People

Contributors

terwanerik avatar daxmediamonks avatar

Stargazers

 avatar

Watchers

Mient-jan Stelling avatar James Cloos avatar Utopia avatar Arjan van Wijk avatar René Drieënhuizen avatar Richard avatar  avatar Robert avatar Thi.js avatar Elmar avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.