Giter Site home page Giter Site logo

jessesquires / presenterkit Goto Github PK

View Code? Open in Web Editor NEW
551.0 12.0 29.0 626 KB

⚠️ Deprecated ⚠️

Home Page: https://www.jessesquires.com/blog/2021/11/06/deprecating-presenterkit/

License: MIT License

Swift 82.22% Ruby 14.03% Shell 3.75%
ios swift swift-library viewcontroller presentation

presenterkit's Introduction

PresenterKit Actions Status

Custom presenters and better view controller presentation for iOS

Requirements

Installation

pod 'PresenterKit', '~> 6.1.0'

# develop branch
pod 'PresenterKit', :git => 'https://github.com/jessesquires/PresenterKit.git', :branch => 'develop'

Add PresenterKit to the dependencies value of your Package.swift.

dependencies: [
    .package(url: "https://github.com/jessesquires/PresenterKit.git", from: "6.1.0")
]

Alternatively, you can add the package directly via Xcode.

Documentation

You can read the documentation here. Generated with jazzy. Hosted by GitHub Pages.

Contributing

Interested in making contributions to this project? Please review the guides below.

Also, consider sponsoring this project or buying my apps! ✌️

Credits

Created and maintained by @jesse_squires.

License

Released under the MIT License. See LICENSE for details.

Copyright © 2016-present Jesse Squires.

presenterkit's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar jessesquires avatar kylebshr avatar psartzetakis avatar sumolari avatar theangelperalta avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

presenterkit's Issues

Typed View Controllers from storyboard

Hi,😀
I have introduced something that personally annoys me, if you find that interesting and you believe that we can include a solution on that issue through PresenterKit we can discuss it further.

The problem

When you bring view controllers from the storyboard usually you do something like that:

let colorViewController = self.storyboard?.instantiateViewController(withIdentifier: "identifier") as! ColorViewController

The thing that I don't like is that part:

as! ColorViewController
or
as? ColorViewController

A suggestion

I believe that it would be much nicer to wrap this functionality into something nicer. Perhaps something like:

extension UIStoryboard {
    func instatiate<T: UIViewController>(type: T.Type, with identifier: String) -> T {
        return instantiateViewController(withIdentifier: identifier) as! T
    }
}

As a result we could do something like that:

let colorViewController = storyboard?.instatiate(type: ColorViewController.self, with: "identifier")

A different suggestion (not that good though..)

Note: - personally I use most of the times as identifier the same name as the class name, so it would suit me something like that:

extension UIStoryboard {
    func instatiate<T: UIViewController>(type: T.Type, identifier: String? = nil) -> T {
        let identifier = identifier ?? "\(type.self)"
        return instantiateViewController(withIdentifier: identifier) as! T
    }
}

So I can use it like that:

let colorViewController = storyboard?.instatiate(type: ColorViewController.self)

But: I don't thing that could be a good idea since it can be misleading ..

What do you think?

Build carthage on travis-ci

Similar to pod spec lint, we should probably run carthage build --no-skip-current on travis-ci to make sure we're carthage-compatible.

How to change popoverViewController size

set the presented ViewController preferredContentSize or fixed at UIPopoverPresentationControllerDelegate's

popoverPresentationController(_ popoverPresentationController: UIPopoverPresentationController, willRepositionPopoverTo rect: UnsafeMutablePointer<CGRect>, in view: AutoreleasingUnsafeMutablePointer<UIView>)

halfModal set Height?

Have you read the Contributing Guidelines?

Describe the feature

Clearly and concisely describe what you would like to add.

Is your feature request related to a problem?

Clearly and concisely describe the problem.

Proposed solution

Clearly and concisely describe the solution you'd like to see. Include implementation details, if possible.

Alternatives considered

Clearly and concisely describe any alternative solutions or features you've considered.

Additional context

Add any other context or screenshots about the feature request here.

Popover sourceRect should be set to view's bounds rather than frame?

Recently I experienced strange behaviour with popovers presented on iPad: I tried to present a popover and it didn't appear on screen. No exception was thrown and UI became kind of frozen for a few moments/taps. After that it worked exactly as it would worked if the popover was cancelled.

My application's UI is quite complex and I don't have time to reproduce this case in a small project. The problem happened when I presented a popover from a UITableViewCell located at the end of a long UITableView. User had to scroll to reach the presenting cell. When tapped a popover is presented asking confirmation. My view's frame is something like:

▿ (0.0, 982.0, 768.0, 53.0)
  ▿ origin : (0.0, 982.0)
    - x : 0.0
    - y : 982.0
  ▿ size : (768.0, 53.0)
    - width : 768.0
    - height : 53.0

And its bounds are:

▿ (0.0, 0.0, 768.0, 53.0)
  ▿ origin : (0.0, 0.0)
    - x : 0.0
    - y : 0.0
  ▿ size : (768.0, 53.0)
    - width : 768.0
    - height : 53.0

(As expected. Frame are view's coordinates expressed in parent's view coordinate system and bounds are view's coordinates expressed in view's coordinate system, so bounds are expected to have a 0 origin and frame's size).

Checking what does PresenterKit I've confirmed that it currently sets view's frame as popover's sourceRect: https://github.com/jessesquires/PresenterKit/blob/develop/Source/ViewControllerExtensions.swift#L129

However checking documentation on UIPopoverPresentationController:

var sourceView: UIView?
The view containing the anchor rectangle for the popover.
var sourceRect: CGRect
The rectangle in the specified view in which to anchor the popover.

Which made me wonder whether PresenterKit should be setting view's bounds as sourceRect instead of frame.

I've tried changing that line and it fixed my issues but without proper test cases or confirmation by a fellow developers I'm not really sure whether this change is actually fixing the issue or just hiding the symptom.

iPad bug in withStyles() when trying to present as .formSheet

The following fails to present as .formSheet on iPad:

present(vc, type: .modal(.withNavigation, .formSheet, .coverVertical), animated: animated)

Because:

public func withStyles(navigation:, presentation:, transition:)

Does not apply presentation and transition styles correctly when embedding view controller inside UINavigationController

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.