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-07-21 16:30:30 +0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
a57772dc7bd267ea08b0a2f2b185ae26d2414a30
a57772dc
1 parent
2b4f3669
MyRewardsVC fixes
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
37 additions
and
177 deletions
SwiftWarplyFramework/SwiftWarplyFramework/cells/MyRewardsBannerOffersScrollTableViewCell/MyRewardsBannerOffersScrollTableViewCell.swift
SwiftWarplyFramework/SwiftWarplyFramework/cells/MyRewardsOfferCollectionViewCell/MyRewardsOfferCollectionViewCell.swift
SwiftWarplyFramework/SwiftWarplyFramework/cells/MyRewardsOffersScrollTableViewCell/MyRewardsOffersScrollTableViewCell.swift
SwiftWarplyFramework/SwiftWarplyFramework/screens/MyRewardsViewController/MyRewardsViewController.swift
SwiftWarplyFramework/SwiftWarplyFramework/screens/ProfileViewController/ProfileViewController.swift
SwiftWarplyFramework/SwiftWarplyFramework/cells/MyRewardsBannerOffersScrollTableViewCell/MyRewardsBannerOffersScrollTableViewCell.swift
View file @
a57772d
...
...
@@ -121,23 +121,15 @@ extension MyRewardsBannerOffersScrollTableViewCell: UICollectionViewDataSource,
public
func
collectionView
(
_
collectionView
:
UICollectionView
,
cellForItemAt
indexPath
:
IndexPath
)
->
UICollectionViewCell
{
let
cell
=
collectionView
.
dequeueReusableCell
(
withReuseIdentifier
:
"MyRewardsBannerOfferCollectionViewCell"
,
for
:
indexPath
)
as!
MyRewardsBannerOfferCollectionViewCell
// Handle
different item types
// Handle
only CampaignItemModel - banner cells are campaign-specific
guard
let
data
=
self
.
data
,
let
itemType
=
data
.
itemType
,
let
items
=
data
.
items
,
indexPath
.
row
<
items
.
count
else
{
indexPath
.
row
<
items
.
count
,
let
campaign
=
items
[
indexPath
.
row
]
as?
CampaignItemModel
else
{
return
cell
}
switch
itemType
{
case
.
campaigns
:
if
let
campaign
=
items
[
indexPath
.
row
]
as?
CampaignItemModel
{
cell
.
configureCell
(
data
:
campaign
)
}
default
:
// Handle other types if needed in the future
break
}
cell
.
configureCell
(
data
:
campaign
)
return
cell
}
...
...
SwiftWarplyFramework/SwiftWarplyFramework/cells/MyRewardsOfferCollectionViewCell/MyRewardsOfferCollectionViewCell.swift
View file @
a57772d
...
...
@@ -65,49 +65,6 @@ public class MyRewardsOfferCollectionViewCell: UICollectionViewCell {
logoImage
.
image
=
UIImage
(
named
:
data
.
merchantLogo
,
in
:
Bundle
.
frameworkResourceBundle
,
compatibleWith
:
nil
)
}
// MARK: - New configureCell methods for different data types
func
configureCell
(
data
:
CampaignItemModel
)
{
// Use campaign's banner image if available
let
imageName
=
data
.
_banner_img_mobile
??
""
if
!
imageName
.
isEmpty
{
bannerImage
.
image
=
UIImage
(
named
:
imageName
,
in
:
Bundle
.
frameworkResourceBundle
,
compatibleWith
:
nil
)
}
else
{
bannerImage
.
image
=
nil
}
// Default to not favorite for campaigns
favoriteImage
.
image
=
UIImage
(
named
:
"favorite_empty"
,
in
:
Bundle
.
frameworkResourceBundle
,
compatibleWith
:
nil
)
// Use campaign category or type for discount display
discountLabel
.
text
=
data
.
_category
??
data
.
_campaign_type
??
""
discountLabel
.
font
=
UIFont
(
name
:
"PingLCG-Bold"
,
size
:
17
)
discountLabel
.
textColor
=
UIColor
(
rgb
:
0xF2F2F2
)
// Default color for campaigns
discountView
.
backgroundColor
=
UIColor
(
rgb
:
0xEE417D
)
titleLabel
.
text
=
data
.
_title
??
""
titleLabel
.
font
=
UIFont
(
name
:
"PingLCG-Bold"
,
size
:
17
)
titleLabel
.
textColor
=
UIColor
(
rgb
:
0x000F1E
)
subtitleLabel
.
text
=
data
.
_subtitle
??
""
subtitleLabel
.
font
=
UIFont
(
name
:
"PingLCG-Regular"
,
size
:
14
)
subtitleLabel
.
textColor
=
UIColor
(
rgb
:
0x00111B
)
// Use campaign expiration date
expirationLabel
.
text
=
data
.
_valid_until
??
""
expirationLabel
.
font
=
UIFont
(
name
:
"PingLCG-Regular"
,
size
:
13
)
expirationLabel
.
textColor
=
UIColor
(
rgb
:
0x00111B
)
// Use campaign logo
let
logoName
=
data
.
_logo_url
??
""
if
!
logoName
.
isEmpty
{
logoImage
.
image
=
UIImage
(
named
:
logoName
,
in
:
Bundle
.
frameworkResourceBundle
,
compatibleWith
:
nil
)
}
else
{
logoImage
.
image
=
nil
}
}
func
configureCell
(
data
:
CouponSetItemModel
)
{
// Use coupon set preview image
...
...
@@ -166,60 +123,4 @@ public class MyRewardsOfferCollectionViewCell: UICollectionViewCell {
}
}
func
configureCell
(
data
:
CouponItemModel
)
{
// Use coupon image
let
imageName
=
data
.
image
??
""
if
!
imageName
.
isEmpty
{
bannerImage
.
image
=
UIImage
(
named
:
imageName
,
in
:
Bundle
.
frameworkResourceBundle
,
compatibleWith
:
nil
)
}
else
{
bannerImage
.
image
=
nil
}
// Default to not favorite for coupons
favoriteImage
.
image
=
UIImage
(
named
:
"favorite_empty"
,
in
:
Bundle
.
frameworkResourceBundle
,
compatibleWith
:
nil
)
// Use coupon discount
discountLabel
.
text
=
data
.
discount
??
""
discountLabel
.
font
=
UIFont
(
name
:
"PingLCG-Bold"
,
size
:
17
)
discountLabel
.
textColor
=
UIColor
(
rgb
:
0xF2F2F2
)
// Color based on coupon status
let
statusColor
:
UInt
=
{
switch
data
.
status
{
case
1
:
return
0x28A745
// Active - green
case
0
:
return
0x6C757D
// Used - gray
default
:
return
0x007AFF
// Default - blue
}
}()
discountView
.
backgroundColor
=
UIColor
(
rgb
:
statusColor
)
titleLabel
.
text
=
data
.
name
??
""
titleLabel
.
font
=
UIFont
(
name
:
"PingLCG-Bold"
,
size
:
17
)
titleLabel
.
textColor
=
UIColor
(
rgb
:
0x000F1E
)
subtitleLabel
.
text
=
data
.
short_description
??
""
subtitleLabel
.
font
=
UIFont
(
name
:
"PingLCG-Regular"
,
size
:
14
)
subtitleLabel
.
textColor
=
UIColor
(
rgb
:
0x00111B
)
expirationLabel
.
text
=
data
.
expiration
??
""
expirationLabel
.
font
=
UIFont
(
name
:
"PingLCG-Regular"
,
size
:
13
)
expirationLabel
.
textColor
=
UIColor
(
rgb
:
0x00111B
)
// Use coupon set data image if available
if
let
couponSetData
=
data
.
couponset_data
,
let
imgArray
=
couponSetData
.
img
,
!
imgArray
.
isEmpty
{
let
logoName
=
imgArray
[
0
]
if
!
logoName
.
isEmpty
{
logoImage
.
image
=
UIImage
(
named
:
logoName
,
in
:
Bundle
.
frameworkResourceBundle
,
compatibleWith
:
nil
)
}
else
{
logoImage
.
image
=
nil
}
}
else
{
logoImage
.
image
=
nil
}
}
}
...
...
SwiftWarplyFramework/SwiftWarplyFramework/cells/MyRewardsOffersScrollTableViewCell/MyRewardsOffersScrollTableViewCell.swift
View file @
a57772d
...
...
@@ -151,7 +151,7 @@ extension MyRewardsOffersScrollTableViewCell: UICollectionViewDataSource, UIColl
public
func
collectionView
(
_
collectionView
:
UICollectionView
,
cellForItemAt
indexPath
:
IndexPath
)
->
UICollectionViewCell
{
let
cell
=
collectionView
.
dequeueReusableCell
(
withReuseIdentifier
:
"MyRewardsOfferCollectionViewCell"
,
for
:
indexPath
)
as!
MyRewardsOfferCollectionViewCell
// Handle
different item types with type checking
// Handle
only CouponSetItemModel and OfferModel - no campaigns
guard
let
data
=
self
.
data
,
let
items
=
data
.
items
,
indexPath
.
row
<
items
.
count
else
{
...
...
@@ -159,27 +159,22 @@ extension MyRewardsOffersScrollTableViewCell: UICollectionViewDataSource, UIColl
}
switch
data
.
itemType
{
case
.
campaigns
:
if
let
campaign
=
items
[
indexPath
.
row
]
as?
CampaignItemModel
{
cell
.
configureCell
(
data
:
campaign
)
}
case
.
couponSets
:
if
let
couponSet
=
items
[
indexPath
.
row
]
as?
CouponSetItemModel
{
cell
.
configureCell
(
data
:
couponSet
)
}
case
.
coupons
:
if
let
coupon
=
items
[
indexPath
.
row
]
as?
CouponItemModel
{
cell
.
configureCell
(
data
:
coupon
)
}
default
:
break
// Handle OfferModel for ProfileViewController compatibility
if
let
offer
=
items
[
indexPath
.
row
]
as?
OfferModel
{
cell
.
configureCell
(
data
:
offer
)
}
}
return
cell
;
}
public
func
collectionView
(
_
collectionView
:
UICollectionView
,
didSelectItemAt
indexPath
:
IndexPath
)
{
// Handle
different item types with type checking
// Handle
only CouponSetItemModel and OfferModel - no campaigns
guard
let
data
=
self
.
data
,
let
items
=
data
.
items
,
indexPath
.
row
<
items
.
count
else
{
...
...
@@ -187,60 +182,28 @@ extension MyRewardsOffersScrollTableViewCell: UICollectionViewDataSource, UIColl
}
switch
data
.
itemType
{
case
.
campaigns
:
if
let
campaign
=
items
[
indexPath
.
row
]
as?
CampaignItemModel
{
// For now, we'll need to convert CampaignItemModel to OfferModel for delegate compatibility
// This maintains backward compatibility while using the new data structure
let
offer
=
OfferModel
(
category
:
campaign
.
_category
??
""
,
title
:
campaign
.
_title
??
""
,
description
:
campaign
.
_subtitle
??
""
,
discount
:
""
,
discountType
:
""
,
bannerImage
:
campaign
.
_banner_img_mobile
??
""
,
merchantLogo
:
campaign
.
_logo_url
??
""
,
expirationDate
:
""
,
color
:
0x000000
,
isFavorite
:
false
)
delegate
?
.
didSelectOffer
(
offer
)
}
case
.
couponSets
:
if
let
couponSet
=
items
[
indexPath
.
row
]
as?
CouponSetItemModel
{
// Convert CouponSetItemModel to OfferModel for delegate compatibility
let
offer
=
OfferModel
(
category
:
""
,
title
:
couponSet
.
_
name
??
""
,
description
:
couponSet
.
_
short_description
??
""
,
discount
:
""
,
discountType
:
""
,
bannerImage
:
""
,
merchantLogo
:
couponSet
.
_img_preview
??
""
,
expirationDate
:
""
,
title
:
couponSet
.
name
??
""
,
description
:
couponSet
.
short_description
??
""
,
discount
:
couponSet
.
discount
??
""
,
discountType
:
couponSet
.
discount_type
??
""
,
bannerImage
:
couponSet
.
img_preview
??
""
,
merchantLogo
:
couponSet
.
img
?
.
first
??
""
,
expirationDate
:
couponSet
.
expiration
??
""
,
color
:
0x000000
,
isFavorite
:
false
)
delegate
?
.
didSelectOffer
(
offer
)
}
case
.
coupons
:
if
let
coupon
=
items
[
indexPath
.
row
]
as?
CouponItemModel
{
// Convert CouponItemModel to OfferModel for delegate compatibility
let
offer
=
OfferModel
(
category
:
""
,
title
:
coupon
.
_name
??
""
,
description
:
coupon
.
_short_description
??
""
,
discount
:
""
,
discountType
:
""
,
bannerImage
:
""
,
merchantLogo
:
coupon
.
_img_preview
??
""
,
expirationDate
:
""
,
color
:
0x000000
,
isFavorite
:
false
)
default
:
// Handle OfferModel directly for ProfileViewController compatibility
if
let
offer
=
items
[
indexPath
.
row
]
as?
OfferModel
{
delegate
?
.
didSelectOffer
(
offer
)
}
default
:
break
}
}
...
...
SwiftWarplyFramework/SwiftWarplyFramework/screens/MyRewardsViewController/MyRewardsViewController.swift
View file @
a57772d
This diff is collapsed. Click to expand it.
SwiftWarplyFramework/SwiftWarplyFramework/screens/ProfileViewController/ProfileViewController.swift
View file @
a57772d
...
...
@@ -247,16 +247,16 @@ import UIKit
let
forYouOffers
=
allOffers
.
filter
{
$0
.
category
==
"Προτάσεις για εσένα"
}
forYouOffersSection
=
SectionModel
(
title
:
"Προτάσεις για εσένα"
,
count
:
forYouOffers
.
count
,
offers
:
forYouO
ffers
items
:
forYouOffers
,
itemType
:
.
o
ffers
)
//
Favorit
e Offers
//
Activ
e Offers
let
activeOffers
=
allOffers
.
filter
{
$0
.
active
??
false
}
activeOffersSection
=
SectionModel
(
title
:
"Ενεργά"
,
count
:
activeOffers
.
count
,
offers
:
activeO
ffers
items
:
activeOffers
,
itemType
:
.
o
ffers
)
filteredOffersSection
=
activeOffersSection
...
...
@@ -265,16 +265,16 @@ import UIKit
let
favoriteOffers
=
allOffers
.
filter
{
$0
.
isFavorite
}
favoriteOffersSection
=
SectionModel
(
title
:
"Αγαπημένα"
,
count
:
favoriteOffers
.
count
,
offers
:
favoriteO
ffers
items
:
favoriteOffers
,
itemType
:
.
o
ffers
)
//
Favorite
Offers
//
Redeemed
Offers
let
redeemedOffers
=
allOffers
.
filter
{
$0
.
redeemed
??
false
}
redeemedOffersSection
=
SectionModel
(
title
:
"Εξαργυρωμένα"
,
count
:
redeemedOffers
.
count
,
offers
:
redeemedO
ffers
items
:
redeemedOffers
,
itemType
:
.
o
ffers
)
self
.
tableView
.
reloadData
()
...
...
@@ -314,7 +314,7 @@ extension ProfileViewController: UITableViewDelegate, UITableViewDataSource {
if
(
section
<=
3
)
{
return
1
}
else
{
return
filteredOffersSection
?
.
offers
.
c
ount
??
0
return
filteredOffersSection
?
.
itemC
ount
??
0
}
}
...
...
@@ -383,7 +383,9 @@ extension ProfileViewController: UITableViewDelegate, UITableViewDataSource {
}
else
{
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
"ProfileCouponTableViewCell"
,
for
:
indexPath
)
as!
ProfileCouponTableViewCell
if
let
offer
=
self
.
filteredOffersSection
?
.
offers
[
indexPath
.
row
]
{
if
let
items
=
self
.
filteredOffersSection
?
.
items
,
indexPath
.
row
<
items
.
count
,
let
offer
=
items
[
indexPath
.
row
]
as?
OfferModel
{
cell
.
configureCell
(
data
:
offer
)
}
return
cell
...
...
@@ -395,7 +397,9 @@ extension ProfileViewController: UITableViewDelegate, UITableViewDataSource {
if
(
indexPath
.
section
<=
3
)
{
// Do nothing
}
else
{
if
let
offer
=
self
.
filteredOffersSection
?
.
offers
[
indexPath
.
row
]
{
if
let
items
=
self
.
filteredOffersSection
?
.
items
,
indexPath
.
row
<
items
.
count
,
let
offer
=
items
[
indexPath
.
row
]
as?
OfferModel
{
openCouponViewController
(
with
:
offer
)
}
}
...
...
Please
register
or
login
to post a comment