Files
Woka_Native_iOS/WOKA/Helpers/ActivityToast&Indicator/Utilities.swift
BilalKhanWDI 3c69db0032 - Added send OTP api
- Added verify  OTP api
- Modified the flow
- Made a authfunc to handle the type of user and the language selected
- Added OTP fields combine logic. Also handled the otp blank checks.
- Added API for intrestes get
2024-05-07 19:33:29 +05:30

109 lines
4.5 KiB
Swift

//
// File.swift
// WOKA
//
// Created by MacBook Pro on 06/05/24.
//
import UIKit
class Utilities{
let activityIndicator = UIActivityIndicatorView(style: UIActivityIndicatorView.Style.medium)
// static func setupProgressHUD() {
// let loaderColor = UIColor.green
// let backgroundColor = #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1)
//
// SVProgressHUD.setInfoImage(UIImage(named: "AppLogo")!)
// SVProgressHUD.setBackgroundColor(backgroundColor)
// SVProgressHUD.setForegroundColor(loaderColor)
// // don't let user press anything on screen while SVProgessHUD is active
// SVProgressHUD.setDefaultMaskType(.black)
// }
static func startProgressHUD(progress: Float? = nil, msg : String? = nil) {
LLSpinner.spin(text: (msg != "" && msg != nil) ? msg : "Please wait...")
// if let progress = progress {
// SVProgressHUD.showProgress(progress)
// } else {
// SVProgressHUD.show()
// }
}
static func dismissProgressHUD() {
DispatchQueue.main.async {
LLSpinner.stop()
}
}
static func stopActivity(view : UIView){
Utilities().activityIndicator.stopAnimating()
}
static func alertWithBtn(title : String , msgBody : String, okBtnStr : String?,vc : UIViewController){
let alert = UIAlertController(title: title, message: msgBody, preferredStyle: .alert)
let titleAttrString = NSMutableAttributedString(string: title != "" ? (title + "\n") : "", attributes: [NSAttributedString.Key.font: UIFont(name: "Nunito-Medium", size: 20)! as Any])
alert.setValue(titleAttrString, forKey: "attributedTitle")
var messageMutableString = NSMutableAttributedString()
messageMutableString = NSMutableAttributedString(string: msgBody as String, attributes: [NSAttributedString.Key.font:UIFont(name: "Nunito-Regular", size: 18)!])
messageMutableString.addAttribute(NSAttributedString.Key.foregroundColor, value: UIColor.black, range: NSRange(location:0,length:msgBody.count))
alert.setValue(messageMutableString, forKey: "attributedMessage")
let okAction = UIAlertAction(title: okBtnStr ?? "OK", style: .default, handler: nil)
okAction.setValue(UIColor.appColor(.TextDarkBlue), forKey: "titleTextColor")
alert.addAction(okAction)
vc.present(alert, animated: true, completion: nil)
}
static func alertWithBtnCompletion(title : String , msgBody : String, okBtnStr : String?,vc : UIViewController ,onCompletion : @escaping (Bool) -> Void){
let alert = UIAlertController(title: title, message: nil, preferredStyle: .alert)
let okAction = UIAlertAction(title: okBtnStr ?? "OK", style: .default, handler: {_ in
onCompletion(true)
})
let messageAttributes = [NSAttributedString.Key.font: UIFont(name: "Nunito-Regular", size: 18)!, NSAttributedString.Key.foregroundColor: UIColor.black]
let messageString = NSAttributedString(string: msgBody, attributes: messageAttributes)
okAction.setValue(UIColor.appColor(.TextDarkBlue), forKey: "titleTextColor")
alert.addAction(okAction)
alert.setValue(messageString, forKey: "attributedMessage")
vc.present(alert, animated: true, completion: nil)
}
static func reportBug(message: String, line: Int = #line, file: String = #file) {
print("Line: \(line): File \(file): \(message)")
//TODO: Send report to ferofly
}
static func alert(line: Int = #line, file: String = #file, title: String, message: String, viewController: UIViewController, toastTime: TimeInterval = 0, onCompletion: (() -> Void)? = nil) {
print("Line: \(line): File \(file): \(title): \(message)")
let alertVC = UIAlertController(title: title, message: message, preferredStyle: .alert)
if toastTime == 0 {
let action = UIAlertAction(title: "Ok", style: .default) { (action) in
alertVC.dismiss(animated: true, completion: onCompletion)
}
alertVC.addAction(action)
}
DispatchQueue.main.async {
viewController.present(alertVC, animated: true, completion: nil)
if toastTime > 0 {
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + toastTime) {
alertVC.dismiss(animated: true, completion: onCompletion)
}
}
}
}
}