Skip to content

Commit 9df115d

Browse files
committed
Added double confirm.
1 parent bd0f582 commit 9df115d

File tree

3 files changed

+35
-20
lines changed

3 files changed

+35
-20
lines changed

Sources/SparrowKit/UIKit/Classes/Buttons/SPButton.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import UIKit
2727

2828
It has one shared init `commonInit` which call for all default inits.
2929

30-
- Note: For Russian-speaking developer available [tutorial about button insets]( https://sparrowcode.by/edge-insets-uibutton).
30+
- Note: For Russian-speaking developer available [tutorial about button insets]( https://sparrowcode.io/edge-insets-uibutton).
3131
*/
3232
open class SPButton: UIButton {
3333

Sources/SparrowKit/UIKit/Extensions/UIAlertControllerExtension.swift

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ public extension UIAlertController {
7070
title: String,
7171
style: UIAlertAction.Style = .default,
7272
handler: ((UIAlertAction) -> Void)? = nil) -> UIAlertAction {
73-
74-
let action = UIAlertAction(title: title, style: style, handler: handler)
75-
addAction(action)
76-
return action
77-
}
73+
74+
let action = UIAlertAction(title: title, style: style, handler: handler)
75+
addAction(action)
76+
return action
77+
}
7878

7979
/**
8080
SparrowKit: Add Text Field to Alert Controller.
@@ -89,15 +89,15 @@ public extension UIAlertController {
8989
placeholder: String? = nil,
9090
editingChangedTarget: Any?,
9191
editingChangedSelector: Selector?) {
92-
93-
addTextField { textField in
94-
textField.text = text
95-
textField.placeholder = placeholder
96-
if let target = editingChangedTarget, let selector = editingChangedSelector {
97-
textField.addTarget(target, action: selector, for: .editingChanged)
92+
93+
addTextField { textField in
94+
textField.text = text
95+
textField.placeholder = placeholder
96+
if let target = editingChangedTarget, let selector = editingChangedSelector {
97+
textField.addTarget(target, action: selector, for: .editingChanged)
98+
}
9899
}
99100
}
100-
}
101101

102102
/**
103103
SparrowKit: Add Text Field to Alert Controller.
@@ -111,14 +111,29 @@ public extension UIAlertController {
111111
text: String? = nil,
112112
placeholder: String? = nil,
113113
action: UIAction?) {
114-
115-
addTextField { textField in
116-
textField.text = text
117-
textField.placeholder = placeholder
118-
if let action = action {
119-
textField.addAction(action, for: .editingChanged)
114+
addTextField { textField in
115+
textField.text = text
116+
textField.placeholder = placeholder
117+
if let action = action {
118+
textField.addAction(action, for: .editingChanged)
119+
}
120120
}
121121
}
122+
123+
static func confirm(title: String, description: String, actionTitle: String, cancelTitle: String, desctructive: Bool, action: @escaping ()->Void, sourceView: UIView, on controller: UIViewController) {
124+
let alertController = UIAlertController.init(title: title, message: description, preferredStyle: .actionSheet)
125+
alertController.popoverPresentationController?.sourceView = sourceView
126+
alertController.addAction(title: actionTitle, style: desctructive ? .destructive : .default) { [] _ in
127+
action()
128+
}
129+
alertController.addAction(title: cancelTitle, style: .cancel, handler: nil)
130+
controller.present(alertController)
131+
}
132+
133+
static func confirmDouble(title: String, description: String, actionTitle: String, cancelTitle: String, desctructive: Bool, action: @escaping ()->Void, sourceView: UIView, on controller: UIViewController) {
134+
confirm(title: title, description: description, actionTitle: actionTitle, cancelTitle: cancelTitle, desctructive: desctructive, action: {
135+
confirm(title: title, description: description, actionTitle: actionTitle, cancelTitle: cancelTitle, desctructive: desctructive, action: action, sourceView: sourceView, on: controller)
136+
}, sourceView: sourceView, on: controller)
122137
}
123138
}
124139
#endif

SparrowKit.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Pod::Spec.new do |s|
22

33
s.name = 'SparrowKit'
4-
s.version = '3.5.0'
4+
s.version = '3.5.1'
55
s.summary = 'Collection of native Swift extensions and classes to boost development process.'
66
s.homepage = 'https://github.com/ivanvorobei/SparrowKit'
77
s.source = { :git => 'https://github.com/ivanvorobei/SparrowKit.git', :tag => s.version }

0 commit comments

Comments
 (0)