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:57:43 +0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
a51d03e133cbb1a7bdef73920b7cfa958ccd6e06
a51d03e1
1 parent
ebd74fe5
update WalletViewController with getCouponList
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
31 deletions
SwiftWarplyFramework/SwiftWarplyFramework/WalletViewController.swift
SwiftWarplyFramework/SwiftWarplyFramework/WalletViewController.swift
View file @
a51d03e
...
...
@@ -28,14 +28,12 @@ import UIKit
@IBOutlet
weak
var
tableView
:
UITableView
!
@IBOutlet
weak
var
activeCodeImage
:
UIImageView
!
public
var
coupons
:
Array
<
swiftApi
.
CouponItemModel
>
=
[]
public
var
coupons
:
Array
<
swiftApi
.
CouponItemModel
>
=
swiftApi
()
.
getCouponList
()
public
var
dfyCoupons
:
Array
<
swiftApi
.
ActiveDFYCouponModel
>
=
swiftApi
()
.
getActiveDFYCoupons
()
public
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
getCouponsRequest
()
setBackButton
()
setNavigationTitle
(
"For You"
)
...
...
@@ -98,9 +96,12 @@ import UIKit
couponEarnView
.
layer
.
shadowOpacity
=
1.0
couponEarnView
.
layer
.
shadowRadius
=
3.0
var
totalCouponDiscount
=
coupons
.
reduce
(
0
)
{
$0
+
(
Float
(
$1
.
discount
??
""
)
??
0
)
}
totalCouponDiscount
=
Float
(
round
(
100
*
totalCouponDiscount
)
/
100
)
let
totalCouponDiscountString
=
String
(
format
:
"%.2f"
,
totalCouponDiscount
)
.
replacingOccurrences
(
of
:
"."
,
with
:
","
,
options
:
.
literal
,
range
:
nil
)
couponEarnLabel
.
text
=
""
couponEarnAmountLabel
.
text
=
"
"
couponEarnLabel
.
text
=
"
Μέχρι τώρα έχεις κερδίσει "
+
totalCouponDiscountString
+
"€ σε προσφορές από "
+
String
(
coupons
.
count
)
+
" κουπόνια!
"
couponEarnAmountLabel
.
text
=
totalCouponDiscountString
+
"€
"
activeCodeView
.
layer
.
cornerRadius
=
5.0
activeCodeView
.
layer
.
shadowColor
=
UIColor
(
red
:
0.00
,
green
:
0.00
,
blue
:
0.00
,
alpha
:
0.16
)
.
cgColor
...
...
@@ -143,32 +144,6 @@ import UIKit
activeCodeExpirationLabel
.
text
=
""
}
}
// MARK: - API Functions
func
getCouponsRequest
()
{
swiftApi
()
.
getCouponsAsync
(
getCouponsCallback
)
}
func
getCouponsCallback
(
_
couponsData
:
Array
<
swiftApi
.
CouponItemModel
>
?)
->
Void
{
if
(
couponsData
!=
nil
)
{
let
activeCouponData
=
swiftApi
()
.
filterActiveCoupons
(
couponsData
??
[])
self
.
coupons
=
activeCouponData
DispatchQueue
.
main
.
async
{
self
.
tableView
.
reloadData
()
var
totalCouponDiscount
=
self
.
coupons
.
reduce
(
0
)
{
$0
+
(
Float
(
$1
.
discount
??
""
)
??
0
)
}
totalCouponDiscount
=
Float
(
round
(
100
*
totalCouponDiscount
)
/
100
)
let
totalCouponDiscountString
=
String
(
format
:
"%.2f"
,
totalCouponDiscount
)
.
replacingOccurrences
(
of
:
"."
,
with
:
","
,
options
:
.
literal
,
range
:
nil
)
self
.
couponEarnLabel
.
text
=
"Μέχρι τώρα έχεις κερδίσει "
+
totalCouponDiscountString
+
"€ σε προσφορές από "
+
String
(
activeCouponData
.
count
)
+
" κουπόνια!"
self
.
couponEarnAmountLabel
.
text
=
totalCouponDiscountString
+
"€"
}
}
else
{
self
.
coupons
=
[]
}
}
// MARK: - Actions
@IBAction
func
qustionnaireButtonAction
(
_
sender
:
Any
)
{
...
...
Please
register
or
login
to post a comment