Skip to content

Commit

Permalink
Fixed dismiss by tap flag.
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanvorobei committed Nov 30, 2021
1 parent 5893a0b commit 1793954
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 16 deletions.
4 changes: 2 additions & 2 deletions Example App/SPAlert.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
F43A587826564DDF009098ED /* SPAlert */ = {isa = PBXFileReference; lastKnownFileType = folder; name = SPAlert; path = ..; sourceTree = "<group>"; };
F47E1DFA26564B6A008D901C /* iOS Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "iOS Example.app"; sourceTree = BUILT_PRODUCTS_DIR; };
F47E1E0B26564B6C008D901C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
F47E1E1226564BB3008D901C /* AlertPresetModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AlertPresetModel.swift; sourceTree = "<group>"; };
F47E1E1426564BB3008D901C /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
F47E1E1626564BB3008D901C /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
F47E1E1726564BB3008D901C /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
F47E1E1926564BB3008D901C /* PresetsController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PresetsController.swift; sourceTree = "<group>"; };
F482FBF42756A77100E40FDA /* SPAlert */ = {isa = PBXFileReference; lastKnownFileType = folder; name = SPAlert; path = ..; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand All @@ -45,7 +45,7 @@
F47E1DF126564B6A008D901C = {
isa = PBXGroup;
children = (
F43A587826564DDF009098ED /* SPAlert */,
F482FBF42756A77100E40FDA /* SPAlert */,
F47E1DFC26564B6A008D901C /* iOS Example */,
F47E1DFB26564B6A008D901C /* Products */,
);
Expand Down
Binary file not shown.
2 changes: 1 addition & 1 deletion SPAlert.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = 'SPAlert'
s.version = '3.5.0'
s.version = '3.5.1'
s.summary = 'Native alert from Apple Music & Feedback. Contains Done, Heart & Message and other presets.'
s.homepage = 'https://github.com/ivanvorobei/SPAlert'
s.source = { :git => 'https://github.com/ivanvorobei/SPAlert.git', :tag => s.version }
Expand Down
31 changes: 18 additions & 13 deletions Sources/SPAlert/SPAlertView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,33 +88,38 @@ open class SPAlertView: UIView {

public init(title: String, message: String? = nil, preset: SPAlertIconPreset) {
super.init(frame: CGRect.zero)

switch preset {
case .spinner:
self.dismissInTime = false
default:
self.dismissInTime = true
}

commonInit()
layout = SPAlertLayout(for: preset)
setTitle(title)
if let message = message {
setMessage(message)
}
setIcon(for: preset)

switch preset {
case .spinner:
dismissInTime = false
dismissByTap = false
default:
dismissInTime = true
dismissByTap = true
}
}

public init(message: String) {
super.init(frame: CGRect.zero)
commonInit()
layout = SPAlertLayout.message()
setMessage(message)
dismissInTime = true
dismissByTap = true
}

public required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
commonInit()
dismissInTime = true
dismissByTap = true
}

private func commonInit() {
Expand All @@ -127,11 +132,6 @@ open class SPAlertView: UIView {
backgroundColor = .clear
addSubview(backgroundView)

if dismissByTap {
let tapGesterRecognizer = UITapGestureRecognizer(target: self, action: #selector(dismiss))
addGestureRecognizer(tapGesterRecognizer)
}

setCornerRadius(self.cornerRadius)
}

Expand Down Expand Up @@ -217,6 +217,11 @@ open class SPAlertView: UIView {
setFrame()
transform = transform.scaledBy(x: self.presentDismissScale, y: self.presentDismissScale)

if dismissByTap {
let tapGesterRecognizer = UITapGestureRecognizer(target: self, action: #selector(dismiss))
addGestureRecognizer(tapGesterRecognizer)
}

// Present

haptic.impact()
Expand Down

0 comments on commit 1793954

Please sign in to comment.