Overview
Welcome to the documentation for Proposer – a library designed to simplify the process of proposing suggestions or alternatives to users. This library provides a hassle-free solution for including suggestion forms or alternative options in your application.
Installation
To use Proposer in your project, follow these simple steps:
- Open Terminal and navigate to your project directory.
- Run the following command:
“`bash
$ pod install
“`
This will install Proposer and all its dependencies within your project.
Getting Started
To start using Proposer in your application, follow these steps:
- Import the Proposer module into your view controller:
“`swift
import Proposer
“`
Note: Make sure you have properly installed Proposer and its dependencies before importing.
- Create an instance of the Proposer class:
“`swift
let proposer = Proposer()
“`
- Add a suggestion form to your view:
“`swift
proposer.showSuggestionForm()
“`
This will present a suggestion form to the user, allowing them to enter their suggestions or alternatives. The form includes fields for a title, description, and any additional details.
Customization
Proposer offers several customization options to enhance the user experience. You can customize the appearance and behavior of the suggestion form by modifying the following properties:
- backgroundColor: Change the background color of the suggestion form.
- titlePlaceholder: Customize the placeholder text for the title field.
- descriptionPlaceholder: Customize the placeholder text for the description field.
- additionalDetailsPlaceholder: Customize the placeholder text for the additional details field.
- textColor: Modify the text color of the suggestion form.
“`swift
proposer.backgroundColor = .white
proposer.titlePlaceholder = “Enter a title”
proposer.descriptionPlaceholder = “Enter a description”
proposer.additionalDetailsPlaceholder = “Enter any additional details”
proposer.textColor = .black
“`
You can set these properties before presenting the suggestion form to the user for a customized experience.
Delegate Methods
Proposer offers delegate methods to provide feedback on user actions and help you manage the suggestion form. Implement the following delegate methods in your view controller:
“`swift
func didSubmitSuggestion(title: String, description: String, additionalDetails: String?) {
// Handle the submitted suggestion here
// Example: Send the suggestion details to the server
}
func didCancelSuggestion() {
// Handle the cancellation of the suggestion form
}
“`
These delegate methods will be called when the user submits a suggestion or cancels the suggestion form.
Sample Code
Here’s a simple example demonstrating how to use Proposer in your project:
“`swift
import UIKit
import Proposer
class ViewController: UIViewController, ProposerDelegate {
let proposer = Proposer()
override func viewDidLoad() {
super.viewDidLoad()
proposer.delegate = self
}
func showSuggestionForm() {
proposer.showSuggestionForm()
}
func didSubmitSuggestion(title: String, description: String, additionalDetails: String?) {
// Handle the submitted suggestion here
// Example: Send the suggestion details to the server
}
func didCancelSuggestion() {
// Handle the cancellation of the suggestion form
}
}
“`