Giter VIP home page Giter VIP logo

popupcontroller's Introduction

PopupController

CI Status Version License Platform

PopupController is a controller for showing temporary popup view.

Demo

Try PopupController on Appetize.io

Installation

CocoaPods

pod 'PopupController'

Carthage

Future

Usage

Before use,
Every ViewController which is added on the PopupController must conform to PopupContentViewController protocol.

class AnyPopupViewController: UIViewController, PopupContentViewController {

	// Do something...

	private var popupSize: CGSize // define the size for showing popup view size.

	// PopupContentViewController Protocol
    func sizeForPopup(popupController: PopupController, size: CGSize, showingKeyboard: Bool) -> CGSize {
	    return popupSize
	}
}

Then, show popup

PopupController
    .create(self)
    .show(AnyPopupViewController())

With some custom.

PopupController
    .create(self)
    .customize(
        [
            .Animation(.FadeIn), 
            .Layout(.Top), 
            .BackgroundStyle(.BlackFilter(alpha: 0.7))
        ]
    )
    .show(AnyPopupViewController())

With Handler

PopupController
    .create(self)
    .customize(
        [
            .Scrollable(false), 
            .DismissWhenTaps(true)
        ]
    )
    .didShowHandler { popup in
        // Do something
    }
    .didCloseHandler { _ in
        // Do something
    }
    .show(AnyPopupViewController())

If you use PopupController instance, do like this below

let popup = PopupController
    .create(self)
    .customize(
        [
            .Animation(.SlideUp)
        ]
    )
    .didShowHandler { popup in
        // Do something
    }
    .didCloseHandler { _ in
       // Do something
    }

popup.show() // show popup
popup.dismiss() // dismiss popup

Customization

public enum PopupCustomOption {
    case Layout(PopupController.PopupLayout)
    case Animation(PopupController.PopupAnimation)
    case BackgroundStyle(PopupController.PopupBackgroundStyle)
    case Scrollable(Bool)
    case DismissWhenTaps(Bool)
    case MovesAlongWithKeyboard(Bool)
}

License

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

popupcontroller's People

Contributors

daisuke310vvv avatar godelfin avatar maziyarpanahi avatar omatty198 avatar tache 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  avatar  avatar  avatar  avatar

popupcontroller's Issues

PopupController over UITableViewController

Hi,

I have clean xib which is just an empty view with sizeForPopup function inside. I am trying to call presentPopupController from my UITableViewController as follow:

let anyPopupViewController = DetailNewsViewController()
let popupController = PopupController.create(self)
popupController.presentPopupController(anyPopupViewController, completion: nil)

But the the TableView is scrollable and in result popup view will stay on that area and will scroll away without disappearing.

Is there anyway to call PopupView from a higher level like NavigationBar and not the UITableViewController? I am guessing this would solve the TableView or I might be mistaking.

Update: I fotgot to mention, if I scroll down in tableView and tap on any row the popup view will show up at the top not in the current view.

Many thanks,

dismiss from inside the controller

How can i dismiss the popup when the user taps a button inside the viewcontroller.

i tried dismis but not working as its not a viewcontrollers method, its a popupcontroller method.

[PGSQL] Error get timestamp now() by code backend

My config pgsql timezone: UTC
My create function:

create function ufn_test_date() returns json
    language plpgsql
as
$$
declare    
    data_return json;    
begin    
    drop table if exists temp_date;
    create temp table temp_date as
    select now();
    -----------------------------------------------------------------------------------------------
    select json_agg(t)
    from (select sdc.*from temp_date sdc) t
    into data_return;
    return data_return;
    -----------------------------------------------------------------------------------------------
end
$$;

========NOW RUN IN pg-client========
select ufn_test_date();
return: [{"now":"2021-09-21T10:49:53.272196+00:00"}]

========run code backend call function========
return: [{"now":"2021-09-21T06:51:49.317205-04:00"}]

lib connect db: https://www.nuget.org/packages/Npgsql.EntityFrameworkCore.PostgreSQL version: 5.0.2
client connect: Microsoft.EntityFrameworkCore:5.0.3

2 time values are 4 hours apart, pls help me :(

Trouble with iOS 11

I've got some trouble with iOS, there is like a value is substract of inset top in the scrollView.

I've find a way to figure out with an hardcoding value to add on contentInsetTop in updateLayouts, but it is so ugly. This substract exactly the height of navigationBar (64)

Something like that could be better

    func updateLayouts() {
        guard let child = self.childViewControllers.last as? PopupContentViewController else { return }
        popupView.frame.size = child.sizeForPopup(self, size: maximumSize, showingKeyboard: isShowingKeyboard)
        popupView.frame.origin.x = layout.origin(popupView).x
        baseScrollView.frame = view.frame
        var toAdd: CGFloat = 0
        if #available(iOS 11, *) {
            // Find a way to get the weird bottom inset of scrollView in iOS 11 (navigation bar height)
        }
        baseScrollView.contentInset.top = layout.origin(popupView).y + toAdd
        defaultContentOffset.y = -baseScrollView.contentInset.top
    }

