Add dial pad tones

This commit is contained in:
ismailgulek
2021-02-15 15:58:19 +03:00
parent ba20945066
commit 18a847fc78
4 changed files with 31 additions and 16 deletions
@@ -85,18 +85,18 @@ class DialpadViewController: UIViewController {
static let sizeOniPad: CGSize = CGSize(width: 375, height: 667)
static let additionalTopInset: CGFloat = 20
static let digitButtonViewDatas: [Int: DialpadButton.ViewData] = [
-2: .init(title: "#"),
-1: .init(title: "*"),
0: .init(title: "0", subtitle: "+"),
1: .init(title: "1", showsSubtitleSpace: true),
2: .init(title: "2", subtitle: "ABC"),
3: .init(title: "3", subtitle: "DEF"),
4: .init(title: "4", subtitle: "GHI"),
5: .init(title: "5", subtitle: "JKL"),
6: .init(title: "6", subtitle: "MNO"),
7: .init(title: "7", subtitle: "PQRS"),
8: .init(title: "8", subtitle: "TUV"),
9: .init(title: "9", subtitle: "WXYZ")
-2: .init(title: "#", tone: 1211),
-1: .init(title: "*", tone: 1210),
0: .init(title: "0", tone: 1200, subtitle: "+"),
1: .init(title: "1", tone: 1201, showsSubtitleSpace: true),
2: .init(title: "2", tone: 1202, subtitle: "ABC"),
3: .init(title: "3", tone: 1203, subtitle: "DEF"),
4: .init(title: "4", tone: 1204, subtitle: "GHI"),
5: .init(title: "5", tone: 1205, subtitle: "JKL"),
6: .init(title: "6", tone: 1206, subtitle: "MNO"),
7: .init(title: "7", tone: 1207, subtitle: "PQRS"),
8: .init(title: "8", tone: 1208, subtitle: "TUV"),
9: .init(title: "9", tone: 1209, subtitle: "WXYZ")
]
}
@@ -274,12 +274,19 @@ class DialpadViewController: UIViewController {
}
@IBAction private func digitButtonAction(_ sender: DialpadButton) {
let digit = Constants.digitButtonViewDatas[sender.tag]?.title ?? ""
guard let digitViewData = Constants.digitButtonViewDatas[sender.tag] else {
return
}
let digit = digitViewData.title
defer {
delegate?.dialpadViewControllerDidTapDigit?(self, digit: digit)
}
if configuration.playTones {
AudioServicesPlaySystemSound(digitViewData.tone)
}
if !configuration.editingEnabled {
phoneNumber += digit
return