Browse Source

added alert in send money

pull/1/head
ccr 6 years ago
parent
commit
a0335d6ed5
  1. 2
      GMERemittance/AppDelegate.swift
  2. 1
      GMERemittance/Library/WebLinks/WebLinksViewController.swift
  3. 32
      GMERemittance/Library/WebLinks/WkWebView/WkWebViewController.swift
  4. 33
      GMERemittance/Model/Account.swift
  5. 15
      GMERemittance/Module/AutoDebit/Application Logic/Service/AutoDebitService.swift
  6. 23
      GMERemittance/Module/AutoDebit/User Interface/View/AutoDebitViewController.swift
  7. 5
      GMERemittance/Module/SendMoney/SendMoneyReceipt/User Interface/View/SendMoneyReceiptViewController.swift
  8. 2
      GMERemittance/Module/SendMoney/SendMoneyReceipt/User Interface/Wireframe/SendMoneyReceiptWireframe.swift
  9. 1
      GMERemittance/Module/SendMoney/SendMoneyVerification/User Interface/Wireframe/SendMoneyVerificationWireframe.swift
  10. 37
      GMERemittance/RestApiManager.swift
  11. 6
      GMERemittance/SideMenu/SideMenuViewController.swift

2
GMERemittance/AppDelegate.swift

