diff --git a/Riot/Modules/Call/Dialpad/DialpadConfiguration.swift b/Riot/Modules/Call/Dialpad/DialpadConfiguration.swift
index 51ec1b687..a1d91f3d2 100644
--- a/Riot/Modules/Call/Dialpad/DialpadConfiguration.swift
+++ b/Riot/Modules/Call/Dialpad/DialpadConfiguration.swift
@@ -20,6 +20,12 @@ import Foundation
@objcMembers
class DialpadConfiguration: NSObject {
+ /// Option for a dial pad to show the title or not.
+ var showsTitle: Bool
+
+ /// Option for a dial pad to show the close button or not.
+ var showsCloseButton: Bool
+
/// Option for a dial pad to show the backspace button or not.
var showsBackspaceButton: Bool
@@ -35,10 +41,14 @@ class DialpadConfiguration: NSObject {
/// Default configuration object. All options are enabled by default.
static let `default`: DialpadConfiguration = DialpadConfiguration()
- init(showsBackspaceButton: Bool = true,
+ init(showsTitle: Bool = true,
+ showsCloseButton: Bool = true,
+ showsBackspaceButton: Bool = true,
showsCallButton: Bool = true,
formattingEnabled: Bool = true,
editingEnabled: Bool = true) {
+ self.showsTitle = showsTitle
+ self.showsCloseButton = showsCloseButton
self.showsBackspaceButton = showsBackspaceButton
self.showsCallButton = showsCallButton
self.formattingEnabled = formattingEnabled
diff --git a/Riot/Modules/Call/Dialpad/DialpadViewController.storyboard b/Riot/Modules/Call/Dialpad/DialpadViewController.storyboard
index b8393781e..8f81e6b7f 100644
--- a/Riot/Modules/Call/Dialpad/DialpadViewController.storyboard
+++ b/Riot/Modules/Call/Dialpad/DialpadViewController.storyboard
@@ -291,6 +291,8 @@
+
+
diff --git a/Riot/Modules/Call/Dialpad/DialpadViewController.swift b/Riot/Modules/Call/Dialpad/DialpadViewController.swift
index d692a1cae..743b39471 100644
--- a/Riot/Modules/Call/Dialpad/DialpadViewController.swift
+++ b/Riot/Modules/Call/Dialpad/DialpadViewController.swift
@@ -22,7 +22,7 @@ import libPhoneNumber_iOS
@objc protocol DialpadViewControllerDelegate: class {
@objc optional func dialpadViewControllerDidTapCall(_ viewController: DialpadViewController,
withPhoneNumber phoneNumber: String)
- func dialpadViewControllerDidTapClose(_ viewController: DialpadViewController)
+ @objc optional func dialpadViewControllerDidTapClose(_ viewController: DialpadViewController)
@objc optional func dialpadViewControllerDidTapDigit(_ viewController: DialpadViewController, digit: String)
}
@@ -32,8 +32,23 @@ class DialpadViewController: UIViewController {
// MARK: Outlets
- @IBOutlet private weak var closeButton: UIButton!
- @IBOutlet private weak var titleLabel: UILabel!
+ @IBOutlet private weak var phoneNumberTextFieldTopConstraint: NSLayoutConstraint! {
+ didSet {
+ if !configuration.showsTitle && !configuration.showsCloseButton {
+ phoneNumberTextFieldTopConstraint.constant = 0
+ }
+ }
+ }
+ @IBOutlet private weak var closeButton: UIButton! {
+ didSet {
+ closeButton.isHidden = !configuration.showsCloseButton
+ }
+ }
+ @IBOutlet private weak var titleLabel: UILabel! {
+ didSet {
+ titleLabel.isHidden = !configuration.showsTitle
+ }
+ }
@IBOutlet private weak var phoneNumberTextField: UITextField! {
didSet {
phoneNumberTextField.text = nil
@@ -57,6 +72,11 @@ class DialpadViewController: UIViewController {
callButton.isHidden = !configuration.showsCallButton
}
}
+ @IBOutlet private weak var spaceButton: UIButton! {
+ didSet {
+ spaceButton.isHidden = !configuration.showsBackspaceButton || !configuration.showsCallButton
+ }
+ }
// MARK: Private
@@ -81,7 +101,7 @@ class DialpadViewController: UIViewController {
}
}
/// Phone number as non-formatted
- private var rawPhoneNumber: String {
+ var rawPhoneNumber: String {
return phoneNumber.vc_removingAllWhitespaces()
}
private var theme: Theme!
@@ -229,7 +249,7 @@ class DialpadViewController: UIViewController {
}
@IBAction private func closeButtonAction(_ sender: UIButton) {
- delegate?.dialpadViewControllerDidTapClose(self)
+ delegate?.dialpadViewControllerDidTapClose?(self)
}
@IBAction private func digitButtonAction(_ sender: DialpadButton) {
@@ -269,6 +289,10 @@ class DialpadViewController: UIViewController {
}
@IBAction private func backspaceButtonAction(_ sender: DialpadActionButton) {
+ defer {
+ delegate?.dialpadViewControllerDidTapDigit?(self, digit: "")
+ }
+
if phoneNumber.isEmpty {
return
}