Browse Source

added view layout

pull/1/head
gme_2 6 years ago
parent
commit
4afd9612a7
  1. 18
      GMERemittance/Module/Home/User Interface/View/Cell/HomeCollectionTableViewCell.swift
  2. 43
      GMERemittance/Module/Home/User Interface/View/Home.storyboard
  3. 8
      GMERemittance/Module/Home/User Interface/View/HomeViewController.swift

18
GMERemittance/Module/Home/User Interface/View/Cell/HomeCollectionTableViewCell.swift

@ -8,11 +8,10 @@
import UIKit import UIKit
class HomeCollectionTableViewCell: UITableViewCell {
class HomeCollectionTableViewCell: UITableViewCell, UICollectionViewDelegateFlowLayout {
@IBOutlet weak var collectionView: UICollectionView! @IBOutlet weak var collectionView: UICollectionView!
private var menus: [HomeCollectionModel]? private var menus: [HomeCollectionModel]?
override func awakeFromNib() { override func awakeFromNib() {
super.awakeFromNib() super.awakeFromNib()
// Initialization code // Initialization code
@ -58,6 +57,17 @@ class HomeCollectionTableViewCell: UITableViewCell {
self.menus = [sendMoneyMenu, mobileRechargeMenu, toadaysRateMenu, trackTransferMenu, transactionStatementMenu, walletToWalletMenu] self.menus = [sendMoneyMenu, mobileRechargeMenu, toadaysRateMenu, trackTransferMenu, transactionStatementMenu, walletToWalletMenu]
} }
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
let itemsPerRow: CGFloat = 2
let paddingSpace: CGFloat = CGFloat(20 * (itemsPerRow + 1))
let availableWidth = frame.width - paddingSpace
let widthPerItem = availableWidth / itemsPerRow
return CGSize(width: widthPerItem, height: widthPerItem)
}
} }
@ -70,6 +80,8 @@ extension HomeCollectionTableViewCell: UICollectionViewDataSource {
return menus?.count ?? 0 return menus?.count ?? 0
} }
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = self.collectionView.dequeueReusableCell(withReuseIdentifier: "HomeCollectionCollectionViewCell", for: indexPath) as! HomeCollectionCollectionViewCell let cell = self.collectionView.dequeueReusableCell(withReuseIdentifier: "HomeCollectionCollectionViewCell", for: indexPath) as! HomeCollectionCollectionViewCell
cell.model = self.menus?.elementAt(index: indexPath.row) cell.model = self.menus?.elementAt(index: indexPath.row)
@ -77,3 +89,5 @@ extension HomeCollectionTableViewCell: UICollectionViewDataSource {
return cell return cell
} }
} }

43
GMERemittance/Module/Home/User Interface/View/Home.storyboard

