[+] Add parameter "okayable" to alert function

This commit is contained in:
Hykilpikonna
2021-01-22 15:18:49 -05:00
parent facf8eaeec
commit 8f829217c1
2 changed files with 17 additions and 4 deletions
+2 -2
View File
@@ -181,8 +181,8 @@ func send<T: Decodable>(_ api: API<T>, _ params: [String: String]? = [:], _ succ
var params = params
if params != nil
{
if params!["email"] == nil { params!["email"] = localStorage.string(forKey: "email") }
if params!["pass"] == nil { params!["pass"] = localStorage.string(forKey: "pass") }
if params!["username"] == nil { params!["username"] = localStorage.string(forKey: "name") }
if params!["password"] == nil { params!["password"] = localStorage.string(forKey: "pass") }
}
let url = createUrl(api.loc, params)
+15 -2
View File
@@ -110,12 +110,25 @@ extension String
}
/// Alerts
/// UI Extensions
extension UIViewController
{
func alert(_ title: String, _ message: String)
/**
Send an alert
- Parameter title: Title of the alert
- Parameter message: Body message of the alert
- Parameter okayable: Whether the alert can be okayed
*/
func alert(_ title: String, _ message: String, okayable: Bool = false)
{
let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
if okayable
{
alert.addAction(UIAlertAction(title: "OK", style: .default))
}
self.present(alert, animated: true, completion: nil)
}
}