Skip to content

Commit 46fb386

Browse files
committed
Added Podspec
1 parent 90999bf commit 46fb386

6 files changed

Lines changed: 76 additions & 38 deletions

File tree

.DS_Store

0 Bytes
Binary file not shown.

AZDialogView.podspec

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Pod::Spec.new do |s|
2+
s.name = "AZDialogView"
3+
s.version = "1.0.0"
4+
s.summary = "A highly customizable alert dialog controller that mimics Snapchat's alert dialog."
5+
s.homepage = "https://github.com/Minitour/AZDialogViewController"
6+
s.license = "MIT"
7+
s.author = { "Antonio Zaitoun" => "tony.z.1711@gmail.com" }
8+
s.platform = :ios, "9.0"
9+
s.source = { :git => "https://github.com/Minitour/AZDialogViewController.git", :tag => "#{s.version}" }
10+
s.source_files = "Sources/**/*.{swift}"
11+
end
0 Bytes
Binary file not shown.
Binary file not shown.

AZDialogViewControllerExample/AZDialogViewControllerExample/ViewController.swift

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,15 @@ class ViewController: UIViewController {
8383
print("Share function")
8484
}
8585

86-
dialogController.dismissDirection = .bottom
86+
dialogController.dismissDirection = .both
8787

8888
dialogController.dismissWithOutsideTouch = true
8989

9090
dialogController.show(in: self)
9191
}
9292

