Skip to content

Commit

Permalink
refactor ReportReason
Browse files Browse the repository at this point in the history
  • Loading branch information
nixzhu committed Aug 12, 2016
1 parent 9b3133a commit 0ec7445
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
10 changes: 5 additions & 5 deletions Yep/Extensions/UIViewController+Yep.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ extension UIViewController {

extension ReportReason {

var description: String {
var title: String {
switch self {
case .Porno:
return String.trans_reportPorno
Expand Down Expand Up @@ -111,22 +111,22 @@ extension UIViewController {

let reportAlertController = UIAlertController(title: NSLocalizedString("Report Reason", comment: ""), message: nil, preferredStyle: .ActionSheet)

let pornoReasonAction: UIAlertAction = UIAlertAction(title: ReportReason.Porno.description, style: .Default) { action -> Void in
let pornoReasonAction: UIAlertAction = UIAlertAction(title: ReportReason.Porno.title, style: .Default) { action -> Void in
reportWithReason(.Porno)
}
reportAlertController.addAction(pornoReasonAction)

let advertisingReasonAction: UIAlertAction = UIAlertAction(title: ReportReason.Advertising.description, style: .Default) { action -> Void in
let advertisingReasonAction: UIAlertAction = UIAlertAction(title: ReportReason.Advertising.title, style: .Default) { action -> Void in
reportWithReason(.Advertising)
}
reportAlertController.addAction(advertisingReasonAction)

let scamsReasonAction: UIAlertAction = UIAlertAction(title: ReportReason.Scams.description, style: .Default) { action -> Void in
let scamsReasonAction: UIAlertAction = UIAlertAction(title: ReportReason.Scams.title, style: .Default) { action -> Void in
reportWithReason(.Scams)
}
reportAlertController.addAction(scamsReasonAction)

let otherReasonAction: UIAlertAction = UIAlertAction(title: ReportReason.Other("").description, style: .Default) { [weak self] action -> Void in
let otherReasonAction: UIAlertAction = UIAlertAction(title: ReportReason.Other("").title, style: .Default) { [weak self] action -> Void in
YepAlert.textInput(title: NSLocalizedString("Other Reason", comment: ""), message: nil, placeholder: nil, oldText: nil, confirmTitle: NSLocalizedString("OK", comment: ""), cancelTitle: NSLocalizedString("Cancel", comment: ""), inViewController: self, withConfirmAction: { text in
reportWithReason(.Other(text))
}, cancelAction: nil)
Expand Down
6 changes: 5 additions & 1 deletion YepKit/Remote/YepService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -871,12 +871,16 @@ public func friendsInContacts(contacts: [UploadContact], failureHandler: Failure
}

public enum ReportReason {

case Porno
case Advertising
case Scams
case Other(String)
}

extension ReportReason {

public var type: Int {
var type: Int {
switch self {
case .Porno:
return 0
Expand Down

0 comments on commit 0ec7445

Please sign in to comment.