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 13:48:35 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
53fe8754e7d62c13e60b81a62bcb5b18e8f7e154
53fe8754
1 parent
7dc8836b
MyCouponsViewController part3
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
8 deletions
SwiftWarplyFramework/SwiftWarplyFramework/cells/ProfileCouponTableViewCell/ProfileCouponTableViewCell.swift
SwiftWarplyFramework/SwiftWarplyFramework/cells/ProfileCouponTableViewCell/ProfileCouponTableViewCell.xib
SwiftWarplyFramework/SwiftWarplyFramework/models/Coupon.swift
SwiftWarplyFramework/SwiftWarplyFramework/screens/MyCouponsViewController/MyCouponsViewController.swift
SwiftWarplyFramework/SwiftWarplyFramework/cells/ProfileCouponTableViewCell/ProfileCouponTableViewCell.swift
View file @
53fe875
This diff is collapsed. Click to expand it.
SwiftWarplyFramework/SwiftWarplyFramework/cells/ProfileCouponTableViewCell/ProfileCouponTableViewCell.xib
View file @
53fe875
This diff is collapsed. Click to expand it.
SwiftWarplyFramework/SwiftWarplyFramework/models/Coupon.swift
View file @
53fe875
...
...
@@ -96,7 +96,7 @@ public class CouponSetItemModel {
/// Try multiple date formats and return the first successful parse
/// - Parameter dateString: The date string to parse
/// - Returns: Parsed Date or nil if no format matched
private
static
func
parseDate
(
_
dateString
:
String
)
->
Date
?
{
static
func
parseDate
(
_
dateString
:
String
)
->
Date
?
{
let
formatter
=
DateFormatter
()
for
format
in
supportedDateFormats
{
formatter
.
dateFormat
=
format
...
...
@@ -411,7 +411,8 @@ public class CouponItemModel {
public
let
couponset_uuid
:
String
?
public
let
name
:
String
?
public
let
image
:
String
?
public
let
expiration
:
String
?
public
let
expiration
:
String
?
// raw string from API e.g. "2026-06-30 11:59:00"
public
let
expiration_formatted
:
String
?
// pre-formatted "dd/MM/yyyy" for display
public
let
created
:
String
?
public
let
description
:
String
?
public
let
discount
:
String
?
...
...
@@ -495,15 +496,16 @@ public class CouponItemModel {
}
// <==
let
expirationString
=
dictionary
[
"expiration"
]
as?
String
?
??
""
let
expirationString
=
dictionary
[
"expiration"
]
as?
String
??
""
self
.
expiration
=
expirationString
let
dateFormatter
=
DateFormatter
()
dateFormatter
.
dateFormat
=
"yyyy-MM-dd HH:mm:ss"
if
let
date
=
dateFormatter
.
date
(
from
:
expirationString
??
""
)
{
if
let
date
=
dateFormatter
.
date
(
from
:
expirationString
)
{
dateFormatter
.
dateFormat
=
"dd/MM/yyyy"
let
resultString
=
dateFormatter
.
string
(
from
:
date
)
self
.
expiration
=
resultString
self
.
expiration_formatted
=
dateFormatter
.
string
(
from
:
date
)
}
else
{
self
.
expiration
=
""
self
.
expiration
_formatted
=
""
}
// Extract created date: try changes_dates.created first (universal coupons), then top-level created
...
...
@@ -558,6 +560,26 @@ public class CouponItemModel {
public
func
setCouponSetData
(
_
couponSet
:
CouponSetItemModel
)
{
self
.
couponset_data
=
couponSet
}
/// Returns the expiration as a Date object for date comparisons (e.g. days-left calculation)
public
var
expirationDate
:
Date
?
{
guard
let
raw
=
self
.
expiration
,
!
raw
.
isEmpty
else
{
return
nil
}
return
CouponSetItemModel
.
parseDate
(
raw
)
}
/// Format expiration date with a custom output format.
/// Uses the same multi-format parser as CouponSetItemModel.
/// - Parameter format: DateFormatter format string (e.g. "MMMM d, yyyy", "dd/MM/yyyy")
/// - Returns: Formatted date string, or empty string if expiration is absent or unparseable
public
func
formattedExpiration
(
format
:
String
)
->
String
{
guard
let
raw
=
self
.
expiration
,
!
raw
.
isEmpty
else
{
return
""
}
if
let
date
=
CouponSetItemModel
.
parseDate
(
raw
)
{
let
formatter
=
DateFormatter
()
formatter
.
dateFormat
=
format
return
formatter
.
string
(
from
:
date
)
}
return
""
}
}
public
class
RedeemedSMHistoryModel
{
...
...
SwiftWarplyFramework/SwiftWarplyFramework/screens/MyCouponsViewController/MyCouponsViewController.swift
View file @
53fe875
...
...
@@ -383,7 +383,7 @@ extension MyCouponsViewController: UITableViewDelegate, UITableViewDataSource {
}
public
func
tableView
(
_
tableView
:
UITableView
,
didSelectRowAt
indexPath
:
IndexPath
)
{
if
(
indexPath
.
section
<=
3
)
{
if
(
indexPath
.
section
<=
1
)
{
// Do nothing
}
else
{
if
let
items
=
self
.
filteredOffersSection
?
.
items
,
...
...
Please
register
or
login
to post a comment