Manos Chorianopoulos

add ProfileVC

Showing 38 changed files with 629 additions and 66 deletions
......@@ -7,7 +7,7 @@
<key>Pods-SwiftWarplyFramework.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
<integer>1</integer>
</dict>
</dict>
</dict>
......
......@@ -7,7 +7,7 @@
<key>SwiftWarplyFramework.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
<integer>0</integer>
</dict>
</dict>
</dict>
......
{
"images" : [
{
"filename" : "contest_banner_5.png",
"filename" : "questionnaire_banner.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "contest_banner_5 1.png",
"filename" : "questionnaire_banner 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "contest_banner_5 2.png",
"filename" : "questionnaire_banner 2.png",
"idiom" : "universal",
"scale" : "3x"
}
......
......@@ -8,7 +8,8 @@
import UIKit
protocol MyRewardsBannerOffersScrollTableViewCellDelegate: AnyObject {
func didSelectBannerOffer(_ offer: OfferModel)
func didSelectBannerOffer(_ index: Int)
func didTapProfileButton()
}
@objc public class MyRewardsBannerOffersScrollTableViewCell: UITableViewCell {
......@@ -17,6 +18,7 @@ protocol MyRewardsBannerOffersScrollTableViewCellDelegate: AnyObject {
@IBOutlet weak var tagView2: UIView!
@IBOutlet weak var tagLabel2: UILabel!
@IBOutlet weak var profileImage: UIImageView!
@IBOutlet weak var profileButton: UIButton!
@IBOutlet weak var collectionView: UICollectionView!
@IBOutlet weak var pageControl: UIPageControl!
......@@ -29,6 +31,8 @@ protocol MyRewardsBannerOffersScrollTableViewCellDelegate: AnyObject {
profileImage.image = UIImage(named: "profile_pic_default", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
profileButton.addTarget(self, action: #selector(profileButtonTapped), for: .touchUpInside)
tagView1.backgroundColor = UIColor(rgb: 0x09914E)
tagView1.layer.cornerRadius = 4.0
tagLabel1.font = UIFont(name: "PingLCG-Regular", size: 17)
......@@ -95,6 +99,10 @@ protocol MyRewardsBannerOffersScrollTableViewCellDelegate: AnyObject {
self.collectionView.reloadData();
}
@objc private func profileButtonTapped() {
delegate?.didTapProfileButton()
}
}
extension MyRewardsBannerOffersScrollTableViewCell: UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout, UIScrollViewDelegate {
......@@ -121,7 +129,7 @@ extension MyRewardsBannerOffersScrollTableViewCell: UICollectionViewDataSource,
// Get the selected offer
if let offer = self.data?.offers[indexPath.row] {
// Call the delegate method to notify the parent
delegate?.didSelectBannerOffer(offer)
delegate?.didSelectBannerOffer(indexPath.row)
}
}
......
//
// ProfileCouponFiltersTableViewCell.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 29/5/25.
//
import UIKit
protocol ProfileCouponFiltersTableViewCellDelegate: AnyObject {
func didSelectFilter(_ filter: CouponFilterModel)
}
@objc public class ProfileCouponFiltersTableViewCell: UITableViewCell {
@IBOutlet weak var titleLabel: UILabel!
@IBOutlet weak var collectionView: UICollectionView!
weak var delegate: ProfileCouponFiltersTableViewCellDelegate?
var data: [CouponFilterModel]?
public override func awakeFromNib() {
super.awakeFromNib()
titleLabel.font = UIFont(name: "PingLCG-Bold", size: 18)
titleLabel.textColor = UIColor(rgb: 0x000F1E)
// Register XIBs for collection view cells
collectionView.register(UINib(nibName: "ProfileFilterCollectionViewCell", bundle: Bundle(for: MyEmptyClass.self)), forCellWithReuseIdentifier: "ProfileFilterCollectionViewCell")
// Fix background colors
// collectionView.backgroundColor = UIColor.clear
// self.backgroundColor = UIColor.clear
// self.contentView.backgroundColor = UIColor.clear
// Remove content insets and gaps
collectionView.contentInset = UIEdgeInsets.zero
collectionView.scrollIndicatorInsets = UIEdgeInsets.zero
if #available(iOS 11.0, *) {
collectionView.contentInsetAdjustmentBehavior = .never
}
// Configure collection view layout
if let layout = collectionView.collectionViewLayout as? UICollectionViewFlowLayout {
layout.scrollDirection = .horizontal
layout.minimumLineSpacing = 15
layout.minimumInteritemSpacing = 0
layout.sectionInset = UIEdgeInsets(top: 0, left: 24, bottom: 0, right: 24)
}
// Enable paging for smooth banner scrolling
// collectionView.isPagingEnabled = true
collectionView.showsHorizontalScrollIndicator = false
// Set delegates
collectionView.delegate = self
collectionView.dataSource = self
}
public override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
func configureCell(data: [CouponFilterModel]?) {
self.data = data
self.collectionView.reloadData();
}
}
extension ProfileCouponFiltersTableViewCell: UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout {
public func numberOfSections(in collectionView: UICollectionView) -> Int {
return 1
}
public func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return self.data?.count ?? 0
}
public func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "ProfileFilterCollectionViewCell", for: indexPath) as! ProfileFilterCollectionViewCell
if let filter = self.data?[indexPath.row] {
// TODO: Fix dynamic
let isSelected = self.data?[indexPath.row].title == "Ενεργά"
cell.configureCell(data: filter, isSelected: isSelected)
}
return cell;
}
public func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
if let filter = self.data?[indexPath.row] {
delegate?.didSelectFilter(filter)
}
}
// MARK: - UICollectionViewDelegateFlowLayout
// public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
// if self.data?.title == "Αγαπημένα" {
// return CGSize(width: 275, height: 350)
// } else {
// return CGSize(width: 257, height: 232)
// }
// }
// Distance Between Item Cells
public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat {
return 15
}
public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat {
return 0
}
// Cell Margin
public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets {
return UIEdgeInsets(top: 0, left: 24, bottom: 0, right: 24)
}
}
<?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="23084"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" reuseIdentifier="ProfileCouponFiltersTableViewCell" rowHeight="161" id="KGk-i7-Jjw" customClass="ProfileCouponFiltersTableViewCell" customModule="SwiftWarplyFramework" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="320" height="161"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
<rect key="frame" x="0.0" y="0.0" width="320" height="161"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="1kR-zd-duR" userLabel="ParentView">
<rect key="frame" x="0.0" y="0.0" width="320" height="161"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="mga-ND-qoh">
<rect key="frame" x="24" y="26" width="272" height="49"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" dataMode="none" translatesAutoresizingMaskIntoConstraints="NO" id="Ddn-dN-xH1">
<rect key="frame" x="0.0" y="118" width="320" height="43"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="height" constant="43" id="5nG-1p-kic"/>
</constraints>
<collectionViewFlowLayout key="collectionViewLayout" scrollDirection="horizontal" automaticEstimatedItemSize="YES" minimumLineSpacing="5" minimumInteritemSpacing="5" id="tAC-pV-kZ6">
<size key="itemSize" width="128" height="120"/>
<size key="headerReferenceSize" width="0.0" height="0.0"/>
<size key="footerReferenceSize" width="0.0" height="0.0"/>
<inset key="sectionInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/>
</collectionViewFlowLayout>
<cells/>
<connections>
<outlet property="dataSource" destination="KGk-i7-Jjw" id="J6c-fu-dH8"/>
<outlet property="delegate" destination="KGk-i7-Jjw" id="D3M-nO-3sC"/>
</connections>
</collectionView>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="Ddn-dN-xH1" firstAttribute="top" secondItem="mga-ND-qoh" secondAttribute="bottom" constant="43" id="1gh-45-u6h"/>
<constraint firstItem="Ddn-dN-xH1" firstAttribute="leading" secondItem="1kR-zd-duR" secondAttribute="leading" id="3IU-v8-7cI"/>
<constraint firstItem="mga-ND-qoh" firstAttribute="top" secondItem="1kR-zd-duR" secondAttribute="top" constant="26" id="J0I-v0-uwq"/>
<constraint firstAttribute="trailing" secondItem="mga-ND-qoh" secondAttribute="trailing" constant="24" id="Ss1-zq-znd"/>
<constraint firstAttribute="bottom" secondItem="Ddn-dN-xH1" secondAttribute="bottom" id="VdN-By-srg"/>
<constraint firstAttribute="trailing" secondItem="Ddn-dN-xH1" secondAttribute="trailing" id="W06-Yi-lzm"/>
<constraint firstItem="mga-ND-qoh" firstAttribute="leading" secondItem="1kR-zd-duR" secondAttribute="leading" constant="24" id="sEy-GV-Pjr"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="1kR-zd-duR" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" id="BHT-r3-dcg"/>
<constraint firstAttribute="trailing" secondItem="1kR-zd-duR" secondAttribute="trailing" id="eLa-yc-CeZ"/>
<constraint firstAttribute="bottom" secondItem="1kR-zd-duR" secondAttribute="bottom" id="rie-jS-xMj"/>
<constraint firstItem="1kR-zd-duR" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" id="vgK-SU-fRu"/>
</constraints>
</tableViewCellContentView>
<viewLayoutGuide key="safeArea" id="njF-e1-oar"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<connections>
<outlet property="collectionView" destination="Ddn-dN-xH1" id="RzU-o5-6Dw"/>
<outlet property="titleLabel" destination="mga-ND-qoh" id="TxL-cQ-O1P"/>
</connections>
<point key="canvasLocation" x="68.702290076335871" y="29.929577464788736"/>
</tableViewCell>
</objects>
</document>
//
// ProfileCouponTableViewCell.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 29/5/25.
//
import UIKit
@objc public class ProfileCouponTableViewCell: UITableViewCell {
@IBOutlet weak var parentView: UIView!
@IBOutlet weak var bannerImage: UIImageView!
@IBOutlet weak var favoriteImage: UIImageView!
@IBOutlet weak var discountView: UIView!
@IBOutlet weak var discountLabel: UILabel!
@IBOutlet weak var titleLabel: UILabel!
@IBOutlet weak var subtitleLabel: UILabel!
@IBOutlet weak var expirationLabel: UILabel!
@IBOutlet weak var logoImage: UIImageView!
public override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
parentView.layer.borderWidth = 1.0
parentView.layer.borderColor = UIColor(rgb: 0xCCCCCC).cgColor
parentView.layer.cornerRadius = 8.0
parentView.clipsToBounds = true
discountView.layer.cornerRadius = 34.0
}
func configureCell(data: OfferModel) {
bannerImage.image = UIImage(named: data.bannerImage, in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
favoriteImage.image = UIImage(named: data.isFavorite ? "favorite_filled" : "favorite_empty", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
let discountSymbol =
data.discountType == "percentage" ? "%"
: data.discountType == "price" ? "€"
: data.discountType == "buyOneGetOne" ? "1+1"
: data.discountType == "free" ? "Δωρεάν"
: ""
// discountLabel.text = "\(data.discount)\(discountSymbol)"
discountLabel.text = data.discount
discountLabel.font = UIFont(name: "PingLCG-Bold", size: 25)
discountLabel.textColor = UIColor(rgb: 0xF2F2F2)
discountView.backgroundColor = UIColor(rgb: data.color)
titleLabel.text = data.title
titleLabel.font = UIFont(name: "PingLCG-Bold", size: 22)
titleLabel.textColor = UIColor(rgb: 0x000F1E)
subtitleLabel.text = data.description
subtitleLabel.font = UIFont(name: "PingLCG-Regular", size: 16)
subtitleLabel.textColor = UIColor(rgb: 0x00111B)
expirationLabel.text = data.expirationDate
expirationLabel.font = UIFont(name: "PingLCG-Regular", size: 13)
expirationLabel.textColor = UIColor(rgb: 0x00111B)
logoImage.image = UIImage(named: data.merchantLogo, in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
}
public override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
}
//
// ProfileFilterCollectionViewCell.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 29/5/25.
//
import UIKit
@objc public class ProfileFilterCollectionViewCell: UICollectionViewCell {
@IBOutlet weak var parentView: UIView!
@IBOutlet weak var titleLabel: UILabel!
public override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
func configureCell(data: CouponFilterModel, isSelected: Bool) {
if (isSelected) {
parentView.backgroundColor = UIColor(rgb: 0x000F1E)
parentView.layer.cornerRadius = 4.0
titleLabel.font = UIFont(name: "PingLCG-Bold", size: 16)
titleLabel.textColor = UIColor(rgb: 0xFFFFFF)
} else {
parentView.backgroundColor = .clear
parentView.layer.borderWidth = 2
parentView.layer.borderColor = UIColor(rgb: 0x56586A).cgColor
parentView.layer.cornerRadius = 4.0
titleLabel.font = UIFont(name: "PingLCG-Bold", size: 16)
titleLabel.textColor = UIColor(rgb: 0xFFFFFF)
}
titleLabel.text = data.title
}
}
<?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="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"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="ProfileFilterCollectionViewCell" id="gTV-IL-0wX" customClass="ProfileFilterCollectionViewCell" customModule="SwiftWarplyFramework" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="145" height="66"/>
<autoresizingMask key="autoresizingMask"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
<rect key="frame" x="0.0" y="0.0" width="145" height="66"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="NgU-Qp-M8l" userLabel="ParentView">
<rect key="frame" x="0.0" y="0.0" width="145" height="66"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Xq0-AN-QT6">
<rect key="frame" x="17" y="12" width="111" height="42"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstItem="Xq0-AN-QT6" firstAttribute="top" secondItem="NgU-Qp-M8l" secondAttribute="top" constant="12" id="Nro-8v-U0C"/>
<constraint firstAttribute="trailing" secondItem="Xq0-AN-QT6" secondAttribute="trailing" constant="17" id="hKh-jv-VQR"/>
<constraint firstItem="Xq0-AN-QT6" firstAttribute="leading" secondItem="NgU-Qp-M8l" secondAttribute="leading" constant="17" id="na6-tV-KQZ"/>
<constraint firstAttribute="bottom" secondItem="Xq0-AN-QT6" secondAttribute="bottom" constant="12" id="pJO-74-XZO"/>
</constraints>
</view>
</subviews>
</view>
<viewLayoutGuide key="safeArea" id="ZTg-uK-7eu"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="NgU-Qp-M8l" firstAttribute="top" secondItem="gTV-IL-0wX" secondAttribute="top" id="RYQ-Qn-MSN"/>
<constraint firstAttribute="trailing" secondItem="NgU-Qp-M8l" secondAttribute="trailing" id="efv-x1-lhD"/>
<constraint firstItem="NgU-Qp-M8l" firstAttribute="leading" secondItem="gTV-IL-0wX" secondAttribute="leading" id="l7p-or-kC2"/>
<constraint firstAttribute="bottom" secondItem="NgU-Qp-M8l" secondAttribute="bottom" id="te6-Qr-T6c"/>
</constraints>
<size key="customSize" width="145" height="66"/>
<connections>
<outlet property="parentView" destination="NgU-Qp-M8l" id="qhP-z2-cWY"/>
<outlet property="titleLabel" destination="Xq0-AN-QT6" id="Hft-IP-ITh"/>
</connections>
<point key="canvasLocation" x="109.16030534351144" y="-5.6338028169014089"/>
</collectionViewCell>
</objects>
<resources>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
</resources>
</document>
//
// ProfileHeaderTableViewCell.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 29/5/25.
//
import UIKit
@objc public class ProfileHeaderTableViewCell: UITableViewCell {
@IBOutlet weak var tagView1: UIView!
@IBOutlet weak var tagLabel1: UILabel!
@IBOutlet weak var tagView2: UIView!
@IBOutlet weak var tagLabel2: UILabel!
@IBOutlet weak var profileImage: UIImageView!
public override func awakeFromNib() {
super.awakeFromNib()
profileImage.image = UIImage(named: "profile_pic_default", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
tagView1.backgroundColor = UIColor(rgb: 0x09914E)
tagView1.layer.cornerRadius = 4.0
tagLabel1.font = UIFont(name: "PingLCG-Regular", size: 17)
tagLabel1.textColor = UIColor(rgb: 0xFFFFFF)
tagView2.backgroundColor = UIColor(rgb: 0xFC9F25)
tagView2.layer.cornerRadius = 4.0
tagLabel2.font = UIFont(name: "PingLCG-Regular", size: 17)
tagLabel2.textColor = UIColor(rgb: 0xFFFFFF)
}
public override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
}
//
// ProfileQuestionnaireTableViewCell.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 29/5/25.
//
import UIKit
@objc public class ProfileQuestionnaireTableViewCell: UITableViewCell {
@IBOutlet weak var questionnaireBannerImage: UIImageView!
public override func awakeFromNib() {
super.awakeFromNib()
questionnaireBannerImage.image = UIImage(named: "questionnaire_banner", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
}
public override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
}
<?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="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"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" reuseIdentifier="ProfileQuestionnaireTableViewCell" rowHeight="211" id="KGk-i7-Jjw" customClass="ProfileQuestionnaireTableViewCell" customModule="SwiftWarplyFramework" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="320" height="211"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" ambiguous="YES" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
<rect key="frame" x="0.0" y="0.0" width="320" height="211"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<view contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="YrO-k4-v2O" userLabel="ParentView">
<rect key="frame" x="24" y="35" width="272" height="9"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="N8L-PD-UP8">
<rect key="frame" x="0.0" y="0.0" width="272" height="159"/>
<color key="backgroundColor" systemColor="systemRedColor"/>
<constraints>
<constraint firstAttribute="height" constant="159" id="r1F-lV-yNf"/>
</constraints>
</imageView>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="N8L-PD-UP8" firstAttribute="leading" secondItem="YrO-k4-v2O" secondAttribute="leading" id="Ay6-kG-U8L"/>
<constraint firstAttribute="bottom" secondItem="N8L-PD-UP8" secondAttribute="bottom" id="S87-T5-YdQ"/>
<constraint firstAttribute="trailing" secondItem="N8L-PD-UP8" secondAttribute="trailing" id="WGt-wu-sFI"/>
<constraint firstItem="N8L-PD-UP8" firstAttribute="top" secondItem="YrO-k4-v2O" secondAttribute="top" id="ZxG-A7-Zci"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" red="0.94901960784313721" green="0.94901960784313721" blue="0.94901960784313721" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstAttribute="bottom" secondItem="YrO-k4-v2O" secondAttribute="bottom" id="6we-5l-yeL"/>
<constraint firstAttribute="trailing" secondItem="YrO-k4-v2O" secondAttribute="trailing" constant="24" id="7CD-5N-Kwy"/>
<constraint firstItem="YrO-k4-v2O" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="24" id="ExZ-x2-yiF"/>
<constraint firstItem="YrO-k4-v2O" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" constant="35" id="iID-80-Men"/>
</constraints>
</tableViewCellContentView>
<viewLayoutGuide key="safeArea" id="njF-e1-oar"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<connections>
<outlet property="questionnaireBannerImage" destination="N8L-PD-UP8" id="BMn-6A-UVw"/>
</connections>
<point key="canvasLocation" x="68.702290076335871" y="47.535211267605639"/>
</tableViewCell>
</objects>
<resources>
<systemColor name="systemRedColor">
<color red="1" green="0.23137254900000001" blue="0.18823529410000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
</resources>
</document>
//
// Models.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 29/5/25.
//
struct SectionModel {
let title: String
let count: Int
let offers: [OfferModel]
}
struct OfferModel {
let category: String
let title: String
let description: String
let discount: String
let discountType: String // e.g., "price", "percentage", "free", "buyOneGetOne", etc.
let bannerImage: String
let merchantLogo: String
let expirationDate: String
let color: UInt
var isFavorite: Bool
var active: Bool?
var redeemed: Bool?
}
struct CouponFilterModel {
let title: String
}
......@@ -7,24 +7,6 @@
import UIKit
struct SectionModel {
let title: String
let count: Int
let offers: [OfferModel]
}
struct OfferModel {
let category: String
let title: String
let description: String
let discount: String
let discountType: String // e.g., "price", "percentage", "free", "buyOneGetOne", etc.
let bannerImage: String
let merchantLogo: String
let expirationDate: String
let color: UInt
var isFavorite: Bool
}
@objc public class MyRewardsViewController: UIViewController {
@IBOutlet weak var tableView: UITableView!
......@@ -80,18 +62,6 @@ struct OfferModel {
color: 0x8A2BE2,
isFavorite: false
),
OfferModel(
category: "Διαγωνισμός",
title: "Διαγωνισμός Κού-πονς!",
description: "13 Απίθανα ΔΩΡΑ σε περιμένουν!",
discount: "",
discountType: "contest",
bannerImage: "contest_banner_5",
merchantLogo: "contest_logo",
expirationDate: "30/06/2025",
color: 0x8A2BE2,
isFavorite: false
),
// Top offers
OfferModel(
category: "Top offers",
......@@ -301,6 +271,13 @@ struct OfferModel {
)
]
let contestUrls: [String] = [
"https://warply.s3.amazonaws.com/dei/campaigns/tesla_dev/index.html",
"https://warply.s3.amazonaws.com/dei/campaigns/EnergySaverContest_dev/index.html",
"https://warply.s3.amazonaws.com/dei/campaigns/match_dev/index.html",
"https://warply.s3.amazonaws.com/dei/campaigns/questionnaire_dev"
]
var bannerOffersSection: SectionModel?
var topOffersSection: SectionModel?
var favoriteOffersSection: SectionModel?
......@@ -423,11 +400,12 @@ struct OfferModel {
self.tableView.reloadData()
}
private func openCampaignViewController(with offer: OfferModel) {
private func openCampaignViewController(with index: Int) {
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
if let vc = storyboard.instantiateViewController(withIdentifier: "CampaignViewController") as? SwiftWarplyFramework.CampaignViewController {
vc.campaignUrl = "https://warply.s3.amazonaws.com/dei/campaigns/DehEasterContest_stage/index.html"
// vc.campaignUrl = "https://warply.s3.amazonaws.com/dei/campaigns/DehEasterContest_stage/index.html"
vc.campaignUrl = contestUrls[index]
vc.showHeader = true
self.navigationController?.pushViewController(vc, animated: true)
// self.present(vc, animated: true)
......@@ -440,6 +418,12 @@ struct OfferModel {
self.navigationController?.pushViewController(vc, animated: true)
}
private func openProfileViewController() {
let vc = SwiftWarplyFramework.ProfileViewController(nibName: "ProfileViewController", bundle: Bundle(for: MyEmptyClass.self))
self.navigationController?.pushViewController(vc, animated: true)
}
}
// MARK: - TableView
......@@ -536,9 +520,14 @@ extension MyRewardsViewController: UITableViewDelegate, UITableViewDataSource{
// Add delegate conformance
extension MyRewardsViewController: MyRewardsBannerOffersScrollTableViewCellDelegate {
func didSelectBannerOffer(_ offer: OfferModel) {
func didSelectBannerOffer(_ index: Int) {
// Navigate to CampaignViewController
openCampaignViewController(with: offer)
openCampaignViewController(with: index)
}
func didTapProfileButton() {
// Navigate to ProfileViewController
openProfileViewController()
}
}
......
......@@ -172,6 +172,14 @@ import UIKit
)
]
let couponFilters: [CouponFilterModel] = [
CouponFilterModel(title: "Ενεργά"),
CouponFilterModel(title: "Αγαπημένα"),
CouponFilterModel(title: "Εξαργυρωμένα")
]
var couponFilterSelected: CouponFilterModel = CouponFilterModel(title: "Ενεργά")
var forYouOffersSection: SectionModel?
var activeOffersSection: SectionModel?
var favoriteOffersSection: SectionModel?
......@@ -187,8 +195,11 @@ import UIKit
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")
tableView.register(UINib(nibName: "ProfileHeaderTableViewCell", bundle: Bundle(for: MyEmptyClass.self)), forCellReuseIdentifier: "ProfileHeaderTableViewCell")
tableView.register(UINib(nibName: "ProfileQuestionnaireTableViewCell", bundle: Bundle(for: MyEmptyClass.self)), forCellReuseIdentifier: "ProfileQuestionnaireTableViewCell")
tableView.register(UINib(nibName: "MyRewardsOffersScrollTableViewCell", bundle: Bundle(for: MyEmptyClass.self)), forCellReuseIdentifier: "MyRewardsOffersScrollTableViewCell")
tableView.register(UINib(nibName: "ProfileCouponFiltersTableViewCell", bundle: Bundle(for: MyEmptyClass.self)), forCellReuseIdentifier: "ProfileCouponFiltersTableViewCell")
tableView.register(UINib(nibName: "ProfileCouponTableViewCell", bundle: Bundle(for: MyEmptyClass.self)), forCellReuseIdentifier: "ProfileCouponTableViewCell")
// Set up table view
tableView.delegate = self
......@@ -211,13 +222,15 @@ import UIKit
)
// Favorite Offers
let activeOffers = allOffers.filter { $0.active }
let activeOffers = allOffers.filter { $0.active ?? false }
activeOffersSection = SectionModel(
title: "Ενεργά",
count: activeOffers.count,
offers: activeOffers
)
filteredOffersSection = activeOffersSection
// Favorite Offers
let favoriteOffers = allOffers.filter { $0.isFavorite }
favoriteOffersSection = SectionModel(
......@@ -227,7 +240,7 @@ import UIKit
)
// Favorite Offers
let redeemedOffers = allOffers.filter { $0.redeemed }
let redeemedOffers = allOffers.filter { $0.redeemed ?? false }
redeemedOffersSection = SectionModel(
title: "Αγαπημένα",
count: redeemedOffers.count,
......@@ -236,13 +249,20 @@ import UIKit
self.tableView.reloadData()
}
private func openCouponViewController(with offer: OfferModel) {
let vc = SwiftWarplyFramework.CouponViewController(nibName: "CouponViewController", bundle: Bundle(for: MyEmptyClass.self))
vc.coupon = offer
self.navigationController?.pushViewController(vc, animated: true)
}
}
// MARK: - TableView
extension MyRewardsViewController: UITableViewDelegate, UITableViewDataSource{
extension ProfileViewController: UITableViewDelegate, UITableViewDataSource {
public func numberOfSections(in tableView: UITableView) -> Int {
return 4 + filteredOffersSection.offers.count
return 4 + (filteredOffersSection?.offers.count ?? 0)
}
public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
......@@ -272,35 +292,37 @@ extension MyRewardsViewController: UITableViewDelegate, UITableViewDataSource{
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)
let cell = tableView.dequeueReusableCell(withIdentifier: "ProfileHeaderTableViewCell", for: indexPath) as! ProfileHeaderTableViewCell
// cell.delegate = self // Set the banner offers delegate
// cell.configureCell(data: self.bannerOffersSection)
// cell.parent = self
return cell
} else {
} else if (indexPath.section == 1) {
let cell = tableView.dequeueReusableCell(withIdentifier: "ProfileQuestionnaireTableViewCell", for: indexPath) as! ProfileQuestionnaireTableViewCell
return cell
} else if (indexPath.section == 2) {
let cell = tableView.dequeueReusableCell(withIdentifier: "MyRewardsOffersScrollTableViewCell", for: indexPath) as! MyRewardsOffersScrollTableViewCell
cell.delegate = self // Set the offers delegate
cell.configureCell(data: self.forYouOffersSection)
return cell
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)
let cell = tableView.dequeueReusableCell(withIdentifier: "ProfileCouponFiltersTableViewCell", for: indexPath) as! ProfileCouponFiltersTableViewCell
cell.delegate = self // Set the offers delegate
cell.configureCell(data: self.couponFilters)
return cell
} else {
cell.configureCell(data: self.shoppingOffersSection)
let cell = tableView.dequeueReusableCell(withIdentifier: "ProfileCouponTableViewCell", for: indexPath) as! ProfileCouponTableViewCell
if let offer = self.filteredOffersSection?.offers[indexPath.row] {
cell.configureCell(data: offer)
}
return cell
}
......@@ -330,3 +352,18 @@ extension MyRewardsViewController: UITableViewDelegate, UITableViewDataSource{
}
}
// Add delegate conformance
extension ProfileViewController: MyRewardsOffersScrollTableViewCellDelegate {
func didSelectOffer(_ offer: OfferModel) {
// Navigate to CouponViewController
openCouponViewController(with: offer)
}
}
// Add delegate conformance
extension ProfileViewController: ProfileCouponFiltersTableViewCellDelegate {
func didSelectFilter(_ filter: CouponFilterModel) {
self.couponFilterSelected = filter
self.tableView.reloadData()
}
}
......