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
2022-06-27 14:05:33 +0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
04858612659060145304a637af62b5ba0c84ee24
04858612
1 parent
4c0de961
add dynamic dfyCoupons at WalletVC
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
6 deletions
SwiftWarplyFramework/SwiftWarplyFramework/WalletViewController.swift
SwiftWarplyFramework/SwiftWarplyFramework/WalletViewController.swift
View file @
0485861
...
...
@@ -29,6 +29,7 @@ import UIKit
@IBOutlet
weak
var
activeCodeImage
:
UIImageView
!
public
var
coupons
:
Array
<
swiftApi
.
CouponItemModel
>
=
[]
public
var
dfyCoupons
:
Array
<
swiftApi
.
ActiveDFYCouponModel
>
=
swiftApi
()
.
getActiveDFYCoupons
()
public
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
...
...
@@ -84,9 +85,12 @@ import UIKit
dfyEarnView
.
layer
.
shadowOpacity
=
1.0
dfyEarnView
.
layer
.
shadowRadius
=
3.0
// TODO: dynamic
dfyEarnLabel
.
text
=
"Μέχρι τώρα έχεις κερδίσει 18,00€ με το DEALS for YOU!"
dfyEarnAmountLabel
.
text
=
"18,00€"
var
totalCouponValue
=
self
.
dfyCoupons
.
reduce
(
0
)
{
$0
+
(
Float
(
$1
.
_value
)
??
0
)
}
totalCouponValue
=
Float
(
round
(
100
*
totalCouponValue
)
/
100
)
let
totalCouponValueString
=
String
(
format
:
"%.2f"
,
totalCouponValue
)
.
replacingOccurrences
(
of
:
"."
,
with
:
","
,
options
:
.
literal
,
range
:
nil
)
dfyEarnLabel
.
text
=
"Μέχρι τώρα έχεις κερδίσει "
+
totalCouponValueString
+
"€ με το DEALS for YOU!"
dfyEarnAmountLabel
.
text
=
totalCouponValueString
+
"€"
couponEarnView
.
layer
.
cornerRadius
=
5.0
couponEarnView
.
layer
.
shadowColor
=
UIColor
(
red
:
0.00
,
green
:
0.00
,
blue
:
0.00
,
alpha
:
0.16
)
.
cgColor
...
...
@@ -104,9 +108,40 @@ import UIKit
activeCodeView
.
layer
.
shadowOpacity
=
1.0
activeCodeView
.
layer
.
shadowRadius
=
6.0
// TODO: dynamic
activeCodeLabel
.
text
=
"961544809"
activeCodeExpirationLabel
.
text
=
"Λήγει σε 4 ημέρες"
if
(
dfyCoupons
.
count
>
0
)
{
let
dateFormatter
=
DateFormatter
()
dateFormatter
.
dateFormat
=
"yyyy-MM-dd hh:mm:ss"
// sort dfyCoupons by date
dfyCoupons
.
sort
(
by
:
{
let
date1
=
dateFormatter
.
date
(
from
:
$0
.
_date
)
let
date2
=
dateFormatter
.
date
(
from
:
$1
.
_date
)
if
((
date1
!=
nil
)
&&
(
date2
!=
nil
))
{
return
date1
!.
compare
(
date2
!
)
==
.
orderedAscending
}
else
{
return
false
}
})
// Get days from now of the most recet coupon
var
daysFromNow
=
""
let
calendar
=
Calendar
.
current
// Replace the hour (time) of both dates with 00:00
let
date1
=
calendar
.
startOfDay
(
for
:
Date
())
if
let
date2
=
dateFormatter
.
date
(
from
:
dfyCoupons
[
0
]
.
_date
)
{
let
components
=
calendar
.
dateComponents
([
.
day
],
from
:
date1
,
to
:
date2
)
daysFromNow
=
(
components
.
day
)
!=
nil
?
String
(
components
.
day
??
0
)
:
""
}
activeCodeLabel
.
text
=
dfyCoupons
[
0
]
.
_code
activeCodeExpirationLabel
.
text
=
"Λήγει σε "
+
daysFromNow
+
" ημέρες"
}
else
{
activeCodeLabel
.
text
=
"-"
activeCodeExpirationLabel
.
text
=
""
}
}
// MARK: - API Functions
...
...
Please
register
or
login
to post a comment