Manos Chorianopoulos

LoyaltyViewController part3

......@@ -13,6 +13,7 @@ import UIKit
@IBOutlet weak var logoImage: UIImageView!
@IBOutlet weak var filtersView: UIView!
@IBOutlet weak var collectionView: UICollectionView!
@IBOutlet weak var containerView: UIView!
var selectedScreen: String = "Offers"
var filtersList: Array<String> = ["Screen", "Όλα", "Σπίτι", "Έξοδος", "Υγεία"]
......@@ -35,6 +36,33 @@ import UIKit
collectionView.contentInset.left = 20
collectionView.contentInset.right = 20
loadVC(vcName: "OffersViewController");
}
func loadVC(vcName: String) {
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
var vc: UIViewController;
if (vcName == "OffersViewController") {
vc = storyboard.instantiateViewController(withIdentifier: "OffersViewController") as! SwiftWarplyFramework.OffersViewController
} else {
vc = storyboard.instantiateViewController(withIdentifier: "MapViewController") as! SwiftWarplyFramework.MapViewController
}
addChild(vc)
vc.view.translatesAutoresizingMaskIntoConstraints = false
containerView.addSubview(vc.view)
NSLayoutConstraint.activate([
vc.view.leadingAnchor.constraint(equalTo: containerView.leadingAnchor, constant: 0),
vc.view.trailingAnchor.constraint(equalTo: containerView.trailingAnchor, constant: 0),
vc.view.topAnchor.constraint(equalTo: containerView.topAnchor, constant: 0),
vc.view.bottomAnchor.constraint(equalTo: containerView.bottomAnchor, constant: 0)
])
vc.didMove(toParent: self)
}
}
......@@ -66,6 +94,7 @@ extension LoyaltyViewController: UICollectionViewDataSource,UICollectionViewDele
if (indexPath.row == 0) {
let offersSelected = selectedScreen == "Offers";
selectedScreen = offersSelected ? "Map" : "Offers"
loadVC(vcName: selectedScreen == "Offers" ? "OffersViewController" : "MapViewController");
} else {
let currentFilter = filtersList[indexPath.row];
......
......@@ -4169,15 +4169,26 @@
<constraint firstItem="3Ff-i2-KRi" firstAttribute="top" secondItem="ZDd-1H-T7x" secondAttribute="top" constant="15" id="ZOb-HP-thS"/>
</constraints>
</view>
<containerView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="JYn-ad-sj7">
<rect key="frame" x="0.0" y="265" width="414" height="631"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<connections>
<segue destination="B4y-Pl-zNk" kind="embed" id="OPh-Qb-zce"/>
</connections>
</containerView>
</subviews>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstItem="JYn-ad-sj7" firstAttribute="top" secondItem="ZDd-1H-T7x" secondAttribute="bottom" id="Kua-T7-oY0"/>
<constraint firstItem="ZDd-1H-T7x" firstAttribute="leading" secondItem="XsW-fz-6VQ" secondAttribute="leading" id="LSl-4t-R39"/>
<constraint firstItem="Iq3-R0-fBz" firstAttribute="leading" secondItem="XsW-fz-6VQ" secondAttribute="leading" id="PAL-j8-olw"/>
<constraint firstAttribute="trailing" secondItem="Iq3-R0-fBz" secondAttribute="trailing" id="PLY-Y8-vLt"/>
<constraint firstAttribute="trailing" secondItem="JYn-ad-sj7" secondAttribute="trailing" id="WHV-5Y-kAr"/>
<constraint firstAttribute="trailing" secondItem="ZDd-1H-T7x" secondAttribute="trailing" id="eYH-Gm-SBy"/>
<constraint firstItem="JYn-ad-sj7" firstAttribute="leading" secondItem="XsW-fz-6VQ" secondAttribute="leading" id="n8j-bS-Kg1"/>
<constraint firstItem="ZDd-1H-T7x" firstAttribute="top" secondItem="Iq3-R0-fBz" secondAttribute="bottom" id="rhx-zr-AVs"/>
<constraint firstItem="Iq3-R0-fBz" firstAttribute="top" secondItem="XsW-fz-6VQ" secondAttribute="top" id="rqp-ps-RYb"/>
<constraint firstAttribute="bottom" secondItem="JYn-ad-sj7" secondAttribute="bottom" id="woo-KR-rGp"/>
</constraints>
</view>
</subviews>
......@@ -4193,6 +4204,7 @@
<connections>
<outlet property="closeImage" destination="b5d-hX-vcb" id="esI-7p-Ycc"/>
<outlet property="collectionView" destination="3Ff-i2-KRi" id="7GZ-4D-yqt"/>
<outlet property="containerView" destination="JYn-ad-sj7" id="hpH-B5-4uH"/>
<outlet property="filtersView" destination="ZDd-1H-T7x" id="HUd-Ox-bcV"/>
<outlet property="headerView" destination="Iq3-R0-fBz" id="E4T-bn-yYD"/>
<outlet property="logoImage" destination="GZK-rw-pZV" id="qwb-ae-QFc"/>
......