@ -19,7 +19,7 @@ import AlamofireNetworkActivityLogger
import IQKeyboardManagerSwift
import LGSideMenuController
let server: Server = .stagging
let server: Server = .uat
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate, MessagingDelegate {

1
GMERemittance/Library/WebLinks/WebLinksViewController.swift

@ -63,6 +63,7 @@ class WebLinksViewController: UIViewController {
if NetworkReachabilityManager()?.isReachable == true {
if let url = URL.init(string: self.url ?? "") {
let request = URLRequest(url: url)
webView?.loadRequest(request)
}
}else {

32
GMERemittance/Library/WebLinks/WkWebView/WkWebViewController.swift

@ -39,16 +39,19 @@ class WkWebViewController: UIViewController {
let headers = self.headers ?? []
print(self.url)
if let myURL = URL(string: self.url ?? "") {
var myRequest = URLRequest(url: myURL)
let _url = (self.url ?? "").addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)!
// var urlStr : String = url.stringByAddingPercentEscapesUsingEncoding(NSUTF8StringEncoding)!
headers.forEach({
myRequest.setValue($0.key ?? "", forHTTPHeaderField: $0.value ?? "")
})
print(myRequest.allHTTPHeaderFields)
if let myURL = URL(string: _url) {
var myRequest = URLRequest(url: myURL)
//
// headers.forEach({
// myRequest.setValue($0.key ?? "", forHTTPHeaderField: $0.value ?? "")
//
// })
//
// print(myRequest.allHTTPHeaderFields)
webView.load(myRequest)
}
}
@ -76,5 +79,16 @@ extension WkWebViewController: WKUIDelegate, WKNavigationDelegate {
// activityIndicator?.isHidden = true
activityIndicator?.stopAnimating()
}
func webView(_ webView: WKWebView, runJavaScriptAlertPanelWithMessage message: String, initiatedByFrame frame: WKFrameInfo, completionHandler: @escaping () -> Void) {
let alertController = UIAlertController(title: message, message: nil,
preferredStyle: UIAlertController.Style.alert);
alertController.addAction(UIAlertAction(title: "OK", style: UIAlertAction.Style.cancel) {
_ in completionHandler()}
);
self.present(alertController, animated: true, completion: {});
}
}

33
GMERemittance/Model/Account.swift

@ -134,3 +134,36 @@ class KftcHeader: Mappable {
value <- map["Value"]
}
}
//class KFTCURLContainer: Mappable {
// var errorCode: String?
// var message: String?
// var id: String?
// var data: KFTCURL?
//
// required init?(map: Map) {
//
// }
//
// func mapping(map: Map) {
// errorCode <- map["ErrorCode"]
// message <- map["Msg"]
// id <- map["Id"]
// data <- map["Data"]
// }
//}
class KFTCURL: Mappable {
var value: String?
required init?(map: Map) {
}
func mapping(map: Map) {
value <- map["location"]
}
}

15
GMERemittance/Module/AutoDebit/Application Logic/Service/AutoDebitService.swift

@ -70,3 +70,18 @@ extension DeleteAccountService {
}
protocol FetchKftcUrlService: ApiServiceType {
func fetchKftcUrlService(url: String, header: [String: String], success: @escaping (String?) -> (), failure: @escaping (Error) -> ())
}
extension FetchKftcUrlService {
func fetchKftcUrlService(url: String, header: [String: String], success: @escaping (String?) -> (), failure: @escaping (Error) -> ()) {
auth.kftcRequest(method: .get, header: header, url: url, params: nil, encoding: URLEncoding.default, success: { (response: KFTCURL) in
success(response.value)
}) { (error) in
failure(error)
}
}
}

23
GMERemittance/Module/AutoDebit/User Interface/View/AutoDebitViewController.swift

@ -39,12 +39,28 @@ class AutoDebitViewController: UIViewController {
var languages: [KftcLanguage]?
var header: [KftcHeader]?
var url: String?
var selectedLanguage: KftcLanguage? {
didSet {
if var url = self.url {
let string = "&lang=\(selectedLanguage?.key ?? "")"
url.append(string)
openWkWebViewWith(url: url)
var _header: [String: String] = [:]
self.header?.forEach({ (header) in
_header[header.key ?? ""] = header.value ?? ""
})
self.fetchKftcUrlService(url: url, header: _header , success: { (location) in
print(location)
guard let location = location else {
print("cannot get location from server")
return
}
self.openWkWebViewWith(url: location)
}) { (error) in
self.alert(message: error.localizedDescription)
}
}
}
}
@ -221,4 +237,7 @@ extension AutoDebitViewController: FetchAccountList, DeleteAccountService {
extension AutoDebitViewController: AutoDebitViewInterface {
}
//AutoDebitViewController
extension AutoDebitViewController: FetchKftcUrlService {
}

5
GMERemittance/Module/SendMoney/SendMoneyReceipt/User Interface/View/SendMoneyReceiptViewController.swift

@ -46,6 +46,7 @@ class SendMoneyReceiptViewController: UIViewController {
var presenter: SendMoneyReceiptModuleInterface?
var hudDelegate: HUDStatusDelegate?
var shouldShowCancelAmmendButton = false
var fromSendMoney = false
var controlNo: String?
var transactionId: String?
var type: MailBoxType?
@ -79,9 +80,9 @@ class SendMoneyReceiptViewController: UIViewController {
// MARK: IBActions
@IBAction func done(_ sender: UIButton) {
if (self.shouldShowCancelAmmendButton) {
self.navigationController?.popToRootViewController(animated: true)
}else {
self.navigationController?.popViewController(animated: true)
}else {
self.navigationController?.popToRootViewController(animated: true)
}
}
// MARK: Other Functions

2
GMERemittance/Module/SendMoney/SendMoneyReceipt/User Interface/Wireframe/SendMoneyReceiptWireframe.swift

@ -40,11 +40,13 @@ extension SendMoneyReceiptWireframe: SendMoneyReceiptWireframeInput {
func openReciept(transactionId: String, source: UINavigationController) {
self.transactionId = transactionId
self.isFromTransactionReport = false
self.pushMainView(in: source)
}
func openRecieptFromTransactionReport(controlNo: String, transactionId: String, shouldShowCancelAmmendButton: Bool, source: UINavigationController) {
self.transactionId = transactionId
self.isFromTransactionReport = shouldShowCancelAmmendButton
self.controlNo = controlNo
self.pushMainView(in: source)
}

1
GMERemittance/Module/SendMoney/SendMoneyVerification/User Interface/Wireframe/SendMoneyVerificationWireframe.swift

@ -36,7 +36,6 @@ extension SendMoneyVerificationWireframe: SendMoneyVerificationWireframeInput {
func openReciept(transactionId: String) {
if let navigation = self.view.navigationController {
reciptWireframe.openReciept(transactionId: transactionId, source: navigation)
}
}

37
GMERemittance/RestApiManager.swift

@ -70,8 +70,7 @@ class RestApiMananger {
]
}
// ccr
@ -93,6 +92,40 @@ class RestApiMananger {
}
}
func kftcRequest<T: Mappable>(method: HTTPMethod, header: [String: String], url: String, params: [String: Any]?, encoding: ParameterEncoding = JSONEncoding.default, needsAuthorization: Bool = true, success: @escaping (T) -> (), failure: @escaping (Error) -> ()) {
if NetworkReachabilityManager()?.isReachable ?? false {
manager.request(
url,
method: method,
parameters: params,
encoding: encoding,
headers: header
).handle(success: success, failure: failure)
}else {
let error = NSError.init(domain: "NETWORK_REACHABILITY_DOMAIN", code: 0, userInfo: [NSLocalizedDescriptionKey : "No Internet connection found. 
Check your connection."])
failure(error)
}
}
//
// func kftcRequest<T: Mappable>(method: HTTPMethod, header: [String: Any], url: String, params: [String: Any]?, encoding: ParameterEncoding = JSONEncoding.default, needsAuthorization: Bool = true, success: @escaping (T) -> (), failure: @escaping (Error) -> ()) {
// if NetworkReachabilityManager()?.isReachable ?? false {
//
// manager.request(
// url,
// method: method,
// parameters: params,
// encoding: encoding,
// headers: header
// ).handle(success: success, failure: failure)
// }else {
// let error = NSError.init(domain: "NETWORK_REACHABILITY_DOMAIN", code: 0, userInfo: [NSLocalizedDescriptionKey : "No Internet connection found.
//Check your connection."])
// failure(error)
func requestMultipart<T: Mappable>(
method: HTTPMethod,
_ URLString: URLConvertible,

6
GMERemittance/SideMenu/SideMenuViewController.swift

@ -70,8 +70,8 @@ class SideMenuViewController: UIViewController {
let shouldShowWithdrawButton = Utility.pennyTestVerified() && Utility.isVerifiedUser()
self.withdrawButton.isHidden = !shouldShowWithdrawButton
// self.manageAccountStackView.isHidden = !shouldShowWithdrawButton
self.manageAccountStackView.isHidden = true
self.manageAccountStackView.isHidden = !shouldShowWithdrawButton
self.view.backgroundColor = AppConstants.themeRedColor
self.roundedBgView.layer.cornerRadius = 20
self.labelBalance.text = "0"
@ -84,7 +84,7 @@ class SideMenuViewController: UIViewController {
self.labelBalance.text = balance
let shouldShowWithdrawButton = Utility.pennyTestVerified() && Utility.isVerifiedUser()
self.withdrawButton.isHidden = !shouldShowWithdrawButton
// self.manageAccountStackView.isHidden = !shouldShowWithdrawButton
self.manageAccountStackView.isHidden = !shouldShowWithdrawButton
}

Loading…
Cancel
Save