Fixed bug with repeating keys in PN keyboard
This commit is contained in:
parent
3f2df89fd0
commit
5be64456c3
@ -1136,7 +1136,7 @@
|
|||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements;
|
CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements;
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
CURRENT_PROJECT_VERSION = 101;
|
CURRENT_PROJECT_VERSION = 102;
|
||||||
DEVELOPMENT_TEAM = 46DTTB8X4S;
|
DEVELOPMENT_TEAM = 46DTTB8X4S;
|
||||||
INFOPLIST_FILE = AutoCat/Info.plist;
|
INFOPLIST_FILE = AutoCat/Info.plist;
|
||||||
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
|
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
|
||||||
@ -1161,7 +1161,7 @@
|
|||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements;
|
CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements;
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
CURRENT_PROJECT_VERSION = 101;
|
CURRENT_PROJECT_VERSION = 102;
|
||||||
DEVELOPMENT_TEAM = 46DTTB8X4S;
|
DEVELOPMENT_TEAM = 46DTTB8X4S;
|
||||||
INFOPLIST_FILE = AutoCat/Info.plist;
|
INFOPLIST_FILE = AutoCat/Info.plist;
|
||||||
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
|
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
|
||||||
|
|||||||
@ -5,6 +5,10 @@ extension UIEdgeInsets {
|
|||||||
init(all: CGFloat) {
|
init(all: CGFloat) {
|
||||||
self.init(top: all, left: all, bottom: all, right: all)
|
self.init(top: all, left: all, bottom: all, right: all)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
init(vertical: CGFloat, horizontal: CGFloat) {
|
||||||
|
self.init(top: vertical, left: horizontal, bottom: vertical, right: horizontal)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension UIEdgeInsets {
|
extension UIEdgeInsets {
|
||||||
@ -12,4 +16,12 @@ extension UIEdgeInsets {
|
|||||||
static func all(_ value: CGFloat) -> UIEdgeInsets {
|
static func all(_ value: CGFloat) -> UIEdgeInsets {
|
||||||
.init(all: value)
|
.init(all: value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static func vertical(_ value: CGFloat) -> UIEdgeInsets {
|
||||||
|
.init(vertical: value, horizontal: 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
static func horizontal(_ value: CGFloat) -> UIEdgeInsets {
|
||||||
|
.init(vertical: 0, horizontal: value)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -58,7 +58,7 @@ class NewNumberController: UIViewController {
|
|||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
|
|
||||||
view.addSubview(mainStackView)
|
view.addSubview(mainStackView)
|
||||||
mainStackView.pin(to: view, insets: .init(top: 16, left: 16, bottom: 16, right: 16))
|
mainStackView.pin(to: view, insets: .all(16))
|
||||||
}
|
}
|
||||||
|
|
||||||
func check() {
|
func check() {
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
import UIKit
|
import UIKit
|
||||||
import AutoCatCore
|
import AutoCatCore
|
||||||
|
|
||||||
protocol PNKeyboardDelegate: class {
|
protocol PNKeyboardDelegate: AnyObject {
|
||||||
func returnClicked()
|
func returnClicked()
|
||||||
}
|
}
|
||||||
|
|
||||||
protocol PNButtonDelegate: class {
|
protocol PNButtonDelegate: AnyObject {
|
||||||
func buttonTapped(_ button: PNButton)
|
func buttonTapped(_ button: PNButton)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -17,8 +17,6 @@ enum PNButtonType {
|
|||||||
|
|
||||||
class PNButton: UIButton {
|
class PNButton: UIButton {
|
||||||
private(set) var type: PNButtonType
|
private(set) var type: PNButtonType
|
||||||
private var timer: Timer?
|
|
||||||
private var waitCount = 0
|
|
||||||
private var rectLayer = CAShapeLayer()
|
private var rectLayer = CAShapeLayer()
|
||||||
private var bgColor = UIColor(named: "KeyBackground")
|
private var bgColor = UIColor(named: "KeyBackground")
|
||||||
|
|
||||||
@ -63,13 +61,15 @@ class PNButton: UIButton {
|
|||||||
self.layer.addSublayer(self.rectLayer)
|
self.layer.addSublayer(self.rectLayer)
|
||||||
self.imageView?.layer.zPosition = 2
|
self.imageView?.layer.zPosition = 2
|
||||||
|
|
||||||
|
self.contentEdgeInsets = .vertical(12)
|
||||||
|
|
||||||
self.rectLayer.shadowColor = UIColor.black.cgColor
|
self.rectLayer.shadowColor = UIColor.black.cgColor
|
||||||
self.rectLayer.shadowOpacity = 0.4
|
self.rectLayer.shadowOpacity = 0.4
|
||||||
self.rectLayer.shadowOffset = CGSize(width: 0.0, height : 1.0)
|
self.rectLayer.shadowOffset = CGSize(width: 0.0, height : 1.0)
|
||||||
self.rectLayer.shadowRadius = radius
|
self.rectLayer.shadowRadius = radius
|
||||||
|
|
||||||
self.addTarget(self, action: #selector(buttonDown), for: .touchDown)
|
self.addTarget(self, action: #selector(buttonDown), for: .touchDown)
|
||||||
self.addTarget(self, action: #selector(buttonUp), for: [.touchUpInside, .touchUpOutside])
|
self.addTarget(self, action: #selector(buttonUp), for: [.touchUpInside, .touchUpOutside, .touchCancel])
|
||||||
self.addTarget(self, action: #selector(touchUpInside), for: .touchUpInside)
|
self.addTarget(self, action: #selector(touchUpInside), for: .touchUpInside)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,19 +81,10 @@ class PNButton: UIButton {
|
|||||||
|
|
||||||
@objc func buttonDown(_ sender: PNButton) {
|
@objc func buttonDown(_ sender: PNButton) {
|
||||||
sender.layer.opacity = 0.3
|
sender.layer.opacity = 0.3
|
||||||
self.timer = Timer.scheduledTimer(withTimeInterval: 0.1, repeats: true, block: { _ in
|
|
||||||
self.waitCount += 1
|
|
||||||
if self.waitCount > 5 {
|
|
||||||
self.delegate?.buttonTapped(self)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc func buttonUp(_ sender: PNButton) {
|
@objc func buttonUp(_ sender: PNButton) {
|
||||||
sender.layer.opacity = 1
|
sender.layer.opacity = 1
|
||||||
self.timer?.invalidate()
|
|
||||||
self.timer = nil
|
|
||||||
self.waitCount = 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc func touchUpInside(_ sender: PNButton) {
|
@objc func touchUpInside(_ sender: PNButton) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user