-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAlertService.swift
More file actions
55 lines (49 loc) · 2.13 KB
/
AlertService.swift
File metadata and controls
55 lines (49 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//
// AlertSevice.swift
// AlertAction
//
// Created by Jayesh Agrawal on 20/07/21.
//
import UIKit
public class AlertService{
public init(){
}
public enum AlertType{
case error
case ok
case success
}
public func alert(type: AlertType ,headLabelTitle: String? = nil ,alertReasonText: String? = nil,alertMessageText: String? = nil,actionButtonText: String? = nil ) -> AlertViewController{
let storyBoard = UIStoryboard(name: "AlertView" , bundle: Bundle(for: AlertService.self) )
let alertVC = storyBoard.instantiateViewController(withIdentifier: "AlertVC") as! AlertViewController
switch type {
case .error:
alertVC.headLabelTitle = headLabelTitle ?? "Error"
alertVC.alertReasonText = alertReasonText ?? "Failed Event"
alertVC.alertMessageText = alertMessageText ?? "There was an error in the event"
alertVC.actionButtonText = actionButtonText ?? "Retry"
// alertVC.image = UIImage(named: "warning.png")!
alertVC.showCancelButton = false
alertVC.cancelButtonTitle = "cancel"
alertVC.color = UIColor.red
alertVC.imgName = "warning"
case .ok:
alertVC.headLabelTitle = headLabelTitle ?? "Ok"
alertVC.alertReasonText = alertReasonText ?? "Done"
alertVC.alertMessageText = alertMessageText ?? "The event has been done"
alertVC.actionButtonText = actionButtonText ?? "Done"
//alertVC.image = UIImage(named: "ok")!
alertVC.showCancelButton = true
alertVC.imgName = "ok"
case .success:
alertVC.headLabelTitle = headLabelTitle ?? "Success"
alertVC.alertReasonText = alertReasonText ?? "Successful Event"
alertVC.alertMessageText = alertMessageText ?? "The Event has been Successful "
alertVC.actionButtonText = actionButtonText ?? "Done"
//alertVC.image = UIImage(named: "success")!
alertVC.showCancelButton = true
alertVC.imgName = "success"
}
return alertVC
}
}