// // DebugManager.swift // GME Remit // // Created by InKwon James Kim on 07/10/2019. // Copyright © 2019 Gobal Money Express Co. Ltd. All rights reserved. // import UIKit //#if DEBUG class DebugManager { static let shared = DebugManager() var testAccountID: String { switch server { case .live: return "bikash@yopmail.com" default: return "bikash@yopmail.com" } } var testAccountPW: String { switch server { case .live: return "Test@12345" default: return "Test@12345" } } func setTestAccount(target: UIViewController, completion: ((String, String) -> Void)? = nil) { let alertcontroller = UIAlertController(title: "Test Account", message: nil, preferredStyle: .actionSheet) alertcontroller.view.tintColor = .themeText let testAction = UIAlertAction(title: testAccountID, style: .destructive, handler: { _ in completion?(self.testAccountID, self.testAccountPW) }) let otherAction = UIAlertAction(title: "Other", style: .default, handler: nil) alertcontroller.addAction(testAction) alertcontroller.addAction(otherAction) if UIDevice.current.userInterfaceIdiom == .pad { if let popoverController = alertcontroller.popoverPresentationController { popoverController.sourceView = target.view popoverController.sourceRect = CGRect( x: target.view.bounds.midX, y: target.view.bounds.midY, width: 0, height: 0 ) popoverController.permittedArrowDirections = [] target.present(alertcontroller, animated: true, completion: nil) } } else { target.present(alertcontroller, animated: true, completion: nil) } } func selectServerAlert(target: UIViewController, completion: (() -> Void)? = nil ) { let alertcontroller = UIAlertController( title: "Select Test Server", message: nil, preferredStyle: .actionSheet ) alertcontroller.view.tintColor = .themeText var actions = [UIAlertAction]() Server.allCases.forEach { value in let action = UIAlertAction(title: value.rawValue, style: .default, handler: { _ in server = value UrlManager.sharedInstance.refreshBaseURL() switch server { default: completion?() } }) actions.append(action) } actions.forEach { alertcontroller.addAction($0) } if UIDevice.current.userInterfaceIdiom == .pad { if let popoverController = alertcontroller.popoverPresentationController { popoverController.sourceView = target.view popoverController.sourceRect = CGRect( x: target.view.bounds.midX, y: target.view.bounds.midY, width: 0, height: 0 ) popoverController.permittedArrowDirections = [] target.present(alertcontroller, animated: true, completion: nil) } } else { target.present(alertcontroller, animated: true, completion: nil) } } } //#endif