Toggle navigation
Toggle navigation
This project
Loading...
Sign in
open-source
/
warply_sdk_framework
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Authored by
Manos Chorianopoulos
2025-05-30 11:11:55 +0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
d0bace0779167235e7960c4a52d5261d148e8c3b
d0bace07
1 parent
e40b8502
ProfileViewController filter functionality
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
22 deletions
SwiftWarplyFramework/SwiftWarplyFramework.xcworkspace/xcuserdata/manos.xcuserdatad/UserInterfaceState.xcuserstate
SwiftWarplyFramework/SwiftWarplyFramework/cells/ProfileCouponFiltersTableViewCell/ProfileCouponFiltersTableViewCell.swift
SwiftWarplyFramework/SwiftWarplyFramework/screens/ProfileViewController/ProfileViewController.swift
SwiftWarplyFramework/SwiftWarplyFramework.xcworkspace/xcuserdata/manos.xcuserdatad/UserInterfaceState.xcuserstate
View file @
d0bace0
No preview for this file type
SwiftWarplyFramework/SwiftWarplyFramework/cells/ProfileCouponFiltersTableViewCell/ProfileCouponFiltersTableViewCell.swift
View file @
d0bace0
...
...
@@ -17,6 +17,8 @@ protocol ProfileCouponFiltersTableViewCellDelegate: AnyObject {
weak
var
delegate
:
ProfileCouponFiltersTableViewCellDelegate
?
var
data
:
[
CouponFilterModel
]?
var
couponFilterSelected
:
CouponFilterModel
?
// var couponFilterSelected: CouponFilterModel = CouponFilterModel(title: "Ενεργά")
public
override
func
awakeFromNib
()
{
super
.
awakeFromNib
()
...
...
@@ -72,8 +74,9 @@ protocol ProfileCouponFiltersTableViewCellDelegate: AnyObject {
// Configure the view for the selected state
}
func
configureCell
(
data
:
[
CouponFilterModel
]?)
{
func
configureCell
(
data
:
[
CouponFilterModel
]?
,
couponFilterSelected
:
CouponFilterModel
)
{
self
.
data
=
data
self
.
couponFilterSelected
=
couponFilterSelected
self
.
collectionView
.
reloadData
();
}
...
...
@@ -93,8 +96,9 @@ extension ProfileCouponFiltersTableViewCell: UICollectionViewDataSource, UIColle
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
==
"Ενεργά"
// let isSelected = self.data?[indexPath.row].title == "Ενεργά"
// let isSelected = self.data?[indexPath.row].title == self.couponFilterSelected.title
let
isSelected
=
self
.
data
?[
indexPath
.
row
]
.
title
==
self
.
couponFilterSelected
?
.
title
??
"Ενεργά"
cell
.
configureCell
(
data
:
filter
,
isSelected
:
isSelected
)
}
return
cell
;
...
...
SwiftWarplyFramework/SwiftWarplyFramework/screens/ProfileViewController/ProfileViewController.swift
View file @
d0bace0
...
...
@@ -242,7 +242,7 @@ import UIKit
// Favorite Offers
let
redeemedOffers
=
allOffers
.
filter
{
$0
.
redeemed
??
false
}
redeemedOffersSection
=
SectionModel
(
title
:
"
Αγαπη
μένα"
,
title
:
"
Εξαργυρω
μένα"
,
count
:
redeemedOffers
.
count
,
offers
:
redeemedOffers
)
...
...
@@ -256,6 +256,19 @@ import UIKit
self
.
navigationController
?
.
pushViewController
(
vc
,
animated
:
true
)
}
private
func
handleFilterPress
(
with
filter
:
CouponFilterModel
)
{
switch
(
filter
.
title
)
{
case
"Ενεργά"
:
self
.
filteredOffersSection
=
activeOffersSection
case
"Αγαπημένα"
:
self
.
filteredOffersSection
=
favoriteOffersSection
case
"Εξαργυρωμένα"
:
self
.
filteredOffersSection
=
redeemedOffersSection
default
:
self
.
filteredOffersSection
=
activeOffersSection
}
}
}
// MARK: - TableView
...
...
@@ -328,7 +341,7 @@ extension ProfileViewController: UITableViewDelegate, UITableViewDataSource {
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
"ProfileCouponFiltersTableViewCell"
,
for
:
indexPath
)
as!
ProfileCouponFiltersTableViewCell
cell
.
delegate
=
self
// Set the offers delegate
cell
.
configureCell
(
data
:
self
.
couponFilters
)
cell
.
configureCell
(
data
:
self
.
couponFilters
,
couponFilterSelected
:
self
.
couponFilterSelected
)
return
cell
...
...
@@ -343,25 +356,12 @@ extension ProfileViewController: UITableViewDelegate, UITableViewDataSource {
}
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
)
{
if
(
indexPath
.
section
<=
3
)
{
// Do nothing
}
else
{
// Do nothing
if
let
offer
=
self
.
filteredOffersSection
?
.
offers
[
indexPath
.
row
]
{
openCouponViewController
(
with
:
offer
)
}
}
}
}
...
...
@@ -378,6 +378,7 @@ extension ProfileViewController: MyRewardsOffersScrollTableViewCellDelegate {
extension
ProfileViewController
:
ProfileCouponFiltersTableViewCellDelegate
{
func
didSelectFilter
(
_
filter
:
CouponFilterModel
)
{
self
.
couponFilterSelected
=
filter
handleFilterPress
(
with
:
filter
)
self
.
tableView
.
reloadData
()
}
}
...
...
Please
register
or
login
to post a comment