GithubHelp home page GithubHelp logo

nurymka / subscriptionprompt Goto Github PK

View Code? Open in Web Editor NEW

This project forked from binchik/subscriptionprompt

0.0 2.0 0.0 243 KB

Subscription View Controller like the Tinder uses

License: MIT License

Ruby 2.34% Swift 95.60% Objective-C 2.06%

subscriptionprompt's Introduction

SubscriptionPrompt

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

SubscriptionPrompt screenshot

Installation

CocoaPods

You can use CocoaPods to install SubscriptionPrompt by adding it to your Podfile:

platform :ios, '8.0'
use_frameworks!
pod 'SubscriptionPrompt'

To get the full benefits import SubscriptionPrompt wherever you import UIKit

import UIKit
import SubscriptionPrompt

Manually

Download and drop /SubscriptionPromptfolder in your project.

Usage

Just initialize the SubscriptionViewontroller with the following constructor, you can omit some parameters since they have default values:

init(title: String? = nil, slides: [Slide], options: [Option],
	cancelMessage: String? = nil, restoreButtonTitle: String? = nil)

and present it.

Slide and Option are structs, use the following inits to create them:

init(image: UIImage?, title: String?, subtitle: String?)
init(title: String?, checked: Bool = false)

To get the index of tapped rows, implement the SubscriptionViewControllerDelegate.

override func viewDidLoad() {
      super.viewDidLoad()
      subscriptionViewController.delegate = self
}

func subscriptionViewControllerRowTapped(atIndex index: Int) {
    print("tapped index: \(index)")
}

animateDraggingToTheRight(duration:) - animates a little drag to the right and back with the given duration [ux hint for the user that the carousel is draggable]

Styles customization

Set stylingDelegate: SubscriptionViewControllerStylingDelegate to customize styles. There are three optional methods:

optional func subscriptionViewControllerSlideStyle(atIndex index: Int) -> SlideStyle
optional func subscriptionViewControllerOptionStyle(atIndex index: Int) -> OptionStyle
optional func subscriptionViewControllerNotNowButtonStyle() -> OptionStyle

The methods return OptionStyle and SlideStyle. They represent the looks of the subscription options at the bottom and of the slides at the top.

Use the following init for OptionStyle:

init(backgroundColor: UIColor? = nil, textFont: UIFont? = nil,
	textColor: UIColor? = nil, accessoryType: UITableViewCellAccessoryType? = nil)

and for SlideStyle:

init(backgroundColor: UIColor? = nil, titleFont: UIFont? = nil,
	subtitleFont: UIFont? = nil, titleColor: UIColor? = nil, 
	subtitleColor: UIColor? = nil)

The title is customizable via the titleFont and titleColor properties. You can also change the background dim color using the dimColor: UIColor and dimView: UIView properties.

TODO

  1. Bug fixes.
  2. Add closure-based delegation API. Example:
subscriptionVC.rowTapped { idx in
	print("tapped index: \(idx)")
}

subscriptionprompt's People

Contributors

binchik avatar basthomas avatar lfarah avatar

Watchers

James Cloos avatar Nurym 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.