Skip to content

Commit 6aa9667

Browse files
committed
updating malert to swift 5 and applying new ident
1 parent 387bca3 commit 6aa9667

22 files changed

Lines changed: 780 additions & 1434 deletions

Example/Malert.xcodeproj/project.pbxproj

Lines changed: 3 additions & 221 deletions
Large diffs are not rendered by default.

Example/Malert/view/FiveCustomView.swift

Lines changed: 0 additions & 42 deletions
This file was deleted.

Example/Malert/view/FiveCustomView.xib

Lines changed: 0 additions & 55 deletions
This file was deleted.

Example/Malert/view/SecondCustomView.swift

Lines changed: 0 additions & 22 deletions
This file was deleted.

Example/Malert/view/SecondCustomView.xib

Lines changed: 0 additions & 41 deletions
This file was deleted.

Example/Podfile

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,4 @@ use_frameworks!
22

33
target 'Malert_Example' do
44
pod 'Malert', :path => '../'
5-
6-
target 'Malert_Tests' do
7-
inherit! :search_paths
8-
9-
end
105
end
11-
12-
#post_install do |installer|
13-
# installer.pods_project.targets.each do |target|
14-
# target.build_configurations.each do |configuration|
15-
# configuration.build_settings['SWIFT_VERSION'] = "3.0"
16-
# end
17-
# end
18-
#end

Example/Tests/Info.plist

Lines changed: 0 additions & 24 deletions
This file was deleted.

Example/Tests/Tests.swift

Lines changed: 0 additions & 29 deletions
This file was deleted.

Malert/Classes/Animations/BaseTransitioning.swift

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,37 +6,36 @@
66
//
77
//
88

9-
109
import UIKit
1110

1211
class BaseTransitioning: NSObject {
13-
14-
var animationType: MalertAnimationType
15-
var duration: TimeInterval
16-
17-
init(animationType: MalertAnimationType, duration: TimeInterval) {
18-
self.animationType = animationType
19-
self.duration = duration
20-
super.init()
21-
}
22-
23-
func buildMalertAnimation(malertView: UIView, width: CGFloat, height: CGFloat) {
24-
switch animationType {
25-
case .modalBottom:
26-
malertView.transform = CGAffineTransform.init(translationX: 0, y: height)
27-
break
28-
29-
case .modalLeft:
30-
malertView.transform = CGAffineTransform.init(translationX: -width, y: 0)
31-
break
32-
33-
case .modalRight:
34-
malertView.transform = CGAffineTransform.init(translationX: width, y: 0)
35-
break
36-
37-
case .fadeIn:
38-
malertView.alpha = 0
39-
break
40-
}
41-
}
12+
13+
var animationType: MalertAnimationType
14+
var duration: TimeInterval
15+
16+
init(animationType: MalertAnimationType, duration: TimeInterval) {
17+
self.animationType = animationType
18+
self.duration = duration
19+
super.init()
20+
}
21+
22+
func buildMalertAnimation(malertView: UIView, width: CGFloat, height: CGFloat) {
23+
switch animationType {
24+
case .modalBottom:
25+
malertView.transform = CGAffineTransform.init(translationX: 0, y: height)
26+
break
27+
28+
case .modalLeft:
29+
malertView.transform = CGAffineTransform.init(translationX: -width, y: 0)
30+
break
31+
32+
case .modalRight:
33+
malertView.transform = CGAffineTransform.init(translationX: width, y: 0)
34+
break
35+
36+
case .fadeIn:
37+
malertView.alpha = 0
38+
break
39+
}
40+
}
4241
}

Malert/Classes/Animations/MalertDimissTransitioning.swift

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,22 @@
99
import UIKit
1010

1111
class MalertDimissTransitioning: BaseTransitioning, UIViewControllerAnimatedTransitioning {
12-
13-
public func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {
14-
return duration
15-
}
16-
17-
public func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
18-
guard let fromVC = transitionContext.viewController(forKey: .from) as? Malert else {return}
19-
20-
let malertView = fromVC.malertView
21-
let duration = transitionDuration(using: transitionContext)
22-
23-
UIView.animate(withDuration: duration, animations: {
24-
self.buildMalertAnimation(malertView: malertView, width: fromVC.view.bounds.size.width, height: fromVC.view.bounds.size.height)
25-
fromVC.view.backgroundColor = .clear
26-
}) { (finished) in
27-
transitionContext.completeTransition(!transitionContext.transitionWasCancelled)
28-
}
29-
30-
// UIView.animate(withDuration: duration, delay: 0, usingSpringWithDamping: 0.5, initialSpringVelocity: 0, options: [], animations: {
31-
// self.buildMalertAnimation(malertView: malertView, width: fromVC.view.bounds.size.width, height: fromVC.view.bounds.size.height)
32-
//
33-
// }, completion: { (finished) in
34-
// transitionContext.completeTransition(!transitionContext.transitionWasCancelled)
35-
// })
36-
37-
}
12+
13+
public func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {
14+
return duration
15+
}
16+
17+
public func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
18+
guard let fromVC = transitionContext.viewController(forKey: .from) as? Malert else {return}
19+
20+
let malertView = fromVC.malertView
21+
let duration = transitionDuration(using: transitionContext)
22+
23+
UIView.animate(withDuration: duration, animations: {
24+
self.buildMalertAnimation(malertView: malertView, width: fromVC.view.bounds.size.width, height: fromVC.view.bounds.size.height)
25+
fromVC.view.backgroundColor = .clear
26+
}) { (finished) in
27+
transitionContext.completeTransition(!transitionContext.transitionWasCancelled)
28+
}
29+
}
3830
}

0 commit comments

Comments
 (0)