Latest 1.0.0
Homepage https://github.com/luispadron/LPIntegratedRating
License MIT
Platforms ios 8.0
Authors

LPIntegratedRating

An integrated rating view for iOS built with Swift 4

LPIntegratedRating

LPIntegratedRating

Features

  • Stops users feeling annoyed from pop ups asking for ratings.
  • Customizable for your app needs.
  • Easy to use with UITableView‘s and UICollectionViews‘s.

Installation

Cocoapods (recommended)

  1. Install CocoaPods
  2. Add this pod to your Podfile

    target 'Example' do
        use_frameworks!
    
        pod 'LPIntegratedRating'
    end
  3. Run pod install
  4. Open up the .xcworkspace that CocoaPods created
  5. Import LPIntegratedRating into any source file where it’s needed

From Source

  1. Simply download the source from here and add it to your Xcode project

Usage

To learn how to properly ask users to rate your app, read the wonderful article which inspired this library here.

Delegate conformance

You must conform to the delegate in order to customize the view.

Here is an example:

extension ViewController: LPRatingViewDelegate {

    func ratingViewDidFinish(with status: LPRatingViewCompletionStatus) {
        switch status {
        case .ratingApproved:
            print("Rating approved")
        case .ratingDenied:
            print("Rating denied")
        case .feedbackApproved:
            print("Feedback approved")
        case .feedbackDenied:
            print("Feedback denied")
        }
    }

    func ratingViewConfiguration(for state: LPRatingViewState) -> LPRatingViewConfiguration? {
        switch state {
        case .initial:
            let title = NSAttributedString(string: "Enjoying this app?",
                                           attributes: [.foregroundColor: UIColor.white])
            let title2 = NSAttributedString(string: "Yes!",
                                            attributes: [.foregroundColor: UIColor(red: 0.376, green: 0.788, blue: 0.773, alpha: 1.00)])
            let title3 = NSAttributedString(string: "Not really",
                                            attributes: [.foregroundColor: UIColor.white])
            return LPRatingViewConfiguration(title: title,
                                             approvalButtonTitle: title2,
                                             rejectionButtonTitle: title3)

        case .approval:
            let title = NSAttributedString(string: "How about rating, then?",
                                           attributes: [.foregroundColor: UIColor.white])
            let title2 = NSAttributedString(string: "Ok, sure",
                                            attributes: [.foregroundColor: UIColor(red: 0.376, green: 0.788, blue: 0.773, alpha: 1.00)])
            let title3 = NSAttributedString(string: "No, thanks",
                                            attributes: [.foregroundColor: UIColor.white])
            return LPRatingViewConfiguration(title: title,
                                             approvalButtonTitle: title2,
                                             rejectionButtonTitle: title3)
        case .rejection:
            let title = NSAttributedString(string: "Would you mind giving us some feedback",
                                           attributes: [.foregroundColor: UIColor.white])
            let title2 = NSAttributedString(string: "Ok, sure",
                                            attributes: [.foregroundColor: UIColor(red: 0.376, green: 0.788, blue: 0.773, alpha: 1.00)])
            let title3 = NSAttributedString(string: "No, thanks",
                                            attributes: [.foregroundColor: UIColor.white])
            return LPRatingViewConfiguration(title: title,
                                             approvalButtonTitle: title2,
                                             rejectionButtonTitle: title3)
        }
    }
}

UITableView

Simply create an instance of LPRatingTableViewCell, assign the delegate and return it!

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = LPRatingTableViewCell(style: .default, reuseIdentifier: nil)
    cell.delegate = self

    return cell
}

UICollectionView

First register the class

override func viewDidLoad() {
    super.viewDidLoad()
    // Register class
    collectionView?.register(LPRatingCollectionViewCell.self, forCellWithReuseIdentifier: "testCell")
}

Then simply create an instance of LPRatingCollectionViewCell, assign the delegate and return it

override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
    let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "testCell", for: indexPath) as! LPRatingCollectionViewCell
    cell.delegate = self

    return cell
}

View Flow

Here is the flow of the view, and the types of cases that will be passed to the delegate along the way.

doc-flow

Documentation

Read the full documentation here

Latest podspec

{
    "name": "LPIntegratedRating",
    "version": "1.0.0",
    "summary": "An integrated rating view for iOS",
    "description": "Integrated rating view for table views and collection views on iOS.",
    "homepage": "https://github.com/luispadron/LPIntegratedRating",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Luis Padron": "[email protected]"
    },
    "social_media_url": "http://luispadron.com",
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/luispadron/LPIntegratedRating.git",
        "tag": "v1.0.0"
    },
    "source_files": [
        "LPIntegratedRating",
        "LPIntegratedRating/**/*.{h,m}"
    ],
    "pushed_with_swift_version": "4.0"
}

Pin It on Pinterest

Share This