Skip to content

Latest commit

 

History

History
97 lines (74 loc) · 3.66 KB

File metadata and controls

97 lines (74 loc) · 3.66 KB

Acknowledgements

A simple solution for adding an acknowledgement section to your app. Includes all pod licenses from the Cocoapods generated plist.

Default Appearance

Screenshots

Quick Start

To use AcknowledgementsListViewController as-is, follow these 4 easy steps:

  1. Add post_install hook to the end of your Podfile to copy the generated plist into your project root folder. Rememeber to replace <project-name> with your project's name
post_install do | installer |
    require 'fileutils'
    FileUtils.cp_r('Pods/Target Support Files/Pods-<project-name>/Pods-<project-name>.plist', '<project-name>/Acknowledgements.plist', :remove_destination => true)
end
  1. Create an instance of AcknowledgementsListViewModel. Requires a try to catch any throw.

  2. Create an instance of AcknowledgementsListViewController using your view model.

  3. Push your view controller onto your existing UINavigationController to take advantage of the built-in back button.

do {
    let viewModel = try AcknowledgementsListViewModel() // STEP 2
    let viewController = AcknowledgementsListViewController(viewModel: viewModel) // STEP 3
    navigationController?.pushViewController(viewController, animated: true) // STEP 4
catch {
    print(error.localizedDescription)
}

Custom Appearance

Screenshots

AcknowledgementsListViewController

To customize, just subclass it. Please note that it is already subclassing UITableViewController so you may need to override table view methods to further customize the look and feel.

Property Type Notes
childViewControllerClass AcknowledgementViewController.Type Be sure to set this if you are using a custom AcknowledgementViewController for the license view.
viewModel AcknowledgementsListViewModel Best to use as-is.
licenseFormatter (String) -> NSAttributedString Closure for formatting the text
licenseViewBackgroundColor UIColor Set the background color for the license view.
cellBackgroundColor UIColor Set the background color for the list view.
class CustomAcknowledgementsListViewController: AcknowledgementsListViewController {
  override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
      let cell = super.tableView(tableView, cellForRowAt: indexPath)
      cell.textLabel?.textColor = .random
      return cell
  }
  override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
      defer { super.tableView(tableView, didSelectRowAt: indexPath) }
      guard let cell = tableView.cellForRow(at: indexPath) else { return }
      licenseViewBackgroundColor = .random
  }
}
do {
  let viewModel = try AcknowledgementsListViewModel()
  let viewController = CustomAcknowledgementsListViewController(viewModel: viewModel)
  navigationController?.pushViewController(viewController, animated: true)  
catch {
  print(error.localizedDescription)
}

AcknowledgementViewController

There isn't that much benefit to subclassing this. Just use the parent view controller properties licenseFormatter and licenseViewBackgroundColor instead.

Screenshots courtesy of AcknowledgementSample