From 8f829217c13e728a8ff66f425b2cb00790c6c92e Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Fri, 22 Jan 2021 15:18:49 -0500 Subject: [PATCH] [+] Add parameter "okayable" to alert function --- ProjectClock/Net.swift | 4 ++-- ProjectClock/Utils.swift | 17 +++++++++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/ProjectClock/Net.swift b/ProjectClock/Net.swift index 9fad282..2408bf4 100644 --- a/ProjectClock/Net.swift +++ b/ProjectClock/Net.swift @@ -181,8 +181,8 @@ func send(_ api: API, _ 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) diff --git a/ProjectClock/Utils.swift b/ProjectClock/Utils.swift index a41641e..894d4e9 100644 --- a/ProjectClock/Utils.swift +++ b/ProjectClock/Utils.swift @@ -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) } }