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
2026-03-17 14:58:17 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
2aedfd633e6e085918091f639b9b7508bc5785b1
2aedfd63
1 parent
4e593ddd
ProfileCouponTableViewCell expired ui
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
73 additions
and
69 deletions
SwiftWarplyFramework/SwiftWarplyFramework/Core/WarplySDK.swift
SwiftWarplyFramework/SwiftWarplyFramework/cells/ProfileCouponTableViewCell/ProfileCouponTableViewCell.swift
SwiftWarplyFramework/SwiftWarplyFramework/Core/WarplySDK.swift
View file @
2aedfd6
...
...
@@ -2287,7 +2287,7 @@ public final class WarplySDK {
let
dateFormatter
=
DateFormatter
()
dateFormatter
.
dateFormat
=
"dd/MM/yyyy"
activeCoupons
.
sort
{
coupon1
,
coupon2
in
couponsArray
.
sort
{
coupon1
,
coupon2
in
let
date1
=
dateFormatter
.
date
(
from
:
coupon1
.
expiration
??
""
)
let
date2
=
dateFormatter
.
date
(
from
:
coupon2
.
expiration
??
""
)
...
...
@@ -2297,7 +2297,7 @@ public final class WarplySDK {
return
false
}
completion
(
activeCoupons
)
completion
(
couponsArray
)
}
}
else
{
let
dynatraceEvent
=
LoyaltySDKDynatraceEventModel
()
...
...
SwiftWarplyFramework/SwiftWarplyFramework/cells/ProfileCouponTableViewCell/ProfileCouponTableViewCell.swift
View file @
2aedfd6
...
...
@@ -25,7 +25,10 @@ public class ProfileCouponTableViewCell: UITableViewCell {
@IBOutlet
weak
var
subtitleLabel
:
UILabel
!
@IBOutlet
weak
var
arrowView
:
UIView
!
@IBOutlet
weak
var
arrowImage
:
UIImageView
!
// Cached width constraint for expirationImage — zeroed out in expired state to collapse the gap
private
var
expirationImageWidthConstraint
:
NSLayoutConstraint
?
public
override
func
awakeFromNib
()
{
super
.
awakeFromNib
()
// Initialization code
...
...
@@ -42,8 +45,10 @@ public class ProfileCouponTableViewCell: UITableViewCell {
arrowImage
.
image
=
UIImage
(
named
:
"ic_forward"
,
in
:
Bundle
.
frameworkResourceBundle
,
compatibleWith
:
nil
)
expirationImage
.
image
=
UIImage
(
named
:
"clock"
,
in
:
Bundle
.
frameworkResourceBundle
,
compatibleWith
:
nil
)
// discountView.layer.cornerRadius = 42.0
// Cache the fixed-width constraint on expirationImage (XIB: width = 14)
expirationImageWidthConstraint
=
expirationImage
.
constraints
.
first
{
$0
.
firstAttribute
==
.
width
&&
$0
.
secondItem
==
nil
}
}
// MARK: - Image Loading Helpers
...
...
@@ -114,93 +119,92 @@ public class ProfileCouponTableViewCell: UITableViewCell {
}
// MARK: - Configure with CouponItemModel (dynamic data)
func
configureCell
(
data
:
CouponItemModel
)
{
// Banner image — load from couponset_data img_preview (remote URL)
// if let imgPreview = data.couponset_data?._img_preview, !imgPreview.isEmpty {
// self.bannerImageURL = imgPreview
// } else {
// bannerImage.image = nil
// }
// Favorite — default to not favorite for now
// favoriteImage.image = UIImage(named: "favorite_empty", in: Bundle.frameworkResourceBundle, compatibleWith: nil)
// // Discount label — use coupon discount or couponset discount
// let discountText = data.discount ?? data.couponset_data?._discount ?? ""
// discountLabel.text = discountText
// discountLabel.font = UIFont(name: "PingLCG-Bold", size: 25)
// discountLabel.textColor = UIColor(rgb: 0xF2F2F2)
// // Discount view color based on discount type
// let discountType = data.couponset_data?._discount_type ?? ""
// let discountColor: UInt = {
// switch discountType {
// case "percentage":
// return 0xFF6B35
// case "value":
// return 0x28A745
// case "plus_one":
// return 0x007AFF
// default:
// return 0xEE417D
// }
// }()
// discountView.backgroundColor = UIColor(rgb: discountColor)
func
configureCell
(
data
:
CouponItemModel
)
{
// Shared content — always set regardless of status
merchantNameLabel
.
font
=
UIFont
(
name
:
"PingLCG-Bold"
,
size
:
14
)
merchantNameLabel
.
textColor
=
UIColor
(
rgb
:
0x5C6369
)
merchantNameLabel
.
text
=
data
.
merchant_details
?
.
_name
// Title — from couponset_data name
titleLabel
.
text
=
data
.
couponset_data
?
.
_name
??
""
titleLabel
.
font
=
UIFont
(
name
:
"PingLCG-Bold"
,
size
:
22
)
titleLabel
.
textColor
=
UIColor
(
rgb
:
0x1D2023
)
// Subtitle — from couponset_data short_description
subtitleLabel
.
text
=
data
.
couponset_data
?
.
_short_description
??
""
titleLabel
.
text
=
data
.
couponset_data
?
.
_name
??
""
subtitleLabel
.
font
=
UIFont
(
name
:
"PingLCG-Regular"
,
size
:
13
)
subtitleLabel
.
text
Color
=
UIColor
(
rgb
:
0x5C6369
)
subtitleLabel
.
text
=
data
.
couponset_data
?
.
_short_description
??
""
expirationView
.
layer
.
cornerRadius
=
6.0
expirationView
.
layer
.
borderWidth
=
1.0
expirationLabel
.
font
=
UIFont
(
name
:
"PingLCG-Bold"
,
size
:
13
)
logoImageView
.
backgroundColor
=
UIColor
(
rgb
:
0xFFFFFF
)
logoImageView
.
layer
.
cornerRadius
=
10.0
if
let
merchantImgPreview
=
data
.
merchant_details
?
.
_img_preview
,
!
merchantImgPreview
.
isEmpty
{
self
.
logoImageURL
=
merchantImgPreview
}
else
{
logoImage
.
image
=
nil
}
// Branch on expired vs active/expiring-soon
if
data
.
status
==
-
1
{
applyExpiredStyle
()
}
else
{
applyActiveStyle
(
data
:
data
)
}
}
// MARK: - Expired Style
private
func
applyExpiredStyle
()
{
parentView
.
backgroundColor
=
UIColor
(
rgb
:
0xF1F2F4
)
parentView
.
layer
.
borderColor
=
UIColor
(
rgb
:
0xD2D6D9
)
.
cgColor
merchantNameLabel
.
textColor
=
UIColor
(
rgb
:
0xADB3B8
)
titleLabel
.
textColor
=
UIColor
(
rgb
:
0xADB3B8
)
subtitleLabel
.
textColor
=
UIColor
(
rgb
:
0xADB3B8
)
// Hide clock icon and collapse its width so the label has no leading gap
expirationImage
.
isHidden
=
true
expirationImageWidthConstraint
?
.
constant
=
0
expirationView
.
backgroundColor
=
UIColor
(
rgb
:
0xF1F2F4
)
expirationView
.
layer
.
borderColor
=
UIColor
(
rgb
:
0xD2D6D9
)
.
cgColor
expirationLabel
.
text
=
"Expired"
expirationLabel
.
textColor
=
UIColor
(
rgb
:
0x393E42
)
}
// MARK: - Active / Expiring-Soon Style
private
func
applyActiveStyle
(
data
:
CouponItemModel
)
{
parentView
.
backgroundColor
=
UIColor
(
rgb
:
0xDDEFFB
)
parentView
.
layer
.
borderColor
=
UIColor
(
rgb
:
0xA5DAF8
)
.
cgColor
merchantNameLabel
.
textColor
=
UIColor
(
rgb
:
0x5C6369
)
titleLabel
.
textColor
=
UIColor
(
rgb
:
0x1D2023
)
subtitleLabel
.
textColor
=
UIColor
(
rgb
:
0x5C6369
)
// Restore clock icon and its original width
expirationImage
.
isHidden
=
false
expirationImageWidthConstraint
?
.
constant
=
14
let
isExpiringSoon
:
Bool
if
let
expirationDate
=
data
.
expirationDate
{
let
today
=
Calendar
.
current
.
startOfDay
(
for
:
Date
())
let
expDay
=
Calendar
.
current
.
startOfDay
(
for
:
expirationDate
)
let
daysLeft
=
Calendar
.
current
.
dateComponents
([
.
day
],
from
:
today
,
to
:
expDay
)
.
day
??
Int
.
max
if
daysLeft
<=
3
{
isExpiringSoon
=
true
expirationLabel
.
text
=
"
\(
daysLeft
)
days left"
expirationView
.
backgroundColor
=
UIColor
(
rgb
:
0xFFF5DA
)
expirationView
.
layer
.
borderColor
=
UIColor
(
rgb
:
0xFFEABA
)
.
cgColor
}
else
{
isExpiringSoon
=
false
expirationLabel
.
text
=
"Valid until "
+
data
.
formattedExpiration
(
format
:
"MMMM d, yyyy"
)
expirationView
.
backgroundColor
=
UIColor
(
rgb
:
0xF1F2F4
)
expirationView
.
layer
.
borderColor
=
UIColor
(
rgb
:
0xD2D6D9
)
.
cgColor
}
}
else
{
isExpiringSoon
=
false
expirationLabel
.
text
=
""
}
if
isExpiringSoon
{
expirationView
.
backgroundColor
=
UIColor
(
rgb
:
0xFFF5DA
)
expirationView
.
layer
.
borderColor
=
UIColor
(
rgb
:
0xFFEABA
)
.
cgColor
}
else
{
expirationView
.
backgroundColor
=
UIColor
(
rgb
:
0xF1F2F4
)
expirationView
.
layer
.
borderColor
=
UIColor
(
rgb
:
0xD2D6D9
)
.
cgColor
}
expirationLabel
.
font
=
UIFont
(
name
:
"PingLCG-Bold"
,
size
:
13
)
expirationLabel
.
textColor
=
UIColor
(
rgb
:
0x002430
)
logoImageView
.
backgroundColor
=
UIColor
(
rgb
:
0xFFFFFF
)
logoImageView
.
layer
.
cornerRadius
=
10.0
// Logo — load from merchant_details img_preview (remote URL)
if
let
merchantImgPreview
=
data
.
merchant_details
?
.
_img_preview
,
!
merchantImgPreview
.
isEmpty
{
self
.
logoImageURL
=
merchantImgPreview
}
else
{
logoImage
.
image
=
nil
}
}
public
override
func
setSelected
(
_
selected
:
Bool
,
animated
:
Bool
)
{
...
...
Please
register
or
login
to post a comment