9393
func editUserDialog(){
94-
let dialogController = AZDialogViewController(title: "Antonio Zaitoun", message: "minitour")
94+
let dialogController = AZDialogViewController(title: "This is a very long string and I am really bored. whatever mate", message: "minitour")
9595
dialogController.showSeparator = true
9696

9797
dialogController.addAction(AZDialogAction(title: "Edit Name", handler: { (dialog) -> (Void) in
@@ -166,24 +166,32 @@ class ViewController: UIViewController {
166166
}
167167

168168
func reportDialog(){
169-
let dialogController = AZDialogViewController(title: "Report Pack", message: "Please let us know the reason you are reporting this pack.",buttonsHeight: 35)
169+
let dialogController = AZDialogViewController(title: nil, message: nil)
170170
dialogController.dismissDirection = .bottom
171171

172172
dialogController.dismissWithOutsideTouch = true
173173

174-
let primary = #colorLiteral(red: 0, green: 0.8213806748, blue: 0.4752416015, alpha: 1)
175-
let primaryDark = #colorLiteral(red: 0, green: 0.7293747497, blue: 0.4250124319, alpha: 1)
174+
let primary = #colorLiteral(red: 0, green: 0.6862745098, blue: 0.9411764706, alpha: 1)
175+
let primaryDark = #colorLiteral(red: 0.02745098039, green: 0.368627451, blue: 0.3294117647, alpha: 1)
176+
176177

177178
dialogController.buttonStyle = { (button,height,position) in
178179
button.tintColor = primary
179-
button.setTitleColor(.white, for: [])
180-
//button.setTitleColor(primary, for: .normal)
180+
button.layer.masksToBounds = true
181181
button.setBackgroundImage(UIImage.imageWithColor(primary) , for: .normal)
182-
button.setBackgroundImage(UIImage.imageWithColor(primaryDark) , for: .highlighted)
182+
button.setBackgroundImage(UIImage.imageWithColor(primaryDark), for: .highlighted)
183+
button.setTitleColor(UIColor.white, for: [])
183184
button.layer.masksToBounds = true
184-
button.layer.cornerRadius = 5
185-
186-
button.layer.borderWidth = 0
185+
button.layer.borderColor = self.primaryColor.cgColor
186+
button.layer.borderColor = primary.cgColor
187+
188+
if position == 4 {
189+
button.setTitleColor(UIColor.white, for: .highlighted)
190+
button.setBackgroundImage(UIImage.imageWithColor(#colorLiteral(red: 1, green: 0.3005838394, blue: 0.2565174997, alpha: 1)), for: .highlighted)
191+
button.setBackgroundImage(nil , for: .normal)
192+
button.setTitleColor(#colorLiteral(red: 1, green: 0.3005838394, blue: 0.2565174997, alpha: 1), for: .normal)
193+
button.layer.borderColor = #colorLiteral(red: 1, green: 0.3005838394, blue: 0.2565174997, alpha: 1).cgColor
194+
}
187195
}
188196

189197
dialogController.cancelButtonStyle = { (button, height) in
@@ -192,22 +200,27 @@ class ViewController: UIViewController {
192200
return true
193201
}
194202

195-
dialogController.addAction(AZDialogAction(title: "Not for me", handler: { (dialog) -> (Void) in
203+
dialogController.addAction(AZDialogAction(title: "Mute", handler: { (dialog) -> (Void) in
196204
dialog.dismiss()
197205
}))
198206

199-
dialogController.addAction(AZDialogAction(title: "Spam", handler: { (dialog) -> (Void) in
207+
dialogController.addAction(AZDialogAction(title: "Group Info", handler: { (dialog) -> (Void) in
200208
dialog.dismiss()
201209
}))
202210

203-
dialogController.addAction(AZDialogAction(title: "Offensive Content", handler: { (dialog) -> (Void) in
211+
dialogController.addAction(AZDialogAction(title: "Export Chat", handler: { (dialog) -> (Void) in
212+
dialog.dismiss()
213+
}))
214+
215+
dialogController.addAction(AZDialogAction(title: "Clear Chat", handler: { (dialog) -> (Void) in
204216
dialog.dismiss()
205217
}))
206218

207-
dialogController.addAction(AZDialogAction(title: "Other", handler: { (dialog) -> (Void) in
219+
dialogController.addAction(AZDialogAction(title: "Exit Chat", handler: { (dialog) -> (Void) in
208220
dialog.dismiss()
209221
}))
210222

223+
211224
dialogController.show(in: self)
212225
}
213226
}

Sources/AZDialogViewController.swift

Lines changed: 37 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ open class AZDialogViewController: UIViewController{
111111
open override func dismiss(animated: Bool = true,completion: (()->Void)?=nil){
112112
if animated {
113113
UIView.animate(withDuration: 0.2, animations: { () -> Void in
114-
self.baseView.center.y = (self.baseView.superview?.frame.maxY)! + (self.baseView.frame.midY)
114+
self.baseView.center.y = self.view.bounds.maxY + (self.baseView.bounds.midY)
115115
self.view.backgroundColor = .clear
116116
}, completion: { (complete) -> Void in
117117
super.dismiss(animated: false, completion: completion)
@@ -348,7 +348,7 @@ open class AZDialogViewController: UIViewController{
348348
super.viewDidAppear(animated)
349349
if !didInitAnimation{
350350
didInitAnimation = true
351-
baseView.center.y = (baseView.superview?.frame.maxY)! + (baseView.frame.midY)
351+
baseView.center.y = self.view.bounds.maxY + baseView.bounds.midY
352352
baseView.isHidden = false
353353
UIView.animate(withDuration: 0.2, delay: 0, usingSpringWithDamping: 1, initialSpringVelocity: 6.0, options: [], animations: { () -> Void in
354354
self.baseView.center = (self.baseView.superview?.center)!
@@ -396,6 +396,7 @@ open class AZDialogViewController: UIViewController{
396396
fontName: String = "AvenirNext-Medium",
397397
boldFontName: String = "AvenirNext-DemiBold"){
398398
self.init(nibName: nil, bundle: nil)
399+
399400
mTitle = title
400401
mMessage = message
401402
self.spacing = spacing
@@ -418,55 +419,68 @@ open class AZDialogViewController: UIViewController{
418419
let translation = sender.translation(in: self.view)
419420
baseView.center = CGPoint(x: baseView.lastLocation.x , y: baseView.lastLocation.y + translation.y)
420421

421-
if sender.state == UIGestureRecognizerState.ended{
422+
let returnToCenter:(CGPoint,Bool)->Void = { (finalPoint,animate) in
423+
if !animate {
424+
self.baseView.center = finalPoint
425+
return
426+
}
427+
UIView.animate(withDuration: 0.35, delay: 0, usingSpringWithDamping: 0.5, initialSpringVelocity: 2.0, options: [], animations: { () -> Void in
428+
self.baseView.center = finalPoint
429+
}, completion: { (complete) -> Void in
430+
})
431+
}
432+
433+
let dismissInDirection:(CGPoint)->Void = { (finalPoint) in
434+
UIView.animate(withDuration: 0.2, animations: { () -> Void in
435+
self.baseView.center = finalPoint
436+
self.view.backgroundColor = .clear
437+
}, completion: { (complete) -> Void in
438+
self.dismiss(animated: false, completion: nil)
439+
})
440+
}
441+
442+
var finalPoint = (baseView.superview?.center)!
443+
444+
if sender.state == .ended{
422445

423446
let velocity = sender.velocity(in: view)
424447
let mag = sqrtf(Float(velocity.x * velocity.x) + Float(velocity.y * velocity.y))
425448
let slideMult = mag / 200
426-
var finalPoint = (baseView.superview?.center)!
427449
let dismissWithGesture = dismissDirection != .none ? true : false
428450

429-
let returnToCenter = {
430-
UIView.animate(withDuration: 0.35, delay: 0, usingSpringWithDamping: 0.5, initialSpringVelocity: 2.0, options: [], animations: { () -> Void in
431-
self.baseView.center = finalPoint
432-
}, completion: { (complete) -> Void in
433-
})
434-
}
435451

436-
let dismissInDirection = {
437-
UIView.animate(withDuration: 0.2, animations: { () -> Void in
438-
self.baseView.center = finalPoint
439-
self.view.backgroundColor = .clear
440-
}, completion: { (complete) -> Void in
441-
self.dismiss(animated: false, completion: nil)
442-
})
443-
}
444452

445453
if dismissWithGesture && slideMult > 1 {
446454
//dismiss
447455
if velocity.y > 0{
448456
//dismiss downward
449457
if dismissDirection == .bottom || dismissDirection == .both {
450458
finalPoint.y = (baseView.superview?.frame.maxY)! + (baseView.bounds.midY)
451-
dismissInDirection()
459+
dismissInDirection(finalPoint)
452460
}else{
453-
returnToCenter()
461+
returnToCenter(finalPoint,true)
454462
}
455463
}else{
456464

457465
//dismiss upward
458466
if dismissDirection == .top || dismissDirection == .both {
459467
finalPoint.y = -(baseView.bounds.midY)
460-
dismissInDirection()
468+
dismissInDirection(finalPoint)
461469
}else{
462-
returnToCenter()
470+
returnToCenter(finalPoint,true)
463471
}
464472
}
465473
}else{
466474
//return to center
467-
returnToCenter()
475+
returnToCenter(finalPoint,true)
468476
}
469477
}
478+
479+
if sender.state == .cancelled || sender.state == .failed{
480+
returnToCenter(finalPoint,false)
481+
}
482+
483+
470484
}
471485

472486
/// Selector method - used to handle view touch.

0 commit comments

Comments
 (0)