Set the new attribute on scrollView available in iOS doesnt solve my problem
self.baseScrollView.contentInsetAdjustmentBehavior = .never

Here's two screenshot, one made in iOS 10, other in iOS 11. You can see the difference of inset.

simulator screen shot - iphone 7 - 2018-04-02 at 21 24 48
simulator screen shot - iphone 7 - 2018-04-02 at 21 25 27

Having trouble with popup

I did exactly like your example but when i tap the button to call the popup it crash right here

in PopupSBVC.swift
class func instance() -> PopupSBVC {
    let storyboard = UIStoryboard(name: "PopupSBVC", bundle: nil)
    return storyboard.instantiateInitialViewController() as! PopupSBVC
}

in my Viewcontroller.swift

@IBAction func rightBtnClicked(sender: AnyObject) {
    PopupController
        .create(self)
        .show(PopupSBVC.instance())

}

I had the storyboard name PopupSBVC

please help, many thanks

closeHandler not run

my code:
var closeHandler: (() -> Void)?`` @IBAction func ____btnCloseAction(sender: AnyObject) { closeHandler?() }
is now action but popup not close

Origin in split view on iPad

Hi,

I am trying to run it on an iPad split view, like Settings. However, when the origin is calculated, it seems that the width of the iPad screen is used size: CGSize = UIScreen.main.bounds.size, rather than the width of the view, which would be much narrower. This causes the popup to go off screen.

I have found this enum (below) which seems responsible for the origin of the popup but I can't see how I could configure the behaviour to work with the split view, as the customisation only seems to accept the actual enum value (top, center, bottom). Do you maybe have any pointers?

Thanks!

`
public enum PopupLayout {
case top, center, bottom

    func origin(_ view: UIView, size: CGSize = UIScreen.main.bounds.size) -> CGPoint {
        switch self {
        case .top: return CGPoint(x: (size.width - view.frame.width) / 2, y: 0)
        case .center: return CGPoint(x: (size.width - view.frame.width) / 2, y: (size.height - view.frame.height) / 2)
        case .bottom: return CGPoint(x: (size.width - view.frame.width) / 2, y: size.height - view.frame.height)
        }
    }
}

`

Manual Installation

CocoaPods and Carthage are awesome tools and make our life really easier, but there are some devs who still don't know how to use them.

It would be cool to add the Manual installation guide in your README.md. You can take a look at my iOS Readme Template to see how you can do it.

PopupBackgroundStyle

BlackFilter(alpha: CGFloat) not work.

in slide up animation there is

            self.baseScrollView.backgroundColor = UIColor.blackColor().colorWithAlphaComponent(0.7)

instead

            self.baseScrollView.backgroundColor = UIColor.blackColor().colorWithAlphaComponent(alpha)

Pass Data

Is it possible to pass data to DemoPopupViewController like a string or nsdata?

carthage

it was when the version with carthage

dismissWhenTaps does not work properly

Hello,

i have tried to setup the custom property dismissWhenTaps but i can not to set it in false. Putting true or false, the behavior is always like true.

NIce work...

Customize

Hello,

Thanks for this library has been really useful. I just wanted to point out that for customization the sintax is .cusomize instead of .custom

That is all. Should be easy to solve.

screen shot 2016-05-27 at 2 16 01 pm
screen shot 2016-05-27 at 2 15 36 pm

Background items are clickable when tapped anywhere on screen to dismiss PopUp

I am showing a PopUp when I click on the cell in TableView. PopUp disappears when I tap outside the PopUp view. But the problem is, I have a tabBar having 3 tabs at the the bottom of the screen and when I tap on the tabBar, the viewController related to clicked tab appears. Since alpha is 0.7 the background appears to be slightly dark, but the items in background are clickable when we tap outside PopUp view.
I don't want that to happen. When I tap anywhere outside the PopUp it should just disappear and I should be able to the TableView properly. Please fix this issue.

Crashes on pop

App crashes due to this:
return storyboard.instantiateInitialViewController() as! PopupView

Passing Data

Hey,
How should I pass data form my parentViewController to the popViewController?

'show' is unused

Is anyone getting swift compiler warning, that says

Result of call to 'show' is unused

ReadMe is deprecated

I found a small bug in your ReadMe usage Instructions.

PopupController .create(self) .show(AnyPopupViewController())

Since you don't have a .show() method (anymore) I think it should be

PopupController .create(self) .presentPopupController(AnyViewController()) { (void) in //code }

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.