@ -152,43 +152,40 @@
<outlet property="userNameLabel" destination="HSv-Iz-JvY" id="aE5-dT-TQa"/> <outlet property="userNameLabel" destination="HSv-Iz-JvY" id="aE5-dT-TQa"/>
</connections> </connections>
</tableViewCell> </tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="HomeCollectionTableViewCell" rowHeight="155" id="va0-Yj-PKZ" userLabel="CollectionTableCell" customClass="HomeCollectionTableViewCell" customModule="GMERemittance" customModuleProvider="target">
<rect key="frame" x="0.0" y="143" width="375" height="155"/>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="HomeCollectionTableViewCell" rowHeight="250" id="va0-Yj-PKZ" userLabel="CollectionTableCell" customClass="HomeCollectionTableViewCell" customModule="GMERemittance" customModuleProvider="target">
<rect key="frame" x="0.0" y="143" width="375" height="250"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="va0-Yj-PKZ" id="UgU-Jo-DQf"> <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="va0-Yj-PKZ" id="UgU-Jo-DQf">
<rect key="frame" x="0.0" y="0.0" width="375" height="155"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="250"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<subviews> <subviews>
<collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" bounces="NO" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" bouncesZoom="NO" dataMode="prototypes" translatesAutoresizingMaskIntoConstraints="NO" id="cS9-wt-rNH">
<rect key="frame" x="10" y="7" width="355" height="140"/>
<collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" bounces="NO" scrollEnabled="NO" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" bouncesZoom="NO" dataMode="prototypes" translatesAutoresizingMaskIntoConstraints="NO" id="cS9-wt-rNH">
<rect key="frame" x="10" y="20" width="355" height="222"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<collectionViewFlowLayout key="collectionViewLayout" minimumLineSpacing="5" minimumInteritemSpacing="5" id="V5P-ja-etg">
<size key="itemSize" width="170" height="138"/>
<collectionViewFlowLayout key="collectionViewLayout" minimumLineSpacing="10" minimumInteritemSpacing="0.0" id="V5P-ja-etg">
<size key="itemSize" width="170" height="173"/>
<size key="headerReferenceSize" width="0.0" height="0.0"/> <size key="headerReferenceSize" width="0.0" height="0.0"/>
<size key="footerReferenceSize" width="0.0" height="0.0"/> <size key="footerReferenceSize" width="0.0" height="0.0"/>
<inset key="sectionInset" minX="0.0" minY="20" maxX="0.0" maxY="0.0"/>
<inset key="sectionInset" minX="10" minY="10" maxX="10" maxY="10"/>
</collectionViewFlowLayout> </collectionViewFlowLayout>
<cells> <cells>
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="HomeCollectionCollectionViewCell" id="Etq-JH-rVI" customClass="HomeCollectionCollectionViewCell" customModule="GMERemittance" customModuleProvider="target"> <collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="HomeCollectionCollectionViewCell" id="Etq-JH-rVI" customClass="HomeCollectionCollectionViewCell" customModule="GMERemittance" customModuleProvider="target">
<rect key="frame" x="0.0" y="20" width="170" height="138"/>
<rect key="frame" x="92.5" y="10" width="170" height="173"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO"> <view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO">
<rect key="frame" x="0.0" y="0.0" width="170" height="138"/>
<rect key="frame" x="0.0" y="0.0" width="170" height="173"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<subviews> <subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="2AS-0D-YqT"> <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="2AS-0D-YqT">
<rect key="frame" x="55" y="17" width="60" height="60"/>
<rect key="frame" x="50" y="25" width="70" height="70"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/> <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints> <constraints>
<constraint firstAttribute="height" constant="60" id="2Sm-Hr-E1M"/>
<constraint firstAttribute="width" constant="60" id="Ddx-6M-Xsk"/>
<constraint firstAttribute="width" secondItem="2AS-0D-YqT" secondAttribute="height" multiplier="1:1" id="5g2-sa-yq3"/>
<constraint firstAttribute="width" constant="70" id="Ddx-6M-Xsk"/>
</constraints> </constraints>
</imageView> </imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Send Money" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" minimumScaleFactor="0.89999997615814209" translatesAutoresizingMaskIntoConstraints="NO" id="1gB-BN-h1P">
<rect key="frame" x="24" y="87" width="122" height="16"/>
<constraints>
<constraint firstAttribute="height" constant="16" id="tlB-tw-oKs"/>
</constraints>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Send Money" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="1gB-BN-h1P">
<rect key="frame" x="24" y="115" width="122" height="17"/>
<fontDescription key="fontDescription" name="SanFranciscoText-Regular" family="San Francisco Text" pointSize="14"/> <fontDescription key="fontDescription" name="SanFranciscoText-Regular" family="San Francisco Text" pointSize="14"/>
<color key="textColor" white="0.33333333329999998" alpha="1" colorSpace="calibratedWhite"/> <color key="textColor" white="0.33333333329999998" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
@ -209,11 +206,11 @@
<constraint firstAttribute="trailing" secondItem="Tto-II-gHc" secondAttribute="trailing" constant="6" id="aDQ-XP-G1H"/> <constraint firstAttribute="trailing" secondItem="Tto-II-gHc" secondAttribute="trailing" constant="6" id="aDQ-XP-G1H"/>
<constraint firstItem="2AS-0D-YqT" firstAttribute="centerX" secondItem="Etq-JH-rVI" secondAttribute="centerX" id="dcN-Y7-VS9"/> <constraint firstItem="2AS-0D-YqT" firstAttribute="centerX" secondItem="Etq-JH-rVI" secondAttribute="centerX" id="dcN-Y7-VS9"/>
<constraint firstItem="2AS-0D-YqT" firstAttribute="centerX" secondItem="Etq-JH-rVI" secondAttribute="centerX" id="kfE-5m-uwt"/> <constraint firstItem="2AS-0D-YqT" firstAttribute="centerX" secondItem="Etq-JH-rVI" secondAttribute="centerX" id="kfE-5m-uwt"/>
<constraint firstItem="2AS-0D-YqT" firstAttribute="top" secondItem="Etq-JH-rVI" secondAttribute="top" constant="17" id="qln-BV-Ym4"/>
<constraint firstItem="1gB-BN-h1P" firstAttribute="top" secondItem="2AS-0D-YqT" secondAttribute="bottom" constant="10" id="qte-7b-e6R"/>
<constraint firstItem="2AS-0D-YqT" firstAttribute="top" secondItem="Etq-JH-rVI" secondAttribute="top" constant="25" id="qln-BV-Ym4"/>
<constraint firstItem="1gB-BN-h1P" firstAttribute="top" secondItem="2AS-0D-YqT" secondAttribute="bottom" constant="20" id="qte-7b-e6R"/>
<constraint firstItem="Tto-II-gHc" firstAttribute="top" secondItem="Etq-JH-rVI" secondAttribute="top" constant="6" id="tqF-Pu-NfF"/> <constraint firstItem="Tto-II-gHc" firstAttribute="top" secondItem="Etq-JH-rVI" secondAttribute="top" constant="6" id="tqF-Pu-NfF"/>
</constraints> </constraints>
<size key="customSize" width="170" height="138"/>
<size key="customSize" width="170" height="173"/>
<userDefinedRuntimeAttributes> <userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="number" keyPath="layer.cornerRadius"> <userDefinedRuntimeAttribute type="number" keyPath="layer.cornerRadius">
<integer key="value" value="10"/> <integer key="value" value="10"/>
@ -231,9 +228,9 @@
<color key="backgroundColor" red="0.83921568629999999" green="0.89019607840000003" blue="0.93333333330000001" alpha="1" colorSpace="calibratedRGB"/> <color key="backgroundColor" red="0.83921568629999999" green="0.89019607840000003" blue="0.93333333330000001" alpha="1" colorSpace="calibratedRGB"/>
<constraints> <constraints>
<constraint firstAttribute="trailing" secondItem="cS9-wt-rNH" secondAttribute="trailing" constant="10" id="5cc-1q-QaY"/> <constraint firstAttribute="trailing" secondItem="cS9-wt-rNH" secondAttribute="trailing" constant="10" id="5cc-1q-QaY"/>
<constraint firstAttribute="bottom" secondItem="cS9-wt-rNH" secondAttribute="bottom" constant="8" id="79s-sf-PQQ"/>
<constraint firstItem="cS9-wt-rNH" firstAttribute="leading" secondItem="UgU-Jo-DQf" secondAttribute="leading" constant="10" id="Dg1-zj-FBQ"/> <constraint firstItem="cS9-wt-rNH" firstAttribute="leading" secondItem="UgU-Jo-DQf" secondAttribute="leading" constant="10" id="Dg1-zj-FBQ"/>
<constraint firstAttribute="bottom" secondItem="cS9-wt-rNH" secondAttribute="bottom" constant="8" id="dH2-5y-7ow"/>
<constraint firstItem="cS9-wt-rNH" firstAttribute="top" secondItem="UgU-Jo-DQf" secondAttribute="top" constant="7" id="haf-zA-yZf"/>
<constraint firstItem="cS9-wt-rNH" firstAttribute="top" secondItem="UgU-Jo-DQf" secondAttribute="top" constant="20" id="haf-zA-yZf"/>
</constraints> </constraints>
</tableViewCellContentView> </tableViewCellContentView>
<connections> <connections>

