Giter Club home page Giter Club logo

popupwindow's Introduction

PopupWindow

Version License Carthage compatible Platform

image

PopupWindow is a simple Popup using another UIWindow

Feature

  • PopupWindow can be displayed at the top or bottom of the screen.
  • Popup can set margins, cornerRadius, blur, etc.
  • When displaying blur, you can't touch the below contents.
  • By erasing blur, you can touch the below contents.
  • Popup are displayed on another window, so you can leave Popup even when screen transitions.
TopToast BottomToast TopCard BottomCard Example
demo_01 demo_02 demo_03 demo_04 demo_05

Installation

CocoaPods

Add PopupWindow to your Podfile:

pod 'PopupWindow'

Carthage

Add PopupWindow to your Cartfile:

github "shin8484/PopupWindow"

Usage

When displaying popup in another window, please call first PopupWindowManager changeKeyWindow(rootViewController: UIViewController)

PopupWindowManager.shared.changeKeyWindow(rootViewController: UIViewController())

Create and show show

Create a PopupItem in the ViewController where you want to display the popup and call the method of BasePopupViewController

let popupOption = PopupOption(shapeType: .roundedCornerTop(cornerSize: 8), viewType: .toast, direction: .bottom)
let popupItem = PopupItem(view: loginView,
                          height: Const.firstViewFrame.height,
                          maxWidth: 500,
                          popupOption: popupOption)

First popup implementation is included in BasePopupViewController's loadView, viewDidAppear. If you want to create the next popup, please call showPopupView().

class SampleViewController: BasePopupViewController {
    override open func loadView() {
        super.loadView()
        setupPopupContainerView()
    }

    override open func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        makePopupView(with: item)
        showPopupView(duration: item.duration, curve: .easeInOut, delayFactor: 0.0)
    }
}

Transform & Replace

Replace the display contents, and perform deformation to the specified size. By using PopupItem, you can specify content contents and size.

transformPopupView(duration: Const.transformDuration, curve: .easeInOut, popupItem: popupItem) { [weak self] _ in
    guard let me = self else { return }
    me.replacePopupView(with: popupItem)
    me.dismissPopupView(duration: 3.3, curve: .easeInOut, delayFactor: 0.9, direction: .top) { _ in }
}

Dismiss

Specify hide animation direction with PopupViewDirection

dismissPopupView(duration: 3.3, curve: .easeInOut, delayFactor: 0.9, direction: .bottom) { _ in
    PopupWindowManager.shared.changeKeyWindow(rootViewController: nil)
}

PopupItem

PopupItem and PopupOption are struct to set up a popup, View, size, direction, whether it is rounded, margin, blurred or not, duration, maxWidth, type

public struct PopupItem {
    public let view: UIView
    public let height: CGFloat
    public let maxWidth: CGFloat
    public let landscapeSize: CGSize?
    public let popupOption: PopupOption
}
public struct PopupOption {
    public let shapeType: ShapeType
    public let viewType: ViewType
    public let direction: PopupViewDirection
    public let margin: CGFloat
    public let hasBlur: Bool
    public let duration: TimeInterval
    public let canTapDismiss: Bool
}

Landscape

maxWidth

By setting maxWidth with popupitem's initializer, you can set the maximum width of the popup in landscape mode.

image

landscapeSize

You can set popup size at landscape. The size changes only when landscape size is set, and the default is nil. Using landscapeSize and SizeClass, you can customize PopupVIew that has the widest width like GIF below when rotating.

demo_06

Requirements

  • iOS 10.0+
  • Xcode 9.1+
  • Swift 3.0.1+

LICENSE

Under the MIT license. See LICENSE file for details.

popupwindow's People

Contributors

shin8484 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

popupwindow's Issues

Can't use with Cocoapods

When performing pod install the error appears:

[!] CocoaPods could not find compatible versions for pod "PopupWindow":
In Podfile:
PopupWindow

Specs satisfying the PopupWindow dependency were found, but they required a higher minimum deployment target.

Which version should I use?

Unidentified view on top of popup view if rendered after camera image picker dismissal

I tried showing login screen popup provided in the demo after a the dismissal of camera imagepicker view. It shows 2 unidentified views on top of the popup view causing to obstruct interaction with the popup view. This happens only if i tried to show the popup after camera view dismissal

Device: iPhone XS
iOS: 13.5.1

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    let imagePickerVC = UIImagePickerController()
    imagePickerVC.delegate = self
    magePickerVC.sourceType = .camera
    imagePickerVC.videoMaximumDuration = 10
    imagePickerVC.mediaTypes = [String(kUTTypeMovie), String(kUTTypeImage)]
    present(imagePickerVC, animated: true)
}

func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
    dismiss(animated: true) {
        PopupWindowManager.shared.changeKeyWindow(rootViewController: LoginPopupViewController())
    }
}

Screenshot 2020-06-27 at 00 36 31

Fatal Error

There is a fatal error in PopupViewContainable.swift using Xcode 11.3:
PopupViewContainable.swift:12:5: error: 'weak' cannot be applied to a property declaration in a protocol
weak var containerView: UIView! { get }

The error can be fixed by removing the "weak" in the var declaration. I'm not sure if a property needs to be declared as "weak" instead.

Top toast not ready for iPhone X

You probably know this but I'll let this here anyway.

I checked because I fought with this already and didn't like my aproach which involves calculating frames... bleah

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.