Browse Source

collection view setup

pull/1/head
gme_2 6 years ago
parent
commit
d5932a97a5
  1. 12
      GMERemittance.xcodeproj/project.pbxproj
  2. 40
      GMERemittance/Module/SendMoneyPaymentMode/User Interface/View/Cells/SendMoenyPaymentModeCollectionViewCell.swift
  3. 21
      GMERemittance/Module/SendMoneyPaymentMode/User Interface/View/SendMoneyPaymentMode.storyboard
  4. 65
      GMERemittance/Module/SendMoneyPaymentMode/User Interface/View/SendMoneyPaymentModeViewController.swift

12
GMERemittance.xcodeproj/project.pbxproj

@ -343,6 +343,7 @@
D9DAFE2521352F3300483E71 /* SenMoneyPaymentModeRecipientViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9DAFE2421352F3300483E71 /* SenMoneyPaymentModeRecipientViewModel.swift */; };
D9DAFE27213530A800483E71 /* PaymentModeRecipientViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9DAFE26213530A800483E71 /* PaymentModeRecipientViewModel.swift */; };
D9DAFE2921353D6C00483E71 /* SendMoneyPaymentModeModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9DAFE2821353D6C00483E71 /* SendMoneyPaymentModeModel.swift */; };
D9DAFE2C21354D8900483E71 /* SendMoenyPaymentModeCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9DAFE2B21354D8900483E71 /* SendMoenyPaymentModeCollectionViewCell.swift */; };
D9E57945212E938D00D47AC0 /* ExchangeRateDetailModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9E57944212E938D00D47AC0 /* ExchangeRateDetailModel.swift */; };
EBFC1719B80F43F88EB01F69 /* Pods_GMERemittanceTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0380AEB198AADC0BC4394515 /* Pods_GMERemittanceTests.framework */; };
FF29296C212B8DFE00FF5BAC /* ExchangeRateCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = FF29296B212B8DFE00FF5BAC /* ExchangeRateCollectionViewCell.swift */; };
@ -718,6 +719,7 @@
D9DAFE2421352F3300483E71 /* SenMoneyPaymentModeRecipientViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SenMoneyPaymentModeRecipientViewModel.swift; sourceTree = "<group>"; };
D9DAFE26213530A800483E71 /* PaymentModeRecipientViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentModeRecipientViewModel.swift; sourceTree = "<group>"; };
D9DAFE2821353D6C00483E71 /* SendMoneyPaymentModeModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SendMoneyPaymentModeModel.swift; sourceTree = "<group>"; };
D9DAFE2B21354D8900483E71 /* SendMoenyPaymentModeCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SendMoenyPaymentModeCollectionViewCell.swift; sourceTree = "<group>"; };
D9E57944212E938D00D47AC0 /* ExchangeRateDetailModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExchangeRateDetailModel.swift; sourceTree = "<group>"; };
E4028C5A57499BB54764190C /* Pods_GMERemittanceUITests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_GMERemittanceUITests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
FF29296B212B8DFE00FF5BAC /* ExchangeRateCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExchangeRateCollectionViewCell.swift; sourceTree = "<group>"; };
@ -1524,6 +1526,7 @@
D922D93B2135124200D43053 /* View */ = {
isa = PBXGroup;
children = (
D9DAFE2A21354D2D00483E71 /* Cells */,
D922D93C2135124200D43053 /* SendMoneyPaymentModeViewController.swift */,
D922D93D2135124200D43053 /* ViewModels */,
D922D93E2135124200D43053 /* SendMoneyPaymentMode.storyboard */,
@ -2072,6 +2075,14 @@
path = ItemPickerView;
sourceTree = "<group>";
};
D9DAFE2A21354D2D00483E71 /* Cells */ = {
isa = PBXGroup;
children = (
D9DAFE2B21354D8900483E71 /* SendMoenyPaymentModeCollectionViewCell.swift */,
);
path = Cells;
sourceTree = "<group>";
};
FF29296A212B8DE600FF5BAC /* Cell */ = {
isa = PBXGroup;
children = (
@ -2610,6 +2621,7 @@
D90D55D521327CD600EEEE04 /* AddReciepientViewInterface.swift in Sources */,
A2B6CF19201469C800151863 /* EditCommentViewController.swift in Sources */,
D90D55CC21327CD600EEEE04 /* AddReciepientServiceType.swift in Sources */,
D9DAFE2C21354D8900483E71 /* SendMoenyPaymentModeCollectionViewCell.swift in Sources */,
A25CF60920467BA40029BC12 /* InviteViewController.swift in Sources */,
D922D9AD21351B7400D43053 /* SendMoneyVerificationPresenter.swift in Sources */,
A25A6C092029ADA80024CDFB /* TranscationStatementViewController.swift in Sources */,

40
GMERemittance/Module/SendMoneyPaymentMode/User Interface/View/Cells/SendMoenyPaymentModeCollectionViewCell.swift

@ -0,0 +1,40 @@
//
// SendMoenyPaymentModeCollectionViewCell.swift
// GMERemittance
//
// Created by gme_2 on 28/08/2018.
// Copyright © 2018 Gobal Money Express Co. Ltd. All rights reserved.
//
import UIKit
class SendMoenyPaymentModeCollectionViewCell: UICollectionViewCell {
@IBOutlet weak var cellBackgroundview: UIView!
@IBOutlet weak var imageview: UIImageView!
@IBOutlet weak var paymentLabel: UILabel!
var cellSelected = false
var image: UIImage?
var paymentServiceMethod: SendMoneyPayoutMode?
func setup() {
self.imageview.image = image
self.paymentLabel.text = paymentServiceMethod?.mode
self.cellBackgroundview.layer.cornerRadius = 5
self.paymentLabel.text = self.paymentServiceMethod?.mode
cellSelected ? showBorderColor() : hideBorderColor()
}
private func showBorderColor() {
self.cellBackgroundview.layer.borderWidth = 1
self.cellBackgroundview.layer.borderColor = UIColor.red.cgColor
}
private func hideBorderColor() {
cellBackgroundview.layer.borderWidth = 0
cellBackgroundview.layer.borderColor = UIColor.clear.cgColor
}
}

21
GMERemittance/Module/SendMoneyPaymentMode/User Interface/View/SendMoneyPaymentMode.storyboard

@ -55,7 +55,7 @@
<inset key="sectionInset" minX="10" minY="0.0" maxX="10" maxY="0.0"/>
</collectionViewFlowLayout>
<cells>
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="ExchangeRateCollectionViewCell" id="Lmo-TW-Yp5" customClass="ExchangeRateCollectionViewCell" customModule="GMERemittance" customModuleProvider="target">
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="SendMoenyPaymentModeCollectionViewCell" id="Lmo-TW-Yp5" customClass="SendMoenyPaymentModeCollectionViewCell" customModule="GMERemittance" customModuleProvider="target">
<rect key="frame" x="10" y="10" width="115" height="115"/>
<autoresizingMask key="autoresizingMask"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO">
@ -79,23 +79,14 @@
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="1 Business Day" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="UxT-vd-ynq">
<rect key="frame" x="0.0" y="98" width="115" height="12"/>
<fontDescription key="fontDescription" name="SanFranciscoDisplay-Regular" family="San Francisco Display" pointSize="10"/>
<color key="textColor" white="0.33333333329999998" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="UxT-vd-ynq" secondAttribute="trailing" id="Mct-A0-zQw"/>
<constraint firstItem="abk-cg-NHm" firstAttribute="top" secondItem="Y0l-DV-G4V" secondAttribute="bottom" constant="5" id="W9Q-9w-ftG"/>
<constraint firstItem="abk-cg-NHm" firstAttribute="leading" secondItem="WJ5-CO-3Wc" secondAttribute="leading" id="YmG-6x-3ve"/>
<constraint firstItem="Y0l-DV-G4V" firstAttribute="centerX" secondItem="WJ5-CO-3Wc" secondAttribute="centerX" id="bN6-rI-hgV"/>
<constraint firstAttribute="trailing" secondItem="abk-cg-NHm" secondAttribute="trailing" id="c2T-KZ-H4e"/>
<constraint firstItem="UxT-vd-ynq" firstAttribute="top" secondItem="abk-cg-NHm" secondAttribute="bottom" id="iER-Rm-bTG"/>
<constraint firstAttribute="height" constant="115" id="iLi-98-91u"/>
<constraint firstItem="UxT-vd-ynq" firstAttribute="leading" secondItem="WJ5-CO-3Wc" secondAttribute="leading" id="nRf-9a-dVP"/>
<constraint firstItem="Y0l-DV-G4V" firstAttribute="top" secondItem="WJ5-CO-3Wc" secondAttribute="top" constant="8" id="uWu-Lj-HrR"/>
</constraints>
</view>
@ -109,10 +100,9 @@
</constraints>
<size key="customSize" width="115" height="115"/>
<connections>
<outlet property="cellBackgroundview" destination="WJ5-CO-3Wc" id="wJa-t5-4oR"/>
<outlet property="imageview" destination="Y0l-DV-G4V" id="jDV-1o-bXR"/>
<outlet property="paymentLabel" destination="abk-cg-NHm" id="jmA-YB-njP"/>
<outlet property="subtitleLabel" destination="UxT-vd-ynq" id="3W1-ss-ykc"/>
<outlet property="cellBackgroundview" destination="WJ5-CO-3Wc" id="qJF-2p-XPG"/>
<outlet property="imageview" destination="Y0l-DV-G4V" id="DHh-10-cr8"/>
<outlet property="paymentLabel" destination="abk-cg-NHm" id="Lr2-LX-7BT"/>
</connections>
</collectionViewCell>
</cells>
@ -129,6 +119,9 @@
<constraint firstItem="vtS-MG-c5V" firstAttribute="leading" secondItem="9Uc-9s-KgO" secondAttribute="leading" constant="10" id="rbB-yW-lJj"/>
</constraints>
</view>
<connections>
<outlet property="collectionView" destination="oTy-T1-Wgq" id="Xl3-XV-eJi"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="8je-5K-XuW" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>

65
GMERemittance/Module/SendMoneyPaymentMode/User Interface/View/SendMoneyPaymentModeViewController.swift

@ -26,6 +26,7 @@ class SendMoneyPaymentModeViewController: UIViewController {
}
}
var selectedPaymentIndex: IndexPath = IndexPath.init(row: 0, section: 0)
// MARK: VC's Life cycle
override func viewDidLoad() {
@ -48,7 +49,69 @@ class SendMoneyPaymentModeViewController: UIViewController {
private func setupDelegates() {
// self.collectionView.delegate = self
// self.collectionView.dataSource = self
self.collectionView.dataSource = self
}
}
extension SendMoneyPaymentModeViewController: UICollectionViewDataSource {
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 3
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let paymentMode = self.payoutMode?.elementAt(index: indexPath.row)
guard let index = PaymentMode.init(rawValue: paymentMode?.id ?? "") else {
return UICollectionViewCell()
}
switch index {
case .bankDeposite:
return configureBankDepositeCell(collectionView: collectionView, indexPath: indexPath)
case .cashDelivery:
return configureCashDeliveryCell(collectionView: collectionView, indexPath: indexPath)
case .homeDelivery:
return configureHomeDeliveryCell(collectionView: collectionView, indexPath: indexPath)
case .mobileWallet:
return configureWalletDeliveryCell(collectionView: collectionView, indexPath: indexPath)
}
}
func configureBankDepositeCell(collectionView: UICollectionView, indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "SendMoenyPaymentModeCollectionViewCell", for: indexPath) as! SendMoenyPaymentModeCollectionViewCell
cell.cellSelected = self.selectedPaymentIndex == indexPath
cell.paymentServiceMethod = self.payoutMode?.elementAt(index: indexPath.row)
cell.image = #imageLiteral(resourceName: "ic_bank")
cell.setup()
return cell
}
func configureWalletDeliveryCell(collectionView: UICollectionView, indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "SendMoenyPaymentModeCollectionViewCell", for: indexPath) as! SendMoenyPaymentModeCollectionViewCell
cell.cellSelected = self.selectedPaymentIndex == indexPath
cell.paymentServiceMethod = self.payoutMode?.elementAt(index: indexPath.row)
cell.image = #imageLiteral(resourceName: "wallet-transfer")
cell.setup()
return cell
}
func configureCashDeliveryCell(collectionView: UICollectionView, indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "SendMoenyPaymentModeCollectionViewCell", for: indexPath) as! SendMoenyPaymentModeCollectionViewCell
cell.cellSelected = self.selectedPaymentIndex == indexPath
cell.paymentServiceMethod = self.payoutMode?.elementAt(index: indexPath.row)
cell.image = #imageLiteral(resourceName: "ic_cash")
cell.setup()
return cell
}
func configureHomeDeliveryCell(collectionView: UICollectionView, indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "SendMoenyPaymentModeCollectionViewCell", for: indexPath) as! SendMoenyPaymentModeCollectionViewCell
cell.cellSelected = self.selectedPaymentIndex == indexPath
cell.paymentServiceMethod = self.payoutMode?.elementAt(index: indexPath.row)
cell.image = #imageLiteral(resourceName: "ic_homeDelivery")
cell.setup()
return cell
}
}

Loading…
Cancel
Save