PopupController is a controller for showing temporary popup view.

Overview

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.

Comments
  • Trouble with iOS 11

    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

    opened by Nexmind 1
  • Enhancement

    Enhancement

    Hey, my enhancement. please merge it.

    • [x] Add SlideDownAnimation
    • [x] Add @discardableResult
    • [x] Improve handling in order to stop force unwrapping into 'popupControllerWillShowKeyboard' func
    opened by omatty198 1
  • PopupBackgroundStyle

    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)
    
    opened by MattiaConfalonieri 1
  • fix access control

    fix access control

    @daisuke310vvv hi, daisuke

    pod install It was not available. 😇

    so I was fixed access control in order to be public protocol about PopupContentViewController.

    opened by omatty198 1
  • [PGSQL] Error get timestamp now() by code backend

    [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 :(

    opened by quanvq 0
  • Background items are clickable when tapped anywhere on screen to dismiss PopUp

    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.

    opened by ikyh 0
  • Origin in split view on iPad

    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)
            }
        }
    }
    

    `

    opened by firvorski 2
Releases(0.2.0)
Owner
daisuke sato
daisuke sato
SSToastMessage is written purely in SwiftUI. It will add toast, alert, and floating message view over the top of any view. It is intended to be simple, lightweight, and easy to use. It will be a popup with a single line of code.

SSToastMessage SSToastMessage is written in SwiftUI. It will add toast, alert, and floating message view over the top of any view. It is intended to b

Simform Solutions 223 Dec 2, 2022
A lightweight library for popup view

SHPopup SHPop is lightweight library used for popup view Sample One Sample Two Sample Three Features SHPopup supports a popup inside another popup wit

Shezad Ahamed 37 Oct 2, 2022
A framework for presenting bars and view controllers as popup, much like the look and feel of Apple Music App.

PBPopupController PBPopupController is a framework for presenting bars and view controllers as popup, much like the look and feel of Apple Music App.

Patrick 58 Dec 3, 2022
STPopup provides STPopupController, which works just like UINavigationController in popup style, for both iPhone and iPad. It's written in Objective-C and compatible with Swift.

STPopup STPopup provides STPopupController, which works just like UINavigationController in popup style, for both iPhone and iPad. It's written in Obj

Kevin Lin 2.6k Jan 6, 2023
Simple Swift class for iOS that shows nice popup windows with animation.

NMPopUpView Simple class for iOS that shows nice popup windows, written in Swift. The project is build with Swift 4.0, so you need Xcode 9.0 or higher

Nikos Maounis 194 Jun 5, 2022
A simple, customizable popup dialog for iOS written in Swift. Replaces UIAlertController alert style.

Introduction Popup Dialog is a simple, customizable popup dialog written in Swift. Features Easy to use API with hardly any boilerplate code Convenien

Orderella Ltd. 3.8k Dec 20, 2022
PopupWindow is a simple Popup using another UIWindow in Swift

PopupWindow PopupWindow is a simple Popup using another UIWindow Feature PopupWindow can be displayed at the top or bottom of the screen. Popup can se

shinji hayashi 415 Dec 5, 2022
⛩ Presenting custom views as a popup in iOS.

FFPopup is a lightweight library for presenting custom views as a popup. Bounce from Top & Bounce to Bottom Bounce from Top & Bounce to Top Bounce in

JonyFang 828 Jan 5, 2023
The library allows to create simple popup menus

react-native-popup-menu This library allows to create simple popup menus Installation "react-native-popup-menu": "sergeymild/react-native-popup-menu"

SergeyMild 0 Aug 20, 2022
WKWebView handling popup windows

WKWebViewWithPopUp WKWebView handling pop-up windows Property If there is a pop-up window, use the pop-up window. If there is no pop-up window, use th

Hankyeol Park 7 Nov 23, 2022
IAMPopup is a simple class for expressing custom popup in various forms.

IAMPopup Introduction IAMPopup is a simple class for expressing custom popup in various forms. This includes where to display the popup and space to d

Hosung Kang 18 Dec 29, 2022
Simple way to present custom views as a popup in iOS and tvOS.

PopupKit PopupKit is a simple and flexible iOS framework for presenting any custom view as a popup. It includes a variety of options for controlling h

Pointwelve 59 Mar 1, 2022
Subscription View Controller like the Tinder uses

SubscriptionPrompt SubscriptionPrompt is a UIViewController with a carousel at the top and a number of rows at the bottom. Written in Swift, works for

Binur Konarbai 235 Nov 17, 2022
A highly customizable alert dialog controller that mimics Snapchat's alert dialog.

AZDialogViewController A highly customizable alert dialog controller that mimics Snapchat's alert dialog. Screenshots Installation CocoaPods: pod 'AZD

Antonio Zaitoun 771 Dec 11, 2022
LNPopupController is a framework for presenting view controllers as popups of other view controllers, much like the Apple Music and Podcasts apps.

LNPopupController LNPopupController is a framework for presenting view controllers as popups of other view controllers, much like the Apple Music and

Leo Natan 2.9k Jan 2, 2023
Pop-up based view(e.g. alert sheet), can be easily customized.

MMPopupView 中文介绍 A basic Pop-Up Kit allows you to easily create Pop-Up view. You can focus on the only view you want to show. Besides, it comes with 2

ralph li 2.1k Jan 3, 2023
A Swift Popup Module help you popup your custom view easily

JFPopup JFPopup is a Swift Module help you popup your custom view easily. Support 3 way to popup, Drawer, Dialog and BottomSheet. Example To run the e

逸风 77 Dec 14, 2022
Useful for showing text or custom view tags in a vertical or horizontal scrollable view and support Autolayout at the same time

Useful for showing text or custom view tags in a vertical or horizontal scrollable view and support Autolayout at the same time. It is highly customizable that most features of the text tag can be configured.

zekunyan 1.8k Dec 30, 2022
SSToastMessage is written purely in SwiftUI. It will add toast, alert, and floating message view over the top of any view. It is intended to be simple, lightweight, and easy to use. It will be a popup with a single line of code.

SSToastMessage SSToastMessage is written in SwiftUI. It will add toast, alert, and floating message view over the top of any view. It is intended to b

Simform Solutions 223 Dec 2, 2022
A controller that uses a UIStackView and view controller composition to display content in a list

StackViewController Overview StackViewController is a Swift framework that simplifies the process of building forms and other static content using UIS

Seed 867 Dec 27, 2022