Browse Source

Merge branch 'dev-swift-d' of http://202.166.220.79:3000/JME-JAPAN/JME-IOS into dev-swift-d

v0.17
stepie.ub 1 year ago
parent
commit
54a37b6669
  1. 10
      GME Remit.xcodeproj/project.pbxproj
  2. 19
      GME Remit/Extensions/Date+Ext.swift
  3. 23
      GME Remit/Modules/RecipientModules/Recipients/Application Logic/Interactor/RecipientsInteractor.swift
  4. 8
      GME Remit/Modules/RecipientModules/Recipients/Application Logic/Interactor/RecipientsInteractorIO.swift
  5. 6
      GME Remit/Modules/RecipientModules/Recipients/Application Logic/Service/RecipientsService.swift
  6. 4
      GME Remit/Modules/RecipientModules/Recipients/Application Logic/Service/RecipientsServiceType.swift
  7. 2
      GME Remit/Modules/RecipientModules/Recipients/Module Interface/RecipientsModuleInterface.swift
  8. 4
      GME Remit/Modules/RecipientModules/Recipients/User Interface/Presenter/RecipientsPresenter.swift
  9. 2
      GME Remit/Modules/RecipientModules/Recipients/User Interface/View/Recipients.storyboard
  10. 52
      GME Remit/Modules/RecipientModules/Recipients/User Interface/View/RecipientsViewController.swift
  11. 14
      GME Remit/Modules/RecipientModules/Recipients/User Interface/View/ViewModel/RecipientsViewModel.swift
  12. 4
      GME Remit/Modules/RemittanceModules/TransactionHistoryModules/TransactionHistory/User Interface/View/DatePickerViewController.swift

10
GME Remit.xcodeproj/project.pbxproj

@ -8917,8 +8917,7 @@
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 8;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = GH2642V3WY;
DEVELOPMENT_TEAM = 68KRG7GPAV;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
@ -8942,7 +8941,7 @@
"$(OTHER_LDFLAGS)",
"-ObjC",
);
PRODUCT_BUNDLE_IDENTIFIER = com.japan.jmeremit1;
PRODUCT_BUNDLE_IDENTIFIER = com.japan.jmeremit;
PRODUCT_NAME = "JME Remit";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_OBJC_BRIDGING_HEADER = "GME Remit/Supported Files/GMERemittance-Bridging-Header.h";
@ -8963,8 +8962,7 @@
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 8;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = GH2642V3WY;
DEVELOPMENT_TEAM = 68KRG7GPAV;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
@ -8988,7 +8986,7 @@
"$(OTHER_LDFLAGS)",
"-ObjC",
);
PRODUCT_BUNDLE_IDENTIFIER = com.japan.jmeremit1;
PRODUCT_BUNDLE_IDENTIFIER = com.japan.jmeremit;
PRODUCT_NAME = "JME Remit";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_OBJC_BRIDGING_HEADER = "GME Remit/Supported Files/GMERemittance-Bridging-Header.h";

19
GME Remit/Extensions/Date+Ext.swift

@ -24,9 +24,18 @@ extension Date {
}
extension Date {
func asString(style: DateFormatter.Style) -> String {
let dateFormatter = DateFormatter()
dateFormatter.dateStyle = style
return dateFormatter.string(from: self)
}
func asString(style: DateFormatter.Style) -> String {
let dateFormatter = DateFormatter()
dateFormatter.dateStyle = style
return dateFormatter.string(from: self)
}
func converToString(dateFormat format: String) -> String
{
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = format
return dateFormatter.string(from: self)
}
}

23
GME Remit/Modules/RecipientModules/Recipients/Application Logic/Interactor/RecipientsInteractor.swift

