Welcome to UsabillaForm — a suite of class that aims to display feedback forms in your existing Swift projects.
pod 'UsabillaForm'
A form must be provided with a UsabillaForm object in order to be initialized
let form = UsabillaForm(formID: "yourFormId", type: .FeedBack)
let usabilla = Usabilla(form: form)
usabilla.delegate = self
usabilla.configureFeedBackForm { [weak self] result in
switch result {
case .success(let form):
self?.present(form, animated: true, completion: nil)
case .failure(let error):
print(error.localizedDescription)
}
}
Or rating view
let form = UsabillaForm(formID: "yourFormId", type: .Rating)
let usabilla = Usabilla(form: form)
usabilla.delegate = self
usabilla.configureFeedBackForm { [weak self] result in
switch result {
case .success(let form):
self?.present(form, animated: true, completion: nil)
case .failure(let error):
print(error.localizedDescription)
}
}
You can set custom properties such as form background color, form title color and form title font
form.customProperties?.formBackgroundColor = .white
form.customProperties?.formTitleFont = UIFont.systemFont(ofSize: 14, weight: .light)
form.customProperties?.formTitleTextColor = .black
form.customProperties?.feedBackQuestionTitle = "Your Feedback ?"
Comfort the UsabillaFormDelegate in your view controller
extension YourViewController: UsabillaFormDelegate {
func didFormSubmit(_ form: UIViewController, _ typedText: String) {
// form.dismiss(animated: true, completion: nil)
}
func didRatingSubmit(_ form: UIViewController, _ rating: Int) {
// form.dismiss(animated: true, completion: nil)
}
}
let surveyQuestions = ["Question 1",
"Question 2",
"Question 3"]
let survey = UsabillaForm.Survey(surveyQuestions: surveyQuestions)
let form = UsabillaForm(formID: "yourFormId",
type: .Survey,
survey: survey)
usabilla = Usabilla(form: form)
usabilla.delegate = self
usabilla.configureSurvey { [weak self] result in
switch result {
case .success(let form):
self?.present(form, animated: true, completion: nil)
case .failure(let error):
print(error.localizedDescription)
}
}
}
Survey Delegate will return [String: Int]. Survey questions and their ratings
func didSurveySubmitted(_ form: UIViewController, _ surveyResult: [String : Int]) {
form.dismiss(animated: true, completion: nil)
}