From f36eb50f53624f4f76ba061aefeee437cab7e559 Mon Sep 17 00:00:00 2001 From: Marzouq Almukhlif Date: Wed, 29 Dec 2021 16:52:47 +0300 Subject: [PATCH] P-2021-12-29:User_Interface->Payment_And_Calendar --- mudaris/.DS_Store | Bin 8196 -> 8196 bytes mudaris/Mudaris.xcodeproj/project.pbxproj | 12 +- .../Controllers/DetailsViewController.swift | 34 +- .../InvoiceController+MFSDKServicesCall.swift | 147 ++ .../Controllers/InvoiceController.swift | 248 ++- .../Controllers/MainViewController.swift | 2 +- .../Controllers/TeacherViewController.swift | 38 +- .../ViewController+MFSDKServicesCall.swift | 249 --- mudaris/Mudaris/Delegates/AppDelegate.swift | 6 +- mudaris/Mudaris/Models/Teachers.swift | 168 +-- mudaris/Mudaris/TimeCell.swift | 13 + .../Mudaris/Views/Base.lproj/Main.storyboard | 1343 +++++++++-------- 12 files changed, 1085 insertions(+), 1175 deletions(-) create mode 100644 mudaris/Mudaris/Controllers/InvoiceController+MFSDKServicesCall.swift delete mode 100644 mudaris/Mudaris/Controllers/ViewController+MFSDKServicesCall.swift create mode 100644 mudaris/Mudaris/TimeCell.swift diff --git a/mudaris/.DS_Store b/mudaris/.DS_Store index a8d464d968be279222334e700dc354fffb2e36de..28b15b9e3abfd59b48797ed1ac58d2780f4d9cc0 100644 GIT binary patch delta 29 lcmZp1XmOa}&&aw^Mo*OW|#QO4ginq32XoW delta 87 zcmZp1XmOa}&nU1lU^hRbz-AtS MFInitiatePaymentRequest { + let request = MFInitiatePaymentRequest() + return request + } + + + +//// PAY + private func getExecutePaymentRequest(paymentMethodId: Int) -> MFExecutePaymentRequest { + let request = MFExecutePaymentRequest(invoiceValue: invoiceValue , paymentMethod: paymentMethodId) + request.customerEmail = "test@myfatoorah.com"// must be email + request.customerMobile = "112233" + request.customerName = "Test MyFatoorah" + let address = MFCustomerAddress(block: "ddd", street: "sss", houseBuildingNo: "sss", address: "sss", addressInstructions: "sss") + request.customerAddress = address + request.language = .arabic + request.mobileCountryCode = MFMobileCountryCodeISO.saudiArabia.rawValue + request.displayCurrencyIso = .saudiArabia_SAR + return request + } + + + + func getSendPaymentRequest() -> MFSendPaymentRequest { +// let invoiceValue = Decimal(string: amountTextField.text ?? "") ?? 0 + let request = MFSendPaymentRequest(invoiceValue: invoiceValue, notificationOption: .all, customerName: "Test") + + //request.userDefinedField = "" + request.customerEmail = "a@b.com"// must be email + request.customerMobile = "mobile no"//Required + request.customerCivilId = "" + request.mobileCountryIsoCode = MFMobileCountryCodeISO.saudiArabia.rawValue + request.customerReference = "" + request.language = .arabic + let address = MFCustomerAddress(block: "ddd", street: "sss", houseBuildingNo: "sss", address: "sss", addressInstructions: "sss") + request.customerAddress = address + request.language = .arabic + request.displayCurrencyIso = .saudiArabia_SAR + let date = Date().addingTimeInterval(1000) + request.expiryDate = date + return request + } + + +} + diff --git a/mudaris/Mudaris/Controllers/InvoiceController.swift b/mudaris/Mudaris/Controllers/InvoiceController.swift index 42fe47c..30e195e 100644 --- a/mudaris/Mudaris/Controllers/InvoiceController.swift +++ b/mudaris/Mudaris/Controllers/InvoiceController.swift @@ -15,54 +15,34 @@ class InvoiceController: UIViewController,FSCalendarDelegate,FSCalendarDataSourc var selectedPaymentMethodIndex: Int? //MARK: Outlet - @IBOutlet weak var errorCodeLabel : UILabel! - @IBOutlet weak var payButton: UIButton! - @IBOutlet weak var amountTextField: UITextField! - @IBOutlet weak var resultTextView: UITextView! @IBOutlet weak var collectionView: UICollectionView! - @IBOutlet var cardInfoStackViews: [UIStackView]! - @IBOutlet weak var activityIndicator: UIActivityIndicatorView! - @IBOutlet weak var cardNumberTextField: UITextField! - @IBOutlet weak var cardHolderNameTextField: UITextField! - @IBOutlet weak var monthTextField: UITextField! - @IBOutlet weak var yearTextField: UITextField! - @IBOutlet weak var secureCodeTextField: UITextField! - @IBOutlet weak var sendPaymentButton: UIButton! - @IBOutlet weak var sendPaymentActivityIndicator: UIActivityIndicatorView! - - - //at list one product Required - let productList = NSMutableArray() - + + @IBOutlet var timeCollectionView: UICollectionView! + @IBOutlet var viewIn: UIView! @IBOutlet var viewBlack: UIView! - @IBOutlet var calender: FSCalendar! - @IBOutlet var buttonTimeOne: UIButton! @IBOutlet var buttonTimeTwo: UIButton! @IBOutlet var buttonTimeThree: UIButton! - - var array:Teachers? - var arrayDate:[DateTime]? - - var selectedDate:String? - var selectedTime:String? - @IBOutlet var teacherSelected: UILabel! - @IBOutlet var ordarLabel: UILabel! - @IBOutlet var dayLabel: UILabel! - @IBOutlet var dateLabel: UILabel! - @IBOutlet var timeLabel: UILabel! - - - @IBOutlet var InvoiceOneStackView: UIStackView! @IBOutlet var InvoiceTwoStackView: UIStackView! + @IBOutlet var payButton: UIButton! + + + var array:Teachers? + var arrayDate:[DateTime]? + var selectedDate:String? + var selectedTime:String? + let invoiceValue:Decimal = 5 + var timeArray = [String]() + + override func viewDidLoad() { super.viewDidLoad() @@ -134,7 +114,6 @@ class InvoiceController: UIViewController,FSCalendarDelegate,FSCalendarDataSourc func calendar(_ calendar: FSCalendar, shouldSelect date: Date, at monthPosition: FSCalendarMonthPosition) -> Bool { let array = arrayDate var dateArray = [String]() - var timeArray = [String]() let dateCalendar = getDate(date) array?.forEach({ DateTime in @@ -146,10 +125,10 @@ class InvoiceController: UIViewController,FSCalendarDelegate,FSCalendarDataSourc } }) - - buttonTimeOne.setTitle(timeArray[0], for: .normal) - buttonTimeTwo.setTitle(timeArray[1], for: .normal) - buttonTimeThree.setTitle(timeArray[2], for: .normal) + timeCollectionView.reloadData() +// buttonTimeOne.setTitle(timeArray[0], for: .normal) +// buttonTimeTwo.setTitle(timeArray[1], for: .normal) +// buttonTimeThree.setTitle(timeArray[2], for: .normal) selectedDate = dateCalendar; return true } @@ -162,16 +141,32 @@ class InvoiceController: UIViewController,FSCalendarDelegate,FSCalendarDataSourc var dateArray = [String]() array?.forEach({ DateTime in + if getDateStringToDate(DateTime.date) <= date { dateArray.append(DateTime.date) + if dateArray.contains(dateCalendar) { + cell.titleLabel.textColor = UIColor(red: 119/255, green: 119/255, blue: 119/255, alpha: 1.0) + cell.isUserInteractionEnabled = true + }else { + cell.titleLabel.textColor = UIColor(red: 206/255, green: 206/255, blue: 206/255, alpha: 1.0) + cell.isUserInteractionEnabled = false + } + + } else { + cell.titleLabel.textColor = UIColor(red: 206/255, green: 206/255, blue: 206/255, alpha: 1.0) + cell.isUserInteractionEnabled = false + + + } }) - if dateArray.contains(dateCalendar) { - cell.titleLabel.textColor = UIColor(red: 119/255, green: 119/255, blue: 119/255, alpha: 1.0) - }else { - cell.titleLabel.textColor = UIColor(red: 206/255, green: 206/255, blue: 206/255, alpha: 1.0) - cell.isUserInteractionEnabled = false - } - + +// if dateArray.contains(dateCalendar) { +// cell.titleLabel.textColor = UIColor(red: 119/255, green: 119/255, blue: 119/255, alpha: 1.0) +// }else { +// cell.titleLabel.textColor = UIColor(red: 206/255, green: 206/255, blue: 206/255, alpha: 1.0) +// cell.isUserInteractionEnabled = false +// } +// } @@ -185,6 +180,13 @@ class InvoiceController: UIViewController,FSCalendarDelegate,FSCalendarDataSourc } + func getDateStringToDate(_ date:String) -> Date { + let dateFormatter = DateFormatter() + dateFormatter.dateFormat = "yyyy-MM-dd" + dateFormatter.locale = NSLocale(localeIdentifier: "en-US") as Locale + let dateCalendar = dateFormatter.date(from: date) + return dateCalendar! + } func minimumDate(for calendar: FSCalendar) -> Date { return Date() @@ -196,6 +198,21 @@ class InvoiceController: UIViewController,FSCalendarDelegate,FSCalendarDataSourc } + @IBAction func payDidPRessed(_ sender: Any) { + if let paymentMethods = paymentMethods, !paymentMethods.isEmpty { + + if let selectedIndex = selectedPaymentMethodIndex { + + if paymentMethods[selectedIndex].paymentMethodCode == MFPaymentMethodCode.applePay.rawValue { + executeApplePayPayment(paymentMethodId: paymentMethods[selectedIndex].paymentMethodId) + } else { + executePayment(paymentMethodId: paymentMethods[selectedIndex].paymentMethodId) + } + } + } + } + + @IBAction func moveToPayButtonTapped(_ sender: UIButton) { if (selectedDate == nil) { @@ -242,45 +259,21 @@ class InvoiceController: UIViewController,FSCalendarDelegate,FSCalendarDataSourc let colorUnSelected = UIColor(red: 119/255, green: 119/255, blue: 119/255, alpha: 1.0) - if sender.tag == 1 { - buttonTimeOne.setTitleColor(colorSelected, for: .normal) - buttonTimeOne.superview!.layer.borderColor = colorSelected.cgColor - buttonTimeOne.superview!.layer.borderWidth = 1 - - buttonTimeTwo.setTitleColor(colorUnSelected, for: .normal) - buttonTimeTwo.superview!.layer.borderColor = UIColor.clear.cgColor - buttonTimeTwo.superview!.layer.borderWidth = 1 - - buttonTimeThree.setTitleColor(colorUnSelected, for: .normal) - buttonTimeThree.superview!.layer.borderColor = UIColor.clear.cgColor - buttonTimeThree.superview!.layer.borderWidth = 1 - - - } else if sender.tag == 2 { - buttonTimeOne.setTitleColor(colorUnSelected, for: .normal) - buttonTimeOne.superview!.layer.borderColor = UIColor.clear.cgColor - buttonTimeOne.superview!.layer.borderWidth = 1 - - buttonTimeTwo.setTitleColor(colorSelected, for: .normal) - buttonTimeTwo.superview!.layer.borderColor = colorSelected.cgColor - buttonTimeTwo.superview!.layer.borderWidth = 1 - - buttonTimeThree.setTitleColor(colorUnSelected, for: .normal) - buttonTimeThree.superview!.layer.borderColor = UIColor.clear.cgColor - buttonTimeThree.superview!.layer.borderWidth = 1 - - } else { - buttonTimeOne.setTitleColor(colorUnSelected, for: .normal) - buttonTimeOne.superview!.layer.borderColor = UIColor.clear.cgColor - buttonTimeOne.superview!.layer.borderWidth = 1 - - buttonTimeTwo.setTitleColor(colorUnSelected, for: .normal) - buttonTimeTwo.superview!.layer.borderColor = UIColor.clear.cgColor - buttonTimeTwo.superview!.layer.borderWidth = 1 - - buttonTimeThree.setTitleColor(colorSelected, for: .normal) - buttonTimeThree.superview!.layer.borderColor = colorSelected.cgColor - buttonTimeThree.superview!.layer.borderWidth = 1 + for button in sender.superview!.superview!.superview!.subviews { + if NSStringFromClass(button.classForCoder) == "_UIScrollViewScrollIndicator" { + } else if button.subviews[0].subviews[0] is UIButton + { + let isButton:UIButton = button.subviews[0].subviews[0] as! UIButton + if isButton.tag == sender.tag { + sender.setTitleColor(colorSelected, for: .normal) + sender.superview!.layer.borderColor = colorSelected.cgColor + sender.superview!.layer.borderWidth = 1 + } else { + isButton.setTitleColor(colorUnSelected, for: .normal) + isButton.superview!.layer.borderColor = colorUnSelected.cgColor + isButton.superview!.layer.borderWidth = 1 + } + } } selectedTime = sender.titleLabel?.text @@ -294,94 +287,45 @@ class InvoiceController: UIViewController,FSCalendarDelegate,FSCalendarDataSourc func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { + if collectionView == self.collectionView { guard let paymentMethods = paymentMethods else { return 0 } return paymentMethods.count + } else { + return timeArray.count + } } func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { - selectedPaymentMethodIndex = indexPath.row -// payButton.isEnabled = true - -// if let paymentMethods = paymentMethods { -// if paymentMethods[indexPath.row].isDirectPayment { -// hideCardInfoStacksView(isHidden: false) -// } else { -// hideCardInfoStacksView(isHidden: true) -// } -// } + selectedPaymentMethodIndex = indexPath.row + payButton.isEnabled = true + collectionView.reloadData() } -// func hideCardInfoStacksView(isHidden: Bool) { -// for stackView in cardInfoStackViews { -// stackView.isHidden = isHidden -// } -// } func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { + let colorUnSelected = UIColor(red: 119/255, green: 119/255, blue: 119/255, alpha: 1.0) + + if collectionView == self.collectionView { let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "payMethodsCell", for: indexPath) as! payMethodsCell if let paymentMethods = paymentMethods, !paymentMethods.isEmpty { let selectedIndex = selectedPaymentMethodIndex ?? -1 cell.configure(paymentMethod: paymentMethods[indexPath.row], selected: selectedIndex == indexPath.row) } return cell + } else { + let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "timeCell", for: indexPath) as! TimeCell + cell.timeButton.setTitle(timeArray[indexPath.row], for: .normal) + cell.timeButton.tag = indexPath.row + cell.timeButton.superview!.layer.borderColor = colorUnSelected.cgColor + cell.timeButton.superview!.layer.borderWidth = 1 + return cell + } } - - - - - } - - -extension InvoiceController { - func startSendPaymentLoading() { -// errorCodeLabel.text = "Status:" -// resultTextView.text = "Result:" -// sendPaymentButton.setTitle("", for: .normal) -// sendPaymentActivityIndicator.startAnimating() - } - func stopSendPaymentLoading() { -// sendPaymentButton.setTitle("Send Payment", for: .normal) -// sendPaymentActivityIndicator.stopAnimating() - } - func startLoading() { -// errorCodeLabel.text = "Status:" -// resultTextView.text = "Result:" -// payButton.setTitle("", for: .normal) -// activityIndicator.startAnimating() - } - func stopLoading() { -// payButton.setTitle("Pay", for: .normal) -// activityIndicator.stopAnimating() - } - func showSuccess(_ message: String) { -// errorCodeLabel.text = "Succes" -// resultTextView.text = "result: \(message)" - } - - func showFailError(_ error: MFFailResponse) { -// errorCodeLabel.text = "responseCode: \(error.statusCode)" -// resultTextView.text = "Error: \(error.errorDescription)" - } -} -extension InvoiceController { - func hideCardInfoStacksView(isHidden: Bool) { - for stackView in cardInfoStackViews { - stackView.isHidden = isHidden - } - } - private func setCardInfo() { - cardNumberTextField.text = "5123450000000008" - cardHolderNameTextField.text = "John Wick" - monthTextField.text = "05" - yearTextField.text = "21" - secureCodeTextField.text = "100" - } -} diff --git a/mudaris/Mudaris/Controllers/MainViewController.swift b/mudaris/Mudaris/Controllers/MainViewController.swift index c1d1dd2..3e02fb4 100644 --- a/mudaris/Mudaris/Controllers/MainViewController.swift +++ b/mudaris/Mudaris/Controllers/MainViewController.swift @@ -18,7 +18,7 @@ class MainViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() - + } diff --git a/mudaris/Mudaris/Controllers/TeacherViewController.swift b/mudaris/Mudaris/Controllers/TeacherViewController.swift index 4dd602d..e410435 100644 --- a/mudaris/Mudaris/Controllers/TeacherViewController.swift +++ b/mudaris/Mudaris/Controllers/TeacherViewController.swift @@ -7,11 +7,15 @@ import UIKit -class TeacherViewController: UIViewController,UITableViewDelegate,UITableViewDataSource { +class TeacherViewController: UIViewController,UITableViewDelegate,UITableViewDataSource, UISearchBarDelegate{ @IBOutlet weak var locationButton: UIButton! + @IBOutlet var SearchBar: UISearchBar! + let shops:[Teachers] = array + var filterData:[Teachers]! + var selectedData:Teachers! @IBOutlet weak var topBarStackView: UIStackView! @IBOutlet weak var tableView: UITableView! @@ -24,7 +28,7 @@ class TeacherViewController: UIViewController,UITableViewDelegate,UITableViewDat view.layer.borderWidth = 0.5 view.layer.borderColor = UIColor.blue.cgColor - + filterData = shops locationButton.layer.borderColor = UIColor(red: 122/255, green: 167/255, blue: 220/255, alpha: 1.0).cgColor @@ -37,16 +41,25 @@ class TeacherViewController: UIViewController,UITableViewDelegate,UITableViewDat } func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - return shops.count + return filterData.count } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "Cell",for: indexPath) as? TeacherTableViewCell - cell?.shopImageView.image = shops[indexPath.row].image - cell?.shopImageView.backgroundColor = .random - cell?.shopName.text = shops[indexPath.row].cores - cell?.shopDescription.text = shops[indexPath.row].info + + if filterData.count != 0 { + cell?.shopImageView.image = filterData[indexPath.row].image + cell?.shopImageView.backgroundColor = .random + cell?.shopName.text = filterData[indexPath.row].cores + cell?.shopDescription.text = filterData[indexPath.row].info + } else { + cell?.shopImageView.image = shops[indexPath.row].image + cell?.shopImageView.backgroundColor = .random + cell?.shopName.text = shops[indexPath.row].cores + cell?.shopDescription.text = shops[indexPath.row].info + } + // Configure the cell... return cell! @@ -60,7 +73,7 @@ class TeacherViewController: UIViewController,UITableViewDelegate,UITableViewDat if let row = tableView.indexPathForSelectedRow?.row { let detailsViewController = segue.destination as! DetailsViewController - detailsViewController.array = shops[row] + detailsViewController.array = filterData[row] } default: @@ -69,5 +82,14 @@ class TeacherViewController: UIViewController,UITableViewDelegate,UITableViewDat } + func searchBar(_ searchBar: UISearchBar, textDidChange searchText: String) { + filterData = searchText.isEmpty ? shops : shops.filter { + (item : Teachers) -> Bool in + + return item.cores.range(of: searchText, options: .caseInsensitive , range: nil,locale: nil) != nil + } + + tableView.reloadData() + } } diff --git a/mudaris/Mudaris/Controllers/ViewController+MFSDKServicesCall.swift b/mudaris/Mudaris/Controllers/ViewController+MFSDKServicesCall.swift deleted file mode 100644 index 579acea..0000000 --- a/mudaris/Mudaris/Controllers/ViewController+MFSDKServicesCall.swift +++ /dev/null @@ -1,249 +0,0 @@ -// -// ViewController+MFSDKServicesCall.swift -// MFSDKDemo-Swift -// -// Created by Elsayed Hussein on 8/29/19. -// Copyright © 2019 Elsayed Hussein. All rights reserved. -// - -import MFSDK - -extension InvoiceController { - func initiatePayment() { - let request = generateInitiatePaymentModel() - startLoading() - MFPaymentRequest.shared.initiatePayment(request: request, apiLanguage: .english, completion: { [weak self] (result) in - self?.stopLoading() - switch result { - case .success(let initiatePaymentResponse): - self?.paymentMethods = initiatePaymentResponse.paymentMethods - self?.collectionView.reloadData() - case .failure(let failError): - self?.showFailError(failError) - } - }) - } - - func executeDirectPayment(paymentMethodId: Int) { - let request = getExecutePaymentRequest(paymentMethodId: paymentMethodId) - let card = getCardInfo() - startLoading() - MFPaymentRequest.shared.executeDirectPayment(request: request, cardInfo: card, apiLanguage: .english) { [weak self] (response, invoiceId) in - self?.stopLoading() - switch response { - case .success(let directPaymentResponse): - if let cardInfoResponse = directPaymentResponse.cardInfoResponse, let card = cardInfoResponse.cardInfo { - self?.resultTextView.text = "Status: with card number: \(card.number ?? "")" - } - if let invoiceId = invoiceId { - self?.errorCodeLabel.text = "Success with invoice id \(invoiceId)" - } else { - self?.errorCodeLabel.text = "Success" - } - case .failure(let failError): - self?.resultTextView.text = "Error: \(failError.errorDescription)" - if let invoiceId = invoiceId { - self?.errorCodeLabel.text = "Fail: \(failError.statusCode) with invoice id \(invoiceId)" - } else { - self?.errorCodeLabel.text = "Fail: \(failError.statusCode)" - } - } - } - } - - func executeApplePayPayment(paymentMethodId: Int) { - let request = getExecutePaymentRequest(paymentMethodId: paymentMethodId) - startLoading() - if #available(iOS 13.0, *) { - MFPaymentRequest.shared.executeApplePayPayment(request: request, apiLanguage: .arabic) { [weak self] (response, invoiceId) in - self?.stopLoading() - switch response { - case .success(let executePaymentResponse): - if let invoiceStatus = executePaymentResponse.invoiceStatus { - self?.showSuccess(invoiceStatus) - } - case .failure(let failError): - self?.showFailError(failError) - } - } - } else { - // Fallback on earlier versions - let urlScheme = "com.myFatoorah.MFSDKDemo" - MFPaymentRequest.shared.executeApplePayPayment(request: request, apiLanguage: .arabic) { [weak self] response, invoiceId in - self?.stopLoading() - switch response { - case .success(let executePaymentResponse): - if let invoiceStatus = executePaymentResponse.invoiceStatus { - self?.showSuccess(invoiceStatus) - } - case .failure(let failError): - self?.showFailError(failError) - } - } - - } - } - - func executePayment(paymentMethodId: Int) { - let request = getExecutePaymentRequest(paymentMethodId: paymentMethodId) - startLoading() - MFPaymentRequest.shared.executePayment(request: request, apiLanguage: .arabic) { [weak self] response, invoiceId in - self?.stopLoading() - switch response { - case .success(let executePaymentResponse): - if let invoiceStatus = executePaymentResponse.invoiceStatus { - self?.showSuccess(invoiceStatus) - } - case .failure(let failError): - self?.showFailError(failError) - } - } - } - - - func sendPayment() { - let request = getSendPaymentRequest() - startSendPaymentLoading() - MFPaymentRequest.shared.sendPayment(request: request, apiLanguage: .arabic) { [weak self] (result) in - self?.stopSendPaymentLoading() - switch result { - case .success(let sendPaymentResponse): - if let invoiceURL = sendPaymentResponse.invoiceURL { - self?.errorCodeLabel.text = "Success" - self?.resultTextView.text = "result: send this link to your customers \(invoiceURL)" - } - case .failure(let failError): - self?.showFailError(failError) - } - - } - } -} -extension InvoiceController { - private func generateInitiatePaymentModel() -> MFInitiatePaymentRequest { - // you can create initiate payment request with invoice value and currency - // let invoiceValue = Double(amountTextField.text ?? "") ?? 0 - // let request = MFInitiatePaymentRequest(invoiceAmount: invoiceValue, currencyIso: .kuwait_KWD) - // return request - - let request = MFInitiatePaymentRequest() - return request - } - - private func getCardInfo() -> MFCardInfo { - let cardNumber = cardNumberTextField.text ?? "" - let cardExpiryMonth = monthTextField.text ?? "" - let cardExpiryYear = yearTextField.text ?? "" - let cardSecureCode = secureCodeTextField.text ?? "" - let cardHolderName = cardHolderNameTextField.text ?? "" - - - let card = MFCardInfo(cardNumber: cardNumber, cardExpiryMonth: cardExpiryMonth, cardExpiryYear: cardExpiryYear, cardHolderName: cardHolderName, cardSecurityCode: cardSecureCode, saveToken: false) - card.bypass = false // default is true - return card - } - private func getExecutePaymentRequest(paymentMethodId: Int) -> MFExecutePaymentRequest { - let invoiceValue = Decimal(string: "35") ?? 0 - let request = MFExecutePaymentRequest(invoiceValue: invoiceValue , paymentMethod: paymentMethodId) - //request.userDefinedField = "" - request.customerEmail = "test@myfatoorah.com"// must be email - request.customerMobile = "112233" - request.customerCivilId = "1234567890" - request.customerName = "Test MyFatoorah" - let address = MFCustomerAddress(block: "ddd", street: "sss", houseBuildingNo: "sss", address: "sss", addressInstructions: "sss") - request.customerAddress = address - request.customerReference = "Test MyFatoorah Reference" - request.language = .english - request.mobileCountryCode = MFMobileCountryCodeISO.kuwait.rawValue - request.displayCurrencyIso = .saudiArabia_SAR -// request.supplierValue = 1 -// request.supplierCode = 2 -// request.suppliers.append(MFSupplier(supplierCode: 1, proposedShare: 2, invoiceShare: invoiceValue)) - - // Uncomment this to add products for your invoice -// var productList = [MFProduct]() -// let product = MFProduct(name: "ABC", unitPrice: 1.887, quantity: 1) -// productList.append(product) -// request.invoiceItems = productList - return request - } - - func getSendPaymentRequest() -> MFSendPaymentRequest { - let invoiceValue = Decimal(string: "35") ?? 0 - let request = MFSendPaymentRequest(invoiceValue: invoiceValue, notificationOption: .all, customerName: "Test") - - // send invoice link as sms to specified number - // let request = MFSendPaymentRequest(invoiceValue: invoiceValue, notificationOption: .sms, customerName: "Test") - // request.customerMobile = "" // required here - - // get invoice link - // let request = MFSendPaymentRequest(invoiceValue: invoiceValue, notificationOption: .link, customerName: "Test") - - // send invoice link to email - // let request = MFSendPaymentRequest(invoiceValue: invoiceValue, notificationOption: .email, customerName: "Test") - // request.customerEmail = "" required here - - - - //request.userDefinedField = "" - request.customerEmail = "a@b.com"// must be email - request.customerMobile = "mobile no"//Required - request.customerCivilId = "" - request.mobileCountryIsoCode = MFMobileCountryCodeISO.kuwait.rawValue - request.customerReference = "" - request.language = .english - let address = MFCustomerAddress(block: "ddd", street: "sss", houseBuildingNo: "sss", address: "sss", addressInstructions: "sss") - request.customerAddress = address - request.language = .english - request.displayCurrencyIso = .saudiArabia_SAR - let date = Date().addingTimeInterval(1000) - request.expiryDate = date - return request - } -} - - // MARK: - Recurring Payment -extension InvoiceController { - - func executeRecurringPayment(paymentMethodId: Int) { - let request = MFExecutePaymentRequest(invoiceValue: 5.000 , paymentMethod: paymentMethodId) - let card = getCardInfo() - MFPaymentRequest.shared.executeRecurringPayment(request: request, cardInfo: card, recurringType: .custom(intervalDays: 10), iteration: 2, apiLanguage: .english) { (response, invoiceId) in - switch response { - case .success(let directPaymentResponse): - if let cardInfoResponse = directPaymentResponse.cardInfoResponse, let card = cardInfoResponse.cardInfo { - print("Status: with card number: \(card.number ?? "")") - print("Status: with recurring Id: \(cardInfoResponse.recurringId ?? "")") - } - if let invoiceId = invoiceId { - print("Success with invoice id \(invoiceId)") - } else { - print("Success") - } - case .failure(let failError): - print("Error: \(failError.errorDescription)") - if let invoiceId = invoiceId { - print("Fail: \(failError.statusCode) with invoice id \(invoiceId)") - } else { - print("Fail: \(failError.statusCode)") - } - } - } - } - - func executeRecurringPayment(recurringId: String) { - MFPaymentRequest.shared.cancelRecurringPayment(recurringId: recurringId, apiLanguage: .english) { [weak self] (result) in - switch result { - case .success(let isCanceled): - if isCanceled { - print("Success") - } - - case .failure(let failError): - self?.showFailError(failError) - } - } - } - -} - diff --git a/mudaris/Mudaris/Delegates/AppDelegate.swift b/mudaris/Mudaris/Delegates/AppDelegate.swift index 20a9c66..c63a2b0 100644 --- a/mudaris/Mudaris/Delegates/AppDelegate.swift +++ b/mudaris/Mudaris/Delegates/AppDelegate.swift @@ -14,7 +14,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { // Override point for customization after application launch. - MFSettings.shared.configure(token: "W_d3MNWeO8Jt1_PeR4R1QWQpdfayqOFD5LGPosWt25kvLboCW3UMilT9XMNdkjO7izGVR9j-jTzz9H1lzfCV9VnvsGrR_EKNWHcVqNcVAtOdk2m88pgcXKUouyRozDDqT74zWDEuK-rzHx6UP_aFKaEuwkJmesqPOkWPhGaCPDGcZGkSJ2FtCNJJjTgVBN1ET-23QpTk3Zqj27wxRK1Ob0q5TmHdd5JyOFUyORcGMeMAwrz7eKfAadeFMMg2J-Ugnjevzu40sZ7MRgRpLVqMFZ4tWvV8xmyS5oVuuv6jXPI8VMwvJoA6iwsrAtvhAN8IpkB-iFuxxnGR-_vnnk0-M892KfGws6oh-cpfLF0Wsas_54msdXgQTCY8hfme9WeYc6ddwGOx48m-1l5QZzzycFKnw2wp3GZGcxbvkN4MXEMa90FIirWZmkb86Y7XS9Hviwoq5K-lO-OReFAwJ11ApbMj6WGsAofz7KLSR1Y6_YNpEQiDDAO2glpJ6zx-1DLXSSpXq2C-b5dVy9LsLtKu0CJ3IgIHuGXM-fa-QeFxDDdEKz3CgAtMNEb3ZICdoGH8hR9Y-lP1CR0i157aEeMHTVxLDutFmmTo3KwIp5sq9O9XxrGaToIy54qCaTSb4UGNTHJd8Nl59pGCkD02r-i2sSExbRwNWP8EjBHAi0KQxM0vSOJc", baseURL: .live) + MFSettings.shared.configure(token: "rLtt6JWvbUHDDhsZnfpAhpYk4dxYDQkbcPTyGaKp2TYqQgG7FGZ5Th_WD53Oq8Ebz6A53njUoo1w3pjU1D4vs_ZMqFiz_j0urb_BH9Oq9VZoKFoJEDAbRZepGcQanImyYrry7Kt6MnMdgfG5jn4HngWoRdKduNNyP4kzcp3mRv7x00ahkm9LAK7ZRieg7k1PDAnBIOG3EyVSJ5kK4WLMvYr7sCwHbHcu4A5WwelxYK0GMJy37bNAarSJDFQsJ2ZvJjvMDmfWwDVFEVe_5tOomfVNt6bOg9mexbGjMrnHBnKnZR1vQbBtQieDlQepzTZMuQrSuKn-t5XZM7V6fCW7oP-uXGX-sMOajeX65JOf6XVpk29DP6ro8WTAflCDANC193yof8-f5_EYY-3hXhJj7RBXmizDpneEQDSaSz5sFk0sV5qPcARJ9zGG73vuGFyenjPPmtDtXtpx35A-BVcOSBYVIWe9kndG3nclfefjKEuZ3m4jL9Gg1h2JBvmXSMYiZtp9MR5I6pvbvylU_PP5xJFSjVTIz7IQSjcVGO41npnwIxRXNRxFOdIUHn0tjQ-7LwvEcTXyPsHXcMD8WtgBh-wxR8aKX7WPSsT1O8d8reb2aR7K3rkV3K82K_0OgawImEpwSvp9MNKynEAJQS6ZHe_J_l77652xwPNxMRTMASk1ZsJL", baseURL: .test) + + + +// MFSettings.shared.configure(token: "PoJR0-s1HF_JFyiuuJ-ojpBiXXsZpq5imON9hbqOzFNpUUL4oaPFtGsCnXd18sogaekm09oJxOwKxjg-79qtq7JvxTNrc3iRYIGqgJV8179WLbR8Oop9NVC_FHmWnxuSut4FOCQvOEamy9-0n5-D0RRbJNhDbniVqpOlFic5iIvHLELWJIEr0b-jTTqm0VRYaYFkdbqGwwmzsKxwnDVrAVIqMphn_leWvO3x6UcgYBBbCtr6vCdmZetrsp05PDPwAk2MvtN1cHqximLPqqI7JbE6kZDW1Jmg3tTz2HO4GT6E-PDgrbozkeIdG87R8qu818F32XdsIflncyEsFAaGYjp97mUEaRVgSxkPoSknDPjVUSWL1oF7rzh0pY8sGL5ufjJyhOMZ-lucBne4KLH-X3sO2NzfmtE-KLxiHdM7q7Xi174qQGTKX-c5Pm9r_NYMXOgfYOtNleBAxGQoXZa2LocWFuZ_zrtJNW_ec1o13qTO-gvVaMUtyc-W0K8UwPg9K8WQjtkB1vk7JLQozt5H3-gXTfvV-f1WnaRGfdUkrn4_WYfSUINMCMxcWVjn0VmBBibtiaeSMS7Qc88LmltpdvQOg9JlYBO1o9qe13-rhQVJwkp552A4RqcaYLfw10_ywvmoJHs2MZ1TJHBwzDW0tvlsdIUyYVX7Tcj2MtYntXnz84ECKALBTv2EaIaD2FQEV2-VRQ", baseURL: .live) // you can change color and title of nvgigation bar diff --git a/mudaris/Mudaris/Models/Teachers.swift b/mudaris/Mudaris/Models/Teachers.swift index 624f410..72663e3 100644 --- a/mudaris/Mudaris/Models/Teachers.swift +++ b/mudaris/Mudaris/Models/Teachers.swift @@ -16,24 +16,24 @@ struct DateTime { let array:[Teachers] = [ Teachers(name: "احمد الخالدي", cores: "مدرس لغة انجليزية", - age: "40", - info: "اقوم بتعليم الطالب في المرحلة الابتدائية اساسيات اللغة الانجليزيه وتعليمه المنهج والقواعد الاساسية ومساعدته في حل واجباته وتعليمه على طريقة الحل الصحيحة ", - exper: "10", + age: "40", + info: "اقوم بتعليم الطالب في المرحلة الابتدائية اساسيات اللغة الانجليزيه وتعليمه المنهج والقواعد الاساسية ومساعدته في حل واجباته وتعليمه على طريقة الحل الصحيحة ", + exper: "10", stage: "الابتدائي", requestDate: [ - DateTime(date: "2021-12-16", time: [ + DateTime(date: "2021-12-26", time: [ "1:00م - 3:00م" - ,"5:00م - 7:00م" - ,"8:00م - 10:00م" - ]), + ,"5:00م - 7:00م" + ,"8:00م - 10:00م" + ]), - DateTime(date: "2021-12-17", time: [ + DateTime(date: "2021-12-27", time: [ "2:00م - 4:00م" ,"6:00م - 8:00م" ,"9:00م - 11:00م" ]), - DateTime(date: "2021-12-18", time: [ + DateTime(date: "2021-12-30", time: [ "9:00ص - 11:00ص" ,"12:00م - 2:00م" ,"6:00م - 8:00م" @@ -41,40 +41,40 @@ let array:[Teachers] = [ ], reservationDate: [ - DateTime(date: "2021-12-16", time: [ - "1:00م - 3:00م" - ,"5:00م - 7:00م" - ,"8:00م - 10:00م" - ]), - - DateTime(date: "2021-12-17", time: [ - "2:00م - 4:00م" - ,"6:00م - 8:00م" - ,"9:00م - 11:00م" - ]), - - DateTime(date: "2021-12-18", time: [ - "9:00ص - 11:00ص" - ,"12:00م - 2:00م" - ,"6:00م - 8:00م" - ]), - ], - image: UIImage(named: "icon")!), - + DateTime(date: "2021-12-26", time: [ + "1:00م - 3:00م" + ,"5:00م - 7:00م" + ,"8:00م - 10:00م" + ]), + + DateTime(date: "2021-12-27", time: [ + "2:00م - 4:00م" + ,"6:00م - 8:00م" + ,"9:00م - 11:00م" + ]), + + DateTime(date: "2021-12-30", time: [ + "9:00ص - 11:00ص" + ,"12:00م - 2:00م" + ,"6:00م - 8:00م" + ]), + ], + image: UIImage(named: "icon")!), + Teachers(name: "محمد المصري", cores: "مدرس لغة عربية", - age: "35", - info: "اقوم بتعليم الطالب في المرحلة الابتدائية اساسيات اللغة العربية وتعليمه المنهج والقواعد الاساسية ومساعدته في حل واجباته وتعليمه على طريقة الحل الصحيحة ", - exper: "6", + age: "35", + info: "اقوم بتعليم الطالب في المرحلة الابتدائية اساسيات اللغة العربية وتعليمه المنهج والقواعد الاساسية ومساعدته في حل واجباته وتعليمه على طريقة الحل الصحيحة ", + exper: "6", stage: "الابتدائي", requestDate: [ DateTime(date: "2021-12-19", time: [ "1:00م - 3:00م" - ,"5:00م - 7:00م" - ,"8:00م - 10:00م" - ]), + ,"5:00م - 7:00م" + ,"8:00م - 10:00م" + ]), DateTime(date: "2021-12-20", time: [ "2:00م - 4:00م" @@ -90,40 +90,40 @@ let array:[Teachers] = [ ], reservationDate: [ - DateTime(date: "2021-12-16", time: [ - "1:00م - 3:00م" - ,"5:00م - 7:00م" - ,"8:00م - 10:00م" - ]), - - DateTime(date: "2021-12-17", time: [ - "2:00م - 4:00م" - ,"6:00م - 8:00م" - ,"9:00م - 11:00م" - ]), - - DateTime(date: "2021-12-18", time: [ - "9:00ص - 11:00ص" - ,"12:00م - 2:00م" - ,"6:00م - 8:00م" - ]), - ], - image: UIImage(named: "icon")!), - + DateTime(date: "2021-12-16", time: [ + "1:00م - 3:00م" + ,"5:00م - 7:00م" + ,"8:00م - 10:00م" + ]), + + DateTime(date: "2021-12-17", time: [ + "2:00م - 4:00م" + ,"6:00م - 8:00م" + ,"9:00م - 11:00م" + ]), + + DateTime(date: "2021-12-18", time: [ + "9:00ص - 11:00ص" + ,"12:00م - 2:00م" + ,"6:00م - 8:00م" + ]), + ], + image: UIImage(named: "icon")!), + Teachers(name: "خالد الشهري", cores: "مدرس رياضيات", - age: "30", - info: "اقوم بتعليم الطالب في المرحلة الابتدائية اساسيات الرياضيات وتعليمه المنهج والقواعد الاساسية ومساعدته في حل واجباته وتعليمه على طريقة الحل الصحيحة ", - exper: "8", + age: "30", + info: "اقوم بتعليم الطالب في المرحلة الابتدائية اساسيات الرياضيات وتعليمه المنهج والقواعد الاساسية ومساعدته في حل واجباته وتعليمه على طريقة الحل الصحيحة ", + exper: "8", stage: "الثانوي", requestDate: [ DateTime(date: "2021-12-16", time: [ "1:00م - 3:00م" - ,"5:00م - 7:00م" - ,"8:00م - 10:00م" - ]), + ,"5:00م - 7:00م" + ,"8:00م - 10:00م" + ]), DateTime(date: "2021-12-17", time: [ "2:00م - 4:00م" @@ -141,26 +141,26 @@ let array:[Teachers] = [ reservationDate: [ - DateTime(date: "2021-12-19", time: [ - "1:00م - 3:00م" - ,"5:00م - 7:00م" - ,"8:00م - 10:00م" - ]), - - DateTime(date: "2021-12-20", time: [ - "2:00م - 4:00م" - ,"6:00م - 8:00م" - ,"9:00م - 11:00م" - ]), - - DateTime(date: "2021-12-23", time: [ - "9:00ص - 11:00ص" - ,"12:00م - 2:00م" - ,"6:00م - 8:00م" - ]), - ], + DateTime(date: "2021-12-19", time: [ + "1:00م - 3:00م" + ,"5:00م - 7:00م" + ,"8:00م - 10:00م" + ]), + + DateTime(date: "2021-12-20", time: [ + "2:00م - 4:00م" + ,"6:00م - 8:00م" + ,"9:00م - 11:00م" + ]), + + DateTime(date: "2021-12-23", time: [ + "9:00ص - 11:00ص" + ,"12:00م - 2:00م" + ,"6:00م - 8:00م" + ]), + ], - image: UIImage(named: "icon")!) + image: UIImage(named: "icon")!) ] struct Teachers { @@ -184,12 +184,12 @@ struct Teachers { ,"مدرس تاريخ" ,"مدرس احمد رياضيات" ,"مدرس خلف فيزياء" - ,"مدرس المرحلة الابتدائة" -,"Salon 4", -"Salon 5"] + ,"مدرس المرحلة الابتدائة" + ,"Salon 4", + "Salon 5"] var shopsDescriptions = ["هذا النص هو مثال لنص يمكن أن يستبدل في نفس المساحة."] - + var shopsImages = ["icon"] diff --git a/mudaris/Mudaris/TimeCell.swift b/mudaris/Mudaris/TimeCell.swift new file mode 100644 index 0000000..d4d611a --- /dev/null +++ b/mudaris/Mudaris/TimeCell.swift @@ -0,0 +1,13 @@ +// +// TimeCell.swift +// +// +// Created by Marzouq Almukhlif on 24/05/1443 AH. +// + +import UIKit + +class TimeCell: UICollectionViewCell { + + @IBOutlet var timeButton: UIButton! +} diff --git a/mudaris/Mudaris/Views/Base.lproj/Main.storyboard b/mudaris/Mudaris/Views/Base.lproj/Main.storyboard index 83b6c20..4d054ca 100644 --- a/mudaris/Mudaris/Views/Base.lproj/Main.storyboard +++ b/mudaris/Mudaris/Views/Base.lproj/Main.storyboard @@ -1,9 +1,10 @@ - - + + + @@ -29,21 +30,21 @@ - + - + - + - + - + - + - + - + - + - + @@ -298,7 +299,7 @@ - + @@ -310,7 +311,7 @@ - + - + @@ -369,7 +370,7 @@ - + + + + + + + + + + + + + + + + + + + + - + + + @@ -427,27 +449,27 @@ - + - + - + - + - + - + @@ -464,17 +486,17 @@ - + - + - + - + + + + - - - - - + + + + - - + + - - + + - - - - - - - - - - - - - - + + - - - - - - + + + - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - - + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - + + + + + + + + + + + + + + + + - - - - + + + + + + + + - - - - - - - - - - - - - - - - + + + - - + + + + + + + + + + + + + + - - + + - - + - - - + + - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - + + + + + + + + - - - - - - - - - - - - - - + + + + - + + - - - - + + + + + - - - - - - - - - - - - - - - - + + + - - - + - - - - - - - - - - - - - - + + + + + + + + + + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + + + + + + - - - - - - - - - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + - + + + + - - - - + + + - + @@ -1046,29 +1088,31 @@ + + - + - + - + - + - + - + - + @@ -1102,13 +1146,13 @@ - + - + - + @@ -1154,7 +1198,7 @@ - + @@ -1234,118 +1278,81 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + - + - + - + @@ -1819,7 +1826,7 @@ - + - - - + + + @@ -1911,18 +1918,18 @@ - + - + - + @@ -1941,11 +1948,14 @@ - + + + + - +