@ -28,16 +28,16 @@ class RecipientsInteractor {
// MARK: Recipients interactor input interface
extension RecipientsInteractor: RecipientsInteractorInput {
func fetchRecipients(isRefresh: Bool) {
func fetchRecipients(isRefresh: Bool, fromDate: String, toDate: String, pageCount: String, countryCode: String) {
if isRefresh {
fetchRecipients()
fetchRecipients(fromDate: fromDate, toDate: toDate, pageCount: pageCount, countryCode: countryCode)
return
}
guard
let recipients = self.recipients
else {
fetchRecipients()
fetchRecipients(fromDate: fromDate, toDate: toDate, pageCount: pageCount, countryCode: countryCode)
return
}
@ -45,17 +45,18 @@ extension RecipientsInteractor: RecipientsInteractorInput {
}
func deleteRecipient(who recipient: Recipient) {
let myUsername = GMEDB.shared.user.string(.userId) ?? ""
service.deleteRecipient(
username: myUsername,
reciepient: recipient,
success: { self.fetchRecipients(isRefresh: true) },
failure: {self.output?.setError(with: $0)}
)
// let myUsername = GMEDB.shared.user.string(.userId) ?? ""
// service.deleteRecipient(
// username: myUsername,
// reciepient: recipient,
// success: { self.fetchRecipients(isRefresh: true) },
// failure: {self.output?.setError(with: $0)}
// )
}
private func fetchRecipients() {
private func fetchRecipients(fromDate: String, toDate: String, pageCount: String, countryCode: String) {
service.fetchRecipients(
fromDate: fromDate, toDate: toDate, pageCount: pageCount, countryCode: countryCode,
success: {
self.recipients = $0.recipients
self.output?.setRecipients(using: $0.recipients)

8
GME Remit/Modules/RecipientModules/Recipients/Application Logic/Interactor/RecipientsInteractorIO.swift

@ -7,11 +7,11 @@
//
protocol RecipientsInteractorInput: class {
func fetchRecipients(isRefresh: Bool)
func deleteRecipient(who recipient: Recipient)
func fetchRecipients(isRefresh: Bool, fromDate: String, toDate: String, pageCount: String, countryCode: String)
func deleteRecipient(who recipient: Recipient)
}
protocol RecipientsInteractorOutput: class {
func setRecipients(using model: FetchBeneficiariesModel?)
func setError(with error: Error)
func setRecipients(using model: FetchBeneficiariesModel?)
func setError(with error: Error)
}

6
GME Remit/Modules/RecipientModules/Recipients/Application Logic/Service/RecipientsService.swift

@ -11,12 +11,16 @@ import Alamofire
class RecipientsService: RecipientsServiceType {
func fetchRecipients(
fromDate: String,
toDate: String,
pageCount: String,
countryCode: String,
success: @escaping (FetchRecipientsModel) -> Void,
failure: @escaping (Error) -> Void
) {
let senderID = GMEDB.shared.user.string(.senderId) ?? ""
APIRouter
.fetchRecipients(senderID: senderID, fromDate: "", toDate: "", countryCode: "", pageCount: "")
.fetchRecipients(senderID: senderID, fromDate: fromDate, toDate: toDate, countryCode: "", pageCount: "")
.json(success: success, failure: failure)
}

4
GME Remit/Modules/RecipientModules/Recipients/Application Logic/Service/RecipientsServiceType.swift

@ -8,6 +8,10 @@
protocol RecipientsServiceType: class, ApiServiceType {
func fetchRecipients(
fromDate: String,
toDate: String,
pageCount: String,
countryCode: String,
success: @escaping (FetchRecipientsModel) -> Void,
failure: @escaping (Error) -> Void
)

2
GME Remit/Modules/RecipientModules/Recipients/Module Interface/RecipientsModuleInterface.swift

@ -7,7 +7,7 @@
//
protocol RecipientsModuleInterface: class {
func fetchRecipients(isRefresh: Bool)
func fetchRecipients(isRefresh: Bool, fromDate: String, toDate: String, pageCount: String, countryCode: String)
func openSendMoneyCalculate(who recipient: Recipient)
func openAddRecipient(with delegate: SetupRecipientDelegate)

4
GME Remit/Modules/RecipientModules/Recipients/User Interface/Presenter/RecipientsPresenter.swift

@ -50,9 +50,9 @@ extension RecipientsPresenter: RecipientsModuleInterface {
interactor?.deleteRecipient(who: recipient)
}
func fetchRecipients(isRefresh: Bool) {
func fetchRecipients(isRefresh: Bool, fromDate: String, toDate: String, pageCount: String, countryCode: String) {
viewModel?.progress(isShow: true)
interactor?.fetchRecipients(isRefresh: isRefresh)
interactor?.fetchRecipients(isRefresh: isRefresh, fromDate: fromDate, toDate: toDate, pageCount: pageCount, countryCode: countryCode)
}
}

2
GME Remit/Modules/RecipientModules/Recipients/User Interface/View/Recipients.storyboard

@ -295,7 +295,7 @@
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" bounces="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Vxa-tz-5xl">
<scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Vxa-tz-5xl">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Jn7-ZO-8UT">

52
GME Remit/Modules/RecipientModules/Recipients/User Interface/View/RecipientsViewController.swift

@ -26,9 +26,9 @@ class RecipientsViewController: UIViewController {
private lazy var deleteTrigger = PublishSubject<Recipient>()
private let impact = UISelectionFeedbackGenerator()
private var model: [Recipient]?
var refreshControl: UIRefreshControl?
var from: String?
var to: String?
private lazy var refreshControl = UIRefreshControl()
var from: Date?
var to: Date?
// MARK: Computed Properties
@ -61,9 +61,9 @@ class RecipientsViewController: UIViewController {
}
@IBAction func cancelDate(_ sender: UIButton) {
from = Calendar.current.date(byAdding: .weekOfMonth, value: -1, to: Date())!.asString(style: .medium)
to = Date().asString(style: .medium)
self.viewModel.fetchTransaction(fromDate: from ?? "", toDate: to ?? "", pageCount: "", countryCode: "")
self.from = Calendar.current.date(byAdding: .weekOfMonth, value: -1, to: Date())
self.to = Date()
self.viewModel.fetchTransaction(fromDate: self.from?.converToString(dateFormat: "yyyy-MM-dd") ?? "", toDate: self.to?.converToString(dateFormat: "yyyy-MM-dd") ?? "", pageCount: "", countryCode: "")
}
@IBAction func dateTapped(_ sender: UIButton) {
@ -88,17 +88,27 @@ class RecipientsViewController: UIViewController {
if self.presentingViewController == nil {
self.navigationItem.leftBarButtonItem = nil
}
}
private func addRefreshControl() {
let colorOption = [NSAttributedString.Key.foregroundColor : UIColor.themeWhite]
let title = NSAttributedString(string: "pull to refresh", attributes: colorOption)
refreshControl.attributedTitle = title
refreshControl.backgroundColor = .themeBlue
refreshControl.tintColor = .themeWhite
refreshControl.addTarget(self, action: #selector(refresh), for: .valueChanged)
refreshControl = UIRefreshControl()
refreshControl?.addTarget(self, action: #selector(refresh(_:)), for: .valueChanged)
scrollView.refreshControl = refreshControl
self.scrollView.refreshControl = refreshControl
}
@objc func refresh(_ sender: AnyObject){
refreshControl?.endRefreshing()
self.viewModel.presenter?.fetchRecipients(isRefresh: true)
}
refreshControl.endRefreshing()
self.viewModel.fetchTransaction(fromDate: self.from?.converToString(dateFormat: "yyyy-MM-dd") ?? "", toDate: self.to?.converToString(dateFormat: "yyyy-MM-dd") ?? "", pageCount: "", countryCode: "")
}
override func viewWillLayoutSubviews() {
super.viewWillLayoutSubviews()
@ -114,6 +124,15 @@ class RecipientsViewController: UIViewController {
view.endEditing(true)
}
func convertToDate(date: String) -> Date? {
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd"
dateFormatter.timeZone = TimeZone.current
dateFormatter.locale = Locale.current
return dateFormatter.date(from: date)
}
private func getHUmanReadableDate(date: String?) -> String? {
if let date = DateFormatter.toDate(dateString: date ?? "", format: AppConstants.dateFormat) {
let dateString = DateFormatter.toString(date: date, format: AppConstants.humanReadableDateFormat)
@ -123,8 +142,8 @@ class RecipientsViewController: UIViewController {
}
private func selectedDate(from: String?, to: String?) {
self.from = from
self.to = to
self.from = convertToDate(date: from ?? "")
self.to = convertToDate(date: to ?? "")
guard let fromDate = from, let toDate = to else {return}
self.viewModel.fetchTransaction(fromDate: fromDate, toDate: toDate, pageCount: "", countryCode: "")
}
@ -184,6 +203,7 @@ extension RecipientsViewController {
)
setUIBinding()
addRefreshControl()
}
private func setUIBinding() {
@ -243,7 +263,7 @@ extension RecipientsViewController {
onNext: {[weak self] _ in guard let `self` = self else { return }
DispatchQueue.main.async {
self.viewWillLayoutSubviews()
guard let fromDate = self.from, let toDate = self.to else {
guard let fromDate = self.from?.asString(style: .medium), let toDate = self.to?.asString(style: .medium) else {
return
}
self.fromDateLabel.text = fromDate

14
GME Remit/Modules/RecipientModules/Recipients/User Interface/View/ViewModel/RecipientsViewModel.swift

@ -58,14 +58,18 @@ class RecipientsViewModel: ViewModelType {
input
.fetchTrigger
.drive(onNext: { [weak self] in guard let `self` = self else { return }
self.presenter?.fetchRecipients(isRefresh: false)
let fromDate = Calendar.current.date(byAdding: .day, value: -7, to: Date())?.converToString(dateFormat: "yyyy-MM-dd")
let toDate = Date().converToString(dateFormat: "yyyy-MM-dd")
self.presenter?.fetchRecipients(isRefresh: false,fromDate: fromDate ?? "", toDate: toDate, pageCount: "", countryCode: "")
})
.disposed(by: disposeBag)
input
.refreshTrigger
.drive(onNext: { [weak self] in guard let `self` = self else { return }
self.presenter?.fetchRecipients(isRefresh: true)
let fromDate = Calendar.current.date(byAdding: .day, value: -7, to: Date())?.converToString(dateFormat: "yyyy-MM-dd")
let toDate = Date().converToString(dateFormat: "yyyy-MM-dd")
self.presenter?.fetchRecipients(isRefresh: true, fromDate: fromDate ?? "", toDate: toDate, pageCount: "", countryCode: "")
})
.disposed(by: disposeBag)
@ -130,7 +134,7 @@ class RecipientsViewModel: ViewModelType {
}
func fetchTransaction(fromDate: String, toDate: String, pageCount: String, countryCode: String) {
self.presenter?.fetchRecipients(isRefresh: true)
self.presenter?.fetchRecipients(isRefresh: true, fromDate: fromDate, toDate: toDate, pageCount: pageCount, countryCode: countryCode)
}
}
@ -186,12 +190,12 @@ extension RecipientsViewModel: SetupRecipientDelegate {
func setupRecieientForTermsVC(_ viewController: TermsAndConditionViewController, didSelectRecipientID: String?) {
selectedRecipientID = didSelectRecipientID
presenter?.fetchRecipients(isRefresh: true)
// presenter?.fetchRecipients(isRefresh: true)
}
func setupRecieient(_ viewController: SetupRecipientViewController, didSelectRecipientID: String?) {
selectedRecipientID = didSelectRecipientID
presenter?.fetchRecipients(isRefresh: true)
// presenter?.fetchRecipients(isRefresh: true)
}
func checkOtp(otp: String, userId: String, receiverID: String) {

4
GME Remit/Modules/RemittanceModules/TransactionHistoryModules/TransactionHistory/User Interface/View/DatePickerViewController.swift

@ -78,8 +78,8 @@ class DatePickerViewController: UIViewController {
configureLanguage()
guard let aMonthAgo = Calendar.current.date(
byAdding: .month,
value: -1,
byAdding: .day,
value: -7,
to: Date()) else {
return
}

Loading…
Cancel
Save