You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

43 lines
1.5 KiB

//
// ActionSheetHelper.swift
// GME Remit
//
// Created by Amrit Giri on 6/30/20.
// Copyright © 2020 Gobal Money Express Co. Ltd. All rights reserved.
//
import UIKit
struct ActionSheetElement {
var title:String = ""
var id:String = ""
var icon: String = ""
}
class ActionSheetHelper: NSObject {
static let shared = ActionSheetHelper()
// Initialization
override init() {
super.init()
}
func open(parentVc: UIViewController?, title: String = "", values: [ActionSheetElement], _ completionHandler: @escaping (_ item: ActionSheetElement) -> Void){
let alertView = UIAlertController(title: title, message: "", preferredStyle: UIAlertController.Style.actionSheet)
let cancel = UIAlertAction(title: "cancel_text".localized(), style: UIAlertAction.Style.cancel, handler: nil)
cancel.setValue(UIColor.themeRed, forKey: "titleTextColor")
for each in values{
let action = UIAlertAction(title: each.title, style: UIAlertAction.Style.default) { (click) in
completionHandler(each)
}
action.setValue(UIColor.themeBlue, forKey: "titleTextColor")
let image = UIImage(named: each.icon)?.withRenderingMode(.alwaysOriginal)
action.setValue(image, forKey: "image")
alertView.addAction(action)
}
alertView.addAction(cancel)
parentVc?.present(alertView, animated: true, completion: nil)
}
}