mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-25 02:52:45 +02:00
Improve dial pad screen with new config
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -291,6 +291,8 @@
|
||||
<outlet property="digitsStackView" destination="fnQ-jm-HT2" id="ltK-Bg-hwY"/>
|
||||
<outlet property="lineView" destination="iak-30-PMd" id="T6L-kl-Dsy"/>
|
||||
<outlet property="phoneNumberTextField" destination="iWR-Bv-qzs" id="ezn-FP-ihl"/>
|
||||
<outlet property="phoneNumberTextFieldTopConstraint" destination="nkS-49-CiR" id="Anh-q0-26b"/>
|
||||
<outlet property="spaceButton" destination="Xig-ln-gBC" id="tJi-AD-WOu"/>
|
||||
<outlet property="titleLabel" destination="ObS-Bw-Z12" id="0ZH-xI-zhw"/>
|
||||
</connections>
|
||||
</viewController>
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user