Manos Chorianopoulos

ProfileViewController part 1

......@@ -101,7 +101,7 @@ struct OfferModel {
discountType: "price",
bannerImage: "dominos_banner",
merchantLogo: "dominos_logo",
expirationDate: "έως 30/09",
expirationDate: "έως 30-09",
color: 0xEE417D,
isFavorite: true
),
......@@ -113,7 +113,7 @@ struct OfferModel {
discountType: "percentage",
bannerImage: "dominos_banner",
merchantLogo: "dominos_logo",
expirationDate: "έως 30/09",
expirationDate: "έως 30-09",
color: 0xEE417D,
isFavorite: false
),
......@@ -127,7 +127,7 @@ struct OfferModel {
// discountType: "percentage",
// bannerImage: "car_rental_banner",
// merchantLogo: "avis_logo",
// expirationDate: "έως 30/09",
// expirationDate: "έως 30-09",
// color: 0xEE417D,
// isFavorite: true
// ),
......@@ -139,7 +139,7 @@ struct OfferModel {
// discountType: "amount",
// bannerImage: "hotel_banner",
// merchantLogo: "booking_logo",
// expirationDate: "έως 30/09",
// expirationDate: "έως 30-09",
// color: 0xEE417D,
// isFavorite: true
// ),
......@@ -153,7 +153,7 @@ struct OfferModel {
discountType: "percentage",
bannerImage: "musa_banner",
merchantLogo: "musa_logo",
expirationDate: "έως 30/09",
expirationDate: "έως 30-09",
color: 0x09914E,
isFavorite: false
),
......@@ -165,7 +165,7 @@ struct OfferModel {
discountType: "percentage",
bannerImage: "musa_banner",
merchantLogo: "musa_logo",
expirationDate: "έως 30/09",
expirationDate: "έως 30-09",
color: 0x09914E,
isFavorite: true
),
......@@ -179,7 +179,7 @@ struct OfferModel {
discountType: "percentage",
bannerImage: "ranch_banner",
merchantLogo: "ranch_logo",
expirationDate: "έως 30/09",
expirationDate: "έως 30-09",
color: 0xFC9F25,
isFavorite: false
),
......@@ -191,7 +191,7 @@ struct OfferModel {
discountType: "buyOneGetOne",
bannerImage: "ranch_banner",
merchantLogo: "ranch_logo",
expirationDate: "έως 30/09",
expirationDate: "έως 30-09",
color: 0xFC9F25,
isFavorite: false
),
......@@ -205,7 +205,7 @@ struct OfferModel {
discountType: "amount",
bannerImage: "coffeeisland_banner",
merchantLogo: "coffeeisland_logo",
expirationDate: "έως 30/09",
expirationDate: "έως 30-09",
color: 0xEE417D,
isFavorite: false
),
......@@ -217,7 +217,7 @@ struct OfferModel {
discountType: "percentage",
bannerImage: "coffeeisland_banner",
merchantLogo: "coffeeisland_logo",
expirationDate: "έως 30/09",
expirationDate: "έως 30-09",
color: 0xEE417D,
isFavorite: false
),
......@@ -231,7 +231,7 @@ struct OfferModel {
discountType: "percentage",
bannerImage: "ninemia_banner",
merchantLogo: "ninemia_logo",
expirationDate: "έως 30/09",
expirationDate: "έως 30-09",
color: 0xEE417D,
isFavorite: true
),
......@@ -243,7 +243,7 @@ struct OfferModel {
discountType: "percentage",
bannerImage: "ninemia_banner",
merchantLogo: "ninemia_logo",
expirationDate: "έως 30/09",
expirationDate: "έως 30-09",
color: 0xEE417D,
isFavorite: false
),
......@@ -257,7 +257,7 @@ struct OfferModel {
discountType: "percentage",
bannerImage: "moustakas_banner",
merchantLogo: "moustakas_logo",
expirationDate: "έως 30/09",
expirationDate: "έως 30-09",
color: 0xEE417D,
isFavorite: false
),
......@@ -269,7 +269,7 @@ struct OfferModel {
discountType: "buyOneGetOne",
bannerImage: "moustakas_banner",
merchantLogo: "moustakas_logo",
expirationDate: "έως 30/09",
expirationDate: "έως 30-09",
color: 0xEE417D,
isFavorite: false
),
......@@ -283,7 +283,7 @@ struct OfferModel {
discountType: "amount",
bannerImage: "migato_banner",
merchantLogo: "migato_logo",
expirationDate: "έως 30/09",
expirationDate: "έως 30-09",
color: 0xEE417D,
isFavorite: false
),
......@@ -295,7 +295,7 @@ struct OfferModel {
discountType: "percentage",
bannerImage: "migato_banner",
merchantLogo: "migato_logo",
expirationDate: "έως 30/09",
expirationDate: "έως 30-09",
color: 0xEE417D,
isFavorite: false
)
......
......@@ -8,22 +8,325 @@
import UIKit
@objc public class ProfileViewController: UIViewController {
@IBOutlet weak var tableView: UITableView!
// MARK: - Dummy Data
let allOffers: [OfferModel] = [
// Προτάσεις για εσένα
OfferModel(
category: "Προτάσεις για εσένα",
title: "15% έκπτωση",
description: "σε όλα τα προϊόντα",
discount: "15%",
discountType: "percentage",
bannerImage: "musa_banner",
merchantLogo: "musa_logo",
expirationDate: "έως 30-09",
color: 0x09914E,
isFavorite: true,
active: false,
redeemed: false
),
OfferModel(
category: "Προτάσεις για εσένα",
title: "10% έκπτωση",
description: "στην κατασκήνωση στο The Ranch",
discount: "10%",
discountType: "percentage",
bannerImage: "ranch_banner",
merchantLogo: "ranch_logo",
expirationDate: "έως 30-09",
color: 0xFC9F25,
isFavorite: false,
active: false,
redeemed: false
),
OfferModel(
category: "Προτάσεις για εσένα",
title: "1+1 εισιτήριο",
description: "δώρο στην είσοδο του παιδότοπου",
discount: "1+1",
discountType: "buyOneGetOne",
bannerImage: "ranch_banner",
merchantLogo: "ranch_logo",
expirationDate: "έως 30-09",
color: 0xFC9F25,
isFavorite: true,
active: false,
redeemed: false
),
OfferModel(
category: "Προτάσεις για εσένα",
title: "10% έκπτωση",
description: "σε όλες τις υπηρεσίες",
discount: "10%",
discountType: "percentage",
bannerImage: "ninemia_banner",
merchantLogo: "ninemia_logo",
expirationDate: "έως 30-09",
color: 0xEE417D,
isFavorite: false,
active: false,
redeemed: false
),
OfferModel(
category: "Προτάσεις για εσένα",
title: "10% έκπτωση",
description: "για αγορές από τα φυσικά καταστήματα",
discount: "10%",
discountType: "percentage",
bannerImage: "moustakas_banner",
merchantLogo: "moustakas_logo",
expirationDate: "έως 30-09",
color: 0xEE417D,
isFavorite: true,
active: false,
redeemed: false
),
// Active
OfferModel(
category: "Top offers",
title: "Μόνο 17,95",
description: "2 πίτσες & Coca-Cola 1,5lt",
discount: "17,95€",
discountType: "price",
bannerImage: "dominos_banner",
merchantLogo: "dominos_logo",
expirationDate: "έως 30-09",
color: 0xEE417D,
isFavorite: true,
active: true,
redeemed: false
),
OfferModel(
category: "Φαγητό και καφές",
title: "2€ έκπτωση",
description: "στην αγορά σου",
discount: "2€",
discountType: "amount",
bannerImage: "coffeeisland_banner",
merchantLogo: "coffeeisland_logo",
expirationDate: "έως 30-09",
color: 0xEE417D,
isFavorite: false,
active: true,
redeemed: false
),
OfferModel(
category: "Top offers",
title: "10% έκπτωση",
description: "σε γλυκούς πειρασμούς",
discount: "10%",
discountType: "percentage",
bannerImage: "zuccherino_banner",
merchantLogo: "zuccherino_logo",
expirationDate: "έως 30-09",
color: 0xEE417D,
isFavorite: false,
active: true,
redeemed: false
),
// Απόδραση
OfferModel(
category: "Απόδραση",
title: "10% έκπτωση",
description: "στην διαμονή/διασκέδαση σου",
discount: "10%",
discountType: "percentage",
bannerImage: "ninemia_banner",
merchantLogo: "ninemia_logo",
expirationDate: "έως 30-09",
color: 0xEE417D,
isFavorite: true,
active: false,
redeemed: true
),
OfferModel(
category: "Παιδί",
title: "1+1 Δώρο",
description: "στην είσοδο του παιδότοπου",
discount: "1+1",
discountType: "buyOneGetOne",
bannerImage: "moustakas_banner",
merchantLogo: "moustakas_logo",
expirationDate: "έως 30-09",
color: 0xEE417D,
isFavorite: false,
active: false,
redeemed: true
),
// Αγορές
OfferModel(
category: "Αγορές",
title: "15€ έκπτωση",
description: "για αγορές",
discount: "15€",
discountType: "amount",
bannerImage: "migato_banner",
merchantLogo: "migato_logo",
expirationDate: "έως 30-09",
color: 0xEE417D,
isFavorite: false,
active: false,
redeemed: true
)
]
var forYouOffersSection: SectionModel?
var activeOffersSection: SectionModel?
var favoriteOffersSection: SectionModel?
var redeemedOffersSection: SectionModel?
var filteredOffersSection: SectionModel?
public override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
// Show navigation bar for this screen (with back button)
self.navigationController?.setNavigationBarHidden(false, animated: false)
setBackButton()
setNavigationTitle("Το προφίλ μου")
// Register XIBs for table view cells
// tableView.register(UINib(nibName: "MyRewardsBannerOffersScrollTableViewCell", bundle: Bundle(for: MyEmptyClass.self)), forCellReuseIdentifier: "MyRewardsBannerOffersScrollTableViewCell")
// tableView.register(UINib(nibName: "MyRewardsOffersScrollTableViewCell", bundle: Bundle(for: MyEmptyClass.self)), forCellReuseIdentifier: "MyRewardsOffersScrollTableViewCell")
// Set up table view
tableView.delegate = self
tableView.dataSource = self
tableView.separatorStyle = .none
tableView.estimatedRowHeight = 200
tableView.rowHeight = UITableView.automaticDimension
initializeSections()
}
// MARK: Function
func initializeSections() {
// Προτάσεις για εσένα
let forYouOffers = allOffers.filter { $0.category == "Προτάσεις για εσένα" }
forYouOffersSection = SectionModel(
title: "Προτάσεις για εσένα",
count: forYouOffers.count,
offers: forYouOffers
)
// Favorite Offers
let activeOffers = allOffers.filter { $0.active }
activeOffersSection = SectionModel(
title: "Ενεργά",
count: activeOffers.count,
offers: activeOffers
)
// Favorite Offers
let favoriteOffers = allOffers.filter { $0.isFavorite }
favoriteOffersSection = SectionModel(
title: "Αγαπημένα",
count: favoriteOffers.count,
offers: favoriteOffers
)
// Favorite Offers
let redeemedOffers = allOffers.filter { $0.redeemed }
redeemedOffersSection = SectionModel(
title: "Αγαπημένα",
count: redeemedOffers.count,
offers: redeemedOffers
)
self.tableView.reloadData()
}
}
// MARK: - TableView
extension MyRewardsViewController: UITableViewDelegate, UITableViewDataSource{
public func numberOfSections(in tableView: UITableView) -> Int {
return 4 + filteredOffersSection.offers.count
}
public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1
}
public func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableView.automaticDimension
}
public func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
return nil
}
/*
// MARK: - Navigation
public func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return 0.0
}
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destination.
// Pass the selected object to the new view controller.
public func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
// return CGFloat.leastNormalMagnitude
return 0.0
}
*/
public func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
return nil
}
public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if (indexPath.section == 0) {
let cell = tableView.dequeueReusableCell(withIdentifier: "MyRewardsBannerOffersScrollTableViewCell", for: indexPath) as! MyRewardsBannerOffersScrollTableViewCell
cell.delegate = self // Set the banner offers delegate
cell.configureCell(data: self.bannerOffersSection)
// cell.parent = self
return cell
} else {
let cell = tableView.dequeueReusableCell(withIdentifier: "MyRewardsOffersScrollTableViewCell", for: indexPath) as! MyRewardsOffersScrollTableViewCell
cell.delegate = self // Set the offers delegate
if (indexPath.section == 1) {
cell.configureCell(data: self.topOffersSection)
} else if (indexPath.section == 2) {
cell.configureCell(data: self.favoriteOffersSection)
} else if (indexPath.section == 3) {
cell.configureCell(data: self.sustainableOffersSection)
} else if (indexPath.section == 4) {
cell.configureCell(data: self.familyOffersSection)
} else if (indexPath.section == 5) {
cell.configureCell(data: self.foodOffersSection)
} else if (indexPath.section == 6) {
cell.configureCell(data: self.escapeOffersSection)
} else if (indexPath.section == 7) {
cell.configureCell(data: self.childOffersSection)
} else {
cell.configureCell(data: self.shoppingOffersSection)
}
return cell
}
}
public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if (indexPath.section == 0) {
// Do nothing - Each button is handled differently
} else if (indexPath.section == 1) {
// Do nothing
} else if (indexPath.section == 2) {
// Do nothing
} else if (indexPath.section == 3) {
// Do nothing
} else if (indexPath.section == 4) {
// Do nothing
} else if (indexPath.section == 5) {
// Do nothing
} else if (indexPath.section == 6) {
// Do nothing
} else if (indexPath.section == 7) {
// Do nothing
} else {
// Do nothing
}
}
}
......
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="13142" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="23094" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_12" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12042"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="23084"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="ProfileViewController" customModuleProvider="target">
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="ProfileViewController" customModule="SwiftWarplyFramework" customModuleProvider="target">
<connections>
<outlet property="tableView" destination="Lyp-gB-nMU" id="qcx-6z-teY"/>
<outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="i5M-Pr-FkT">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<rect key="frame" x="0.0" y="0.0" width="393" height="852"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="35E-2c-fwB" userLabel="Main View">
<rect key="frame" x="0.0" y="59" width="393" height="793"/>
<subviews>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="none" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" estimatedSectionHeaderHeight="-1" sectionFooterHeight="28" estimatedSectionFooterHeight="-1" contentViewInsetsToSafeArea="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Lyp-gB-nMU">
<rect key="frame" x="0.0" y="0.0" width="393" height="793"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<color key="separatorColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<color key="sectionIndexBackgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<connections>
<outlet property="dataSource" destination="-1" id="YLY-kN-FuL"/>
<outlet property="delegate" destination="-1" id="8wu-Tv-kNd"/>
</connections>
</tableView>
</subviews>
<color key="backgroundColor" red="0.94901960780000005" green="0.94901960780000005" blue="0.94901960780000005" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstItem="Lyp-gB-nMU" firstAttribute="top" secondItem="35E-2c-fwB" secondAttribute="top" id="ZSr-fH-jKR"/>
<constraint firstAttribute="bottom" secondItem="Lyp-gB-nMU" secondAttribute="bottom" id="kxk-Ld-8kk"/>
<constraint firstItem="Lyp-gB-nMU" firstAttribute="leading" secondItem="35E-2c-fwB" secondAttribute="leading" id="nId-cX-Bq6"/>
<constraint firstAttribute="trailing" secondItem="Lyp-gB-nMU" secondAttribute="trailing" id="wzt-qW-Jpz"/>
</constraints>
</view>
</subviews>
<viewLayoutGuide key="safeArea" id="fnl-2z-Ty3"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="35E-2c-fwB" secondAttribute="trailing" id="6p0-6e-iUG"/>
<constraint firstItem="35E-2c-fwB" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" id="GVO-tH-EEu"/>
<constraint firstAttribute="bottom" secondItem="35E-2c-fwB" secondAttribute="bottom" id="Hmw-0d-E4K"/>
<constraint firstItem="35E-2c-fwB" firstAttribute="top" secondItem="fnl-2z-Ty3" secondAttribute="top" id="ajn-1A-hAX"/>
</constraints>
<point key="canvasLocation" x="11" y="-11"/>
</view>
</objects>
<resources>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
</resources>
</document>
......