Skip to content

Commit

Permalink
[fix] Fix back button title
Browse files Browse the repository at this point in the history
  • Loading branch information
Samet Aktaş committed Oct 3, 2019
1 parent ccecc12 commit 27aafee
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 9 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion Desk360.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "Desk360"
s.version = "0.9.1"
s.version = "0.9.2"
s.summary = "Desk360 iOS SDK"
s.description = <<-DESC
Desk360 iOS SDK [WIP]
Expand Down
14 changes: 14 additions & 0 deletions Sources/Desk360+Config.swift
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,20 @@ public extension Desk360.Config.Requests.Listing {
}
}()

/// Back button icon.
static var backIcon: UIImage = {
switch Desk360.Config.theme {
case .light:
guard let path = Desk360.Config.bundle?.path(forResource: "Images/backButtonLight", ofType: "png") else { return UIImage() }
let image = UIImage(contentsOfFile: path)!
return image
case .dark:
guard let path = Desk360.Config.bundle?.path(forResource: "Images/backButtonDark", ofType: "png") else { return UIImage() }
let image = UIImage(contentsOfFile: path)!
return image
}
}()

}

/// Use `SupportConfig.Listing.Cell` to set up request cells in request listing page in your application.
Expand Down
10 changes: 9 additions & 1 deletion Sources/Scenes/Conversation/ConversationViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import UIKit
import Result

final class ConversationViewController: UIViewController, Layouting, UITableViewDataSource, UITableViewDelegate {
final class ConversationViewController: UIViewController, Layouting, UITableViewDataSource, UITableViewDelegate, UIGestureRecognizerDelegate {

var request: Ticket!
convenience init(request: Ticket) {
Expand Down Expand Up @@ -70,6 +70,10 @@ final class ConversationViewController: UIViewController, Layouting, UITableView

layoutableView.conversationInputView.createRequestButton.addTarget(self, action: #selector(didTapNewRequestButton), for: .touchUpInside)
navigationItem.title = Desk360.Strings.Support.mySupportRequest
navigationController?.interactivePopGestureRecognizer?.isEnabled = true
navigationController?.interactivePopGestureRecognizer?.delegate = self

navigationItem.leftBarButtonItem = NavigationItems.back(target: self, action: #selector(didTapBackButton))
}

override func viewDidAppear(_ animated: Bool) {
Expand Down Expand Up @@ -248,4 +252,8 @@ extension ConversationViewController {
navigationController?.pushViewController(CreateRequestViewController(checkLastClass: true), animated: true)
}

@objc func didTapBackButton() {
navigationController?.popViewController(animated: true)
}

}
18 changes: 11 additions & 7 deletions Sources/Scenes/CreateRequest/CreateRequestViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import UIKit

final class CreateRequestViewController: UIViewController, Layouting {
final class CreateRequestViewController: UIViewController, Layouting, UIGestureRecognizerDelegate {

typealias ViewType = CreateRequestView
override func loadView() {
Expand All @@ -30,26 +30,30 @@ final class CreateRequestViewController: UIViewController, Layouting {
guard let check = checkLastClass, check else { return }
let count = navigationController?.viewControllers.count ?? 0
navigationController?.viewControllers.removeSubrange(count-2..<count-1)

// navigationItem.leftBarButtonItem = NavigationItems.back(target: self, action: #selector(didTapBackButton))

}

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)

navigationItem.title = Desk360.Strings.Support.listingNavTitle

fetchTicketType()

if let icon = Desk360.Config.Requests.Create.backBarButtonIcon {
navigationController?.navigationBar.backIndicatorImage = icon
navigationController?.navigationBar.backIndicatorTransitionMaskImage = icon
navigationItem.backBarButtonItem = .init(title: "", style: .plain, target: nil, action: nil)
}
navigationController?.interactivePopGestureRecognizer?.isEnabled = true
navigationController?.interactivePopGestureRecognizer?.delegate = self
navigationItem.rightBarButtonItem = nil

navigationItem.leftBarButtonItem = NavigationItems.back(target: self, action: #selector(didTapBackButton))
// }
}

@objc private func didTapSendRequestButton() {

guard let name = layoutableView.nameTextField.trimmedText, name.count > 2 else {
layoutableView.nameErrorLabel.isHidden = false
// layoutableView.scrollView.scrollsToTop = true
layoutableView.scrollView.setContentOffset(CGPoint(x: 0, y: 0), animated: true)
layoutableView.nameTextField.shake()
layoutableView.nameTextField.becomeFirstResponder()
Expand Down
4 changes: 4 additions & 0 deletions Sources/Scenes/NavigationItems.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,8 @@ struct NavigationItems {
return UIBarButtonItem(image: Desk360.Config.Requests.Listing.NavItem.closeIcon, style: .plain, target: target, action: action)
}

static func back(target: Any?, action: Selector?) -> UIBarButtonItem {
return UIBarButtonItem(image: Desk360.Config.Requests.Listing.NavItem.backIcon, style: .plain, target: target, action: action)
}

}

0 comments on commit 27aafee

Please sign in to comment.