8
GMERemittance/Module/Home/User Interface/View/HomeViewController.swift

@ -8,7 +8,7 @@
import UIKit import UIKit
class HomeViewController: UIViewController {
class HomeViewController: UIViewController, UICollectionViewDelegateFlowLayout {
enum Sections: Int { enum Sections: Int {
@ -24,7 +24,7 @@ class HomeViewController: UIViewController {
var presenter: HomeModuleInterface? var presenter: HomeModuleInterface?
var sections: [Sections] = [.balance, .collection] var sections: [Sections] = [.balance, .collection]
// MARK: VC's Life cycle // MARK: VC's Life cycle
@ -99,9 +99,6 @@ extension HomeViewController: UITableViewDelegate {
let ramainingBalanceCellHeight: CGFloat = 110 let ramainingBalanceCellHeight: CGFloat = 110
let finalHeight = totalHeight - ramainingBalanceCellHeight let finalHeight = totalHeight - ramainingBalanceCellHeight
return finalHeight return finalHeight
// let width = ((view.frame.width - (insetForCollectionView * 3) ) - 10) / 2
// let heightForCollectionViewCell = width * (170 / 120)
// return heightForCollectionViewCell * 1.7
} }
} }
} }
@ -139,3 +136,4 @@ extension HomeViewController: UITableViewDataSource {
return cell return cell
} }
} }
Loading…
Cancel
Save